function init_cms() {
  XBrowserAddHandler(window, 'load', init_cms2);
}

function init_cms2() {
  // controleren of deze wel toegevoegd moet worden
  if (typeof(checkformonsubmit) == 'undefined' && document.forms.length > 0) {
    filename = '/cmsstandaard.js';
    var f = document.createElement('SCRIPT');
    f.setAttribute("type","text/javascript");
    f.setAttribute("src", filename);
    document.getElementsByTagName("head")[0].appendChild(f);
  }
  
  var d = document.createElement('DIV');
  d.innerHTML = '<div id="cmsmetcontent" name="cmsmetcontent"></div>';
  d.id = d.name = "cms_content";
  d.style.zIndex = 101;
  d.style.position = "absolute";
  d.style.left = "0px";
  d.style.top = "0px";
  d.style.height = "100%";
  d.style.width = "100%";
  d.style.display = "none";
  d.style.backgroundImage = "url(/_cms/agtrans.png)";
  d.align = "center";
  d.valign = "middle";
  document.body.appendChild(d);
}

var status = "off";
var verloopt = new Date(); 
var voorkeur = "-1";
verloopt.setMonth(verloopt.getMonth() + 1); 

function switchcms(){
	
	balkoff = document.getElementById('cmsbalk_off');
	balkon = document.getElementById('cmsbalk_on');
	
	
		if(status == 'off'){
			
			balkoff.style.display = "none";
			balkon.style.display = "block";
			status  = "on";
			 				 
			 document.cookie = "stcms="+status+";expires="+verloopt+";path=/"; 
	 			 
			 return;
			 		}
		
		if(status == 'on'){
			
			balkoff.style.display = "block";
			balkon.style.display = "none";
			status  = "off";
			
			document.cookie = "stcms="+status+";expires="+verloopt+";path=/"; 

			return;
		}
}

function init(){
	if(csearch('stcms') == 'on') {
    switchcms();
	}	
	
}



function csearch(naam) { 
  var str = document.cookie; 
  var zstr = naam + "="; 
  var start = str.indexOf(zstr, 0); 
  if(start == -1) { 
    return false; 
  } else { 
    start += zstr.length; 
    var eind = str.indexOf(";", start); 
    if(eind == -1) eind = str.length; 
    return unescape(str.substring(start, eind)); 
  } 
} 



function configuratiescherm(){
		
	cms_layer(laden);
	getcmscontent('?a=p&action=edit&type=configuratie','Configuratiescherm');
		
}


function kaarten(){	
	
	cms_layer(laden);
	getcmscontent('?a=p&action=edit&type=kaarten','Kaartenbeheer');
		
}




/*
CMS FUNCTIONS
*/

/*
editor
*/

		function plaatseditor(inhoud){
			mceid = inhoud;
			if (document.getElementById(inhoud) == null) {
				setTimeout('restart()',500);
			}
			else {
				tinyMCE.execCommand('mceAddControl', false, inhoud);
			}
		}
		
		function plaatseditor2(inhoud){
			mceid2 = inhoud;
			if (document.getElementById(inhoud) == null) {
				setTimeout('restart2()',500);
			}
			else{
				tinyMCE.execCommand('mceAddControl', false, inhoud);
			}
		}
				
		
		function restart(){
			plaatseditor(mceid);
		}		
		
		function restart2(){
			plaatseditor2(mceid2);
		}				
				
		function kopieercontenteditor(){
					
			tinyMCE.triggerSave(true,true); 
	
		}



	/*
	artikelen 
	*/
		var laden = "<TABLE><TR><TD>bezig met laden</TD></TR></TABLE>";
		var mceid = "";
		
		
		
		function nieuwetekst(pad,id,soort){
			
			
			var l = layout_basis('Artikel aanmaken','<form action="?a=p&action=edit&type=artikel&id='+id+'&ac=nieuw" method="post" target="saveframe" onsubmit="kopieercontenteditor(\'inhoud\');"><table><TR><TD class="cms_td_standaard">Titel</TD><TD><input type="text" id="titel" name="titel"></TD></TR><TR><TD class="cms_td_standaard" valign=top>Inhoud</TD><TD><textarea id="inhoud" name="inhoud" cols=50 rows=14></textarea></TD></TR><TR><TD></TD><TD align=right><input type="submit" value="aanmaken"></TD></TR></table>');
			cms_layer(l);
			
			plaatseditor('inhoud');
			
			
		}
		

		
		
		
		function edittekst(pad,id,soort){
		
			cms_layer(laden);
			pad = '-1';
			if(pad == '-1'){
				getcmscontent('?a=p&action=edit&type=artikel&id='+id+'&overrulecontent=1','Wijzig artikel');
			}
			else{
				getcmscontent(pad+'?a=p&action=edit&type=artikel&id='+id,'Wijzig artikel');
			}
			

			//plaatsen van de editor, geef id textarea mee!
			plaatseditor('inhoud');
			
			
		}
		
		
		
		function removetekst(pad,id,soort){
		
			var l = layout_basis('Artikel verwijderen','<center class="cms_td_standaard">Weet u zeker dat u dit artikel wilt wijzigen?<BR> <a class="cmslink" href="?a=p&action=edit&type=artikel&id='+id+'&ac=verwijderen" target="saveframe">JA</A> | <a class="cmslink" href="javascript:cms_sluiten();">NEE</A></center>');
			cms_layer(l);

			
		
		}
		
		
		function nieuwdossier(pad,id){
			var l = layout_basis('Dossier aanmaken','<form action="?a=p&action=edit&type=artikel&id='+id+'&ac=dossieraanmaken" method="post" target="saveframe" onsubmit="kopieercontenteditor(\'inhoud\');"><table><TR><TD>Titel</TD><TD><input type="text" id="titel" name="titel"></TD></TR><TR><TD valign=top>Inhoud</TD><TD><textarea id="inhoud" name="inhoud" cols=50 rows=14></textarea></TD></TR><TR><TD></TD><TD align=right><input type="submit"></TD></TR></table>');
			cms_layer(l);
			plaatseditor('inhoud');
		}		
		
		function editdossier(id){
			getcmscontent('?a=p&action=edit&type=artikel&id='+id+'&ac=wijzigdossier','Wijzig dossier informatie');
			plaatseditor('inhoud');
		}		

	/*
	sitemap
	*/

		function sitemap(id){

			if(id == '-1'){
				var l = getcmscontent('?a=p&action=edit&type=sitemap','Sitemap');
			}
			else{
				var l = getcmscontent('?a=p&action=edit&type=sitemap&startid='+id,'Sitemap');
			}
				
			cms_layer(l);
			
		
		}
		
	
		function overzichtgastenboek(){
			var l = getcmscontent('?a=p&action=edit&type=overzichtgastenboek','Overzicht gastenboek');
			
				
			cms_layer(l);
			
		
		}
	
	/*
	users
	*/	
	function users(){
		
		var l = getcmscontent('?a=p&action=edit&type=users','Gebruikers & Groepen');
		cms_layer(l);
	}
	
	
	/*
	MODULE OVERZICHT
	
	*/
	
	
	function artikeltoevoegen(id){
		
		var l = getcmscontent('?a=p&action=edit&type=module_overzicht&event=toevoegen&id='+id,'Artikel aan overzicht toevoegen');
		cms_layer(l);		

			plaatseditor('inhoud');
			plaatseditor2('teaser');
			loadimagelist('icoon','');
		
	}
	
  function wijzigartikel(id,img) {
    var l = getcmscontent('?a=p&action=edit&type=module_overzicht&event=wijzig&id='+id,'Artikel wijzigen');
    cms_layer(l);
    plaatseditor('inhoud');
    plaatseditor2('teaser');
    loadimagelist('icoon',img);
  }	


	
	
	
	function verwijderartikel(id){
		
		var l = getcmscontent('?a=p&action=edit&type=module_overzicht&event=verwijder&id='+id,'Artikel verwijderen');
		cms_layer(l);		


		
	}	
	
	function overzicht(id){
		
		var l = getcmscontent('?a=p&action=edit&type=module_overzicht&event=overzicht&id='+id,'Overzicht instellingen');
		cms_layer(l);		


		
	}	
	
	function sjablonen(id){
		
		var l = getcmscontent('?a=p&action=edit&type=module_sjablonen&event=overzicht&id='+id,'Selecteer sjabloon');
		cms_layer(l);		


		
	}
	
		
var lijst2;
	
	function loadimagelist(lijst,img){
		
		lijst2 = lijst
		voorkeur = img
			

			if (document.getElementById(lijst2) == null) {
				
				setTimeout('imagerestart()',500);
				
			}
			else{
				
				laden_image();
				//document.getElementById(lijst2).style.display = "none";
				
			}
		
		
		
	}	
	

		function imagerestart(){
			loadimagelist(lijst2,voorkeur);
		}	
		
		
		function laden_image(){
				
				xmlHttp=GetXmlHttpObject()
				if (xmlHttp==null)
				 {
				 alert ("Browser does not support HTTP Request")
				 return
				 } 
				url="/_cms/imagelist.php?sid="+Math.random()
				xmlHttp.onreadystatechange=tolist
				xmlHttp.open("GET",url,true)
				xmlHttp.send(null)
			
		}
		
		
		function tolist(){
			 if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
			 { 

				 arr_img = xmlHttp.responseText.split("|||");
				 				 
				var Counter = 0;
			
				
				//leeg maken van lijstje
				document.getElementById(lijst2).length = 0;	 
				
				//opnieuw vullen
				 
				while(Counter < arr_img.length){

				   var elOptNew = document.createElement('option');
					  elOptNew.text = arr_img[Counter];
					  elOptNew.value = arr_img[Counter];
					  
					  if(arr_img[Counter] == voorkeur){
					  	elOptNew.selected = "selected";
				  		}
					  
					  
					  var elSel = document.getElementById(lijst2);
					
					  try {
					    elSel.add(elOptNew, null);
					  }
					  catch(ex) {
					    elSel.add(elOptNew); 
					  }					
					
					
					Counter++;
				}

			 
			 	
			 } 			
			
		}
		
	
	
	
	
	/*
	statistieken
	*/
	
	
	function stats(){
		
		var l = getcmscontent('?a=p&action=edit&type=stats','Statistieken');
		cms_layer(l);
		
	}
	
	function onloadstats(){
	
		document.getElementById('counterframe').style.display = "block";
		document.getElementById('counterdiv').style.display = "none";
			
		
	}
	
	
	/*
	PROFIEL
	*/
	
	
	function profiel(id,naam){
		
		var l = getcmscontent('?a=p&action=edit&type=users&ac=wijziggebruiker&gid='+id,'Wijzig gebruiker:'+naam,'Statistieken');
		cms_layer(l);	
		
			
	}
	
	
	/*
	LOGBOEK
	*/
	
	function logboek(){
		
		var l = getcmscontent('?a=p&action=edit&type=logboek','Logboek','Logboek');
		cms_layer(l);	
		
			
	}
	
	/*
	FOTOBOEK
	*/
	
	function nieuwfotoboek(id){
		
		var l = getcmscontent('?a=p&action=edit&type=fotoboek&event=nieuw&id='+id,'Nieuw fotoboek','Nieuw fotoboek');
		cms_layer(l);	
		
			
	}
	
	
	function fotoboek(id,e){
		
		var l = getcmscontent('?a=p&action=edit&type=fotoboek&event='+e+'&id='+id,e+' fotoboek',e+' fotoboek');
		cms_layer(l);	
		
		
		
		
	}
	
	
	
	
	
	/*
	enquete
	*/
	
	
	function enquete(){
		
		var l = getcmscontent('?a=p&action=edit&type=enquete','Enquete beheer');
		cms_layer(l);
		
	}
	
	function bevestig(url) 
{ 
var where_to= confirm("Weet je zeker dat je deze vraag wilt verwijderen?");
if (where_to == true)
{ 
window.location = url;
} 
} 
		
	
function popUp(URL) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=yes,location=0,statusbar=0,menubar=0,resizable=0,width=450,height=420,left = 600,top = 400');");
}	
	
	
/*
AJAX
*/

// RN: functie om alleen een CMS actie uit te voeren, zonder verdere acties
function executecms(url) {
	var xml = window.XMLHttpRequest ? new XMLHttpRequest() : (window.ActiveXObject ? new ActiveXObject("Microsoft.XMLHTTP") : null);
	if (xml == null) {
    alert ("Browser does not support HTTP Request");
    return
  } 
	url = url+"&random="+Math.random();
	xml.onreadystatechange = function() {
    if (xml.readyState == 4 || xml.readyState=="complete") {
      window.location.reload();
    }
  }
	xml.open("GET", url, true)
	xml.setRequestHeader("Content-Type", "text/html; charset=iso-8859-1");
	xml.send("");
}




var xmlHttp,t
var urlhis = new Array();
var geenback = "0";
function getcmscontent(url,titel) {
		if(url == undefined){
			alert('Er staat op dit moment geen pagina in uw historie');
		}
		else{
		
			if(geenback == '0'){
				urlhis.push(url);
		    huidigepagina = urlhis.length-1; // RN
			}
			else{
				geenback = "0";
			}
				
			
			
			t = titel;
			
			xmlHttp=GetXmlHttpObject()
			if (xmlHttp==null)
			 {
			 alert ("Browser does not support HTTP Request")
			 return
			 } 
			url=url+"&encoder=1&sid="+Math.random()
			xmlHttp.onreadystatechange= function (x) { stateChanged(titel, x); }
			xmlHttp.open("GET",url,true)
			xmlHttp.setRequestHeader("Content-Type", "text/html; charset=iso-8859-1");
			//xmlHttp.setRequestHeader("Content-Type", "text/html; charset=UTF-8");
			
		
			xmlHttp.send(null)
		}
	
	} 
	
	function stateChanged(t, tinymce) 
	{ 
	 if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	 { 
		 //alert(xmlHttp.getAllResponseHeaders());

		 
		 	s = unescape(xmlHttp.responseText);
			s = s.replace(/([^\x01-\x7E])/g,function(word){return'&#'+word.charCodeAt(0)+ ';';});
      if (s != "") {
        // ******************************************************************************************************
        // *** BEGIN - RN - PluginManager
        // ******************************************************************************************************
        if (typeof cmsmanager == "xobject") {
          cmsmanager.dialog(t, s);
          alert(s);
        } else {
          cms_layer(layout_basis(t,s));
        }
        // ******************************************************************************************************
        // *** EINDE - RN - PluginManager
        // ******************************************************************************************************
      }
	 	
	 } 
	} 
	
	function GetXmlHttpObject()
	{ 
	var objXMLHttp=null
	if (window.XMLHttpRequest)
	 {
	 objXMLHttp=new XMLHttpRequest()
	 }
	else if (window.ActiveXObject)
	 {
	 objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP")
	 }
	return objXMLHttp

	
		
}


function layout_basis(t,c){
	
	var l = "<table cellpadding=0 cellspacing=0 border=0 style=\"font-size:8pt;text-align:left;\"><TR><TD bgcolor=black><table width=500 height=300 cellpadding=0 cellspacing=1 border=0>";
//	l = l+"<TR><TD bgcolor='#efefef' background='/_cms/cms_ag.jpg' style=\"height:20px;\"><table width=100% cellpadding=0 cellspacing=0 border=0><TR><TD valign='top' style=\"padding:4;\"><B><font color='#000000' size='2' face='verdana'>"+t+"</font></B></TD><TD align=right style=\"text-align: right;\" valign=\"top\"><table cellpadding=0 cellspacing=0 border=0><TR><TD valign=\"top\"><A href=\"javascript:goback();\"><img src='/_cms/ico_back.jpg' border=0 alt='Vorige pagina'></A><BR></TD><TD valign=\"top\"><A href=\"javascript:cms_sluiten('');\" style=\"color:#ffffff;font-family:verdana;font-size:8pt;padding:3;\"><img src='/_cms/ico_sluiten.jpg' border=0 alt='Beheer sluiten'></A><BR></TD></TR></table></TD></TR></table></TD></TR>";
	l = l+'<tr><td bgcolor="#efefef" background="/_cms/cms_ag.jpg" style="height:20px;">'+
    '<table width="100%" cellpadding="0" cellspacing="0" border="0">'+
    '<tr><td valign="top" style="padding:4px;"><b><font color="#000000" size="2" face="verdana">'+t+'</font></b></td><td align="right">'+
    '<a style="float: right;" href="javascript:cms_sluiten();"><img src="/_cms/ico_sluiten.jpg" border="0" alt="Vorige pagina"></a>'+
    '<a style="float: right;" href="javascript:goback();"><img src="/_cms/ico_back.jpg" border="0" alt="Beheer sluiten"></a>'+
    '</td></tr></table></td></tr>';
    
	l = l+"<TR><TD bgcolor='white' valign=top style='font-family:verdana;'>"+c+"</TD></TR>";
		
	//l = l+"</table><div align=right><iframe id=\"saveframe\" name=\"saveframe\" width=\"100\" height=\"100\" marginwidth=\"0\" marginheight=\"0\" scrolling=\"no\" frameborder=\"0\" src=\"http://www.google.com\"></iframe></div></TD></TR></table>";
	l = l+"</table></TD></TR></table>";
	
	
	return l;
	
}

function verbergflash(naam){ 
 var alletags=document.all? document.all : document.getElementsByTagName("*"); 
	 for (i=0; i<alletags.length; i++){ 
	   if (alletags[i].className==naam) 
	   
	     alletags[i].style.display = "none";
	    
	 } 
  
} 

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;       
	}    
		arrayPageSizeWithScroll = new Array(xWithScroll,yWithScroll);     
		//alert( 'The height is ' + yWithScroll + ' and the width is ' + xWithScroll );     
	return arrayPageSizeWithScroll; 
} 



function cms_layer(html) {
  if (typeof html != "undefined") {
    window.scrollTo(0,0);
    
    // RN: 20-10-2011, eerst even alle editors opruimen alvorens we nieuwe textarea's plaatsen
    while (tinymce.editors.length > 0) {
      tinyMCE.execCommand("mceRemoveControl", true, tinymce.editors[0].id);
    }
    
    //OPHALEN HISTORIE
    gethis = document.getElementById('cmsmetcontent');
    
    
		v = getPageSizeWithScroll();
    
    
    
    
    //REST CMS LAYER
    cmscontent = document.getElementById('cms_content');
    cmscontent.style.display = "block";
    cmscontent.style.width = v['0'] + 'px';
    cmscontent.innerHTML = "<div id=\"cmsmetcontent\" name=\"cmsmetcontent\"></div>";
    
    
    //VULLEN VAN DE LAYER
    cmscontent2 = document.getElementById('cmsmetcontent');
    cmscontent2.innerHTML = html;
    
    // RN: focus op 1ste form element, todo: controleer hidden fields
    var t = cmscontent2.getElementsByTagName("INPUT");
    if (t.length > 0) t[0].focus();
    
    
    if (document.getElementById('videocontainer')){
      
      document.getElementById('videocontainer').style.display = "none";
      
      
    }
    
    
    verbergflash('flashlaag');
    var i = cmscontent2.getElementsByTagName("TR")[0];
    if (i) {
      i = i.getElementsByTagName("TR")[0]
      if (i) Drag.init(i, cmscontent2);
    }
    
    /***/
    var x = cmscontent2.getElementsByTagName("script");   
    for(var i=0; i < x.length; i++) {
       //alert(x[i].text);  
       eval(x[i].text);  
    }
    /***/
  }

}

var backstep = "-1";
var huidigepagina = -1;
var eerstepagina = "-1";


function backreset(){
	 goback();
}

function goback(steps){
	
	if(soortterug == '1'){ //iframe terug optie
		
    // RN: 7/9/2011 het is window.frames, niet document.frames
		//document.frames['iframeformulier'].history.back();
		window.frames['iframeformulier'].history.back();
	
	}
	else{	
		
		
	  if (typeof steps == "undefined" || isNaN(steps)) steps = 1;
	  
	  geenback = "1";
		if(backstep == '-1') {
	    if(urlhis.length == '1') {
	      alert('Er staan geen pagina in de historie');
	    }
	    else {
	      backstep = "0";
	//      huidigepagina = urlhis.length-1-steps;
	      huidigepagina = huidigepagina-steps;
	      
		    if(urlhis[huidigepagina] == undefined){
			   alert('Er staan geen pagina in de historie');
		    }
		    else{
		      	getcmscontent(urlhis[huidigepagina],'');	
		  	}
	    }
	  } else {
	    if (huidigepagina-steps < 0 || urlhis[huidigepagina-steps] == undefined) {
	      huidigepagina = "0";
	      eerstepagina = urlhis[0]; //onthouden eerste pagina uit array
	      urlhis = new Array(); //reset 
	      urlhis[0] = eerstepagina; //0 waarde weer vullen uit historie
	      
	      
	       if(urlhis[0] == undefined){
			    alert('Er staan geen pagina in de historie');
		    }
		    else{
		      	getcmscontent(urlhis[0],''); //terug naar 0 site
		  	}
	      
	      
	      
	    } else {
	      huidigepagina = huidigepagina-steps;
	      urlhis.length = huidigepagina+1; // RN
	      
	      
	        if(urlhis[huidigepagina] == undefined){
			   alert('Er staan geen pagina in de historie');
		    }
		    else{
		      	getcmscontent(urlhis[huidigepagina],'');
		  	}     
	      
	      
	    }
	  }
  }
}





function cms_sluiten(html) {
	location.reload();	
}


function pagereload(){
  var sf = document.getElementById("saveframe");
  sf.src = "about:blank"; // get rid of POST data
  setTimeout(realreload, 0);
	
}

function realreload() {
  location.reload();
}



/*
gastenboek
*/


function gastenboekverwijder(id){
	
	
		var l = getcmscontent('?a=p&action=edit&type=gastenboek&event=verwijder&id='+id,'Verwijder gastenboek bericht','Verwijder gastenboek bericht');
		cms_layer(l);
	
	
}

/*
DOSSIER
*/


function dossierverwijderen(id){
	
		var l = getcmscontent('?a=p&action=edit&type=artikel&ac=verwijderdossier&id='+id,'Verwijder dossier','Verwijder dossier');
		cms_layer(l);
	
		
}

/*
NARROWCAST
*/


function narrowcast(){
	
		var l = getcmscontent('?a=p&action=edit&type=module_narrowcast','Narrowcast','Narrowcast');
		cms_layer(l);
	
}

function getdata(pid){
	
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	 {
	 alert ("Browser does not support HTTP Request")
	 return
	 } 
	url="/ncast.php?get="+pid+"&n="+Math.random()
	xmlHttp.onreadystatechange=vullboxen
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)	
	
	
	//document.getElementById('hoofdmenu').innerHTML = '<select  onchange="getdata(this.value);"><option>RICK</option></select>';
	
}	



	function vullboxen() 
	{ 
	 if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	 { 
//		 alert(xmlHttp.getAllResponseHeaders());

		 
		 	var xmldoc = xmlHttp.responseXML;
			subnodes = xmlHttp.responseXML.getElementsByTagName("sub");
			
			var subbox;

				subbox = '<select onchange="getdata(this.value);">';
				
				
				if(subnodes.length != 0){
					subbox = subbox+"<option value='-1'>maak uw subkeuze</option>";
				}
				
				
				for(var i = 0 ; i < subnodes.length ; i++){
					var item =  xmldoc.getElementsByTagName("item")[i].childNodes[0].nodeValue;
					var itemid =  xmldoc.getElementsByTagName("id")[i].childNodes[0].nodeValue;
				
					
					subbox = subbox+'<option value="'+itemid+'">'+item+'</option>';	
						
				}
				
				subbox = subbox+"<option value='-1'>---------</option><option value='-1'>terug naar hoofdmenu</option></select>";
			
			if(subnodes.length != 0){
			
				document.getElementById('hoofdmenu').innerHTML = subbox;
				
			}
			
			
			
			subnodes = xmlHttp.responseXML.getElementsByTagName("content");
			
			var subbox;

			subbox = "<select id='contentbox' name='contentbox'><option value='-1'>content binnen deze groep</option>";
			
			
			
			for(var i = 0 ; i < subnodes.length ; i++){
				var item =  xmldoc.getElementsByTagName("sitem")[i].childNodes[0].nodeValue;
				var itemid =  xmldoc.getElementsByTagName("sid")[i].childNodes[0].nodeValue;
			
				
				subbox = subbox+'<option value="'+itemid+'">'+item+'</option>';	
					
			}
			
			subbox = subbox+'</select>';
			
			document.getElementById('contentbox').innerHTML = subbox;			
			
			
			
			
			
			
	 	
	 	
	 } 
	} 
	
	function soortkeuze(){
	
		
		var e = document.getElementById('soort').value;
		
		if(e == '-1'){
			alert('maak een keuze welk soort programma u wilt toevoegen');
		}
		else{
			
			
			if(e == 'tekst'){
				document.getElementById('txtlayer').style.display = "block";
			}
			else if(e == 'video'){
				document.getElementById('videolayer').style.display = "block";
			}
			else if(e == 'foto'){
				document.getElementById('fotolayer').style.display = "block";
			}			
			document.getElementById('soortlayer').style.display = "none";
			
		}
			
		
	}
	
	
function goNewWin() {

// Set height and width
var NewWinHeight=1024;
var NewWinWidth=768;

// Here move it to any point on screen
var NewWinPutX=0;
var NewWinPutY=0;

// Where 

TheNewWin =window.open("/ncast.php",'TheNewpop','channelmode=yes,type=fullWindow');
//TheNewWin.resizeTo(NewWinHeight,NewWinWidth);
//TheNewWin.moveTo(NewWinPutX,NewWinPutY);

}



function changeorder(menuid,waarde,menuplaats){
	
	
	
	if(menuplaats == '-1'){ // hoofdmenu
	
	
		var l = getcmscontent('?a=p&action=edit&type=sitemap&changeorder=1&menuid='+menuid+'&waarde='+waarde,'Sitemap');
	
		
	}
	else{
						
		var l = getcmscontent('?a=p&action=edit&type=sitemap&startid='+menuplaats+'&changeorder=1&menuid='+menuid+'&waarde='+waarde,'Sitemap');	
		
	}
	
	
	cms_layer(l);
	
	
	
}

function tooltip(text) {
  var tooltip = document.getElementById("cms_tooltip");
  if (tooltip != null) tooltip.innerHTML = text;
}


/*
VIDEO
*/


function nieuwevideo(id,actie){
	
	if(actie == 'nieuw'){
		
		var l = getcmscontent('?a=p&action=edit&type=module_video&actie=new&id='+id,'Video');	
		cms_layer(l);
	}
	
	
}


/*
BANNER BMS
*/

function bms(){
	
		var l = getcmscontent('?a=p&action=edit&type=module_bms','Banner Management Systeem');	
		cms_layer(l);	
		
}

function changeview(ind){
	
	
	
	if(ind == 'perperiode'){
	
		document.getElementById('periode').style.display = "block";
		document.getElementById('impressies').style.display = "none";
			
	}
	else{
	
		document.getElementById('periode').style.display = "none";
		document.getElementById('impressies').style.display = "block";
			
		
	}
		
}


function loadbannerdata(id, sts){
	
	if(sts == '0'){
		getcmscontent('?a=p&action=edit&type=module_bms&actie=newbanner&id='+id,'Banner Management Systeem');
		bannerloadimagelist('bannerlist','-1');
	}
	
	else{
		getcmscontent('?a=p&action=edit&type=module_bms&actie=wijzig_banner&id='+id,'Banner Management Systeem');
		bannerloadimagelist('bannerlist',sts);

		
	}
	
	
	
	
}




var lijst2;
var voorkeur;
	
	function bannerloadimagelist(lijst,img){
		
				
		lijst2 = lijst
		voorkeur = img
			

			if (document.getElementById(lijst2) == null) {
				
				setTimeout('bannerimagerestart()',500);
				
			}
			else{
				
				bannerladen_image();
				//document.getElementById(lijst2).style.display = "none";
				
			}
		
		
		
	}	
	

		function bannerimagerestart(){
			bannerloadimagelist(lijst2,voorkeur);
		}	
		
		
		function bannerladen_image(){
				
				xmlHttp=GetXmlHttpObject()
				if (xmlHttp==null)
				 {
				 alert ("Browser does not support HTTP Request")
				 return
				 } 
				url="/showbanner.php?files=ja&v="+voorkeur+"&sid="+Math.random()
				xmlHttp.onreadystatechange=bannertolist
				xmlHttp.open("GET",url,true)
				xmlHttp.send(null)
			
		}
		
		
		function bannertolist(){
			 if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
			 { 
				 
				 document.getElementById(lijst2).innerHTML = xmlHttp.responseText;
				 
/*
				 arr_img = xmlHttp.responseText.split("|||");
				 				 
				var Counter = 0;
			
				
				//leeg maken van lijstje
				document.getElementById(lijst2).length = 0;	 
				
				//opnieuw vullen
				 
				while(Counter < arr_img.length){

				   var elOptNew = document.createElement('option');
					  elOptNew.text = arr_img[Counter];
					  elOptNew.value = arr_img[Counter];
					  
					  if(arr_img[Counter] == voorkeur){
					  	elOptNew.selected = "selected";
				  		}
					  
					  
					  var elSel = document.getElementById(lijst2);
					
					  try {
					    elSel.add(elOptNew, null);
					  }
					  catch(ex) {
					    elSel.add(elOptNew); 
					  }					
					
					
					Counter++;
				}

			 
*/



			 	
			 } 			
			
		}
		
		
var soortterug = "0";		
function formulieren(){
	
	soortterug = "1";
	
	var t = "Formulieren";
	var s = '<iframe id="iframeformulier" name="iframeformulier" width="500" height="540" marginwidth="0" marginheight="0" scrolling="auto" frameborder="0" src="?a=p&action=edit&type=module_formulieren"></iframe>';
	
	cms_layer(layout_basis(t,s));
}


//frames['framename'].history.back();

function XBrowserAddHandler(target,eventName,handlerName) {
if ( target.addEventListener )
  target.addEventListener(eventName, handlerName, false);
else if ( target.attachEvent )
  target.attachEvent("on" + eventName, handlerName);
else
  target["on" + eventName] = handlerName;
}


/*WEBSHOP*/

function webshopprice(waarde,soort){

	if(soort == 'in'){
		nieuweprijs = waarde/1.19;
		nieuweprijs = Math.round(nieuweprijs*100)/100; // 2 decimalen afronden
		document.insertartikelform.shopkenmerk_PRICE.value = nieuweprijs;

	}
	else if(soort == 'ex'){
		nieuweprijs = waarde*1.19;
		nieuweprijs = Math.round(nieuweprijs*100)/100; // 2 decimalen afronden
		document.insertartikelform.shopkenmerk_PRICE_inc.value = nieuweprijs;		
	}

	
}


function webshop(){
	getcmscontent('?a=p&action=edit&type=module_webshop&actie=overzicht','Webshop orders');
}


function cancelBubble(e) {
  if (!e) var e = window.event;
  e.cancelBubble = true;
  if (e.stopPropagation) e.stopPropagation();
}

/*
GIS
*/
/*
var setgeocode = false;
var geocoder;
var mapid = "1";
var siteid = "1";

function inc(filename)
{
var body = document.getElementsByTagName('body').item(0);
script = document.createElement('script');
script.src = filename;
script.type = 'text/javascript';
body.appendChild(script)
setgeocode = true;
}

inc("http://maps.google.com/maps/api/js?sensor=true&language=nl");


function codeAddress(address) { 
	geocoder = new google.maps.Geocoder(); 
	if (geocoder) { 
	  geocoder.geocode( { 'address': address}, function(results, status) { 
		if (status == google.maps.GeocoderStatus.OK) {  
			var punt  = results[0].geometry.location;			
			saveadres(punt);
		
		} else { 
		  alert("Er geen goede plaats bepaling plaatsvinden omdat: " + status); 
		} 
	  }); 
	} 
} 

function createAddress(){

	var s = document.getElementById("straatnaam").value
	var h = document.getElementById("huisnummer").value
	var p = document.getElementById("postcode").value
	var w = document.getElementById("woonplaats").value


	var address = s+" "+h+","+p+", "+w;
	codeAddress(address);

}

function saveadres(punt){
	var s = document.getElementById("straatnaam").value
	var h = document.getElementById("huisnummer").value
	var p = document.getElementById("postcode").value
	var w = document.getElementById("woonplaats").value

	var adres = s+"||"+h+"||"+p+"||"+w;
	
	
	siteid = document.getElementById("siteid").value;
	mapid = document.getElementById("mapid").value;
	
	parent.saveframe.location.href = '/maps/kaartacties.php?&actie=nieuw&siteid='+siteid+'&mapid='+mapid+'&longlat='+punt+'&adres='+adres;	
	
	
}	  

function putadres(straatnaam,huisnr,postcode,woonplaats,puntid){

	document.getElementById("straatnaambewerking").value = straatnaam;
	document.getElementById("huisnummerbewerking").value = huisnr;
	document.getElementById("postcodebewerking").value = postcode;
	document.getElementById("woonplaatsbewerking").value = woonplaats;
	document.getElementById("pointid").value = puntid;
			
	document.getElementById("GISbewerking").style.display = "block";
	closenewAddress();

}

function newAddress(){
	document.getElementById("GISnieuw").style.display = "block";
	document.getElementById("GISnieuwbutton").style.display = "none";
	document.getElementById("GISbewerking").style.display = "none";

}

function closenewAddress(){
	document.getElementById("GISnieuw").style.display = "none";
	document.getElementById("GISnieuwbutton").style.display = "block";
}	


function closechangeAddress(){
	document.getElementById("GISbewerking").style.display = "none";
}		



function changeAddress(){
	alert('wijzigen');
}

function removeAddress(){
	var puntid = document.getElementById("pointid").value;
	
	siteid = document.getElementById("siteid").value;
	mapid = document.getElementById("mapid").value;	
	
	parent.saveframe.location.href = '/maps/kaartacties.php?&actie=verwijder&siteid='+siteid+'&mapid='+mapid+'&punt='+puntid;
	
}
*/


//var dateformat = '%d-%m-%Y %H:%M:%S';
var dateformat = '%d-%m-%Y';

function doDatePicker(sObject) {
  var retValue = showCalendar(sObject, dateformat, false, true);
  if (retValue) {
    document.getElementById(sObject).value = retValue.toString();
  }
}

// This function gets called when the end-user clicks on some date.
function selected(cal, date) {
  cal.sel.value = date;
  document.getElementById(cal.sel.id).value = date;
  if (cal.dateClicked) {
    var x = new Date(cal.date);
    x.setMonth(x.getMonth()+1);
    dateNextMonth = x.print(cal.dateFormat);
    
    var x = new Date(cal.date);
    x.setFullYear(x.getFullYear()+1);
    dateNextYear = x.print(cal.dateFormat);

    cal.callCloseHandler();
  }
}

function onchangedate(node) {
  node.value = Date.parseDate(node.value, dateformat).print(dateformat);
}



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;
    }

