// MM functions start
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}
// MM functions end

function alarm(string)
{
  alert (string);
}

/* xAjax calls Start */
/* <input name="texto" type="text" onKeyUp="updateResults(this.value);"> */
var suggestTimer = null;
function updateResults(searchinput)
{
  if (searchinput.length > 3)
  {
    if (suggestTimer != null)
    {
      clearTimeout(suggestTimer);
    }
    suggestTimer = setTimeout("xajax_updateresult('"+searchinput+"')", 1000);
  }
  /*
  else
  {
    document.getElementById('resultbox').innerHTML = '';
  }
  */
}

function submitForm(frm, rt_editors)
{
  if (arguments.length > 1)
  {
    for (var i = 0; i < rt_editors.length; i++)
    {
      var val = getText(rt_editors[i]);
      frm.elements[rt_editors[i]].value = val;
    }
  }
  xajax_processForm(xajax.getFormValues(frm));
  return false;
}

function getText(editor_name)
{
  var oEditor = FCKeditorAPI.GetInstance(editor_name);
  if (oEditor.EditorDocument.body.innerHTML)
  {
    return oEditor.EditorDocument.body.innerHTML;
  }
  else
  {
    return '';
  }
}

function confirmDelete(id, message, table, rowIndex)
{
	if (confirm (message+'?'))
	{
		xajax_deleteSingle(id, table, rowIndex);
	}
	return false;
}

function addOption(selectId, txt, val)
{
  var objOption = new Option(txt, val);
  document.getElementById(selectId).options.add(objOption);
}
/* all other */
//set a style attribute value
function setStyleAttribute(objId, styleAttr, attrValue){
	
	document.getElementById(objId).style[styleAttr]=attrValue;
}


//user JS

var soundstatus=1;
function play(){
	if(document.test_sound){
	document.test_sound.TCallLabel("/mc_controls", "start_sound");
	}
	if(document.getElementById("id_controls_buttons")){
		document.getElementById("id_controls_buttons").innerHTML='<a href="javascript:stop()"><img id="id_play_button"  src="system/icons/stopbutton.jpg" border=0 title="Stop"></a>';
	}
	
	soundstatus=1;
	
}
function stop(){
	if(document.test_sound){
		document.test_sound.TCallLabel("/mc_controls", "stop_sound");
	}
	if(document.getElementById("id_controls_buttons")){
		document.getElementById("id_controls_buttons").innerHTML='<a href="javascript:play()"><img id="id_play_button"  src="system/icons/playbutton.jpg" border=0 title="Play"></a>';
	}
	
	soundstatus=0;
	
}

function init_sound_button(){
	if(soundstatus==1){
		//playing
		if(document.getElementById("id_controls_buttons")){
		document.getElementById("id_controls_buttons").innerHTML='<a href="javascript:stop()"><img id="id_play_button"  src="system/icons/stopbutton.jpg" border=0 title="Stop"></a>';
		}
	}
	else{
		if(document.getElementById("id_controls_buttons")){
			document.getElementById("id_controls_buttons").innerHTML='<a href="javascript:play()"><img id="id_play_button"  src="system/icons/playbutton.jpg" border=0 title="Play"></a>';
		}
	}
		
}
function dim_in(){
		var div=xajax.$('id_dimmer');
		div.className="dimin";
		var b=document.getElementsByTagName("BODY");
		var h=screen.availHeight;
		
		div.style.height=""+h + "px";
}
function dim_out(){
	var div=xajax.$('id_dimmer');
	div.className="dimout";
}
function show_mixer(){
	
	var ref=document.getElementById("id_mixer");
	ref.style.width="526px";
	ref.style.height="400px";
	
	ref.style.left=""+ parseInt(screen.availWidth/2) - 250 + "px";
	ref.style.top=""+ parseInt(screen.availHeight/2 - 200) + "px";
	
	document.test_sound.style.width="526px";
	document.test_sound.style.height="385px";
	dim_in();
}
function hide_mixer(){
	
	var ref=document.getElementById("id_mixer");
	ref.style.width="1px";
	ref.style.height="0px";
	ref.style.left="0px";
	ref.style.top="0px";
	
	document.test_sound.style.width="0px";
	document.test_sound.style.height="0px";
	dim_out();
}
function show_gbook(){
	var ref=document.getElementById('id_gbook');
	if(!ref) return;
	ref.style.width="800px";
	ref.style.height="620px";
	ref.style.overflow='auto';
	ref.style.display="block";
	var b=document.getElementsByTagName("BODY");
	var h=b[0].offsetHeight;
	ref.style.left=""+ (parseInt(screen.availWidth/2) -400) + "px";
	//ref.style.top=""+ (parseInt(h/2) - 220) + "px";
	ref.style.top=""+ (parseInt(screen.availHeight/2) -380) + "px";
	
	dim_in();
}
function hide_gbook(){
	var ref=document.getElementById('id_gbook');
	if(!ref) return;
	
	ref.style.display='none';
	dim_out();
}
function show_gallery(){
	var ref=document.getElementById('id_id_media');
	if(!ref) return;
	ref.style.width="800px";
	ref.style.height="450px";
	ref.style.overflow='auto';
	ref.style.display="block";
	var b=document.getElementsByTagName("BODY");
	var h=b[0].offsetHeight;
	
	ref.style.left=""+ (parseInt(screen.availWidth/2) -400) + "px";
	ref.style.top=""+ (parseInt(screen.availHeight/2) - 300) + "px";
	dim_in();
}
function hide_gallery(){
	var ref=document.getElementById('id_id_media');
	if(!ref) return;
	
	ref.style.display='none';
	dim_out();
}
//Video anzeigen
function show_tv_video(){
	var ref=xajax.$('id_tv_video');
	if(!ref) return;
	
	ref.style.backgroundColor="#eaeaea";
	ref.style.display='block';
}
function hide_tv_video(){
	var ref_video=xajax.$('id_play_video');
	if(!ref_video) return;
	var ref_div=xajax.$('id_tv_video');
	if(!ref_div) return;
	ref_video.innerHTML="";
	ref_div.style.display='none';
}
//upload - dim
function show_upload(url){
	//iframe
	var up_frame=document.getElementById('id_iframe_upload');
	if(!up_frame) return;
	up_frame.src=url;
	var ref=document.getElementById('id_id_upload');
	if(!ref) return;
	ref.style.width="800px";
	ref.style.height="450px";
	ref.style.overflow='auto';
	ref.style.display="block";
	var b=document.getElementsByTagName("BODY");
	var h=b[0].offsetHeight;
	ref.style.left=""+ (parseInt(screen.availWidth/2) -400) + "px";
	ref.style.top=""+ (parseInt(h/2) - 220) + "px";
	dim_in();
}
function hide_upload(){
	var ref=document.getElementById('id_id_upload');
	if(!ref) return;
	
	ref.style.display='none';
	dim_out();
}
function getScreenSize(){
	var sWidth=screen.width;
	var sHeight=screen.height;
}
function show_teaser(){
	new Effect.Appear('id_freib', { duration: 2.0, from:0.1, to:1} );
}
//funkt nicht, da nur beim ersten laden ausgeführt
function execOnLoadContent(){
	var execTags=document.getElementsByTagName("EXECJS");
	if(execTags){
		var execTag=execTags[0];
		if(execTag){
			var func=execTag.getAttribute("function");
			if(func){
				if(func=="show_teaser")show_teaser();
				
			}
		}
	}
}
function show_umenu(id){
	var ref=document.getElementById(id);
	if(ref)	ref.style.display='block';
}
function hide_umenu(id){	
	var ref=document.getElementById(id);
	if(ref) ref.style.display='none';
}
sfHover = function() {
	if(! document.getElementById("mainnavigation")) return;
	
	var sfEls = document.getElementById("mainnavigation").getElementsByTagName("LI");
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			this.className+=" sfhover";
		}
		sfEls[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
		}
	}
}

function showContentWindow(page, anker){
	var o=window.open("show_content.php?seite=" + page +"#"+anker, 'Info', "width=500, height=600, scrollbars=yes, status=no");
	o.focus();
}

function load_page(page){
	xajax_loadPage(page);
	if(page.indexOf('#') !=-1)
		reset_hmenus();
		if(page.indexOf('pressecds')>-1){
			//id:1dm6
			if(document.getElementById('idm6')){
				var o=document.getElementById('idm6');
				set_selected_hmenu(o);
			}
			
		}
		else if(page.indexOf('cds1')>-1){
			//id:1dm6
			if(document.getElementById('idm3')){
				var o=document.getElementById('idm3');
				set_selected_hmenu(o);
			}
			
		}
}
function jump_anchor(anchor){
	window.location.href = "#"+anchor;
	
}
function back_to_cds(anchor){
	var id="id_back_to_cds_"+anchor;
	if(document.getElementById(id)){
		document.getElementById(id).innerHTML='<a href="javascript:load_page('+ "'cds1#" + anchor + "'" + ')">zurück zu CDs</a>';
		
	}

}
if (window.attachEvent) window.attachEvent("onload", sfHover);




