var newwin;
function launchwin(winurl,winname,winfeatures)
{
	newwin = window.open(winurl,winname,winfeatures);
	if(javascript_version > 1.0) {
		setTimeout('newwin.focus();',250);
	}
}
function ValidateNoHTML(theinput)
{
	s=theinput.value
	if(s.length==0) return true;
	var ht = new RegExp(/http\:\/\/|https\:\/\/|ftp\:\/\//i);
	var re = new RegExp("<[^<>]+>");
	if (s.match(re)) {
		return false
	} else if (s.match(ht)) {
		return false
	} else {
		return true
	}
}
function ValidateEmailOrNull(theinput)
{
	s=theinput.value
	if(s.length==0) return true;
	if(s.search)
	{
		return (s.search(new RegExp("^([-!#$%&'*+./0-9=?A-Z^_`a-z{|}~])+@([-!#$%&'*+/0-9=?A-Z^_`a-z{|}~]+\\.)+[a-zA-Z]{2,4}$","gi"))>=0)
	}
	if(s.indexOf)
	{
		at_character=s.indexOf('@')
		if(at_character<=0 || at_character+4>s.length)
			return false
	}
	if(s.length<6)
		return false
	else
		return true
}

function ValidateHyperlinkOrNull(theinput)
{
	s=theinput.value
	if(s.length==0) return true;

	var RegExp = /^(http|https|ftp):\/\/(([A-Z0-9][A-Z0-9_-]*)(\.{0,1}[A-Z0-9][A-Z0-9_-]*)(\.[A-Z0-9][A-Z0-9_-]*)+)(:(\d+))?/i;
				
    if(RegExp.test(s)){ 
        return true;
    }else{
        return false;
    } 	
}

function ValidateEmailOrPhone(theinput)
{
	s=theinput.value
	if(theinput.form.phone.value.length!=0) return true;
	if(s.search)
	{
		return (s.search(new RegExp("^([-!#$%&'*+./0-9=?A-Z^_`a-z{|}~])+@([-!#$%&'*+/0-9=?A-Z^_`a-z{|}~]+\\.)+[a-zA-Z]{2,4}$","gi"))>=0)
	}
	if(s.indexOf)
	{
		at_character=s.indexOf('@')
		if(at_character<=0 || at_character+4>s.length)
			return false
	}
	if(s.length<6)
		return false
	else
		return true
}

function ValidateEmail(theinput)
{
	s=theinput.value
	if(s.search)
	{
		return (s.search(new RegExp("^([-!#$%&'*+./0-9=?A-Z^_`a-z{|}~])+@([-!#$%&'*+/0-9=?A-Z^_`a-z{|}~]+\\.)+[a-zA-Z]{2,4}$","gi"))>=0)
	}
	if(s.indexOf)
	{
		at_character=s.indexOf('@')
		if(at_character<=0 || at_character+4>s.length)
			return false
	}
	if(s.length<6)
		return false
	else
		return true
}

function editImage(image) 
{
	var url = "/lib/ImageManager/editor.php?img="+image;
	Dialog(url, function(param) 
	{
		if (!param) // user must have pressed Cancel
			return false;
		else
		{
			return true;
		}
	}, null);		
}

function ta_hover(id) {
	document.getElementById('row_' + id).style.background='#fff';
}
function ta_unhover(id) {
	document.getElementById('row_' + id).style.background='#eee';
}

function reformat (s)

{   var arg;
    var sPos = 0;
    var resultString = "";

    for (var i = 1; i < reformat.arguments.length; i++) {
       arg = reformat.arguments[i];
       if (i % 2 == 1) resultString += arg;
       else {
           resultString += s.substring(sPos, sPos + arg);
           sPos += arg;
       }
    }
    return resultString;
}
function ValidatePhone(theinput)
{

	var _p=theinput.value;
	var RegExp1= /[^\d]/g;
	var x=_p.replace(RegExp1,'');
	var RegExp2= /^(\d{3})(\d{3})(\d{4})$/;
	if(x.match(RegExp2))
	{
	  theinput.value=reformat(x,"",3,"",3,"",4);
	  return true;
	}
	else
	return false;
}
function removeAccents(s)
{
	var s;
	var diacritics =[
	/[\300-\306]/g, /[\340-\346]/g, // A, a
	/[\310-\313]/g, /[\350-\353]/g, // E, e
	/[\314-\317]/g, /[\354-\357]/g, // I, i
	/[\322-\330]/g, /[\362-\370]/g, // O, o
	/[\331-\334]/g, /[\371-\374]/g,  // U, u
	/[\321]/g, /[\361]/g, // N, n
	/[\307]/g, /[\347]/g, // C, c
	];
	var chars = ['A','a','E','e','I','i','O','o','U','u','N','n','C','c'];
	for (var i = 0; i < diacritics.length; i++)
	{
		s = s.replace(diacritics[i],chars[i]);
	}
	return s;
}
function formValidateLoginForm(theform) {
	if(theform.username.value=='') {
		alert('[E-mailadres] is een verplicht veld.');
		theform.username.focus();
		theform.username.old_className = theform.username.className;
		theform.username.className = 'input1_error';
		return false;
	}else if(ValidateEmailOrNull(theform.username)==false) {
		alert('Het ingevoerde E-mailadres is niet geldig. U moet een geldig E-mailadres invullen')
		theform.username.focus();
		theform.username.old_className = theform.username.className;
		theform.username.className = 'input1_error';
		return false;
	} else { 
		theform.username.className = 'input1';
	} 
	if(theform.password.value=='') {
		alert('[Wachtwoord] is een verplicht veld.');
		theform.password.focus();
		theform.password.old_className = theform.password.className;
		theform.password.className = 'input1_error';
		return false;
	} else { 
		theform.password.className = 'input1';
	} 
	return true;
}
function searchformValidate(theform) {
	if(theform.search.value.length<4) {
		alert('Geef een zoekterm op die bestaat uit minimaal 4 karakters.');
		theform.search.focus();
		theform.search.old_className = theform.search.className;
		theform.search.className = 'input1_error';
		return false;
	} else { 
		theform.search.className = 'input1';
	} 
	return true;
}
function formValidateSubscribe(theform) {
	if(theform.name.value=='') {
		alert('[naam] is een verplicht veld.');
		theform.name.focus();
		theform.name.old_className = theform.name.className;
		theform.name.className = 'input1_error';
		return false;
	} else { 
		theform.name.className = 'input1';
	} 
	if(theform.name.value=='Naam') {
		alert('[naam] is een verplicht veld.');
		theform.name.value="";
		theform.name.focus();
		theform.name.old_className = theform.name.className;
		theform.name.className = 'input1_error';
		return false;
	} else { 
		theform.name.className = 'input1';
	} 
	if(theform.email.value=='') {
		alert('[e-mail] is een verplicht veld.');
		theform.email.focus();
		theform.email.old_className = theform.email.className;
		theform.email.className = 'input1_error';
		return false;
	} else { 
		theform.email.className = 'input1';
	} 
	if(theform.email.value=='E-mail adres') {
		alert('[e-mail] is een verplicht veld.');
		theform.email.value="";
		theform.email.focus();
		theform.email.old_className = theform.email.className;
		theform.email.className = 'input1_error';
		return false;
	} else { 
		theform.email.className = 'input1';
	} 
	if(ValidateEmail(theform.email)==false)
	{
		alert('Het ingevoerde e-mailadres is niet geldig. Geef een geldig e-mailadres op.')
		theform.email.focus()
		theform.email.old_className = theform.email.className;
		theform.email.className = 'input1_error';
		return false;
	} else { 
		theform.email.className = 'input1';
	} 				
}
function formValidateContact(theform) {
	if(theform.cf_name.value=='') {
		alert('[Naam] is een verplicht veld.');
		theform.cf_name.focus();
		theform.cf_name.old_className = theform.cf_name.className;
		theform.cf_name.className = 'input1_error';
		return false;
	} else { 
		theform.cf_name.className = 'input1';
	} 
	if(!document.getElementById('cf_geslacht_M').checked && !document.getElementById('cf_geslacht_V').checked) {
		alert('[Geslacht] is een verplicht veld. Maak een keuze.');
		theform.cf_geslacht[0].focus();
		return false;
	}
	if(theform.cf_telephone.value!='' && ValidatePhone(theform.cf_telephone)==false)
	{
		alert('Het ingevoerde telefoonummer is niet geldig. Geef een 10-cijferige telefoonnummer op.')
		theform.cf_telephone.focus();
		theform.cf_telephone.old_className = theform.cf_telephone.className;
		theform.cf_telephone.className = 'input1_error';
		return false;
	} else { 
		theform.cf_telephone.className = 'input1';
	} 
	if(theform.cf_email.value=='') {
		alert('[E-mail] is een verplicht veld.');
		theform.cf_email.focus();
		theform.cf_email.old_className = theform.cf_email.className;
		theform.cf_email.className = 'input1_error';
		return false;
	} else { 
		theform.cf_email.className = 'input1';
	} 
	if(ValidateEmailOrNull(theform.cf_email)==false)
	{
		alert('Het ingevoerde e-mailadres is niet geldig. Geef een geldig e-mailadres op.')
		theform.cf_email.focus()
		theform.cf_email.old_className = theform.cf_email.className;
		theform.cf_email.className = 'input1_error';
		return false;
	} else { 
		theform.cf_email.className = 'input1';
	} 
	if(theform.cf_message.value=='') {
		alert('[Bericht] is een verplicht veld.');
		theform.cf_message.focus();
		theform.cf_message.old_className = theform.cf_message.className;
		theform.cf_message.className = 'input1_error';
		return false;
	} else { 
		theform.cf_message.className = 'input1';
	} 
	return true;
}
function formValidateBrochure(theform) {
	if(theform.bf_name.value=='') {
		alert('[Naam] is een verplicht veld.');
		theform.bf_name.focus();
		theform.bf_name.old_className = theform.bf_name.className;
		theform.bf_name.className = 'input1_error';
		return false;
	} else { 
		theform.bf_name.className = 'input1';
	} 
	if(!document.getElementById('bf_geslacht_M').checked && !document.getElementById('bf_geslacht_V').checked) {
		alert('[Geslacht] is een verplicht veld. Maak een keuze.');
		theform.bf_geslacht[0].focus();
		return false;
	}
	if(theform.bf_telephone.value!='' && ValidatePhone(theform.bf_telephone)==false)
	{
		alert('Het ingevoerde telefoonummer is niet geldig. Geef een 10-cijferige telefoonnummer op.')
		theform.bf_telephone.focus();
		theform.bf_telephone.old_className = theform.bf_telephone.className;
		theform.bf_telephone.className = 'input1_error';
		return false;
	} else { 
		theform.bf_telephone.className = 'input1';
	} 
	if(theform.bf_email.value=='') {
		alert('[E-mail] is een verplicht veld.');
		theform.bf_email.focus();
		theform.bf_email.old_className = theform.bf_email.className;
		theform.bf_email.className = 'input1_error';
		return false;
	} else { 
		theform.bf_email.className = 'input1';
	} 
	if(ValidateEmailOrNull(theform.bf_email)==false)
	{
		alert('Het ingevoerde e-mailadres is niet geldig. Geef een geldig e-mailadres op.')
		theform.bf_email.focus()
		theform.bf_email.old_className = theform.bf_email.className;
		theform.bf_email.className = 'input1_error';
		return false;
	} else { 
		theform.bf_email.className = 'input1';
	} 
	return true;
}
function formValidateVacature(theform) {
	if(theform.vf_name.value=='') {
		alert('[Naam] is een verplicht veld.');
		theform.vf_name.focus();
		theform.vf_name.old_className = theform.vf_name.className;
		theform.vf_name.className = 'input1_error';
		return false;
	} else { 
		theform.vf_name.className = 'input1';
	} 
	if(!document.getElementById('vf_geslacht_M').checked && !document.getElementById('vf_geslacht_V').checked) {
		alert('[Geslacht] is een verplicht veld. Maak een keuze.');
		theform.vf_geslacht[0].focus();
		return false;
	}
	if(theform.vf_telephone.value=='') {
		alert('[Telefoon] is een verplicht veld.');
		theform.vf_telephone.focus();
		theform.vf_telephone.old_className = theform.vf_telephone.className;
		theform.vf_telephone.className = 'input1_error';
		return false;
	} else { 
		theform.vf_telephone.className = 'input1';
	} 
	if(theform.vf_telephone.value!='' && ValidatePhone(theform.vf_telephone)==false)
	{
		alert('Het ingevoerde telefoonummer is niet geldig. Geef een 10-cijferige telefoonnummer op.')
		theform.vf_telephone.focus();
		theform.vf_telephone.old_className = theform.vf_telephone.className;
		theform.vf_telephone.className = 'input1_error';
		return false;
	} else { 
		theform.vf_telephone.className = 'input1';
	} 
	if(theform.vf_email.value=='') {
		alert('[E-mail] is een verplicht veld.');
		theform.vf_email.focus();
		theform.vf_email.old_className = theform.vf_email.className;
		theform.vf_email.className = 'input1_error';
		return false;
	} else { 
		theform.vf_email.className = 'input1';
	} 
	if(ValidateEmailOrNull(theform.vf_email)==false)
	{
		alert('Het ingevoerde e-mailadres is niet geldig. Geef een geldig e-mailadres op.')
		theform.vf_email.focus()
		theform.vf_email.old_className = theform.vf_email.className;
		theform.vf_email.className = 'input1_error';
		return false;
	} else { 
		theform.vf_email.className = 'input1';
	} 
	if(theform.vf_message.value=='') {
		alert('[Toelichting] is een verplicht veld.');
		theform.vf_message.focus();
		theform.vf_message.old_className = theform.vf_message.className;
		theform.vf_message.className = 'input1_error';
		return false;
	} else { 
		theform.vf_message.className = 'input1';
	} 
	return true;
}
function formValidateInschrijven(theform) {
	if(theform.if_name.value=='') {
		alert('[Naam] is een verplicht veld.');
		theform.if_name.focus();
		theform.if_name.old_className = theform.if_name.className;
		theform.if_name.className = 'input1_error';
		return false;
	} else { 
		theform.if_name.className = 'input1';
	} 
	if(!document.getElementById('if_geslacht_M').checked && !document.getElementById('if_geslacht_V').checked) {
		alert('[Geslacht] is een verplicht veld. Maak een keuze.');
		theform.if_geslacht[0].focus();
		return false;
	}
	if(theform.if_telephone.value=='') {
		alert('[Telefoon] is een verplicht veld.');
		theform.if_telephone.focus();
		theform.if_telephone.old_className = theform.if_telephone.className;
		theform.if_telephone.className = 'input1_error';
		return false;
	} else { 
		theform.if_telephone.className = 'input1';
	} 
	if(theform.if_telephone.value!='' && ValidatePhone(theform.if_telephone)==false)
	{
		alert('Het ingevoerde telefoonummer is niet geldig. Geef een 10-cijferige telefoonnummer op.')
		theform.if_telephone.focus();
		theform.if_telephone.old_className = theform.if_telephone.className;
		theform.if_telephone.className = 'input1_error';
		return false;
	} else { 
		theform.if_telephone.className = 'input1';
	} 
	if(theform.if_email.value=='') {
		alert('[E-mail] is een verplicht veld.');
		theform.if_email.focus();
		theform.if_email.old_className = theform.if_email.className;
		theform.if_email.className = 'input1_error';
		return false;
	} else { 
		theform.if_email.className = 'input1';
	} 
	if(ValidateEmailOrNull(theform.if_email)==false)
	{
		alert('Het ingevoerde e-mailadres is niet geldig. Geef een geldig e-mailadres op.')
		theform.if_email.focus()
		theform.if_email.old_className = theform.if_email.className;
		theform.if_email.className = 'input1_error';
		return false;
	} else { 
		theform.if_email.className = 'input1';
	} 
	if(theform.if_message.value=='') {
		alert('[Toelichting] is een verplicht veld.');
		theform.if_message.focus();
		theform.if_message.old_className = theform.if_message.className;
		theform.if_message.className = 'input1_error';
		return false;
	} else { 
		theform.if_message.className = 'input1';
	} 
	return true;
}
function formValidateActualisatie(theform) {
	if(theform.a_roepnaam.value=='') {
		alert('[Roepnaam] is een verplicht veld.');
		theform.a_roepnaam.focus();
		theform.a_roepnaam.old_className = theform.a_roepnaam.className;
		theform.a_roepnaam.className = 'input1_error';
		return false;
	} else { 
		theform.a_roepnaam.className = 'input1';
	} 
	Capitalize(theform.a_roepnaam);
	if(theform.a_voorletters.value=='') {
		alert('[Voorletters] is een verplicht veld.');
		theform.a_voorletters.focus();
		theform.a_voorletters.old_className = theform.a_voorletters.className;
		theform.a_voorletters.className = 'input1_error';
		return false;
	} else { 
		theform.a_voorletters.className = 'input1';
	} 
	UpperCase(theform.a_voorletters);
	if(theform.a_achternaam.value=='') {
		alert('[Achternaam] is een verplicht veld.');
		theform.a_achternaam.focus();
		theform.a_achternaam.old_className = theform.a_achternaam.className;
		theform.a_achternaam.className = 'input1_error';
		return false;
	} else { 
		theform.a_achternaam.className = 'input1';
	} 
	Capitalize(theform.a_achternaam);
	if(!document.getElementById('a_geslacht_M').checked && !document.getElementById('a_geslacht_V').checked) {
		alert('[Geslacht] is een verplicht veld. Maak een keuze.');
		theform.a_geslacht[0].focus();
		return false;
	}
	if(theform.a_adres.value=='') {
		alert('[Adres] is een verplicht veld.');
		theform.a_adres.focus();
		theform.a_adres.old_className = theform.a_adres.className;
		theform.a_adres.className = 'input1_error';
		return false;
	} else { 
		theform.a_adres.className = 'input1';
	} 
	Capitalize(theform.a_adres);
	if(theform.a_postcode.value=='') {
		alert('[Postcode] is een verplicht veld.');
		theform.a_postcode.focus();
		theform.a_postcode.old_className = theform.a_postcode.className;
		theform.a_postcode.className = 'input1_error';
		return false;
	} else { 
		theform.a_postcode.className = 'input1';
	} 
	if(theform.a_postcode.value!='' && ValidatePostcode(theform.a_postcode)==false)
	{
		alert('De ingevoerde postcode is niet geldig. Je moet een geldige postcode invullen')
		theform.a_postcode.focus();
		theform.a_postcode.old_className = theform.a_postcode.className;
		theform.a_postcode.className = 'input1_error';
		return false;
	} else {
		theform.a_postcode.className = 'input1';
	}
	if(theform.a_woonplaats.value=='') {
		alert('[Woonplaats] is een verplicht veld.');
		theform.a_woonplaats.focus();
		theform.a_woonplaats.old_className = theform.a_woonplaats.className;
		theform.a_woonplaats.className = 'input1_error';
		return false;
	} else { 
		theform.a_woonplaats.className = 'input1';
	} 
	Capitalize(theform.a_woonplaats);
	if(theform.a_telefoon.value=='' && theform.a_mobiel.value=='') {
		alert('[Telefoon of Mobiel] is een verplicht veld.');
		theform.a_telefoon.focus();
		return false;
	} 
	if(theform.a_telefoon.value!='' && ValidatePhone(theform.a_telefoon)==false)
	{
		alert('Het ingevoerde telefoonummer is niet geldig. Geef een 10-cijferige telefoonnummer op.')
		theform.a_telefoon.focus();
		theform.a_telefoon.old_className = theform.a_telefoon.className;
		theform.a_telefoon.className = 'input1_error';
		return false;
	} else { 
		theform.a_telefoon.className = 'input1';
	} 
	if(theform.a_mobiel.value!='' && ValidatePhone(theform.a_mobiel)==false)
	{
		alert('Het ingevoerde mobiele nummer is niet geldig. Geef een 10-cijferige telefoonnummer op.')
		theform.a_mobiel.focus();
		theform.a_mobiel.old_className = theform.a_mobiel.className;
		theform.a_mobiel.className = 'input1_error';
		return false;
	} else { 
		theform.a_mobiel.className = 'input1';
	} 
	if(theform.a_email.value=='') {
		alert('[E-mail] is een verplicht veld.');
		theform.a_email.focus();
		theform.a_email.old_className = theform.a_email.className;
		theform.a_email.className = 'input1_error';
		return false;
	} else { 
		theform.a_email.className = 'input1';
	} 
	if(ValidateEmailOrNull(theform.a_email)==false)
	{
		alert('Het ingevoerde e-mailadres is niet geldig. Geef een geldig e-mailadres op.')
		theform.a_email.focus()
		theform.a_email.old_className = theform.a_email.className;
		theform.a_email.className = 'input1_error';
		return false;
	} else { 
		theform.a_email.className = 'input1';
	} 
}




function ValidatePostcode(theinput)
{
	var x=theinput.value.toUpperCase();
	var y=x.replace(' ','');
	var RegExp1= /^[1-9][0-9]{3}[a-zA-Z]{2}$/;
	if(y.match(RegExp1))
	{
	  theinput.value=reformat(y,"",4," ",2);
	  return true;
	}
	else
	return false;
}
function ValidatePostcode2(theinput)
{

	var x=theinput.value;
	var y=x.replace(' ','');
	var RegExp1= /^[1-9][0-9]{3}$/;
	if(y.match(RegExp1))
	{
	  return true;
	}
	else
	return false;
}
function ValidatePostcode3(theinput)
{
	var x=theinput.value.toUpperCase();
	var y=x.replace(' ','');
	var RegExp1= /^[A-Z]{2}$/;
	if(y.match(RegExp1))
	{
	  return true;
	}
	else
	return false;
}
function ValidateNumber(theinput)
{
	var _p=theinput.value;
	var RegExp1= /[^\d]/g;
	var RegExp2= /^[0-9]{1,}$/;
	var x=_p.replace(RegExp1,'');
	if(_p.match(RegExp2))
	{
	theinput.value=x;
	  return true;
	}
	else {
	theinput.value=x;
	return false;
	}
}
function Capitalize(theinput)
{
	var _p=theinput.value;
	var newValue = '';
	firstChar = _p.substring(0,1);
	remainChar = _p.substring(1);

	// convert case
	firstChar = firstChar.toUpperCase(); 
	remainChar = remainChar.toLowerCase();

	newValue = firstChar + remainChar;
	theinput.value=newValue;
	return true;
}
function LowerCase(theinput)
{
	var _p=theinput.value;
	var newValue = _p.toLowerCase();
	theinput.value=newValue;
	return true;
}
function UpperCase(theinput)
{
	var _p=theinput.value;
	var newValue = _p.toUpperCase();
	theinput.value=newValue;
	return true;
}

