// JavaScript Document

window.onresize = function(){

	applyLayout();

}

window.onload = function(){

	applyLayout();
	fnFixPng();
	pngFix();

}

function applyLayout() {
			
	var heightMenu = document.getElementById('links').clientHeight; 
	var heightInhoud = document.getElementById('inhoud').scrollHeight;
	
	//alert(heightMenu);
	//alert(heightInhoud);
	
	if(heightMenu > document.getElementById('inhoud').scrollHeight){

	//alert("menu is hoger dan inhoud");
	
		document.getElementById('inhoud').style.height = heightMenu - 249 + "px" ;	
		
	}
	
	//alert(document.getElementById('inhoud').scrollHeight);
	//alert(document.getElementById('inhoud').clientHeight);
	
	if( document.getElementById('inhoud').scrollHeight >  document.getElementById('midden').clientHeight){
		
		//alert("inhoud firefox issue");		
		
		document.getElementById('inhoud').style.height = document.getElementById('inhoud').scrollHeight;
		
	}
	
	if(document.body.scrollHeight+1 > document.getElementById('midden').scrollHeight){

		//alert("body is groter");		

		var paginaHoogte = document.body.scrollHeight;
		var paginaMaxHoogte = paginaHoogte - 211 - 196 - 80;
		document.getElementById('inhoud').style.height = paginaMaxHoogte - 40 + "px" ;
		document.getElementById('links').style.height = paginaMaxHoogte + 219 + "px" ;
		
	} else {

		//alert("body is kleiner");		

		var paginaHoogte = document.getElementById('midden').scrollHeight;
		var paginaMaxHoogte = paginaHoogte - 211 - 196 - 80;
		document.getElementById('links').style.height = paginaMaxHoogte + 219 + "px" ;

	}
	
	//alert(paginaHoogte);
	
	document.getElementById('left').style.height = paginaHoogte + "px";
	document.getElementById('right').style.height = paginaHoogte + "px" ;
				
}
		
function fnFixPng() { 

    var obj = document.getElementById("left"); 
    var bg    = obj.currentStyle.backgroundImage; 
    var src = bg.substring(5,bg.length-2); 
    obj.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + src + "', sizingMethod='scale')"; 
    obj.style.backgroundImage = "none"; 
	
    var obj = document.getElementById("right"); 
    var bg    = obj.currentStyle.backgroundImage; 
    var src = bg.substring(5,bg.length-2); 
    obj.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + src + "', sizingMethod='scale')"; 
    obj.style.backgroundImage = "none"; 

}	

function pngFix(){

	var arVersion = navigator.appVersion.split("MSIE")
	var version = parseFloat(arVersion[1])
	
	if ((version >= 5.5) && (document.body.filters)) 
	{
	   for(var i=0; i<document.images.length; i++)
	   {
		  var img = document.images[i]
		  var imgName = img.src.toUpperCase()
		  if (imgName.substring(imgName.length-3, imgName.length) == "PNG")
		  {
			 var imgID = (img.id) ? "id='" + img.id + "' " : ""
			 var imgClass = (img.className) ? "class='" + img.className + "' " : ""
			 var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' "
			 var imgStyle = "display:inline-block;" + img.style.cssText 
			 if (img.align == "left") imgStyle = "float:left;" + imgStyle
			 if (img.align == "right") imgStyle = "float:right;" + imgStyle
			 if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle
			 var strNewHTML = "<span " + imgID + imgClass + imgTitle
			 + " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
			 + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
			 + "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>" 
			 img.outerHTML = strNewHTML
			 i = i-1
		  }
	   }
	}
}

function movepic(img_name,img_src) {
document.getElementById(img_name).src=img_src;
}
