// JavaScript for Contact Us Starts here
function formValidation()
{
	var name = document.getElementById('name');
	if(isAlphabet(name, "Name should not be left blank!"))
{	
	var phone = document.getElementById('phone');
	if(isNumeric(phone, "Phone Number should not be left blank!"))
{
	if(echeck(frm.email.value)==false)	
	{
	  frm.email.select();
	  frm.email.focus();
	  return false;
	}
{
	if(document.frm.contact_method.selectedIndex==0) 
	{
		alert("Please select your Preferred Contact Method");
		frm.contact_method.focus();
		return false;
	}
{
	if(document.frm.order_number.value == "")
	{
		alert("Order Number should not be left blank!");
		frm.order_number.focus();
		return false;
	}
{
	if(document.frm.site_purchase.value == "")
	{
		alert("Website Purchased from should not be left blank!");
		frm.site_purchase.focus();
		return false;
	}
{
	if(document.frm.address.value == "")
	{
		alert("Address should not be left blank!");
		frm.address.focus();
		return false;
	}
{
	if(document.frm.contact.value == "")
	{
		alert("Contact should not be left blank!");
		frm.contact.focus();
		return false;
	}
{
return true;
}
}
}
}
}
}
}
}
return false;
}

function isAlphabet(elem, helperMsg){
	var alphaExp = /^[a-zA-Z\ \'\"]+$/;
	if(elem.value.match(alphaExp)){
		return true;
	}else{
		alert(helperMsg);
		elem.focus();
		elem.select();
		return false;
	}
}

function isNumeric(elem, helperMsg){
	var numericExpression = /^[0-9\-,\#\ ]+$/;
	if(elem.value.match(numericExpression)){
		return true;
	}else{
		alert(helperMsg);
		elem.focus();
		elem.select();
		return false;
	}
}
	
function echeck(str) 
{
		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str=='')
			{
			alert("Email Id should not left blank!")
			return false;
			}
		if (str.indexOf(at)==-1)
		{
		   alert("Invalid E-mail ID")
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   alert("Invalid E-mail ID")
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    alert("Invalid E-mail ID")
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    alert("Invalid E-mail ID")
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    alert("Invalid E-mail ID")
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    alert("Invalid E-mail ID")
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		    alert("Invalid E-mail ID")
		    return false
		 }
}
// JaveScript for Contact Us Ends here