// JavaScript Document
String.prototype.trim = function() {
	return this.replace(/^\s+|\s+$/g,"");
}
String.prototype.ltrim = function() {
	return this.replace(/^\s+/,"");
}
String.prototype.rtrim = function() {
	return this.replace(/\s+$/,"");
}
function checkContactForm()
{
	var required = {	
	"name": "Name cannot be left blank",
	"email": "Email id cannot be left blank",
	"phone": "Phone cannot be left blank",
	"message": "Message cannot be left blank"
	};
	for (var i in required) 
	{
		var el = document.getElementById(i);
		if (!el.value.trim()) 
		{
			alert(required[i]);
			el.value=el.value.trim();
			el.focus();	
			return false;
		}
	}


	var emailRegEx = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	var email = document.getElementById("email");
	str = email.value.trim();;
	if(str!='')
	{
		if(str.match(emailRegEx)){	
		}
		else{
			alert('Invalid email address.');
			email.focus();
			return false;
		}
	}
}
