
function checkContactform(){
	var root=document.contactForm;

	var name=root.name;
	var company=root.company;
	var street=root.street;
	var city=root.city;
	var state=root.state;
	var country=root.country;
	var phone=root.phone;
	var mobile=root.mobile;
	var email=root.email;
	var department=root.department;
	var subject=root.subject;
	var message=root.message;

	if(name.value==""){
		blinkBlink('name');
		alert('Please enter your full name.');
		name.focus();
		return false;
	}
	if(country.value==""){
		blinkBlink('country');
		alert('Please select a country from the list.');
		country.focus();
		return false;
	}
	if(phone.value==""){
		blinkBlink('phone');
		alert('Please enter your home phone number.');
		phone.focus();
		return false;
	}
	if(isNaN(phone.value)){
		blinkBlink('phone');
		alert('The phone number should only contain digits.');
		phone.select();
		return false;
	}
	if(isNaN(mobile.value) && mobile.value!=""){
		blinkBlink('mobile');
		alert('The mobile phone number should only contain digits');
		mobile.select();
		return false;
	}
	if(email.value==""){
		blinkBlink('email');
		alert('Please enter an email address.');
		email.focus();
		return false;
	}
	if(department.value==""){
		blinkBlink('department');
		alert('Please select the department you wish to contact.');
		department.focus();
		return false;
	}
	if(subject.value==""){
		blinkBlink('subject');
		alert('Please enter the subject.');
		subject.focus();
		return false;
	}
	if(message.value==""){
		blinkBlink('message');
		alert('Please enter your message.');
		message.focus();
		return false;
	}
}

function clearContactForm(){
	var root=document.contactForm;

	var name=root.name;
	var company=root.company;
	var street=root.street;
	var city=root.city;
	var state=root.state;
	var country=root.country;
	var phone=root.phone;
	var mobile=root.mobile;
	var email=root.email;
	var department=root.department;
	var subject=root.subject;
	var message=root.message;

	if(confirm('Are you sure you want to clear this form?')){
		name.value="";
		company.value="";
		street.value="";
		city.value="";
		state.value="";
		country.value="";
		phone.value="";
		mobile.value="";
		email.value="";
		department.value="";
		subject.value="";
		message.value="";

		return false;
	}

	return false;
}


function blinkExecute(target,color){
	document.getElementById(target).style.backgroundColor = color;
}

function blinkBlink (target){
	color1 = "#92C2ED"; // blinking color
	color2 = "#ffffff"; // background color

	setTimeout('blinkExecute("'+target+'","'+color1+'")',0);
	setTimeout('blinkExecute("'+target+'","'+color2+'")',500);
	setTimeout('blinkExecute("'+target+'","'+color1+'")',1000);
	setTimeout('blinkExecute("'+target+'","'+color2+'")',1500);
	setTimeout('blinkExecute("'+target+'","'+color1+'")',2000);
	setTimeout('blinkExecute("'+target+'","'+color2+'")',2500);
	setTimeout('blinkExecute("'+target+'","'+color1+'")',3000);
	setTimeout('blinkExecute("'+target+'","'+color2+'")',3500);
	document.getElementById(target).focus();
}

function openTarget (form, features, windowName) {
	if (!windowName)
	windowName = 'formTarget' + (new Date().getTime());
	form.target = windowName;
	open ('', windowName, features);
}

function validateApplicationForm(){
	var root=document.application;

	var fname=root.fname;
	var lname=root.lname;
	var gender=root.gender;
	var cbirth=root.cbirth;
	var country=root.country;
	var address=root.address;
	var paddress=root.paddress;
	var email=root.email;
	var phone=root.phone;
	var fax=root.fax;
	var mobile=root.mobile;
	var status=root.status;
	var degree=root.degree;
	var occupation=root.occupation;
	var motivation=root.motivation;


	if(fname.value==''){
		alert('Please enter your first name.')
		fname.focus();
		return false;
	}
	if(lname.value==''){
		alert('Please enter your last name.')
		lname.focus();
		return false;
	}
	if(gender.value==''){
		alert('Please select a gender.')
		gender.focus();
		return false;
	}
	if(cbirth.value==''){
		alert('Please select your country of birth.')
		cbirth.focus();
		return false;
	}
	if(country.value==''){
		alert('Please select your country of residence.')
		country.focus();
		return false;
	}
	if(address.value==''){
		alert('Please enter your address.')
		address.focus();
		return false;
	}
	if(paddress.value==''){
		alert('Please enter your postal address.')
		paddress.focus();
		return false;
	}
	if(email.value==''){
		alert('Please enter your email address.')
		email.focus();
		return false;
	}
	var pattern = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/;
	var email = root.email.value;
	flag=email.match(pattern);
	if(!flag){
		alert('Please insert a valid email address.');
		root.email.select();
		return false;
	}
	if(phone.value==''){
		alert('Please enter your phone number.')
		phone.focus();
		return false;
	}
	if(fax.value==''){
		alert('Please enter your fax number.')
		fax.focus();
		return false;
	}
	if(mobile.value==''){
		alert('Please enter your mobile number.')
		mobile.focus();
		return false;
	}
	if(status.value==''){
		alert('Please select your marital status.')
		status.focus();
		return false;
	}
	if(degree.value==''){
		alert('Please select your educational level.')
		degree.focus();
		return false;
	}
	if(occupation.value==''){
		alert('Please enter your occupation.')
		occupation.focus();
		return false;
	}
	if(motivation.value==''){
		alert('Please write a motivation letter (100 words).')
		motivation.focus();
		return false;
	}
}