var Watte2 = '';
var ProvID=0;
var LandID=0;
var WDID=0;
var jsToonZoekmenu='';
var jsQry='';
var jsSP=1;
var jsZO=0;
var jsCL=0;
var jsAP=0;
var jsOB='pl';
var jsZMUGB='false';
var jsListboxGeladen=false;
var jsSnelcode = '';
var jsPlaats = '';
var waro='';
var posProv=0;
var jsProvTypeIDs='';
document.domain = "ertussenuit.com"
/*hoost = 'http://www.ertussenuit.com'; //www en www2
if (document.location.host=='lokaal.ertussenuit.com'){hoost=''};*/

jsDom = 'http://www.ertussenuit.com';
if (document.location.host=='lokaal.ertussenuit.com'){jsDom='';waro='lokaal'};
if (document.location.host=='2010.ertussenuit.com'){jsDom='';waro='lokaal'};



function dateDiff(strDate1,strDate2){
     datDate1= Date.parse(strDate1);
     datDate2= Date.parse(strDate2);
     return ((datDate2-datDate1)/(24*60*60*1000))
}
//if (dateDiff(Date(),'2007/06/11')>0){document.write('toon tot 11 juni 07');}

function OpenNewWindow(WindowNaam,Link,Breedte,Hoogte) {
  Xpositie = (screen.width/2)-(Breedte/2);
  Ypositie = (screen.height/2)-(Hoogte/2);
  window.open(Link,WindowNaam,"toolbar=no,location=0,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,copyhistory=0,width="+Breedte+",height="+Hoogte+",top="+Ypositie+",left="+Xpositie);
};	

function getCookieVal (offset) {
  var endstr = document.cookie.indexOf (";", offset);
  if (endstr == -1)
    endstr = document.cookie.length;
  return unescape(document.cookie.substring(offset, endstr));
}

function GetCookie (name) {
  var arg = name + "=";
  var alen = arg.length;
  var clen = document.cookie.length;
  var i = 0;
  while (i < clen) {
    var j = i + alen;
    if (document.cookie.substring(i, j) == arg)
      return getCookieVal (j);
    i = document.cookie.indexOf(" ", i) + 1;
    if (i == 0) break; 
  }
  return null;
}

function SetCookie (name, value) {
//	alert(name + '*' + value);
  var argv = SetCookie.arguments;
  var argc = SetCookie.arguments.length;
  var expires = (argc > 2) ? argv[2] : null;
//	var expires = new Date (); 
//	expires.setTime(expires.getTime() + (365 * 24 * 60 * 60 * 1000)); 
//	var expires = '05 Jan 2005 00:00:00 GMT';
//  var path = (argc > 3) ? argv[3] : null;
  var path = "/";
//  var domain = (argc > 4) ? argv[4] : null;
	var domain = 'ertussenuit.com';	
//  var secure = (argc > 4) ? argv[5] : false;
  document.cookie = name + "=" + escape (value) + ((expires == null) ? "" : ("; expires=" + expires.toGMTString())) + ((path == null) ? "" : ("; path=" + path)) + ((domain == null) ? "" : ("; domain=" + domain));
}

function KlapIN(DivID) {
		document.getElementById(DivID).style.display='none';
}
function KlapUIT(DivID) {
//alert(DivID);
		document.getElementById(DivID).style.display='inline';
}

function Klapper(DivID) {
/*		if ((document.all[DivID].style.display=='inline')||(document.all[DivID].style.display==''))
		{document.all[DivID].style.display='none'}
		else
		{document.all[DivID].style.display='inline'}*/
		if ((document.getElementById(DivID).style.display=='inline')||(document.getElementById(DivID).style.display==''))
		{document.getElementById(DivID).style.display='none'}
		else
		{document.getElementById(DivID).style.display='inline'}	
}

function KlapperADV(DivID) {
	if (document.getElementById(DivID).style.display=='inline')
	{document.getElementById(DivID).style.display='none';
	 document.getElementById(DivID+'_swap').style.display='inline';
	 SetCookie(DivID+'_koek',false);}
	else
	{document.getElementById(DivID).style.display='inline';
	document.getElementById(DivID+'_swap').style.display='none';
	SetCookie(DivID+'_koek',true);}
}

function klprMenu(pX){
if(pX==0){
document.getElementById('klprUGB').style.display='inline';
document.frmZM.qry.value=document.frmZMnor.qry.value;
SetCookie('ZMUGB','true');
}else{
document.getElementById('klprUGB').style.display='none';
SetCookie('ZMUGB','');
}}



var arrLB = new Array('');
var arrLBv = new Array(0);


function ToonListbox(pLBnaam)
{
	document.write('<select name="' + pLBnaam + '" ID="' + pLBnaam + '" class="txt_Z">');	
	for (i=0;i<arrLB.length;i++){
		document.write('<option value="' + arrLBv[i] + '">' + arrLB[i] + '</option>');
	}	
	document.write('</select><br>');
}

function ToonListbox2007(pLBnaam,pOC,pExtra)
{
	document.write('<select name="' + pLBnaam + '" ID="' + pLBnaam + '" ' + pExtra);
	document.write(' onChange="' + pOC + '"');
	document.write('">');	
	for (i=0;i<arrLB.length;i++){
		document.write('<option value="' + arrLBv[i] + '">' + arrLB[i] + '</option>');
	}	
	document.write('</select><br>');
}

function ResetListbox(){
	arrLB[0] = '';
	arrLBv[0] = '';
	arrLB.length=0;
}

function ReloadListbox(objName,pLBnaam){
	var veldnaam = objName;
	veldnaam.length=arrLB.length;
	for (i=0;i<arrLB.length;i++){
		veldnaam.options[i].value=arrLB[i];
		veldnaam.options[i].text=arrLBv[i];
	}
	veldnaam.options[0].selected = true;
}

function selListbox(objName,pWaarde){
		var veldnaam = objName;
			var selVals = new Array();
			for (var i = 0; i < veldnaam.length; i++){
				if (veldnaam.options[i].value==pWaarde){
					veldnaam.options[i].selected = true;
				i += 10000;		}	}
}

function divfunc(){
	var qry = GetCookie('qry');
	if ((qry!='')&&(qry!=null)){document.frmLM.qry.value=qry;};
}



//ajax load html
var rootdomain="http://"+window.location.hostname


function ajaxinclude(url) {
var page_request = false
if (window.XMLHttpRequest) // if Mozilla, Safari etc
page_request = new XMLHttpRequest()
else if (window.ActiveXObject){ // if IE
try {
page_request = new ActiveXObject("Msxml2.XMLHTTP")
} 
catch (e){
try{
page_request = new ActiveXObject("Microsoft.XMLHTTP")
}
catch (e){}
}
}
else
return false
page_request.open('GET', url, false) //get page synchronously 
page_request.send(null)
writecontent(page_request)
}

function writecontent(page_request){
if (window.location.href.indexOf("http")==-1 || page_request.status==200)
document.write(page_request.responseText)
}
//end ajax load html











function loadjscssfile(filename, filetype){
 if (filetype=="js"){ //if filename is a external JavaScript file
  var fileref=document.createElement('script')
  fileref.setAttribute("type","text/javascript")
  fileref.setAttribute("src", filename)
 }
 else if (filetype=="css"){ //if filename is an external CSS file
  var fileref=document.createElement("link")
  fileref.setAttribute("rel", "stylesheet")
  fileref.setAttribute("type", "text/css")
  fileref.setAttribute("href", filename)
 }
 if (typeof fileref!="undefined")
  document.getElementsByTagName("head")[0].appendChild(fileref)
}

//

function jsfuncInStr(inputString,zoekString) { //komt zoekstr voor in inputstr?
   var temp = inputString;
	 if (temp.indexOf(zoekString) == -1) {return false}else{return true}
}

//

function replaceSubstring(inputString, fromString, toString) {
   // Goes through the inputString and replaces every occurrence of fromString with toString
	 //replaceSubstring("Getting rid of unwanted words", "unwanted", "unneeded") = "Getting rid of unneeded words"
   var temp = inputString;
   if (fromString == "") {
      return inputString;
   }
   if (toString.indexOf(fromString) == -1) { // If the string being replaced is not a part of the replacement string (normal situation)
      while (temp.indexOf(fromString) != -1) {
         var toTheLeft = temp.substring(0, temp.indexOf(fromString));
         var toTheRight = temp.substring(temp.indexOf(fromString)+fromString.length, temp.length);
         temp = toTheLeft + toString + toTheRight;
      }
   } else { // String being replaced is part of replacement string (like "+" being replaced with "++") - prevent an infinite loop
      var midStrings = new Array("~", "`", "_", "^", "#");
      var midStringLen = 1;
      var midString = "";
      // Find a string that doesn't exist in the inputString to be used
      // as an "inbetween" string
      while (midString == "") {
         for (var i=0; i < midStrings.length; i++) {
            var tempMidString = "";
            for (var j=0; j < midStringLen; j++) { tempMidString += midStrings[i]; }
            if (fromString.indexOf(tempMidString) == -1) {
               midString = tempMidString;
               i = midStrings.length + 1;
            }
         }
      } // Keep on going until we build an "inbetween" string that doesn't exist
      // Now go through and do two replaces - first, replace the "fromString" with the "inbetween" string
      while (temp.indexOf(fromString) != -1) {
         var toTheLeft = temp.substring(0, temp.indexOf(fromString));
         var toTheRight = temp.substring(temp.indexOf(fromString)+fromString.length, temp.length);
         temp = toTheLeft + midString + toTheRight;
      }
      // Next, replace the "inbetween" string with the "toString"
      while (temp.indexOf(midString) != -1) {
         var toTheLeft = temp.substring(0, temp.indexOf(midString));
         var toTheRight = temp.substring(temp.indexOf(midString)+midString.length, temp.length);
         temp = toTheLeft + toString + toTheRight;
      }
   } // Ends the check to see if the string being replaced is part of the replacement string or not
   return temp; // Send the updated string back to the user
} // Ends the "replaceSubstring" function


///


function getProvAantal(pProvID,pWatte) {
	wid=0;pos=-1;
	if (pWatte=='BU'){wid=3};
	if (pWatte=='CA'){wid=4};
	if (pWatte=='GA'){wid=5};
	if (pWatte=='HO'){wid=6};
	if (pWatte=='VW'){wid=7};
	if (pWatte=='RZ'){wid=8};
	//zoek pos
	if (arrProvs.length>0){
		for (i=0;i<arrProvs.length;i++){
			if (arrProvs[i][1]==pProvID){pos=i;}
		}
	
		if (wid==0){return 1}else{if (pos>-1){return arrProvs[pos][wid]}else{return 0}};
	}
	else
	{return 0}	
}


function getLandAantal(pLandID,pWatte) {
	wid=0;pos=-1;
	if (pWatte=='BU'){wid=3};
	if (pWatte=='CA'){wid=4};
	if (pWatte=='GA'){wid=5};
	if (pWatte=='HO'){wid=6};
	if (pWatte=='VW'){wid=7};
	if (pWatte=='RZ'){wid=8};
	//zoek pos
	if (arrLanden.length>0){
		for (i=0;i<arrLanden.length;i++){
			if (arrLanden[i][1]==pLandID){pos=i;}
		}
	
		if (wid==0){return 1}else{if (pos>-1){return arrLanden[pos][wid]}else{return 0}};
	}
	else
	{return 0}	
}


function getWattetekst(pWatte) {
	//zoek pos
	pos=-1;
	if (arrWatte.length>0){
		for (i=0;i<arrWatte.length;i++){
			if (arrWatte[i][1]==pWatte){pos=i;}
		}
	
//		if (pos==-1){return ''}else{return arrWatte[pos][2].toLowerCase()};
		if (pos==-1){return ''}else{return arrWatte[pos][2]};
	}
	else
	{return '-'}	
};

function getProvincietekst(pProvID) {
	//zoek pos
	pos=-1;
	if (arrProvs.length>0){
		for (i=0;i<arrProvs.length;i++){
			if (arrProvs[i][1]==pProvID){pos=i;}
		}
	
		if (pos==-1){return ''}else{return arrProvs[pos][2]};
	}
	else
	{return '-'}	
};

function getLinkTypetekst(pLTID) {
	//zoek pos
	pos=-1;
	if (arrLinkTypen.length>0){
		for (i=0;i<arrLinkTypen.length;i++){
			if (arrLinkTypen[i][0]==pLTID){pos=i;}
		}
	
		if (pos==-1){return ''}else{return arrLinkTypen[pos][2]};
	}
	else
	{return '-'}	
};
