/* Developed by U-Lab 2006 - www.u-lab.nl */

// Checks for Contact Form

function sendContactForm(){
	var msg = "";
	String(document.forms['contact'].firstname.value)=="" ? msg += "- Voornaam\n" : "";
	String(document.forms['contact'].lastname.value)=="" ? msg += "- Achternaam\n" : "";
	String(document.forms['contact'].email.value)=="" ? msg += "- E-mail\n" : "";
	if (msg != ""){
		msg = "Vul alstublieft de volgende gegevens in:\n\n" + msg + "\nen probeer het opnieuw.";
		alert (msg);
	}
	else{
		document.forms['contact'].submit();
	}
}

// Checks for Vacature Form

function sendVacatureForm(){
	var msg = "";
	String(document.forms['vacature'].firstname.value)=="" ? msg += "- Voornaam\n" : "";
	String(document.forms['vacature'].lastname.value)=="" ? msg += "- Achternaam\n" : "";
	String(document.forms['vacature'].address.value)=="" ? msg += "- Adres\n" : "";
	String(document.forms['vacature'].zipcode.value)=="" ? msg += "- Postcode\n" : "";
	String(document.forms['vacature'].city.value)=="" ? msg += "- Plaats\n" : "";			
	String(document.forms['vacature'].phone.value)=="" ? msg += "- Telefoonnummer\n" : "";				
	String(document.forms['vacature'].email.value)=="" ? msg += "- E-mail\n" : "";
	String(document.forms['vacature'].cvdoc.value)=="" ? msg += "- CV\n" : "";
	if (msg != ""){
		msg = "Vul alstublieft de volgende gegevens in:\n\n" + msg + "\nen probeer het opnieuw.";
		alert (msg);
	}	
	else{
		if (document.forms['vacature'].cvdoc.value != ""){
			document.getElementById("upload_progress").style.display = 'block';
		}
		document.forms['vacature'].submit();
	}
}




// General functions

function CheckPassword(theForm, user_password1, user_password2){
	if (theForm.user_password1.value != theForm.user_password2.value){
		alert("The passwords do not match!");
		theForm.user_password2.value = "";
 		return (false);
	}
}

function CheckEmailaddress(ea){
	// assume address is valid
	valid = true;
	ea = ea.toLowerCase();

	// check email address syntax
	if(ea == null) valid = false;
	else if(ea.indexOf("@") < 2) valid = false;
	else if(ea.indexOf("@") != ea.lastIndexOf("@")) valid = false;
	else if(ea.length - ea.lastIndexOf(".") < 3) valid = false;
	else if(ea.substr(ea.indexOf("@")+1,ea.length-1).indexOf(".") < 2) valid = false;

	// make sure the last set set of chars only contain alpha chars
	s = ea.substr(ea.lastIndexOf(".")+1,ea.length-1);
	for(i = 0 ; i < s.length ; i++){
		if(s.charCodeAt(i) < 97 || s.charCodeAt(i) > 122) valid = false;
	}

	// make sure the chars before the @ are valid (charCodes 33-57,65-90,95,97-122)
	s = ea.substr(0,ea.indexOf("@"));
	for(i = 0 ; i < s.length ; i++){
		c = s.charCodeAt(i);
		if(c == 95 || (c >= 33 && c <= 57) || (c >= 65 && c <= 90) || (c >= 97 && c <= 122)) ;
		else {
			valid = false;
			break;
		}
	} 
	if (valid == false){
	msg = "Please fill out a valid email-address!";
		alert (msg);
	}
}

function CheckURL(url,target){
	if (String(url).substring(0,7)=="http://"){
		target.value = String(url).substring(7,String(url).length);
	}
}

/* Developed by U-Lab 2006 - www.u-lab.nl */


