// JavaScript Document
function is_blank(str)
{
	var regex;

	// For our purposes, a null string is blank
	if(str == "")
		return true;
	regex = /[^ +]/;
	if(str.match(regex))
		return false;
	else
		return true;
}

function isValid_email(str)
{	
	apos = str.indexOf("@")
	dotpos = str.lastIndexOf(".")
	
	if (apos < 1 || dotpos-apos < 2)	 
		return true;
	else
		return false;
}

function isValid_phone(str)
{	
	var myRegExp = /^(\d{10})?$/;
	if(str.match(myRegExp))
		return false;
	else
		return true;
}

function validation_this(the_form)
{	
	 if(the_form["name"] && is_blank(the_form["name"].value))
	 {
		alert('Please enter Name');
	 	the_form.name.focus();
		the_form.name.select();
		return false;
	 }
	 if(the_form["telephone"] && isValid_phone(the_form["telephone"].value))
	 {
		alert('Please enter correct Phone Number e.g. 4161234567');
	 	the_form.telephone.focus();
		the_form.telephone.select();
		return false;
	 }
	 if(the_form["email"] && isValid_email(the_form["email"].value))
	 {
		alert('Please enter valid Email');
	 	the_form.email.focus();
		the_form.email.select();
		return false;
	 }
	return true;
}