if (top.location == self.location){
	var regex = new RegExp("&","gi");
	top.location.href = webRoot + "index.asp?page=" + document.URL.replace(regex, "__AND__");
}

//===============================================
// general functions
//===============================================
/**
 * Deze functie is een vervanger voor ExplorerFix() en geldt in ieder geval voor IE & Netscape 6+. Oproepen in: body onload="fixFocus();"
 */
function fixFocus(){var v=Array("button","a", "input");var a,m,i,j,b;for(j=0;j<v.length;j++){a=document.getElementsByTagName(v[j]);
	for(i=0;i<a.length;i++){m=a[i];b=false;if(v[j]=="input"){if(m.type=="button" || m.type=="submit"){b=true;}}else{b=true;}if(b){m.onfocus=m.blur;}}}
}

var popUpWin=0;

function openCentered(documentSrc, windowWidth, windowHeight,scrBars,res){
	var resizable = (res != null) ? res : 0;

	if(popUpWin){
		if(!popUpWin.closed) popUpWin.close();
	}
	
	windowLeft = (window.screen.width  - windowWidth)  >> 1;
	windowTop  = (window.screen.height - windowHeight) >> 1;

	popUpWin = window.open(documentSrc, '','toolbar=0,channelmode=0,location=0,menubar=0,resizable=' + resizable + ',status=0,scrollbars=' + scrBars + ',width=' + windowWidth + ',height=' + windowHeight + ',left=' + windowLeft + ',top=' + windowTop);
	popUpWin.focus();
}

function openLink(anchorLink, anchorTarget){
	var tmpLink = (anchorLink.indexOf("http://") == 0) ? anchorLink : webRoot + anchorLink;
	if (anchorTarget == "_blank"){
		window.open(tmpLink);
	}
	else{
		document.location.href = tmpLink;
	}
}

function download(downloadLink){
	if(popUpWin){
		if(!popUpWin.closed) popUpWin.close();
	}
	
	windowWidth  = 800;
	windowHeight = 600;
	windowLeft   = (window.screen.width  - windowWidth)  >> 1;
	windowTop    = (window.screen.height - windowHeight) >> 1;

	popUpWin = window.open(webRoot + "content/download.asp?downloadlink=" + downloadLink, '','toolbar=0,channelmode=0,location=0,menubar=1,resizable=1,status=1,scrollbars=1,width=' + windowWidth + ',height=' + windowHeight + ',left=' + windowLeft + ',top=' + windowTop);
	popUpWin.focus();
}


//formulieren functions
function LTrim(str) {
	var whitespace = new String(" \t\n\r");
	var s = new String(str);
	if (whitespace.indexOf(s.charAt(0)) != -1) {
		var j=0, i = s.length;
		while (j < i && whitespace.indexOf(s.charAt(j)) != -1) {
	  	j++;
		}

		s = s.substring(j, i);
  }
	return s;
 }

function RTrim(str) {
	var whitespace = new String(" \t\n\r");
	var s = new String(str);
	if (whitespace.indexOf(s.charAt(s.length-1)) != -1) {
		var i = s.length - 1;
		while (i >= 0 && whitespace.indexOf(s.charAt(i)) != -1) {
    	i--;
		}

		s = s.substring(0, i+1);
	}
	return s;
}

function Trim(str) {
	return LTrim(RTrim(str));
}

function Cent(amount) {
	if(amount*1==0) return("");
	amount -= 0;
	return (amount == Math.floor(amount)) ? amount + ',00' : (  (amount*10 == Math.floor(amount*10)) ? amount + '0' : amount);
}

function RoundIt(number,X) {
    X = (!X ? 2 : X);
		var value = Cent(Math.round(number*Math.pow(10,X))/Math.pow(10,X));
    return (value == "") ? "0,00" : value;//Cent(Math.round(number*Math.pow(10,X))/Math.pow(10,X));
}

// variant op roundit -> zet ook punten tussen de duizendtallen
function RoundIt2(number, X){
   X = (X==undefined) ? 2 : X;
	
	var intVal = Math.floor(number);
	var fraction = number - intVal;
	if (fraction > 0){
		fraction = String(fraction);//Math.round(fraction*Math.pow(10, X));
		fraction = fraction.replace("0.", "");

		var fractionRounder = new Number(fraction.substr((X-1), 2))/10;
		fractionRounder = Math.round(fractionRounder, 0);

		fraction = fraction.substr(0, X-1);
		fraction += fractionRounder;
	}
	else{
		fraction = ""
		for (var i=0; i<X; i++){
			fraction += "0";
		}
	}
	
	intVal = String(intVal);
	llength = Math.floor((intVal.length - 1)/3);
	llength2 = intVal.length;
	for (var i=1; i<=llength; i++){
		var subStr1 = intVal.substr(0, llength2 - i*3);
		var subStr2 = intVal.substr(llength2 - i*3, intVal.length);
		intVal = subStr1 + "." + subStr2;
	}
	
	return(intVal+","+fraction);
}

function CheckZero(number) {
	if(number*1==0) {
		return("");
	} else {
		return(number);
	}
}

function Venster(newloc) {
	articlewindow=window.open(newloc,'Selecteren', 'width=300,height=500,status=no,toolbar=no,menubar=no,location=no,scrollbars');
	articlewindow.focus();
}

function IsValid(SString, valid) {
	for(var i=0;i<SString.length;i++) {
		tmp = SString.charAt(i)
		if(valid.indexOf(tmp)==-1) return false;
	}
	return true;
}

function IsValidEmail(SString) {
	if(SString.indexOf('.')==-1 || SString.indexOf('@')==-1 || SString.length<6) {
		return false;
	}
	return true;
}

