/*
#########################################################
#
# default javascript functions for the entire site
#
# Copyright:		2007 S-Inside
# Project:			www.aspergerecepten.nl
# Platform:			Javascript
#
#########################################################
*/

if (top != self) self.location.href = "index.html";

window.onload = function() {
	if (navigator.appName == "Microsoft Internet Explorer") {
		var htmlStyle = document.getElementsByTagName('html')[0].style;
		var bodyStyle = document.body.style;
		
		bodyStyle.scrollbarFaceColor = htmlStyle.scrollbarFaceColor = '#0a4329';
		bodyStyle.scrollbarArrowColor = htmlStyle.scrollbarArrowColor = '#fef500';
		bodyStyle.scrollbarTrackColor = htmlStyle.scrollbarTrackColor = '#8f8f8f';
		bodyStyle.scrollbarShadowColor = htmlStyle.scrollbarShadowColor = '#5C5a5a';
		bodyStyle.scrollbarHighlightColor = htmlStyle.scrollbarHighlightColor = '#0a4329';
		bodyStyle.scrollbar3dlightColor = htmlStyle.scrollbar3dlightColor = '#e0dada';
		bodyStyle.scrollbarDarkshadowColor = htmlStyle.scrollbarDarkshadowColor = '#000000';
	}
}

function MM_showHideLayers() { //v3.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; v=(v=='show')?'visible':(v='hide')?'hidden':v;
			}
    		obj.visibility=v; 
		}
	}
	
	if (document.getElementById("image_big")) {
		hideBigImage();
	}
	if (document.getElementById("menu_zIndex")) {
		if (v == 'visible') {
			document.getElementById("menu_zIndex").style.zIndex = 111;			
		} else {
			document.getElementById("menu_zIndex").style.zIndex = 11;
		}
	}
}

function MM_findObj(n, d) { //v4.0
	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 && document.getElementById) {
		x=document.getElementById(n); 
	}
	return x;
}

function MM_openBrWindow(theURL,winName,width,height)
    { //v2.0 for Aurora Magazine
        height = height ;
        var winl = (screen.width - width) / 2;
        var wint = (screen.height - height) / 2;
        var i = width ;
        var j = height ;
        var features = 'scrollbars=no,resizable=no,width='+width+',height='+height+',top='+wint+',left='+winl+'';
        var popupscherm;
        popupscherm=window.open(theURL,winName,features);
        popupscherm.resizeTo(i,j);
        popupscherm.focus();
    }
    
function pophtml(src,winwidth,winheight){
	var wLook='width='+winwidth+',height='+winheight+',resizable=yes,scrollbars=yes,toolbar=no,titlebar=no,status=no,menubar=yes'
	popwin=window.open(src,"",wLook)
	
	if (window.focus) {
    	popwin.focus()
    }
}

function pophtm(src,winwidth,winheight){
	var wLook='width='+winwidth+',height='+winheight+',resizable=yes,scrollbars=yes,toolbar=no,titlebar=no,status=no,menubar=yes'
	popwin=window.open(src,"",wLook)
}

function loadPDF($p_sPDFFile) {
	//alert($p_sPDFFile);
	if (($p_sPDFFile) && ($p_sPDFFile.length > 1)) {
		window.open($p_sPDFFile);
	}
}

/* toon grote foto en vervaag de rest van de pagina 
voorbeeld: onclick="showBigImage('consument_1.jpg',350,249);return false;"
*/ 
function showBigImage ($p_sImage, $p_nWidth, $p_nHeight) {
	//alert($p_nImage);
	var $sText = "";
	var $nWindowWidth = 0, $nWindowHeight = 0;
	var $nPosLeft = 0;
	var $nPosTop = 0;
	
	document.getElementById("image_big").innerHTML = "";
	
	if (parseInt(navigator.appVersion)>3) {
		if (navigator.appName=="Netscape") {
			$nWindowWidth = window.innerWidth;
			$nWindowHeight = window.innerHeight;
		}
		if (navigator.appName.indexOf("Microsoft")!=-1) {
			$nWindowWidth = document.body.offsetWidth;
			$nWindowHeight = document.body.offsetHeight;
		}
	}
	$nPosLeft = ($nWindowWidth - $p_nWidth + 150) / 2;
	
	if (window.pageYOffset) {
		$nPosTop = window.pageYOffset;
	} else if (document.documentElement.scrollTop) {
		$nPosTop = document.documentElement.scrollTop;
	}
	
	$sText = "<img src='"+$p_sImage+"' width='"+$p_nWidth+"' height='"+$p_nHeight+"' border='0' ";
	$sText += "alt='Klik om te sluiten' title='Klik om te sluiten' />";
	
	fadeContent(2);
    if ($nPosLeft > 0) {
    	document.getElementById("image_big").style.left = parseInt($nPosLeft)+'px';
	}
	if ($nPosTop > 50) {
		if ($nPosTop < 150) {
			$nPosTop += 120;
		} else if ($nPosTop > ($nWindowHeight - $p_nHeight)) {
			$nPosTop = $nWindowHeight - $p_nHeight - 100;
		}		
		document.getElementById("image_big").style.top = parseInt($nPosTop)+'px';
	}
	
    document.getElementById("image_big").innerHTML = $sText;
    document.getElementById("image_big").style.display = "inline";
    
}

function hideBigImage () {
	
	fadeContent(10);
	if (document.getElementById("image_big")) {
		document.getElementById("image_big").style.display = "none";
		document.getElementById("image_big").innerHTML = "";
	}	
}

function fadeContent($p_nOpacity) {
	var $sDisplay = "none";
	if ($p_nOpacity == 10) {
		$sDisplay = "inline";
	}
	if (document.getElementById("page")) {
		document.getElementById('page').style.opacity = $p_nOpacity/10;
		
		// deze veroorzaakt in IE7 lichtere letters, vooral bij titels zichtbaar
		// ligt aan opacity en cleartype 
		if ((document.getElementById('page').style.filter) || ($p_nOpacity < 10)) {
			document.getElementById('page').style.filter = 'alpha(opacity=' + $p_nOpacity*10 + ')';
		}		
	}
	
	if (document.forms.length > 0) {
		// hide select boxes because they get in front of error div
		for (n = 0; n < document.forms.length; n++) {
			var $field = document.forms[n];
				
		    // loop through the fields of the form
			for (i = 0; i < $field.length; i++) {
				if (($field.elements[i].type == "select-one") && ($field.elements[i].name != "mce_editor_0_formatSelect")) {
					//alert($field.elements[i].name);
					if ($field.elements[i]) {
						$field.elements[i].style.display = $sDisplay;
					}
		     	}
		  	}
	  	}
  	}
}

function showTextField ($p_sID) {
	if (document.getElementById($p_sID)) {
		if (document.getElementById($p_sID).style.display != "block") {
			document.getElementById($p_sID).style.display = "block";
		} else {
			document.getElementById($p_sID).style.display = "none";
		}
	}
}

function hideError () {
	
	fadeContent(10);
	if (document.getElementById("foutmelding")) {
		document.getElementById("foutmelding").innerHTML = "";
		document.getElementById("foutmelding").style.display = "none";
	}	
}

function checkForm() {
	var $sText = "", $sValue;
	var $nCounter = 0, $nPosLeft = 0, $nPosTop = 0, $nWindowWidth = 0;
	var $aMissing = new Array();
	if (document.forms[0].elements['verplicht']) {
		var $aRequired = document.forms[0].elements['verplicht'].value.split(",");
		
		for($i = 0; $i < $aRequired.length; $i++) {
			$sValue = document.forms[0].elements[$aRequired[$i]].value;
			if ($sValue) {
				if ($sValue.length < 2) {
					$aMissing[$nCounter] = $aRequired[$i];
					$nCounter++;
				}
			}
		}
	}	
	
	if ($nCounter > 0) {
		// we have empty required fields, show error
		if (parseInt(navigator.appVersion)>3) {
			// get screenport width
			if (navigator.appName=="Netscape") {
				$nWindowWidth = window.innerWidth;
			}
			if (navigator.appName.indexOf("Microsoft")!=-1) {
				$nWindowWidth = document.body.offsetWidth;
			}
		}
		$nPosLeft = ($nWindowWidth - 400) / 2;
		
		// get screenport height
		if (window.pageYOffset) {
			$nPosTop = window.pageYOffset;
		} else if (document.documentElement.scrollTop) {
			$nPosTop = document.documentElement.scrollTop;
		}
		
		// fade rest of the page
		fadeContent(2);
		
		// set position of error div
	    if ($nPosLeft > 0) {
	    	document.getElementById("foutmelding").style.left = parseInt($nPosLeft)+'px';
		}
		if ($nPosTop > 50) {
			if ($nPosTop < 150) {
				$nPosTop += 120;
			}
			document.getElementById("foutmelding").style.top = parseInt($nPosTop)+'px';
		}
		
		// create text with missing fields in bold		
		$sText += "<h3>Foutmelding</h3><p>De volgende verplichte velden zijn niet ingevuld:</p>";
		for($i = 0; $i < $aMissing.length; $i++) {
			$sText += "&nbsp;&nbsp;&nbsp;<b>"+$aMissing[$i]+"</b><br />";
		}
		$sText += "<p>Sluit dit venster en vul de aangegeven velden correct in.</p>";
		$sText += "<img src='img/closelabel.gif' width='66' height='22' border='0' alt='' align='right' hspace='5' />";
		
		// show text in error div and show text
		document.getElementById("foutmelding").innerHTML = $sText;
	    document.getElementById("foutmelding").style.display = "inline";
		
		return false; 
		
	} else {
		// all required fields filled out, go on
		return true;
	}
}

function switchYearCalendar ($p_nYear, $p_nSite) {
	self.location.href = $p_nSite + $p_nYear;
}