// JavaScript Document

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_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_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];}
}


// altered by elp - to work with display CSS property
function MM_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
 
	  if (obj.style) {
			  obj=obj.style; 
				 if (v=='show') {
				 obj.display = 'block'; 
				 } else {
				 obj.display = 'none'; 
				 }
  	}
  }
}


   // write hide - show button - for admin contentblock
	function writeRedExp(divId, ctrldiv) {
		var clayer = document.getElementById(ctrldiv);
		var content = '';
	    var divContent = document.getElementById(divId);
	    var divId = divId;
	    var ctrldiv = ctrldiv;
	
		if (divContent.style.display != 'block') {
			content += '<a href="javascript:void(0);"';
			content += ' onClick="MM_showHideLayers(\''+divId+'\',\'\',\'show\'); writeRedExp(\''+divId+'\',\''+ctrldiv+'\'); ">';
			content += '[ ÖFFNEN ]</a>';
		} else if (divContent.style.display != 'none') {
		    content += '<a href="javascript:void(0);"';
			content += 'onClick="MM_showHideLayers(\''+divId+'\',\'\',\'hide\'); writeRedExp(\''+divId+'\',\''+ctrldiv+'\');  ">';
			content += '[ SCHLIESSEN ]</a>';
		}
		clayer.innerHTML = content;
	}	






/* hide detail layers - only if js user */
  function hide(ID) {
      document.getElementById(ID).style.display = 'none';
  }
  
  function dummy() {
  }
  
  
  /* Ajax Slide Menu - elp 
     Using Scriptaculous effect */
 
  function slider(myID, timer) {
 
    var Header    = document.getElementById('Header'+myID);
    var Icon      = 'ImgShowHide' + myID;
    var Speed     = 0.3;
    var ImgUp = 'templates/images/arrowhide.gif';
    var ImgDown = 'templates/images/arrowslide.gif';
    
     if (document.getElementById(myID).style.display == 'none') {  
         Header.className = 'branchOuterActive';
         new Effect.BlindDown(myID,
           { duration: Speed });
           document[Icon].src = ImgUp; 
 
        
    } else {  
        document[Icon].src = ImgDown; 
        new Effect.BlindUp(myID,
        { duration: Speed });
        Header.className = 'branchOuter';
    }
  }   
 
function lookFGuide(id) {
	//new Ajax.Request("lookfg.php?id="+encodeURI(id),
	new Ajax.Request("lookfg.php",
	 {
		method:"get",
		onComplete:function(xhr){
			$('nav'+id).src = "templates/images/nav"+id+"_over.gif"
			$('LeftCell').innerHTML = xhr.responseText;
		}
	 });	
}
 
function chgBG(bgId, pic) {
	document.getElementById(bgId).style.backgroundImage="url(templates/images/"+pic+")";
}


 

function merken(vid,id){
	new Ajax.Request("remember.php?vid="+encodeURI(vid),
	 {
		method:"get",
		onLoading:function() {
				chgBG('FestivalGuide','bg_guide_anim.gif');
			},
		onComplete:function(xhr){
			$('fg_'+vid).innerHTML = "My Festival Guide <img src=\"templates/images/guide_small.gif\" alt=\"Festival Guide\" align=\"texttop\" />";
			var mnum = xhr.responseText;
			if (mnum >0) {
				if (mnum == 1) txt = "<a href=\"My-Festival-Guide_10.html\">1 Konzert vorgemerkt</a>";
				else txt = "<a href=\"My-Festival-Guide_10.html\">"+mnum+" Konzerte vorgemerkt</a>";
			}
			$('merklist').innerHTML = txt;
		}
	 });
	

}

function delFGuide(id) {
	new Ajax.Request("lookfg.php?del="+encodeURI(id),
		 {
			method:"get"
		 });
}







   /* hidenav detail layers - only if js user and appear active navigation */
  function hidenav() {

    for (i=0; i< NavArr.length; i++) {
      if (NavArr[i] != myActiveID) {
        if (document.getElementById(NavArr[i]).style.display != 'none') {  
       	   document.getElementById(NavArr[i]).style.display = 'none';    
     	  } // if    
     	} // if  
    } // for 
    
     // show active menu block
    if (myActiveID != '') {
      if (document.getElementById(myActiveID).style.display == 'none') {  
         new Effect.Appear(myActiveID,
            {duration:Speed, from:0.0, to:opActive});
       }  // if
     } // if  
    
    return true;
    
  } // hidenav
  

  function slideNav(myID) {
    
	for (i=0; i< NavArr.length; i++) {
      if (NavArr[i] != myID) {
        if (document.getElementById(NavArr[i]).style.display != 'none') {  
       	   document.getElementById(NavArr[i]).style.display = 'none';    
     	  } // if    
     	} // if  
    } // for 
	
	
	// activated layer is not visible
      if (document.getElementById(myID).style.display == 'none') {  
         new Effect.Appear(myID,
            {duration:Speed, from:0.0, to:opActive});
      } 
	  
  }
   // bei link innerhalb layer wird global active geschalten, damit layer nicht ausgebl. wird
 	 function globalActive(status) {
 	   if (status == 1) {
 	     active = 1;
 	     outeractive = 1;
 	   }  
 	   else if (status == 0)
 	     active = 0;  
 	  else if (status == 3) 
 	     outeractive = 1;
 	  else if (status == 4) 
 	     outeractive = 0;    
 	   // document.getElementById('test').value = active + ' - ' + outeractive;  
 	 }
    
  
  function hideNavTime() {
    setTimeout("slideNavOut()", 1000); 
  }
  
  function slideNavOut() {
  
    	for (i=0; i< NavArr.length; i++) {
    	  if ((NavArr[i] != myActiveID) && (active == 1) && (outeractive == 0)) {
      	  if (document.getElementById(NavArr[i]).style.display != 'none') {  
       	    document.getElementById(NavArr[i]).style.display = 'none';    
     		  } // if    
     		} // if    			
    	} // for 
      if (outeractive == 0) {
	  		changeBG(0,"inactiv");
	   	} // if  

    	// slideNav();
 	 } // slideNavOut  
 	 
	 
	function setFilter(id, elem, ftyp) {
		new Ajax.Request("filter.php?id="+encodeURI(id)+"&elem="+encodeURI(elem)+"&ftyp="+encodeURI(ftyp),
				 {
				 	method:"get",
				 	onComplete:function(xhr){
						for (i=0; i< DropArr.length; i++) {
							$(DropArr[i]).innerHTML = DropArr[i].substring(7);
					    } // for
						
						$('dropBox'+ftyp).innerHTML = ftyp+" :: "+elem;
						$('vaContainer').innerHTML = xhr.responseText;
						$('filter').setAttribute("class","");
						window.location.reload();
				 	}
				 });
		//window.location.reload();
	}
		
	function changeBG(dropID,status) {
	
		for (i=0; i< DropArr.length; i++) {
	      if (DropArr[i] != dropID) {
	   	   document.getElementById(DropArr[i]).style.color = "#FFFFFF";    
		   document.getElementById(DropArr[i]).style.backgroundImage = "url(templates/images/bg_select.gif)";
		   	}
	    }
		
		if (status == "activ") {
			document.getElementById(dropID).style.color = "#dd007a";
			document.getElementById(dropID).style.backgroundImage = "url(templates/images/bg_select_over.gif)";
		}
		else if (status == "inactiv") {
			document.getElementById(dropID).style.color = "#FFFFFF";
			document.getElementById(dropID).style.backgroundImage = "url(templates/images/bg_select.gif)";
		}
		else {
			if (dropID != 0) {
			document.getElementById(dropID).style.color = "#FFFFFF";
			document.getElementById(dropID).style.backgroundImage = "url(templates/images/bg_select.gif)";
			}
		}
	}
	 
 	

			
			