// JavaScript Document

var win=null;
function NewWindow(mypage, myname, w, h, scroll, pos) {
	if(pos == "random") {
		LeftPosition = (screen.width) ? Math.floor(Math.random()*(screen.width-w)) : 100;
		TopPosition = (screen.height) ? Math.floor(Math.random()*((screen.height-h)-75)) : 100;
	}
	
	if(pos == "center") {
		LeftPosition = (screen.width) ? (screen.width-w)/2 : 100;
		TopPosition = (screen.height) ? (screen.height-h)/2 : 100;
	} else if ((pos != "center" && pos != "random") || pos == null) {
		LeftPosition = 0;
		TopPosition = 20;
	}
	
	settings = 'width=' + w + ', height=' + h + ', top=' + TopPosition + ', left=' + LeftPosition + ', scrollbars=' + scroll + ', location=no, directories=no, status=no, menubar=no, toolbar=no, resizable=no';
	
	win = window.open(mypage,myname,settings);
}

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_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

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];}
}

var AutoPrint = true; // Indien 'false' wordt de pagina niet automatisch uitgeprint 

function PrintPagina(){ 
	if (document.getElementById != null){ 
		var html = '<HTML>\n<HEAD>\n'; 
		html += '\n<title>Print</title>';
		html += '\n<meta http-equiv="Content-Type" content="text/html; charset=utf-8">';
		html += '\n<meta http-equiv="Content-Language" content="nl">';
		html += '\n<link href="./stylesheet_print.css" rel="stylesheet" type="text/css" media="print">';
	/*	if (document.getElementsByTagName != null){ 
			var headTags = document.getElementsByTagName("head"); 
			
			if (headTags.length > 0) 
				html += headTags[0].innerHTML;
		} 
			*/
		html += '\n</HE' + 'AD>\n<BODY>\n'; 
		var PrintKlaarElem = document.getElementById("PrintKlaar"); 
		if (PrintKlaarElem != null){ 
			html += PrintKlaarElem.innerHTML;
		} 

		html += '\n</BO' + 'DY>\n</HT' + 'ML>'; 
		
		var printWin = window.open("","PrintPagina"); 
		printWin.document.open(); 
		printWin.document.write(html); 
		printWin.document.close(); 
	
		if (AutoPrint)
			printWin.print();
	}
} 

function validEmail(strEmail) {
	var x = strEmail;
	
	// create filter
	var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
	
	// Test email
	if (filter.test(x))
		return true; // Email correct, return true
	else
		return false; // Email niet correct, return false
}

// check if input is empty
function isEmpty(strInput) {
	if (strInput.match(/^\s+$/) || strInput == '') {
		return true;
	} else {
		return false;
	} 
}

function isZipcode(strInput) {
	if (strInput.match(/^[0-9][0-9][0-9][0-9] ?[a-zA-Z][a-zA-Z]$/gi)) {
		return true;
	} else {
		return false;
	} 
}

function isPhone(strInput) {
	if (strInput.match(/^[0-9]{10}|[0-9]{2}\-[0-9]{8}|[0-9]{3}\-[0-9]{7}|[0-9]{4}\-[0-9]{6}$/)) {
		return true;
	} else {
		return false;
	} 
}

function validString(strInput) {
	
	// Stel filter in
	//var filter = /^([a-z])+([a-z -\.\'\`]*)$/i;
	var filter = /^[a-z -\.\'\`\\\\\\\\\\\\\\]*$/i;
	
	// Test invoer
	if (filter.test(strInput))
		return true; // Invoer correct, return true
	else
		return false; // Invoer niet correct, return false
}

function checkContact() {
	// Declarate variabels
	var noErrors = 0;
	var errorColor = "#c1fd6a";
	var noErrorColor = "white";
	var formObj = document.forms['contactform'];
	var fieldNames = new Array();
	var email = formObj.elements['emailadres'].value;
	var zipcode = formObj.elements['postcode'].value;
	var telephone = formObj.elements['overdag'].value;

	// Check fields
	fieldNames[0] = 'achternaam';
	fieldNames[1] = 'voorletter';
	fieldNames[2] = 'geboortedatum';
	fieldNames[3] = 'straatnaam';
	fieldNames[4] = 'huisnummer';
	fieldNames[5] = 'postcode';
	fieldNames[6] = 'woonplaats';
	fieldNames[7] = 'overdag';
	fieldNames[8] = 'emailadres';
	fieldNames[9] = 'tekst';
	
	// Loop thru array with fields
	for (i=0; i < fieldNames.length; i++) {
		fieldName = fieldNames[i];		
		fieldValue = formObj.elements[fieldName].value; // get value from field
		
		if(isEmpty(fieldValue)) {			
			document.getElementById(fieldName).style.background = errorColor; // Value is not correct, make label red
			noErrors++;
		} else {			
			document.getElementById(fieldName).style.background = noErrorColor;// Value is correct, make label black
		}
	}
	
	if(!validEmail(email)) {		
		document.getElementById('emailadres').style.background = errorColor; // Value is not correct, make label red
		noErrors++;
	} else {		
		document.getElementById('emailadres').style.background = noErrorColor; // Value is correct, make label black
	}
	
	if(!isZipcode(zipcode)) {		
		document.getElementById('postcode').style.background = errorColor; // Value is not correct, make label red
		noErrors++;
	} else {		
		document.getElementById('postcode').style.background = noErrorColor; // Value is correct, make label black
	}
	
	if(!isPhone(telephone)) {		
		document.getElementById('overdag').style.background = errorColor; // Value is not correct, make label red
		noErrors++;
	} else {		
		document.getElementById('overdag').style.background = noErrorColor; // Value is correct, make label black
	}
	
	// Check if there are no errors
	if(noErrors == 0) {		
		//document.getElementById('error').style.display = "none"; // Hide error		
		document.forms['contactform'].submit(); // Submit form
	} else {		
		//document.getElementById('error').style.display = "block"; // Show error
	}
}

var isIE=document.all?true:false;
var isDOM=document.getElementById?true:false;
var isNS4=document.layers?true:false;

/* _w : which ID (1) or (2) */
/* _h : (h)ide or (s)how */
function toggleT(_w,_h,_x) {
  if (isDOM)
  {
    if (_h=='s') document.getElementById(_w).style.display='block';
    if (_h=='h') document.getElementById(_w).style.display='none';
	
	if(_x == 'pages') {
		document.getElementById('pages').style.display='block';
		document.getElementById('menu').style.display='none';
	} else {	
		document.getElementById('pages').style.display='none';
		document.getElementById('menu').style.display='block';
	}	
  }
  else if (isIE) {
    if (_h=='s') eval("document.all."+_w+".style.display='block';");
    if (_h=='h') eval("document.all."+_w+".style.display='none';");
  }
  else if(isNS4)
  {
    if (_h=='s') eval("document.layers['"+_w+"'].display='block';");
    if (_h=='h') eval("document.layers['"+_w+"'].display='none';");
  }
}

function settingMenu(which) {
	if(which == 'general') {
		document.getElementById('general_settings').style.display = "block";
		document.getElementById('contact_settings').style.display = "none";
	} else {
		document.getElementById('general_settings').style.display = "none";
		document.getElementById('contact_settings').style.display = "block";
	}
}

function hideFields() {
	// Controleer welke radiobutton gekozen is
	if(document.forms['subscribe'].elements['subscribe'][0].checked) {
		document.getElementById('namefields').style.display = "block";
	}
	else {
		// Uitschrijven is gekozen, verberg overige velden
		document.getElementById('namefields').style.display = "none";
	}
}
/*
IE5=NN4=NN6=false
if(document.all)IE5=true
else if(document.layers)NN4=true
else if(document.getElementById)NN6=true

function showDiv( which, intFaq ) {
	for(i=0;i<intFaq;i++) {
		if(NN4) eval("document.div"+i+".display='none'")
		if(IE5) eval("document.all.div"+i+".style.display='none'")
		if(NN6) eval("document.getElementById('div"+i+"').style.display='none'")
	}
	if(NN4) eval("document.div"+which+".display='block'")
	if(IE5) eval("document.all.div"+which+".style.display='block'")
	if(NN6) eval("document.getElementById('div"+which+"').style.display='block'")
}
*/
function checkSelect()
{
	if(document.forms['addpage'].elements['setpage'][2].checked) {
		toggleT('form', 'h');
	}	
	if(document.forms['addpage'].elements['setpage'][3].checked) {
		toggleT('form', 's', 'pages');
	}
}

function checkSubscribe(which) {

	// Declaratie variabelen
	var noErrors = 0;
	var fieldnames = new Array();
	var errorColor = "#c1fd6a";
	var noErrorColor = "white";
	var formObj = document.forms['subscribe'];
	var email = formObj.elements['email'].value;

	// Standaard wordt de velden email, voornaam en achternaam gecontroleerd
	fieldnames[0] = "firstname";
	fieldnames[1] = "lastname";
	fieldnames[2] = "email";
	
	// Doorloop array met te controleren velden
	for (i=0; i < fieldnames.length; i++) {
		fieldName = fieldnames[i];	
		fieldValue = formObj.elements[fieldName].value; // get value from field
		
		if(formObj.subscribe[0].checked) {
			if(isEmpty(fieldValue)) {			
				document.getElementById(fieldName).style.background = errorColor; // Value is not correct, make label red
				noErrors++;
			} else {			
				document.getElementById(fieldName).style.background = noErrorColor;// Value is correct, make label black
			}
		} else if(fieldName != "email" && formObj.subscribe[0].checked) {
			//if(isEmpty(fieldValue) || !validString(formObj.elements[fieldName].value)) {
			if(isEmpty(fieldValue)) {			
				document.getElementById(fieldName).style.background = errorColor; // Value is not correct, make label red
				noErrors++;
			} else {			
				document.getElementById(fieldName).style.background = noErrorColor;// Value is correct, make label black
			}
		}
	} 	
	
	if(!validEmail(email)) {		
		document.getElementById('email').style.background = errorColor; // Value is not correct, make label red
		noErrors++;
	} else {		
		document.getElementById('email').style.background = noErrorColor; // Value is correct, make label black
	}
	
	// Controleer of alles ok is
	if(noErrors == 0) {
		// Verberg foutmelding
		// Submit formulier
		document.forms['subscribe'].submit();
	}
}


function checkSub(which) {
	// Declaratie variabelen
	var noErrors = 0;
	var fieldnames = new Array();
	var errorColor = "#c1fd6a";
	var noErrorColor = "white";
	var formObj = document.forms['add_sub'];
	var email = formObj.elements['sub_email'].value;
	var firstname = formObj.elements['sub_firstname'].value;
	var lastname = formObj.elements['sub_lastname'].value;
	
	//if(isEmpty(firstname) || !validString(firstname)) {	
	if(isEmpty(firstname)) {			
		document.getElementById('sub_firstname').style.background = errorColor; // Value is not correct, make label red
		noErrors++;
	} else {			
		document.getElementById('sub_firstname').style.background = noErrorColor;// Value is correct, make label black
	}
	
	//if(isEmpty(lastname) || !validString(lastname)) {
	if(isEmpty(lastname)) {			
		document.getElementById('sub_lastname').style.background = errorColor; // Value is not correct, make label red
		noErrors++;
	} else {			
		document.getElementById('sub_lastname').style.background = noErrorColor;// Value is correct, make label black
	} 
	
	if(which == 'add') {		
		if(isEmpty(formObj.elements['sub_signup'].value))
		{
			document.getElementById('sub_signup').style.background = errorColor; // Value is not correct, make label red
			noErrors++;
		} else {			
			document.getElementById('sub_signup').style.background = noErrorColor;// Value is correct, make label black
		}
	} 	
	
	if(!validEmail(email)) {		
		document.getElementById('sub_email').style.background = errorColor; // Value is not correct, make label red
		noErrors++;
	} else {		
		document.getElementById('sub_email').style.background = noErrorColor; // Value is correct, make label black
	}
	
	// Controleer of alles ok is
	if(noErrors == 0) {
		// Verberg foutmelding
		// Submit formulier
		document.forms['add_sub'].submit();
	}
}

function sendFormPage(intPage)
{
	document.forms['prevNext'].elements['page'].value = intPage;
	// Submit form
	document.forms['prevNext'].submit();
}

function sendFormSortName(strName)
{
	document.forms['sortName'].elements['sort_name'].value = strName;
	// Submit form
	document.forms['sortName'].submit();
}

function sendFormSortChar(intCharacter)
{
	document.forms['sortChar'].elements['sort_character'].value = intCharacter;
	// Submit form
	document.forms['sortChar'].submit();
}

function sendFormShow(intShowPage)
{
	document.forms['show'].elements['show_page'].value = intShowPage;
	// Submit form
	document.forms['show'].submit();
}

/***********************************************
* Pausing up-down scroller- © Dynamic Drive (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit http://www.dynamicdrive.com/ for this script and 100s more.
***********************************************/

function pausescroller(content, divId, divClass, delay){
this.content=content //message array content
this.tickerid=divId //ID of ticker div to display information
this.delay=delay //Delay between msg change, in miliseconds.
this.mouseoverBol=0 //Boolean to indicate whether mouse is currently over scroller (and pause it if it is)
this.hiddendivpointer=1 //index of message array for hidden div
if(content[1] == null)
{
	content[1] = content[0];
}

document.write('<div id="'+divId+'" class="'+divClass+'" style="position: relative; overflow: hidden"><div class="innerDiv" style="position: absolute; width: 100%" id="'+divId+'1">'+content[0]+'</div><div class="innerDiv" style="position: absolute; width: 100%; visibility: hidden" id="'+divId+'2">'+content[1]+'</div></div>')
var scrollerinstance=this
if (window.addEventListener) //run onload in DOM2 browsers
window.addEventListener("load", function(){scrollerinstance.initialize()}, false)
else if (window.attachEvent) //run onload in IE5.5+
window.attachEvent("onload", function(){scrollerinstance.initialize()})
else if (document.getElementById) //if legacy DOM browsers, just start scroller after 0.5 sec
setTimeout(function(){scrollerinstance.initialize()}, 500)
}

// -------------------------------------------------------------------
// initialize()- Initialize scroller method.
// -Get div objects, set initial positions, start up down animation
// -------------------------------------------------------------------

pausescroller.prototype.initialize=function(){
this.tickerdiv=document.getElementById(this.tickerid)
this.visiblediv=document.getElementById(this.tickerid+"1")
this.hiddendiv=document.getElementById(this.tickerid+"2")
this.visibledivtop=parseInt(pausescroller.getCSSpadding(this.tickerdiv))
//set width of inner DIVs to outer DIV's width minus padding (padding assumed to be top padding x 2)
this.visiblediv.style.width=this.hiddendiv.style.width=this.tickerdiv.offsetWidth-(this.visibledivtop*2)+"px"
this.getinline(this.visiblediv, this.hiddendiv)
this.hiddendiv.style.visibility="visible"
var scrollerinstance=this
document.getElementById(this.tickerid).onmouseover=function(){scrollerinstance.mouseoverBol=1}
document.getElementById(this.tickerid).onmouseout=function(){scrollerinstance.mouseoverBol=0}
if (window.attachEvent) //Clean up loose references in IE
window.attachEvent("onunload", function(){scrollerinstance.tickerdiv.onmouseover=scrollerinstance.tickerdiv.onmouseout=null})
setTimeout(function(){scrollerinstance.animateup()}, this.delay)
}


// -------------------------------------------------------------------
// animateup()- Move the two inner divs of the scroller up and in sync
// -------------------------------------------------------------------

pausescroller.prototype.animateup=function(){
var scrollerinstance=this
if (parseInt(this.hiddendiv.style.top)>(this.visibledivtop+5)){
this.visiblediv.style.top=parseInt(this.visiblediv.style.top)-5+"px"
this.hiddendiv.style.top=parseInt(this.hiddendiv.style.top)-5+"px"
setTimeout(function(){scrollerinstance.animateup()}, 50)
}
else{
this.getinline(this.hiddendiv, this.visiblediv)
this.swapdivs()
setTimeout(function(){scrollerinstance.setmessage()}, this.delay)
}
}

// -------------------------------------------------------------------
// swapdivs()- Swap between which is the visible and which is the hidden div
// -------------------------------------------------------------------

pausescroller.prototype.swapdivs=function(){
var tempcontainer=this.visiblediv
this.visiblediv=this.hiddendiv
this.hiddendiv=tempcontainer
}

pausescroller.prototype.getinline=function(div1, div2){
div1.style.top=this.visibledivtop+"px"
div2.style.top=Math.max(div1.parentNode.offsetHeight, div1.offsetHeight)+"px"
}

// -------------------------------------------------------------------
// setmessage()- Populate the hidden div with the next message before it's visible
// -------------------------------------------------------------------

pausescroller.prototype.setmessage=function(){
var scrollerinstance=this
if (this.mouseoverBol==1) //if mouse is currently over scoller, do nothing (pause it)
setTimeout(function(){scrollerinstance.setmessage()}, 100)
else{
var i=this.hiddendivpointer
var ceiling=this.content.length
this.hiddendivpointer=(i+1>ceiling-1)? 0 : i+1
this.hiddendiv.innerHTML=this.content[this.hiddendivpointer]
this.animateup()
}
}

pausescroller.getCSSpadding=function(tickerobj){ //get CSS padding value, if any
if (tickerobj.currentStyle)
return tickerobj.currentStyle["paddingTop"]
else if (window.getComputedStyle) //if DOM2
return window.getComputedStyle(tickerobj, "").getPropertyValue("padding-top")
else
return 0
}
