// JavaScript Document
if((document.all)&&(navigator.appVersion.indexOf("MSIE 7.")!=-1))
	{
    document.write("<style type=\"text/css\">.mainMenuSub{margin-left:0px;margin-top:5px;}</style>");
	}
else if((document.all)&&(navigator.appVersion.indexOf("MSIE 6.")!=-1))
	{
    document.write("<style type=\"text/css\">.mainMenuSub{margin-left:0px;margin-top:5px;width:200px;}.ContentContainer{height:500px;}</style>");
    }
	
function getPageSize(){
	
	var xScroll, yScroll;
	
	if (window.innerHeight && window.scrollMaxY) {	
		xScroll = document.body.scrollWidth;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	
	var windowWidth, windowHeight;
	if (self.innerHeight) {	// all except Explorer
		windowWidth = self.innerWidth;
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}	
	
	// for small pages with total height less then height of the viewport
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else { 
		pageHeight = yScroll;
	}

	// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth){	
		pageWidth = windowWidth;
	} else {
		pageWidth = xScroll;
	}


	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight) 
	return arrayPageSize;
}

// script voor target attribute
function externalLinks() { 
 if (!document.getElementsByTagName) return; 
 var anchors = document.getElementsByTagName("a"); 
 for (var i=0; i<anchors.length; i++) { 
   var anchor = anchors[i]; 
   if (anchor.getAttribute("href") && 
       anchor.getAttribute("rel") == "external") 
     anchor.target = "_blank"; 
 } 
} 
window.onload = externalLinks;

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

// move on max forms
function moveOnMax(field,nextFieldID){
  if(field.value.length >= field.maxLength){
    document.getElementById(nextFieldID).focus();
  }
}

// form validation


function validateEmail(required, imgID, inputID) 
	{
	var str = document.getElementById(inputID).value;
	var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
	if (filter.test(str))
		{ 
		changeState("valid", imgID);
		return true;
		}
	else if(required==true || str!='')
		{
		changeState("invalid", imgID);
		return false;
		}
	else
		{
		changeState("invalid_noreq", imgID);
		return true;
		}
	}

function validatePostcode(required, imgID, postcodeveld1, postcodeveld2) 
	{
	var str1 = document.getElementById(postcodeveld1).value;
	var str2 = document.getElementById(postcodeveld2).value;
	var filter1=/\d{4}$/i
	var filter2=/\D{2}$/i
	if (filter1.test(str1) && filter2.test(str2))
		{ 
		changeState("valid", imgID);
		return true;
		}
	else if(required==true || str1!='' || str2!='')
		{
		changeState("invalid", imgID);
		return false;
		}
	else
		{
		changeState("invalid_noreq", imgID);
		return true;
		}
	}

function validateBasic(required, imgID, inputID) 
	{
	var str = document.getElementById(inputID).value;
	if (str!='')
		{ 
		changeState("valid", imgID);
		return true;
		}
	else if(required==true)
		{
		changeState("invalid", imgID);
		return false;
		}
	else
		{
		changeState("invalid_noreq", imgID);
		return true;
		}
	}
	
function validateDual(required, imgID, inputID1, inputID2) 
	{
	var str1 = document.getElementById(inputID1).value;
	var str2 = document.getElementById(inputID2).value;
	if (str1!='' && str2!='')
		{ 
		changeState("valid", imgID);
		return true;
		}
	else if(required==true || str1!='' || str2!='')
		{
		changeState("invalid", imgID);
		return false;
		}
	else
		{
		changeState("invalid_noreq", imgID);
		return true;
		}
	}
	
function validateSelect(required, imgID, selectID) 
	{
	var str = document.getElementById(selectID).value;
	if (str!='' && str!='none')
		{ 
		changeState("valid", imgID);
		return true;
		}
	else if(required==true)
		{
		changeState("invalid", imgID);
		return false;
		}
	else
		{
		changeState("invalid_noreq", imgID);
		return true;
		}
	}
	
function validateRadioDep(required, formname, fieldname, dependance) 
	{
	var str = eval("document." + getElementById(formname) + "." + fieldname + ".value");
	if (getCheckedValue(eval("document." + getElementById(formname) + "." + fieldname))=="nee")
		{
		showHide(dependance,"hidden");
		changeState("valid", fieldname);
		}
	if (getCheckedValue(eval("document." + getElementById(formname) + "." + fieldname))=="ja")
		{
		showHide(dependance,"visible");
		changeState("valid", fieldname);
		}
	}
	
function validateRadio(required, formname, fieldname) 
	{
	var str = eval("document." + getElementById(formname) + "." + fieldname + ".value");
	if (getCheckedValue(eval("document." + getElementById(formname) + "." + fieldname))!="")
		{
		changeState("valid", fieldname);
		return true;
		}
	else if(required==true)
		{
		changeState("invalid", imgID);
		return false;
		}
	else
		{
		changeState("invalid_noreq", imgID);
		return true;
		}
	}

function getCheckedValue(radioObj) 
	{
	var radioLength = radioObj.length;
	if(radioLength == undefined)
		if(radioObj.checked)
			return radioObj.value;
		else
			return "";
	for(var i = 0; i < radioLength; i++) {
		if(radioObj[i].checked) {
			return radioObj[i].value;
		}
	}
	return "";
}

function changeState(state, elementid) 
	{
	if (state=="valid")
		{
		document.getElementById(elementid).src = "images/validation_valid.png";
		}
	else if (state=="invalid_noreq")
		{
		document.getElementById(elementid).src = "images/validation_invalidOptional.png";
		}
	else if (state=="invalid")
		{
		document.getElementById(elementid).src = "images/validation_invalidRequired.png";
		}
	}

function showHide(layer_ref,state) 
	{
	if (document.all) 
		{ //IS IE 4 or 5 (or 6 beta)
		eval( "document.all." + layer_ref + ".style.visibility = state");
		}
	if (document.layers) 
		{ //IS NETSCAPE 4 or below
		document.layers[layer_ref].visibility = state;
		}
	if (document.getElementById && !document.all) 
		{
		maxwell_smart = document.getElementById(layer_ref);
		maxwell_smart.style.visibility = state;
		}
	}

function statusBox(status,sMessage)
	{
		oStatusBox = document.getElementById('statusBox');
	if(status=='succes')
		{
		oStatusBox.innerHTML = sMessage;
		oStatusBox.style.border = "1px solid #009900"
		oStatusBox.style.backgroundColor = "#c8e2c8";
		oStatusBox.style.color = "#009900";
		oStatusBox.style.visibility = "visible";
		}
	else if(status=='fail')
		{
		oStatusBox.innerHTML = sMessage;
		oStatusBox.style.border = "1px solid #FF0000"
		oStatusBox.style.backgroundColor = "#fccdcd";
		oStatusBox.style.color = "#FF0000";
		oStatusBox.style.visibility = "visible";	
		}
	else if(status=='tip')
		{
			
		}
	else if(status=='warning')
		{
			
		}
	}
	
	
function confirmWindow(sTitle,sStatus,sQuestion,sURL) {
	var popupWindow = document.getElementById("popupWindow");
	popupWindow.innerHTML = '<strong>' + sTitle + '</strong><br /><br /><span class="groeneTekst">' + sStatus + '</span><br /><br />' + sQuestion + '<br /><br /><table width="100%" border="0" cellspacing="0" cellpadding="0"><tr><td><div align="center"><input name="ignJa" type="button" onclick="closePopupWindow();" style="width:75px;" value="Ja"></div></td><td><div align="center"><input name="ignNee" type="button" onclick="closePopupWindow();gotoURL(\'' + sURL + '\');" style="width:75px;" value="Nee"></div></td></tr></table>';
	var arrayPageSize = getPageSize();
	popupWindow.style.top = ((arrayPageSize[1] / 2) - (popupWindow.offsetHeight / 2)) + "px";
	popupWindow.style.left = ((arrayPageSize[0] / 2) - (popupWindow.offsetWidth / 2)) + "px";
	popupWindow.style.visibility = "visible";
	fadeBody('fadein');
	if (window.createPopup && !window.XmlHttpRequest){ //if IE5.5 to IE6, create iframe for iframe shim technique
		setShim("popupWindow","iframePopup");
	}
}

function confWindow(sQuestion,sFormId,sAction) {
	var popupWindow = document.getElementById("popupWindow");
	popupWindow.innerHTML = '<strong>Bevestiging</strong><br /><br />' + sQuestion + '<br /><br /><table width="100%" border="0" cellspacing="0" cellpadding="0"><tr><td><div align="center"><input name="ignJa" type="button" onclick="closePopupWindow();submitForm(\'' + sFormId + '\',\'' + sAction + '\');" style="width:75px;" value="Ja"></div></td><td><div align="center"><input name="ignNee" type="button" onclick="closePopupWindow();resetForm(\'' + sFormId + '\');" style="width:75px;" value="Nee"></div></td></tr></table>';
	var arrayPageSize = getPageSize();
	popupWindow.style.top = ((arrayPageSize[1] / 2) - (popupWindow.offsetHeight / 2)) + "px";
	popupWindow.style.left = ((arrayPageSize[0] / 2) - (popupWindow.offsetWidth / 2)) + "px";
	popupWindow.style.visibility = "visible";
	fadeBody('fadein');
	if (window.createPopup && !window.XmlHttpRequest){ //if IE5.5 to IE6, create iframe for iframe shim technique
		setShim("popupWindow","iframePopup");
	}
}

function submitForm(elementID,sAction) {
	document.forms[elementID].action = document.forms[elementID].action + sAction;
	document.forms[elementID].submit();
}

function resetForm(elementID) {
	document.forms[elementID].reset();
}

function alertWindow(sTitle,sInfo,sURL) {
	var popupWindow = document.getElementById("popupWindow");
	popupWindow.innerHTML = '<strong>' + sTitle + '</strong><br /><br /><span class="rodeTekst">' + sInfo + '</span><br /><br /><table width="100%" border="0" cellspacing="0" cellpadding="0"><tr><td><div align="center"><input name="ignSluiten" type="button" onclick="closePopupWindow();" style="width:75px;" value="OK"></div></td></tr></table>';
	var arrayPageSize = getPageSize();
	popupWindow.style.top = ((arrayPageSize[1] / 2) - (popupWindow.offsetHeight / 2)) + "px";
	popupWindow.style.left = ((arrayPageSize[0] / 2) - (popupWindow.offsetWidth / 2)) + "px";
	popupWindow.style.visibility = "visible";
	fadeBody('fadein');
	if (window.createPopup && !window.XmlHttpRequest){ //if IE5.5 to IE6, create iframe for iframe shim technique
		setShim("popupWindow","iframePopup");
	}
}

function alertWindowURL(sTitle,sInfo,sURL) {
	var popupWindow = document.getElementById("popupWindow");
	popupWindow.innerHTML = '<strong>' + sTitle + '</strong><br /><br /><span class="rodeTekst">' + sInfo + '</span><br /><br /><table width="100%" border="0" cellspacing="0" cellpadding="0"><tr><td><div align="center"><input name="ignSluiten" type="button" onclick="closePopupWindow();gotoURL(\'' + sURL + '\');" style="width:75px;" value="OK"></div></td></tr></table>';
	var arrayPageSize = getPageSize();
	popupWindow.style.top = ((arrayPageSize[1] / 2) - (popupWindow.offsetHeight / 2)) + "px";
	popupWindow.style.left = ((arrayPageSize[0] / 2) - (popupWindow.offsetWidth / 2)) + "px";
	popupWindow.style.visibility = "visible";
	fadeBody('fadein');
	if (window.createPopup && !window.XmlHttpRequest){ //if IE5.5 to IE6, create iframe for iframe shim technique
		setShim("popupWindow","iframePopup");
	}
}

function closePopupWindow() {
	fadeBody('fadeout');
	document.getElementById('popupWindow').style.visibility = "hidden";	
	if (window.createPopup && !window.XmlHttpRequest){ //if IE5.5 to IE6, create iframe for iframe shim technique
		unsetShim("popupWindow","iframePopup");
	}
}

function gotoURL(sURL) {
	window.location = sURL;	
}

var x;var y
function displayHelp(elementID) {
	x=elementID.offsetLeft;
	y=elementID.offsetTop;
	while(elementID.offsetParent)
		{
		if(elementID==document.getElementsByTagName('body')[0])
			{
			break;
			}
		else
			{
			x=x+elementID.offsetParent.offsetLeft;
			y=y+elementID.offsetParent.offsetTop;
			elementID=elementID.offsetParent;
			}
		}
	var helpWindow = document.getElementById("popupHelp");
	var sContents = '<table width="250" border="0" cellspacing="0" cellpadding="0"><tr><td style="width:25px;"></td><td><strong>Formulier validatie hulp</strong><br /><br /></td></tr><tr><td valign="top"><img src="images/validation_valid.png" style="vertical-align:text-top;" width="16" height="16" alt="Valid"></td><td valign="top">De inhoud van het veld is geldig.<br /><br /></td></tr><tr><td valign="top"><img src="images/validation_invalidOptional.png" style="vertical-align:text-top;" width="16" height="16" alt="Ongeldig Optioneel"></td><td valign="top">De inhoud van het veld is ongeldig, maar het veld is optioneel. Formulier kan opgeslagen worden.<br /><br /></td></tr><tr><td valign="top"><img src="images/validation_invalidRequired.png" style="vertical-align:text-top;" width="16" height="16" alt="Ongeldig Verplicht"></td><td valign="top">De inhoud van het veld is ongeldig, dit is een verplicht veld. Zolang de inhoud ongeldig is kan het formulier niet opgeslagen worden. Verander de inhoud tot er een groen vinkje verschijnt.<br /><br /></td></tr></table>';
	helpWindow.innerHTML = sContents;
	helpWindow.style.top = y + 20 + "px";
	helpWindow.style.left = x + 20 + "px";
	helpWindow.style.visibility = "visible";
	if (window.createPopup && !window.XmlHttpRequest){ //if IE5.5 to IE6, create iframe for iframe shim technique
		setShim("popupHelp","iframePopup");
	}
	
}

function hideHelp(elementID) {
	var helpWindow = document.getElementById("popupHelp");
	helpWindow.style.visibility = "hidden";
	if (window.createPopup && !window.XmlHttpRequest){ //if IE5.5 to IE6, create iframe for iframe shim technique
		setShim("popupHelp","iframePopup");
	}
}


function createShim() {
	if (window.createPopup && !window.XmlHttpRequest){ //if IE5.5 to IE6, create iframe for iframe shim technique
		document.write('<IFRAME id="iframePopup"  src="" style="display: none; left: 0; top: 0; z-index: 80; position: absolute; filter: progid:DXImageTransform.Microsoft.Alpha(style=0,opacity=0)" frameBorder="0" scrolling="no"></IFRAME>')
	}
}

function setShim(objName,frameName){ //display iframe shim function
if (typeof document.getElementById(frameName)!="undefined")
	{
	if (document.getElementById(objName).style.visibility=="visible")
		{
		document.getElementById(frameName).style.width=document.getElementById(objName).offsetWidth+"px";
		document.getElementById(frameName).style.height=document.getElementById(objName).offsetHeight+"px";
		document.getElementById(frameName).style.left=document.getElementById(objName).style.left;
		document.getElementById(frameName).style.top=document.getElementById(objName).style.top;
		}
	document.getElementById(frameName).style.display=(document.getElementById(objName).style.visibility=="visible")? "block" : "none";
	}
}

function unsetShim(objName,frameName){
if (typeof document.getElementById(frameName)!="undefined")
	{
	document.getElementById(frameName).style.display='none';
	}
}

createShim();

function fadeBody(state) 
	{
	if(state=='fadein') 
		{
		document.getElementById("bodyTag").className = "fade";
		} 
	else if(state=='fadeout')
		{
		document.getElementById("bodyTag").className = "none";
		}	
	}

function toggleAllCheckboxes(check)
{
	formObj = check.form;
	for (var i=0;i < formObj.length; i++) {
		fldObj = formObj.elements[i];
		if (fldObj.type == 'checkbox') {
			fldObj.checked = check.checked;
		}
	}
}

function submitLive(id)
{
	document.pagBekijken.action = 'index.php?sec=sde&act=pagBekijken&qAct=ignToggleState&qId='+id;
	document.pagBekijken.submit();	
}

function submitLiveNews(id)
{
	document.pagBewerken.action = 'index.php?sec=sde&act=pagBewerken&qAct=ignToggleState&qItemId='+id;
	document.pagBewerken.submit();	
}

function submitLiveFAQ(id)
{
	document.pagBewerken.action = 'index.php?sec=sde&act=pagBewerken&qAct=ignToggleState&qItemId='+id;
	document.pagBewerken.submit();	
}

function submitHome(id)
{
	document.pagBekijken.action = 'index.php?sec=sde&act=pagBekijken&qAct=ignSetHome&qId='+id;
	document.pagBekijken.submit();	
}
