
// check browsertype
var isMinNS4 = (navigator.appName.indexOf("Netscape") >= 0 &&
                parseFloat(navigator.appVersion) >= 4) ? 1 : 0;
var isMinIE4 = (document.all) ? 1 : 0;
var isMinIE5 = (isMinIE4 && navigator.appVersion.indexOf("5.") >= 0) ? 1 : 0;
var isNS6 = (navigator.userAgent.indexOf("Gecko")    > 0) ? 1 : 0;
var isOpera = (navigator.userAgent.indexOf("Opera") != -1);

//if (isMinNS4) {alert ('isMinNS4');};
//if (isMinIE4) {alert ('isMinIE4');};
//if (isMinIE5) {alert ('isMinIE5');};
//if (isNS6) {alert ('isNS6');};
//if (this.opera) {alert ('isOpera');}; 

// bepaald variabelen voor later gebruik
if (isMinNS4 || isNS6) {
	doc="document.";				// document
	val = ".value";					// waarde
	stijl="";						// stijl
	horz=".left";					// horizontale afstand
	vert=".top";					// vertikale afstand
	innerW="window.innerWidth";		// breedte scherm
	innerH="window.innerHeight";	// hoogte scherm
	offsetX="window.pageXOffset";	// offset breedte
	offsetY="window.pageYOffset";	// offset hoogte
};
if (isMinIE4){
	doc="";
	val = ".value";
	stijl=".style";
	horz=".pixelLeft";
	vert=".pixelTop";
	innerW="document.body.clientWidth";
	innerH="document.body.clientHeight";
	offsetX="document.body.scrollLeft";
	offsetY="document.body.scrollTop";
};
 
// functie om form te submitten + verplichte velden controle +disable submitknop
// getest: ie5.5 ok, ie6.0 ok, ns4.7 ok, ns6.2 ok, opera5.12 ok,
// gebruik: in form tag: onSubmit="return checkverplicht('formuliernaam','naam van 
// velden','titel van velden');" 
function checkverplicht(formulier,reqlijstveld,reqlijstnaam,lang) {
var Checkveld = reqlijstveld;
var Checknaam = reqlijstnaam;
var Checklang = lang;
var isok ='ja';
form = formulier;
var buttontekst = eval(doc+form+".verstuur"+val);
if (Checklang == 'nl'){
eval(doc+form+".verstuur"+val+"='Even geduld aub'");
} else if (Checklang == 'fr'){
eval(doc+form+".verstuur"+val+"='Even geduld aub'");
} else if (Checklang == 'en'){
eval(doc+form+".verstuur"+val+"='Please wait'");
} else {
eval(doc+form+".verstuur"+val+"='Even geduld aub'");
}
eval(doc+form+".verstuur.disabled=true");
if (Checkveld != '') {
var CheckveldArray = Checkveld.split(",");
var ChecknaamArray = Checknaam.split(","); 
for (var i=0; i<CheckveldArray.length; i++)
	{
	var naam = ChecknaamArray[i];
	veld = "."+CheckveldArray[i]+"";
	waarde = eval(doc+form+veld+val);
		if (waarde == ''|| waarde == null) {
			if (Checklang == 'nl'){
			alert(''+naam+' is een verplicht veld');
			} else if (Checklang == 'fr'){
			alert(''+naam+' is a required field');
			} else if (Checklang == 'en'){
			alert(''+naam+' is a required field');
			} else {
			alert(''+naam+' is a required field');
			}
		var isok = 'nee';
		};
	};
};
if (isok == 'nee') {
eval(doc+form+".verstuur"+val+"='"+buttontekst+"'");
eval(doc+form+".verstuur.disabled=false");
return false;
}else
{return true};
};


function PopIt(filename, w, h, s){  
	var wp = (screen.width/100)*w;
	var hp = (screen.height/100)*h;
	var midw = (screen.width/2)-(wp/2);
	var midh = (screen.height/2)-(hp/2);
	popup = window.open(filename,"popDialog","left="+midw+" top="+midh+" height="+hp+",width="+wp+",scrollbars=yes resizable=1")  
	if ( popup.document.close() ) {
		popup.document.close()
	}
};

function PopItpx(filename, w, h, s){  
	var wp = w;
	var hp = h;
	var midw = (screen.width/2)-(wp/2);
	var midh = (screen.height/2)-(hp/2);
	popup = window.open(filename,"popDialog","left="+midw+" top="+midh+" height="+hp+",width="+wp+",scrollbars=yes resizable=1")  
	if ( popup.document.close() ) {
		popup.document.close()
	}
};

function setbgcolor(field,color) {
	eval("document.mainform."+field+".style.backgroundColor='"+color+"'");
}

function setreqfield(field,fieldname,type) {
	if (type == 1){
		document.mainform.required_fields.value = document.mainform.required_fields.value + ","+field;
		document.mainform.required_fieldnames.value = document.mainform.required_fieldnames.value + ","+fieldname;
	} else {
		document.mainform.required_fields.value = document.mainform.required_fields.value.replace(","+field, "");
		document.mainform.required_fieldnames.value = document.mainform.required_fieldnames.value.replace(","+fieldname, "");
	}
}

function copyfield(field1,field2) {
	eval("document.mainform."+field2+".value=document.mainform."+field1+".value");
}

function checkinvoice() {
	if (document.mainform.client_same_invoice.checked == true){
	setbgcolor('client_address_invoice','#ffffff');
	setbgcolor('client_city_invoice','#ffffff');
	setbgcolor('client_zipcode_invoice','#ffffff');
	setbgcolor('client_country_invoice','#ffffff');
	setreqfield('client_address_invoice','invoice address',0);
	setreqfield('client_city_invoice','invoice city',0);
	setreqfield('client_zipcode_invoice','invoice zipcode',0);
	setreqfield('client_country_invoice','invoice country',0);
	eval("document.mainform.client_address_invoice.value = ''");
	eval("document.mainform.client_city_invoice.value = ''");
	eval("document.mainform.client_zipcode_invoice.value = ''");
	eval("document.mainform.client_country_invoice.value = ''");
	eval("document.mainform.client_address_invoice.disabled = true");
	eval("document.mainform.client_city_invoice.disabled = true");
	eval("document.mainform.client_zipcode_invoice.disabled = true");
	eval("document.mainform.client_country_invoice.disabled = true");
	} else {
	setbgcolor('client_address_invoice','#D2D1C9');
	setbgcolor('client_city_invoice','#D2D1C9');
	setbgcolor('client_zipcode_invoice','#D2D1C9');
	setbgcolor('client_country_invoice','#D2D1C9');
	setreqfield('client_address_invoice','invoice address',1);
	setreqfield('client_city_invoice','invoice city',1);
	setreqfield('client_zipcode_invoice','invoice zipcode',1);
	setreqfield('client_country_invoice','invoice country',1);
	eval("document.mainform.client_address_invoice.disabled = false");
	eval("document.mainform.client_city_invoice.disabled = false");
	eval("document.mainform.client_zipcode_invoice.disabled = false");
	eval("document.mainform.client_country_invoice.disabled = false");
	}
}

function checksameperson() {
	if (document.mainform.client_same_person.checked == true){
		if (eval("document.mainform.client_name.value == ''") || eval("document.mainform.client_firstname.value == ''") || eval("document.mainform.client_email.value == ''")){
			alert ('Registering person not fully entered!');
			eval("document.mainform.client_same_person.checked = false");
			return false;
		} else {
			setbgcolor('client_title_1','#ffffff');
			setbgcolor('client_name_1','#ffffff');
			setbgcolor('client_firstname_1','#ffffff');
			setbgcolor('client_email_1','#ffffff');
			setreqfield('client_name_1','participant 1 name',0);
			setreqfield('client_firstname_1','participant 1 firstname',0);
			setreqfield('client_email_1','participant 1 email',0);
			copyfield('client_name','client_name_1');
			copyfield('client_firstname','client_firstname_1');
			copyfield('client_email','client_email_1');
			copyfield('client_jobtitle','client_jobtitle_1');
			document.mainform.client_title_1.disabled = true;
			document.mainform.client_name_1.disabled = true;
			document.mainform.client_firstname_1.disabled = true;
			document.mainform.client_email_1.disabled = true;
			document.mainform.client_jobtitle_1.disabled = true;
		}
	} else {
	setbgcolor('client_title_1','#D2D1C9');
	setbgcolor('client_name_1','#D2D1C9');
	setbgcolor('client_firstname_1','#D2D1C9');
	setbgcolor('client_email_1','#D2D1C9');
	setreqfield('client_name_1','participant 1 name',1);
	setreqfield('client_firstname_1','participant 1 firstname',1);
	setreqfield('client_email_1','participant 1 email',1);
	document.mainform.client_title_1.disabled = false;
	document.mainform.client_name_1.disabled = false;
	document.mainform.client_firstname_1.disabled = false;
	document.mainform.client_email_1.disabled = false;
	document.mainform.client_jobtitle_1.disabled = false;
	}
}

function checkpart(nr) {
	prev = nr - 1;
	if (eval("document.mainform.part"+nr+".checked == true")){
		if (eval("document.mainform.client_name_"+prev+".value == ''") || eval("document.mainform.client_firstname_"+prev+".value == ''") || eval("document.mainform.client_email_"+prev+".value == ''")){
			alert ('Previous participant not fully entered!');
			eval("document.mainform.part"+nr+".checked = false");
			return false;
		} else {
			setbgcolor('client_title_'+nr,'#D2D1C9');
			setbgcolor('client_name_'+nr,'#D2D1C9');
			setbgcolor('client_firstname_'+nr,'#D2D1C9');
			setbgcolor('client_email_'+nr,'#D2D1C9');
			setreqfield('client_name_'+nr,'participant '+nr+' name',1);
			setreqfield('client_firstname_'+nr,'participant '+nr+' firstname',1);
			setreqfield('client_email_'+nr,'participant '+nr+' email',1);
			eval("document.mainform.client_title_"+nr+".disabled = false");
			eval("document.mainform.client_name_"+nr+".disabled = false");
			eval("document.mainform.client_firstname_"+nr+".disabled = false");
			eval("document.mainform.client_email_"+nr+".disabled = false");
			eval("document.mainform.client_jobtitle_"+nr+".disabled = false");
		}
	} else {
	setbgcolor('client_title_'+nr,'#ffffff');
	setbgcolor('client_name_'+nr,'#ffffff');
	setbgcolor('client_firstname_'+nr,'#ffffff');
	setbgcolor('client_email_'+nr,'#ffffff');
	setreqfield('client_name_'+nr,'participant '+nr+' name',0);
	setreqfield('client_firstname_'+nr,'participant '+nr+' firstname',0);
	setreqfield('client_email_'+nr,'participant '+nr+' email',0);
	eval("document.mainform.client_title_"+nr+".disabled = true");
	eval("document.mainform.client_name_"+nr+".disabled = true");
	eval("document.mainform.client_firstname_"+nr+".disabled = true");
	eval("document.mainform.client_email_"+nr+".disabled = true");
	eval("document.mainform.client_jobtitle_"+nr+".disabled = true");
	}
}

function checkcode() {
frames['validcode'].location.href="special/valid_code.php?ID="+document.mainform.registration_cursusdataID.value+"&code="+document.mainform.registration_discountcode.value;
}

function handleDiscounts(nr) {
document.mainform.partnr.value = nr;
discount = nr;
parts = nr;
if (discount > 4){discount=4;}
document.mainform.part1_discount.value = discount*5;
document.mainform.part1_nr.value = parts+1;
discount=discount+1; if (discount > 4){discount=4;}
document.mainform.part2_discount.value = discount*5;
document.mainform.part2_nr.value = parts+2;
discount=discount+1; if (discount > 4){discount=4;}
document.mainform.part3_discount.value = discount*5;
document.mainform.part3_nr.value = parts+3;
discount=discount+1; if (discount > 4){discount=4;}
document.mainform.part4_discount.value = discount*5;
document.mainform.part4_nr.value = parts+4;
discount=discount+1; if (discount > 4){discount=4;}
document.mainform.part5_discount.value = discount*5;
document.mainform.part5_nr.value = parts+5;
if (nr != 0){
further.style.display = 'none';
} else {
further.style.display = 'inline';
}
}

function specialDiscounts(procent) {
document.mainform.part1_discount.value = procent;
document.mainform.part2_discount.value = procent;
document.mainform.part3_discount.value = procent;
document.mainform.part4_discount.value = procent;
document.mainform.part5_discount.value = procent;
further.style.display = 'none';
}

function changevat() {
	if (eval("document.paypalform.checkvat.checked == true")){
		document.paypalform.temp_vat.value='0';
		document.paypalform.temp_vattotal.value=document.paypalform.total.value;
		document.paypalform.amount.value=document.paypalform.total.value;
		document.paypalform.custom.value='0';
	} else {
		document.paypalform.temp_vat.value=document.paypalform.vat.value;
		document.paypalform.temp_vattotal.value=document.paypalform.vattotal.value;
		document.paypalform.amount.value=document.paypalform.vattotal.value;
		document.paypalform.custom.value='1';
	}
}

function checkpaypal() {
	if (document.mainform.registration_month.checked == true){
			if (document.mainform.registration_paypal.checked == true){
				document.mainform.registration_month.checked = true;
			} else {
				alert('Check -Pay online with Paypal- to receive this additional 10% discount');
				document.mainform.registration_month.checked = false;
			}
	}
}

function validemail(field) {
  var str = field.value;
  if (str == "") {
return true;
}
  if (window.RegExp) {
    var reg1str = "(@.*@)|(\\.\\.)|(@\\.)|(\\.@)|(^\\.)";
    var reg2str =
"^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,3}|[0-9]{1,4})(\\]?)$";
    var reg1 = new RegExp(reg1str);
    var reg2 = new RegExp(reg2str);
    if (!reg1.test(str) && reg2.test(str)) {
      return true;
    }
    field.focus();
    alert('Geen geldig emailadres.');
    return false;
  } else {
    if(str.indexOf("@") >= 0)
      return true;
    field.focus();
    alert('Geen geldig emailadres.');
    return false;
  }
};


function validpaswoord(field,field2) {
var str = field.value;
var str2 = field2.value;
if (str != ""){
	if (str != str2) {
		field2.focus();
		alert('Je moet tweemaal hetzelfde paswoord ingeven.');
		field.value='';
		field2.value='';
		return false;
		}
 	return true;	
	}
return true;
};

function checkCR(evt) {
var evt  = (evt) ? evt : ((event) ? event : null);
var node = (evt.target) ? evt.target : ((evt.srcElement) ? evt.srcElement : null);
if ((evt.keyCode == 13) && (node.type=="text")) {return false;}
};

function changesourcefield() {
var w=document.mainform.fwidth.value;
var l=document.mainform.flimit.value;
var f = document.mainform.ffloat.options[document.mainform.ffloat.options.selectedIndex].value;
document.mainform.fsource.value="<scr"+"ipt type='text/javascript' src='http://www.paircoaching.net/scripts/workshops_widget.js.php?width="+w+"&limit="+l+"&float="+f+"'></sc"+"ript>";
frames['preview'].location.href="http://www.paircoaching.net/scripts/workshops_widget_example.php?width="+w+"&limit="+l+"&float="+f+"";
}