function onloadWindow(){
	var message_div = document.getElementById('message_div');
	message_div.innerHTML = "The fields marked with (*) are obligatory.";
}
function checkContactUsForm(){
	var root = document.contactus;
	var first_name = root.first_name;
	var last_name = root.last_name;
	var email = root.email;
	var email_value = email.value;
	var comments = root.comments;
	
	if (first_name.value == ''){
		alert('Please insert your first name');
		first_name.focus();
		return false;
	}
	if (last_name.value == ''){
		alert('Please insert your last name');
		last_name.focus();
		return false;
	}
	if (email_value == ''){
		alert('Please insert your email address');
		email.focus();
		return false;
	}
	var pattern = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/;
	flag=email_value.match(pattern);
	if(!flag){
		alert('Please insert a valid email address');
		email.select();
		return false;
	}
	if(comments.value == ''){
		alert('Please insert your comments');
		comments.focus();
		return false;
	}
	var position = root.position;
	var address = root.address;
	var phone = root.phone;
	$.ajax({
	type: "POST",
	url: "/send_contactus.php",
 	dataType: "html",
 	data: "first_name="+first_name.value+"&last_name="+last_name.value+"&email="+email_value+"&comments="+comments.value+"&position="+position.value+"&address="+address.value+"&phone="+phone.value,
		success: function(msg){
			if(msg == '1'){
				alert("Your mail has been sent successfully\nThank you for contacting us");
				window.location='/contactus.php';
			}
			else if(msg == '2'){
				alert("An Error occured while sending your mail. Please try again later");
				window.location='/contactus.php';
			}
			else{
				alert(msg);
			}
			return false;
		}
	});
}