function IsNumeric(strString){
   //  check for valid numeric strings	
   var strValidChars = "0123456789.-";
   var strChar;
   var blnResult = true;

   if (strString.length == 0) return false;

   //  test strString consists of valid characters listed above
   for (i = 0; i < strString.length && blnResult == true; i++)
      {
      strChar = strString.charAt(i);
      if (strValidChars.indexOf(strChar) == -1)
         {
         blnResult = false;
         }
      }
   return blnResult;
}


function CuralisSubmit(){
	if (event.keyCode == 13){
		event.keyCode=9;	
        return false;
	}
	else{
		return true;
	}
}

function CuralisValidate(InputType, ElementId){
	var d,x;  if(!d) d=document; 
	x=d.getElementById(ElementId.id);
	if( x.value.length > 0){
		var i;
		i = ElementId.id.indexOf("txt");
		if  (i != -1){
			var Id=x.id.substring(i+4);
			if( ( typeof MinValue[Id] != 'undefined') &&  (typeof MaxValue[Id] != 'undefined' ) && (MinValue[Id] != MaxValue[Id])){
				if (IsNumeric(x.value)){
					if (x.value < MinValue[Id] || x.value > MaxValue[Id]){
						alert("De waarde moet tussen " + MinValue[Id] + " en " + MaxValue[Id] + " liggen.");
						x.focus();
					}					
				}
				else{
					alert("U moet een getal invullen.");
					x.focus();
				}				
			}
		}
		if (ElementId.id.indexOf("date") != -1){
			if (x.value.length != 0 && !isDate(x.value)){
				x.focus();
			}
		}
	}
}

var dtCh= "-";
var minYear=1900;
var maxYear=2100;

function isInteger(s){
	var i;
    for (i = 0; i < s.length; i++){   
        // Check that current character is number.
        var c = s.charAt(i);
        if (((c < "0") || (c > "9"))) return false;
    }
    // All characters are numbers.
    return true;
}

function stripCharsInBag(s, bag){
	var i;
    var returnString = "";
    // Search through string's characters one by one.
    // If character is not in bag, append to returnString.
    for (i = 0; i < s.length; i++){   
        var c = s.charAt(i);
        if (bag.indexOf(c) == -1) returnString += c;
    }
    return returnString;
}

function daysInFebruary (year){
	// February has 29 days in any year evenly divisible by four,
    // EXCEPT for centurial years which are not also divisible by 400.
    return (((year % 4 == 0) && ( (!(year % 100 == 0)) || (year % 400 == 0))) ? 29 : 28 );
}
function DaysArray(n) {
	for (var i = 1; i <= n; i++) {
		this[i] = 31
		if (i==4 || i==6 || i==9 || i==11) {this[i] = 30}
		if (i==2) {this[i] = 29}
   } 
   return this
}

function isDate(dtStr){
	var daysInMonth = DaysArray(12)
	var pos1=dtStr.indexOf(dtCh)
	var pos2=dtStr.indexOf(dtCh,pos1+1)
	var strDay=dtStr.substring(0,pos1)
	var strMonth=dtStr.substring(pos1+1,pos2)
	var strYear=dtStr.substring(pos2+1)
	strYr=strYear
	if (strDay.charAt(0)=="0" && strDay.length>1) strDay=strDay.substring(1)
	if (strMonth.charAt(0)=="0" && strMonth.length>1) strMonth=strMonth.substring(1)
	for (var i = 1; i <= 3; i++) {
		if (strYr.charAt(0)=="0" && strYr.length>1) strYr=strYr.substring(1)
	}
	month=parseInt(strMonth)
	day=parseInt(strDay)
	year=parseInt(strYr)
	if (pos1==-1 || pos2==-1){
		alert("De datum moet voldoen aan : dd-mm-jjjj")
		return false
	}
	if (strMonth.length<1 || month<1 || month>12){
		alert("Voer a.u.b. een geldige maand in")
		return false
	}
	if (strDay.length<1 || day<1 || day>31 || (month==2 && day>daysInFebruary(year)) || day > daysInMonth[month]){
		alert("Voer a.u.b. een geldige dag in")
		return false
	}
	if (strYear.length != 4 || year==0 || year<minYear || year>maxYear){
		alert("Voer een jaartal tussen "+minYear+" en "+maxYear)
		return false
	}
	if (dtStr.indexOf(dtCh,pos2+1)!=-1 || isInteger(stripCharsInBag(dtStr, dtCh))==false){
		alert("Voer een geldige datum in")
		return false
	}
return true
}


function toggleLayer(whichLayer){
	if (document.getElementById){
	// this is the way the standards work
	var style2 = document.getElementById(whichLayer).style;
	style2.display = style2.display? "":"block";
	}
	else if (document.all){
	// this is the way old msie versions work
	var style2 = document.all[whichLayer].style;
	style2.display = style2.display? "":"block";
	}
	else if (document.layers){
	// this is the way nn4 works
	var style2 = document.layers[whichLayer].style;
	style2.display = style2.display? "":"block";
	}
}

function pausecomp(millis){
var date = new Date();
var curDate = null;

do { curDate = new Date(); } 
while(curDate-date < millis);
} 

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

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 MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_changeProp(objName,x,theProp,theValue) { //v3.0
	var obj = MM_findObj(objName);
	if (obj && (theProp.indexOf("style.")==-1 || obj.style)) eval("obj."+theProp+"='"+theValue+"'");
	}
function Closewin(){
	parent.close();
}			
function PrintVersion() { //v4.0
	theSelect=document.getElementById("ReturnToNormal");
	if (theSelect != undefined) {
		theSelect.style.display = "block";
	}
	theSelect=document.getElementById("TopPane");
	if (theSelect != undefined) {
		theSelect.style.display = "none";
	}
	theSelect=document.getElementById("leftcolumn");
	if (theSelect != undefined) {
		theSelect.style.display = "none";
	}
	theSelect=document.getElementById("rightcolumn");
	if (theSelect != undefined) {
		theSelect.style.display = "none";
	}
} 
function returnToNormal() {
	theSelect=document.getElementById("ReturnToNormal");
	if (theSelect != undefined) {
		theSelect.style.display = "none";
	}
	theSelect=document.getElementById("TopPane");
	if (theSelect != undefined) {
		theSelect.style.display = "block";
	}
	theSelect=document.getElementById("leftcolumn");
	if (theSelect != undefined) {
		theSelect.style.display = "block";
	}				
	theSelect=document.getElementById("rightcolumn");
	if (theSelect != undefined) {
		theSelect.style.display = "block";
	}
} 
/* Kalender popup*/
var popUp;

function OpenCalendar(idname, postBack){
		popUp = window.open('Controls/Calendar.aspx?history=false&formname=' + document.forms[0].name + '&id=' + idname + '&selected=' + document.forms[0].elements[idname].value + '&postBack=' + postBack, 'popupcal', 'width=310,height=380,left=200,top=250');
}


function SetDate(formName, id, newDate, postBack){
    eval('var theform = document.' + formName + ';');
	popUp.close();
	theform.elements[id].value = newDate;
	theform.elements[id].focus();
	if (postBack)
		__doPostBack(id,'');
}
function PopupParentPostback(formName, id, postBack){
	eval('var theform = document.' + formName + ';');
	popUp.close()	
	__doPostBack(id,'');
}
function SetDate2(formName, id, newDate, postBack){
	eval('var theform = document.' + formName + ';');
	Popup2.close();	
	theform.elements[id].value = newDate;
	theform.elements[id].focus();
	if (postBack)
		__doPostBack(id,'');
}

function SetParentValues(formName, id1, Value1, id2, Value2, postBack){
	eval('var theform = document.' + formName + ';');
	popUp.close();
	theform.elements[id1].value = Value1;
	theform.elements[id2].value = Value2;
	theform.elements[id1].focus();
	if (postBack)
		__doPostBack(id1,'');
}

function HelpPopUp (URL){   
    window.open(URL, 'Helpme', 'toolbar=0,scrollbars=1,directories=0,location=0,statusbar=0,menubar=0,resizable=1,status=1,width=500,height=400,left = 200,top = 200');
}

function HowtoPopUp (URL){   
    window.open(URL, 'Howtooo', 'toolbar=0,scrollbars=1,directories=0,location=0,statusbar=0,menubar=0,resizable=1,status=1,width=806,height=570,left=0,top=0');
}
function HowtoMoviePopUp (URL){   
    window.open(URL, 'HowtoMoviePopUp', 'toolbar=0,scrollbars=0,directories=0,location=0,statusbar=0,menubar=0,resizable=0,status=0,width=790,height=550,left=100,top=100');
}
/* SMOELENBOEK */

var smoelenBoekImagesCount =  48;
var smoelenBoekImagesArray = new Array();

function showMeThisOne(_personsPic,_personsTitle,_personsDescription){
	var personPicTarget = document.getElementById("SmoelenBoekBigPicContainer");
	var oldTitle = document.getElementById("SmoelenBoekTitle");
	var oldDescription = document.getElementById("SmoelenBoekDescription");
	var smoelenBoek = document.getElementById("SmoelenBoek");
	personPicTarget.src = _personsPic;
	
	var newTitle = document.createElement('p');
	newTitle.setAttribute('id','SmoelenBoekTitle');
	newTitle.style.fontFamily = "Arial, Helvetica, Verdana, sans-serif";
	newTitle.style.color = "#fff";
	newTitle.style.fontSize = 14+"px";
	newTitle.style.fontWeight = "bold";
	newTitle.style.margin = "18px 30px 3px 30px";
	newTitle.style.padding = 0;
	newTitle.style.width = 'auto';
	var title = document.createTextNode(_personsTitle);
	newTitle.appendChild(title);
	
	var newDescription = document.createElement('p');
	newDescription.setAttribute('id','SmoelenBoekDescription');
	newDescription.style.fontFamily = "Arial, Helvetica, Verdana, sans-serif";
	newDescription.style.color = "#fff";
	newDescription.style.fontSize = 12+"px";
	newDescription.style.margin = "3px 60px 5px 30px";
	newDescription.style.padding = 0;
	newDescription.style.width = 'auto';
	var description = document.createTextNode(_personsDescription);
	newDescription.appendChild(description);
	
	smoelenBoek.replaceChild(newTitle,oldTitle);
	smoelenBoek.replaceChild(newDescription,oldDescription);
}
function generateSmoelenBoek(){
	//alert(smoelenBoekImagesArray);
	var imagesLengthDifference = smoelenBoekImagesCount - smoelenBoekImagesArray.length;
	if (imagesLengthDifference > 0){
	 for ( var i = 0 ; i < imagesLengthDifference ; i++ ){
		 var tempEmptyArray = new Array("","","","","");
		 smoelenBoekImagesArray.push(tempEmptyArray);
	 }
	 for ( var j=0 ; j < smoelenBoekImagesCount ; j++){
		 var getThisOne = Math.floor(Math.random()*(smoelenBoekImagesArray.length-1));
		 addToSmoelenBoek(smoelenBoekImagesArray[getThisOne][1],smoelenBoekImagesArray[getThisOne][0],smoelenBoekImagesArray[getThisOne][2],smoelenBoekImagesArray[getThisOne][3],smoelenBoekImagesArray[getThisOne][4]);
		 smoelenBoekImagesArray.splice(getThisOne,1);
		 }
	 }else{
		 alert("More pictures added than there are picture spots...");
	 }
}
function addToSmoelenBoek(smallPic,bigPic,title,description,url){
	var imagesFolder = "Userdata/contacts/";
	var smoelenboekTarget = document.getElementById("SmoelenBoekPicContainer");
	var SDiv = document.createElement('div');
	SDiv.setAttribute('class', 'SmoelenBoekLink');
	SDiv.style.display = "inline";
	SDiv.style.styleFloat = "right";
	SDiv.style.float = "right";
	var SImg = document.createElement('img');
	SImg.style.border = "none";
	if(bigPic != ""){
		var SA = document.createElement('a');
		
		SImg.setAttribute('src', smallPic);
		SImg.setAttribute('width', '50');
		SImg.setAttribute('height', '69');
		
		SA.setAttribute('href', url);
		//SA.setAttribute('target','blank');
		SA.setAttribute('onMouseOver' , 'showMeThisOne("'+bigPic+'","'+ title+'","'+description+'")');
		SA.onmouseover = function(){
			showMeThisOne(bigPic,title,description);
		}
	
		SDiv.appendChild(SA);
		SA.appendChild(SImg);
	}else{
		SImg.setAttribute('src', imagesFolder+'spacer.gif');
		SImg.setAttribute('width', '50');
		SImg.setAttribute('height', '69');
		SDiv.appendChild(SImg);
	}
	smoelenboekTarget.appendChild(SDiv);
}
function addToImagesArray(BigPic,SmallPic,Title,Description,URL){
 var tempArray = new Array(BigPic,SmallPic,Title,Description,URL);
 //alert("Added to imagesArray = "+ tempArray);
 smoelenBoekImagesArray.push(tempArray);
}
/* /SMOELENBOEK */

function getDimensions(){
	var totalWidth, totalheight;
	if( typeof( window.innerWidth ) == 'number' ) {
		totalWidth = window.innerWidth;
		totalHeight = window.innerHeight;
 		} else if(document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
			totalWidth = document.documentElement.clientWidth;
			totalHeight = document.documentElement.clientHeight;
  		} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
		totalWidth = document.body.clientWidth;
		totalHeight = document.body.clientHeight;
	}
	info.width = totalWidth;
	info.height = totalHeight;
}
function getScroll() {
	var X,Y;
	if( typeof( window.pageYOffset ) == 'number' ) {
		X = window.pageXOffset;
		Y = window.pageYOffset;
	} else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
		X = document.body.scrollLeft;
		Y = document.body.scrollTop;
	} else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
		X = document.documentElement.scrollLeft;
		Y = document.documentElement.scrollTop;
	}
	if( X == undefined)
		X = 0;
	if(Y == undefined)
		Y = 0;
	info.scrollX = X;
	info.scrollY = Y;
}
function object(o) {
    function F() {}
    F.prototype = o;
    return new F();
}
function addEventHandler(node, type, f) {
	if(node.addEventListener) {
 		node.addEventListener(type, f, false);
	}else if (node.attachEvent) {
		node.attachEvent("on" + type, f);
	}else{
		node["on" + type] = f;
	}
}
function getXMLData(target){
	var returnXMLObject;
	var parseSource = target;
	if(parseSource){
		returnXMLObject = parseXML(parseSource);
	}
	return returnXMLObject;
}
function parseXML(text){
    if (typeof DOMParser != "undefined") {
        return new DOMParser().parseFromString(text, "application/xml");
    }else if (typeof ActiveXObject != "undefined") {
		var XML = new ActiveXObject("Microsoft.XMLDOM");
        XML.loadXML(text);
        return XML;
    }else {
        var url = "data:text/xml;charset=utf-8," + encodeURIComponent(text);
        var request = new XMLHttpRequest();
        request.open("GET", url, false);
        request.send(null);
        return request.responseXML;
    }
}
//COOKIES
function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}
function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}
function eraseCookie(name) {
	createCookie(name,"",-1);
}
// Section added to resolve the Eolas Patent isue, this section will generate the tags in html that embed Flash or Shockwave;
function PGAddExtension(src, ext){
  if (src.indexOf('?') != -1)
    return src.replace(/\?/, ext+'?'); 
  else
    return src + ext;
}

function PGGenerate(objAttrs, params, embedAttrs){ 
  var str = '<object ';
  for (var i in objAttrs)
    str += i + '="' + objAttrs[i] + '" ';
  str += '>';
  for (var i in params)
    str += '<param name="' + i + '" value="' + params[i] + '" /> ';
  str += '<embed ';
  for (var i in embedAttrs)
    str += i + '="' + embedAttrs[i] + '" ';
  str += ' ></embed></object>';

  document.write(str);
}

function PGEmbedFlash(){
  var ret = 
    PGGetArguments
    (  arguments, ".swf", "movie", "clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"
     , "application/x-shockwave-flash"
    );
  PGGenerate(ret.objAttrs, ret.params, ret.embedAttrs);
}

function PGEmbedShockwave(){
  var ret = 
    PGGetArguments
    (  arguments, ".dcr", "src", "clsid:166B1BCA-3F9C-11CF-8075-444553540000"
     , null
    );
  PGGenerate(ret.objAttrs, ret.params, ret.embedAttrs);
}

function PGGetArguments(args, ext, srcParamName, classid, mimeType){
  var ret = new Object();
  ret.embedAttrs = new Object();
  ret.params = new Object();
  ret.objAttrs = new Object();
  for (var i=0; i < args.length; i=i+2){
    var currArg = args[i].toLowerCase();    

    switch (currArg){	
      case "classid":
        break;
      case "pluginspage":
        ret.embedAttrs[args[i]] = args[i+1];
        break;
      case "src":
      case "movie":	
        args[i+1] = PGAddExtension(args[i+1], ext);
        ret.embedAttrs["src"] = args[i+1];
        ret.params[srcParamName] = args[i+1];
        break;
      case "onafterupdate":
      case "onbeforeupdate":
      case "onblur":
      case "oncellchange":
      case "onclick":
      case "ondblClick":
      case "ondrag":
      case "ondragend":
      case "ondragenter":
      case "ondragleave":
      case "ondragover":
      case "ondrop":
      case "onfinish":
      case "onfocus":
      case "onhelp":
      case "onmousedown":
      case "onmouseup":
      case "onmouseover":
      case "onmousemove":
      case "onmouseout":
      case "onkeypress":
      case "onkeydown":
      case "onkeyup":
      case "onload":
      case "onlosecapture":
      case "onpropertychange":
      case "onreadystatechange":
      case "onrowsdelete":
      case "onrowenter":
      case "onrowexit":
      case "onrowsinserted":
      case "onstart":
      case "onscroll":
      case "onbeforeeditfocus":
      case "onactivate":
      case "onbeforedeactivate":
      case "ondeactivate":
      case "type":
      case "codebase":
        ret.objAttrs[args[i]] = args[i+1];
        break;
      case "width":
      case "height":
      case "align":
      case "vspace": 
      case "hspace":
      case "class":
      case "title":
      case "accesskey":
      case "name":
      case "id":
      case "tabindex":
        ret.embedAttrs[args[i]] = ret.objAttrs[args[i]] = args[i+1];
        break;
      default:
        ret.embedAttrs[args[i]] = ret.params[args[i]] = args[i+1];
    }
  }
  ret.objAttrs["classid"] = classid;
  if (mimeType) ret.embedAttrs["type"] = mimeType;
  return ret;
}