var varCMSTable;
var varCMSID;
var varCMSIDT;
var varCMSIDPC;
var varCMSxID;
var varRPThema;
var varRPPortaal;
var CMSAction;
var varCodeLogin;

varRPPortaal=1;

function alertWin(gotoURL,msg){
	if (confirm(msg)){
		sUrl = gotoURL + '&del=1'
		//alert(sUrl)
		window.location.href = sUrl
	}
}

	function setHash(hashID){
		oItem=MM_findObj('sHash');
		oItem.value=hashID;			
			
	}

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 setFrame(Page,IDProduct){
	objFrame=MM_findObj('winFrame');
	gotoURL=Page+'?IDproduct=' + IDProduct;
	objFrame.src=gotoURL;
	MM_showHideLayers('winLarge','','show');
}

function setFrameSmall(Page,IDPage){
	objFrame=MM_findObj('winFrameSmall');
	gotoURL=Page+'?IDPage=' + IDPage;
	objFrame.src=gotoURL;
	MM_showHideLayers('winSmall','','show');
}

function MM_showHideLayers() { //v9.0
var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) 
  with (document) if (getElementById && ((obj=getElementById(args[i]))!=null)) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}

function hideOverlay(){
	//document.body.style.overflow='';
	oOverlay=MM_findObj('totalOverlay')	
	
	if(oOverlay){
		oOverlay.style.display='none';	
	}
	oFrame=MM_findObj('frameTop')	
	if(oFrame){
		oFrame.src='empty.html'
	}
}
function MM_setTextOfLayer(objId,x,newText) { //v9.0
  with (document) if (getElementById && ((obj=getElementById(objId))!=null))
    with (obj) innerHTML = unescape(newText);
}

function randomNumber(limit){
  return Math.floor(Math.random()*limit);
}

function randOrd(){
return (Math.round(Math.random())-0.5); } 

function submitForm(frmName){
	oForm=MM_findObj(frmName);
	oForm.submit();
}
function showPageTitle(){
	objPageTitle=MM_findObj('themaText')
	objPageTitle.style.display='block'
}

function hideAll(tagName){
	var tag = document.getElementsByTagName('UL')
	for(x=0; x<tag.length; x++){
	//hide all div layers with the 'nav' attribute	
		if(tag[x].getAttribute(tagName)){
			tag[x].style.left='-10000px';
		}
	}
}

function hideAllCMS(){
	var tag = document.getElementsByTagName('DIV')
	for(x=0; x<tag.length; x++){
	//hide all div layers with the 'nav' attribute	
		if(tag[x].getAttribute('cms')){		
				tag[x].style.display='none';

		}
	}
}
function setCMS(){
	var tag = document.getElementsByTagName('DIV')
	for(x=0; x<tag.length; x++){
	//hide all div layers with the 'nav' attribute	
		if(tag[x].getAttribute('cms')){
			if (tag[x].style.display=='block'){
				tag[x].style.display='none';
			}else{
				tag[x].style.display='block';	
			}
		}
	}
}


function closeLayer(){
	oWindow=MM_findObj('windowTop')
	if(oWindow){
		oWindow.style.display='none';
	}
}

function getScrollHeight(){
	var h = window.pageYOffset || document.body.scrollTop || document.documentElement.scrollTop;
	return h ? h : 0;
}
function openLayer(iWidth,iHeight,sPage){
	hideCMS();
	oOverlay=MM_findObj('totalOverlay');	
	yScroll=getScrollHeight();	
	//document.body.style.overflow='hidden';
	winHeight=document.documentElement.clientHeight;
	winWidth=document.documentElement.clientWidth;
	
	var myWidth = 0, myHeight = 0;
	oContainer=MM_findObj("container")
	if (oContainer){
		hContainer=oContainer.offsetHeight
	}
	
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }
  	winHeight=myHeight;
	winWidth=myWidth;

	
	if(oOverlay){
		oOverlay.style.display='block'
		oOverlay.style.height=hContainer+80 +'px';
		
	}
	
	oWindow=MM_findObj('windowTop')
	if(oWindow){
		oWindow.style.display='block';
		oWindow.style.top=yScroll+100+'px';
		oWindow.style.width=iWidth+'px';
		oWindow.style.height=iHeight+'px';
		oWindow.style.left=(winWidth-iWidth)/2 + 'px';
	}
	oFrame=MM_findObj('frameTop')
	if(oFrame){
		oFrame.style.display='block';
		oFrame.style.width=iWidth-10+'px';
		oFrame.style.height=iHeight-30+'px';
		oFrame.src=sPage;
	}
	oClose=MM_findObj('winClose')
	if(oClose){
		oClose.style.width=iWidth-10+'px';
	}
	oTrans=MM_findObj('winTrans')
	if(oTrans){
		oTrans.style.height=iHeight-10+'px';
	}
	
	oMT=MM_findObj('winMT')
	if(oMT){
		oMT.style.width=iWidth-10+'px';
	}
	oMB=MM_findObj('winMB')
	if(oMB){
		oMB.style.width=iWidth-10+'px';
	}
}
function closeQuote(){
	oFrame=MM_findObj('frameQuoteTop')	
	if(oFrame){
		oFrame.src='empty.html'
	}
	oWindow=MM_findObj('quoteTop')
	if(oWindow){
		oWindow.style.display='none';
	}
}

function openQuote(oItem,iTop,iLeft,iWidth,iHeight,sPage){
	
	pos=findPos(oItem);
	iTop=pos.y-iTop;

	winHeight=document.documentElement.clientHeight;
	winWidth=document.documentElement.clientWidth;

	oWindow=MM_findObj('quoteTop')
	if(oWindow){
		oWindow.style.display='block';
		oWindow.style.width=iWidth+'px';
		oWindow.style.height=iHeight+'px';
		oWindow.style.top=iTop+'px';
		oWindow.style.left=(winWidth-iWidth)/2 - iLeft+'px';
		
	}
	oFrame=MM_findObj('frameQuoteTop')
	if(oFrame){
		oFrame.style.display='block';
		oFrame.style.width=iWidth-40+'px';
		oFrame.style.height=iHeight-45+'px';
		oFrame.src=sPage;
	}
}

function showCMS(oItem,iID,iIDT,iIDPC,ixID){
	varCMSID=iID;
	varCMSIDT=iIDT
	varCMSIDPC=iIDPC
	varCMSxID=ixID
	pos=findPos(oItem);
	iTop=pos.y+10;
	iLeft=pos.x+10;

	oItem=MM_findObj('menuItem1')
	if(oItem){
		if(ixID==0){
			oItem.style.display='none';
		}else{
			oItem.style.display='block';
		}
	}
	

	oWindow=MM_findObj('cmsMenu')
	if(oWindow){
		oWindow.style.display='block';
		oWindow.style.top=iTop+'px';
		oWindow.style.left=iLeft+'px';
	}
	
	
}

function hideCMS(){
	oWindow=MM_findObj('cmsMenu')
	if(oWindow){
		oWindow.style.display='none';
	}
}

function showCMSWindow(iAction){
	switch (iAction){
		case 1://wijzig
			gotoURL='http://cms2009.digitnet.nl/indexWindow.asp?ID='+varCMSID+'&IDT='+varCMSIDT+'&IDPC='+varCMSIDPC+'&xID='+varCMSxID +"&CL="+ varCodeLogin+"&IDDocThema="+ varRPThema
			openLayer(640,520,gotoURL);
		break;
		case 3://nieuw
			varCMSxID='';
			gotoURL='http://cms2009.digitnet.nl/indexWindow.asp?ID='+varCMSID+'&IDT='+varCMSIDT+'&IDPC='+varCMSIDPC+'&xID='+varCMSxID +"&CL="+ varCodeLogin+"&IDDocThema="+ varRPThema
			openLayer(640,520,gotoURL);
		break;
		case 4://verwijder
			gotoURL='/delWindow.asp?ID='+varCMSID+'&IDT='+varCMSIDT+'&IDPC='+varCMSIDPC+'&xID='+varCMSxID +"&CL="+ varCodeLogin+"&IDDocThema="+ varRPThema
			openLayer(300,200,gotoURL);
		break;
	}
	//gotoURL='CMSTable.asp?Table='+varCMSTable +'&ID='+varCMSID +'&Action='+iAction
	
	
}



function findPos(ctrl){
	var pos = {x:0,y:0}
	if (ctrl.offsetParent){
		while(ctrl.offsetParent){
		   pos.x+= ctrl.offsetLeft;
		   pos.y+= ctrl.offsetTop;
		   ctrl=ctrl.offsetParent;
		   }
	}else{
		  pos.x += ctrl.x;
		  pos.y += ctrl.y;
	  }
	  return pos;
}
function setSearchTab(tabVisible,tabV){
	tab1=MM_findObj('searchDoc')
	tab2=MM_findObj('searchNews')
	tab3=MM_findObj('searchAgenda')
	tab4=MM_findObj('searchLink')
	tab5=MM_findObj('searchContact')
	tab1.style.display='none';
	tab2.style.display='none';
	tab3.style.display='none';
	tab4.style.display='none';
	tab5.style.display='none';
	
	tabx1=MM_findObj('tabDoc')
	tabx2=MM_findObj('tabNews')
	tabx3=MM_findObj('tabAgenda')
	tabx4=MM_findObj('tabLink')
	tabx5=MM_findObj('tabContact')
	tabx1.style.backgroundColor='#EEEEEE';
	tabx2.style.backgroundColor='#EEEEEE';
	tabx3.style.backgroundColor='#EEEEEE';
	tabx4.style.backgroundColor='#EEEEEE';
	tabx5.style.backgroundColor='#EEEEEE';
	tabx1.style.fontWeight='normal';
	tabx2.style.fontWeight='normal';
	tabx3.style.fontWeight='normal';
	tabx4.style.fontWeight='normal';
	tabx5.style.fontWeight='normal';
	tabx1.style.color='#666666';
	tabx2.style.color='#666666';
	tabx3.style.color='#666666';
	tabx4.style.color='#666666';
	tabx5.style.color='#666666';
	
	tabV=MM_findObj(tabV)
	tabV.style.backgroundColor="#ffffff";
	tabV.style.fontWeight="bold";
	tabV.style.color="#000000";

	tabVis=MM_findObj(tabVisible)
	tabVis.style.display='block';
	
}

function setSelectAction(){
	oAction=MM_findObj("iAction")
	oflagAction=MM_findObj("flagAction")
	if(oAction.value!='0'){	
		oflagAction.value='1'
		oForm=MM_findObj('selectForm')
		switch (oAction.value){
			case "5":
				oForm.action="mailWindow.asp"				
				break;
			case "1":
				oForm.action="mailWindow.asp"				
				break;
			default:
				
		}
		oForm.submit();
	}else{
		alert('U moet een actie kiezen')
	}
}

function showMail(){
	
}

function setUserSelections(numUser){
	oAll=MM_findObj('selUserAll')
	if (oAll.checked){
		sValue=true;	
	}else{
		sValue=false;
	}
	for(i=0;i<numUser;i++){
		oItem=MM_findObj('selUser'+i)
		if (oItem){
			oItem.checked=sValue;
		}
	}
}

function formCheck(){
		flagError=0;
		arForm=new Array("Hash", "Naam","Adres","Plaats","Telefoon","Email","Vakken");
		for (var i=0; i<arForm.length; i++){
			oName='s' + arForm[i];
			oItem=MM_findObj(oName);
			oName='formErr'+arForm[i];
			oError=MM_findObj(oName);
			oName='form'+arForm[i];
			oBlock=MM_findObj(oName);
			//alert(oName+'='+oItem.value)
			if (oItem.value==''){				
				oError.style.display='block';	
				oBlock.style.borderLeft='5px solid #ff0000';
				oBlock.style.backgroundColor='#CCCCCC'
				flagError=1
			}else{
				oError.style.display='none';
				oBlock.style.borderLeft='5px solid #eeeeee';
				oBlock.style.backgroundColor='#eeeeee'
			}
			if (arForm[i]=='Email'){
				var a=oItem.value.indexOf('@')
				var p=oItem.value.indexOf('.')
				if (a==-1 || p==-1){
					oError.style.display='block';	
					oBlock.style.borderLeft='5px solid #ff0000';
					oBlock.style.backgroundColor='#CCCCCC'
					flagError=1
				}else{
					oError.style.display='none';
					oBlock.style.borderLeft='5px solid #eeeeee';
					oBlock.style.backgroundColor='#eeeeee'
				}
			}
			
			if (arForm[i]=='Plaats'){
				oPostCode=MM_findObj('sPostcode');				
				if (IsNumeric(oPostCode.value.substring(0,4))&& oPostCode.value.length>=4){
					oError.style.display='none';
					oBlock.style.borderLeft='5px solid #eeeeee';
					oBlock.style.backgroundColor='#eeeeee'
				}else{
					oError.style.display='block';	
					oBlock.style.borderLeft='5px solid #ff0000';
					oBlock.style.backgroundColor='#CCCCCC'
					flagError=1	
				}				
			}
		}
		
		
		
		arForm2=new Array("Geslacht");
		for (var i=0; i<arForm2.length; i++){
			oName = "b" + arForm2[i];
			oItem=MM_findObj(oName);
			flagSel=0
			for (var j=0; j<oItem.length;j++){
				if (oItem[j].checked){
					flagSel=1;			
				}
			}
			oName='formErr'+arForm2[i];;
			oError=MM_findObj(oName);
			oName='form'+arForm2[i];;
			oBlock=MM_findObj(oName);
			if (flagSel==0){
					oError.style.display='block';	
					oBlock.style.borderLeft='5px solid #ff0000';
					oBlock.style.backgroundColor='#CCCCCC'
					flagError=1
				}else{
					oError.style.display='none';
					oBlock.style.borderLeft='5px solid #eeeeee';
					oBlock.style.backgroundColor='#eeeeee'
			}
		}
		
		oButton=MM_findObj('formButton')
		
		oItem=MM_findObj('formErrorBlock')	
		if (flagError==1){
			oItem.style.display='block';
			oButton.style.display='block'
		}else{
			oItem.style.display='none';
			oButton.style.display='none'
			document.inschrijfFormulier.submit();
		}
		
		
	}
	
	
	function formCheck2(){
		flagError=0;
		arForm=new Array("Onderwijsinstelling","Contactpersoon","Adres","Plaats","Telefoon","Email");
		for (var i=0; i<arForm.length; i++){
			oName='s' + arForm[i];
			oItem=MM_findObj(oName);
			oName='formErr'+arForm[i];
			oError=MM_findObj(oName);
			oName='form'+arForm[i];
			oBlock=MM_findObj(oName);
			//alert(oName+'='+oItem.value)
			if (oItem.value==''){				
				oError.style.display='block';	
				oBlock.style.borderLeft='5px solid #ff0000';
				oBlock.style.backgroundColor='#CCCCCC'
				flagError=1
			}else{
				oError.style.display='none';
				oBlock.style.borderLeft='5px solid #eeeeee';
				oBlock.style.backgroundColor='#eeeeee'
			}
			if (arForm[i]=='Email'){
				var a=oItem.value.indexOf('@')
				var p=oItem.value.indexOf('.')
				if (a==-1 || p==-1){
					oError.style.display='block';	
					oBlock.style.borderLeft='5px solid #ff0000';
					oBlock.style.backgroundColor='#CCCCCC'
					flagError=1
				}else{
					oError.style.display='none';
					oBlock.style.borderLeft='5px solid #eeeeee';
					oBlock.style.backgroundColor='#eeeeee'
				}
			}
			
			if (arForm[i]=='Plaats'){
				oPostCode=MM_findObj('sPostcode');				
				if (IsNumeric(oPostCode.value.substring(0,4))&& oPostCode.value.length>=4){
					oError.style.display='none';
					oBlock.style.borderLeft='5px solid #eeeeee';
					oBlock.style.backgroundColor='#eeeeee'
				}else{
					oError.style.display='block';	
					oBlock.style.borderLeft='5px solid #ff0000';
					oBlock.style.backgroundColor='#CCCCCC'
					flagError=1	
				}				
			}
		}

		oButton=MM_findObj('formButton')
		
		oItem=MM_findObj('formErrorBlock')	
		if (flagError==1){
			oItem.style.display='block';
			oButton.style.display='block'
		}else{
			oItem.style.display='none';
			oButton.style.display='none'
			document.inschrijfFormulier.submit();
		}
		
		
	}
	
	
	function setHash(hashID){
		oItem=MM_findObj('sHash');
		oItem.value=hashID;			
			
	}
	
	function setGroup(){
		hideAllMenu('functieMenuTag');
		oItem=MM_findObj('sIDFunctieGroep');
		sValue=oItem.options[oItem.selectedIndex].value;
		if (sValue!=''){
			oName='functieGroep'+ sValue;
			oItem=MM_findObj(oName);
			oItem.style.display='block';
		}
	}
	function hideAllMenu(tagName){
	var tag = document.getElementsByTagName('DIV')
	for(x=0; x<tag.length; x++){
		//hide all div layers with the 'nav' attribute	
			if(tag[x].getAttribute(tagName)){
				tag[x].style.display='none';
			}
		}
	}
	
	function setTotalSelected(IDGroup, oBox){
		
		oItem=MM_findObj('sIDFunctieGroep');
		if(oBox.checked){
			arFG[IDGroup][1] = arFG[IDGroup][1]+1
		}else{
			arFG[IDGroup][1] = arFG[IDGroup][1]-1
		}
		if (arFG[IDGroup][1]!=0){
			oItem.options[IDGroup].text=arFG[IDGroup][0]+' ('+arFG[IDGroup][1]+')';
			oItem.options[IDGroup].style.color='#0092d3';
		}else{
			oItem.options[IDGroup].text=arFG[IDGroup][0]
			oItem.options[IDGroup].style.color='#000000';			
		}
	}
	
	function IsNumeric(sText){
		   var ValidChars = "0123456789.";
		   var IsNumber=true;
		   var Char;		
		 
		   for (i = 0; i < sText.length && IsNumber == true; i++) 
			  { 
			  Char = sText.charAt(i); 
			  if (ValidChars.indexOf(Char) == -1) 
				 {
				 IsNumber = false;
				 }
			  }
		   return IsNumber;
   
   }


function openAnswer(numQ){
	hideAllMenu('navQ')
	oQ=MM_findObj(numQ)
	if (oQ){
		oQ.style.display='block'	;
	}	
}


