// JavaScript Document

function toggleDiv(id){

	$$('div.category').each(function(el){
       el.style.display = "none";
    }); 
	
	$$('img.menu_img').each(function(el){
       el.src = el.src.replace(/_active/,"_inactive");
    }); 
	
	
	
	
	img = document.getElementById(id+"_img");
	
	img.src = img.src.replace(/_inactive/,"_active");
	img.src = img.src.replace(/_rollOver/,"_active");
	
	elem = document.getElementById(id);
	elemChild = $$('#'+id+' div')[0];
	elemChild.className = elemChild.className + " active_div";
	//alert(window.innerHeight);
	//alert(document.body.clientHeight);
	
	
	
	
	
	
	
	if(elem.style.display != "block"){
		
		elem.style.display = "block";	
		
	}else{
		
		elem.style.display = "none";
	}
	
	if (window.innerHeight) {
		height = window.innerHeight
	}
	else {
		height = window.document.body.clientHeight
	}
	
	elemChild.style.minHeight = height - 114 + "px";
	//elemChild.style.height = "auto !important";
	elemChild.style.height = height - 114 + "px";
	$$('div.back_shade').each(function(el){
			//el.style.minHeight = height - 114 - 46 + "px";
			
			el.style.minHeight = height + "px";
			el.style.height = height + "px";
		});	
	bgHeight = getPageSizeWithScroll();
	
	if(bgHeight > height){
		$$('div.back_shade').each(function(el){
			//el.style.minHeight = height - 114 - 46 + "px";
			
			el.style.minHeight = bgHeight + "px";
			el.style.height = bgHeight + "px";
		});	
	}
	
}

function toggleDivIE(id){

	$$('div.category').each(function(el){
       el.style.display = "none";
    }); 
	
	$$('span.menu_img').each(function(el){
       el.filters(0).src = el.filters(0).src.replace(/_active/,"_inactive");
    }); 
	id = id.replace("_img","");
	img = document.getElementById(id+"_img");
	var currentAlphaImg = img.filters(0).src

	img.filters(0).src = currentAlphaImg.replace(/_inactive/,"_active");
	
	elem = document.getElementById(id);
	elemChild = $$('#'+id+' div')[0];
	elemChild.className = elemChild.className + " active_div";
	//alert(window.innerHeight);
	//alert(document.body.clientHeight);
	
		imgs = $$('div.imageBlock');
		for(i=0;i<imgs.length;i++){
			imgs[i].style.display = "none";	
		}
	
	if(elem.style.display != "block"){
		
		elem.style.display = "block";	
		img = document.getElementById("images1").style.display = "block";
		
	}else{
		elem.style.display = "none";
	}
	if (window.innerHeight) {
		height = window.innerHeight
	}
	else {
		height = window.document.body.clientHeight
	}
	
	elemChild.style.minHeight = height - 114 + "px";
	//elemChild.style.height = "auto !important";
	elemChild.style.height = height - 114 + "px";
	$$('div.back_shade').each(function(el){
			//el.style.minHeight = height - 114 - 46 + "px";
			
			el.style.minHeight = height + "px";
			el.style.height = height + "px";
		});	
	bgHeight = getPageSizeWithScroll();
	
	if(bgHeight > height){
		$$('div.back_shade').each(function(el){
			//el.style.minHeight = height - 114 - 46 + "px";
			
			el.style.minHeight = bgHeight + "px";
			el.style.height = bgHeight + "px";
		});	
	}
}

function switchBlock(col,id){
	$$('li.linkLi').each(function(el){
       el.style.color = "#018183";
	   el.style.textDecoration = "underline";
    });
	$$('li.subitem').each(function(el){
       el.style.color = "#018183";
	   el.style.textDecoration = "none";
    });
	elem = document.getElementById("link_"+id);
	
	if(typeof(elem) != "undefined"){
		elem.style.color = "#000000";
		elem.style.textDecoration = "none";
	}
	$$('div.'+col).each(function(el){
       el.style.display = "none";
    }); 
	$$('div.'+id).each(function(el){
       el.style.display = "block";
    });
	$$('div.imageBlock').each(function(el){
      	el.style.display = "none";
    }); 
	$$('div.'+id).each(function(el){
      	el.style.display = "block";
    }); 
	if(col == 3){
    	document.getElementById("voorstelling_input").value = $('hidden_'+id).value;
    	$('success').innerHTML = "";
		$('contact-form').style.display = "block";
	}
}

function setHeight(){
	
	if (window.innerHeight) {
		height = window.innerHeight
	}
	else {
		height = window.document.body.clientHeight
	}
	
	minheight = height - 114;
	//elemChild.style.height = "auto !important";
	height2 = height - 114;
	
	$$('div.active_div').each(function(el){
      	//el.style.minHeight = height - 114 - 46 + "px";
		
		el.style.minHeight = minheight + "px";
		el.style.height = height2 + "px";
    });	
	
	$$('div.back_shade').each(function(el){
			//el.style.minHeight = height - 114 - 46 + "px";
			
			el.style.minHeight = height + "px";
			el.style.height = height + "px";
		});	
	bgHeight = getPageSizeWithScroll();
	
	if(bgHeight > height){
		$$('div.back_shade').each(function(el){
			//el.style.minHeight = height - 114 - 46 + "px";
			
			el.style.minHeight = bgHeight  + "px";
			el.style.height = bgHeight + "px";
		});	
	}
}

var arVersion = navigator.appVersion.split("MSIE")
var version = parseFloat(arVersion[1])


function fixPNG(myImage, id, col) 
{
    if ((version >= 5.5) && (version < 7) && (document.body.filters)) 
    {
	   var imgID = (myImage.id) ? "id='" + myImage.id + "' " : ""
	   var imgClass = (myImage.className) ? "class='" + myImage.className + "' " : ""
	   var imgTitle = (myImage.title) ? 
		             "title='" + myImage.title  + "' " : "title='" + myImage.alt + "' "
	   var imgStyle = "display:inline-block;" + myImage.style.cssText
	   var imgSrc = myImage.src.replace(".png",".png");
	   
	   var strNewHTML = "<span " + imgID + imgClass + imgTitle
                  + " style=\"" + "width:" + myImage.width 
                  + "px; height:" + myImage.height 
                  + "px;" + imgStyle + ";"
                  + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
                  + "(src=\'" + imgSrc + "\', sizingMethod='image');\" onclick=\"toggleDivIE('"+myImage.id+"');switchBlock('"+col+"','"+col+"_"+id+"');\"></span>"
	   myImage.outerHTML = strNewHTML	  
    }
}

function getPageSizeWithScroll(){
	if (window.innerHeight && window.scrollMaxY) {// Firefox
		yWithScroll = window.innerHeight + window.scrollMaxY;
		xWithScroll = window.innerWidth + window.scrollMaxX;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		yWithScroll = document.body.scrollHeight;
		xWithScroll = document.body.scrollWidth;
	} else { // works in Explorer 6 Strict, Mozilla (not FF) and Safari
		yWithScroll = document.body.offsetHeight;
		xWithScroll = document.body.offsetWidth;
  	}
	
	//alert( 'The height is ' + yWithScroll + ' and the width is ' + xWithScroll );
	return yWithScroll;
}

function sendForm(){
	 $('contact-form').style.display = "none";
	 $('success').innerHTML = "<p>Je kaartjes zijn gereserveerd, je ontvangt hier binnenkort bericht over!</p>"; 
	var req = new Request({
           method: 'get',
            url: "http://www.projectvida.nl/sendMail.php",
            data: $('contact-form').toQueryString(),
            onRequest: function() {  
				$('contact-form').style.display = "none";
	 			$('success').innerHTML = "<p>De reservering wordt verzonden...</p>";  
			},
            onComplete: function(response) { 
				 $('contact-form').style.display = "none";
				 $('success').innerHTML = "<p>Je kaartjes zijn gereserveerd, je ontvangt hier binnenkort bericht over!</p>"; 
			}
        }).send();
}

function setRes(val){
	if(val == "1"){
		document.getElementById("reserveringsForm").style.display = "";
	}else{
		document.getElementById("reserveringsForm").style.display = "none";
		
	}
}
