// JavaScript Document
function checkIt(evt) {
    evt = (evt) ? evt : window.event
    var charCode = (evt.which) ? evt.which : evt.keyCode
    if (charCode > 31 && (charCode < 48 || charCode > 57)) {
	if (charCode == 43 || charCode == 45)
	return true
        status = "This field accepts numbers only."
        alert("This field accepts numbers only.");
		return false
    }
    status = ""
    return true
}
function echeck(str) {
		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		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
		 }
 		 return true					
	}
function ValidateForm(){
	var emailID=document.contact.email;
	var Name=document.contact.name;
	var Msg=document.contact.message;
	var Phone=document.contact.numeric;
	var vcode=document.contact.vcode;
	if ((Name.value=="Name")||(Name.value==""))
	{
		alert("Please Enter Your Name");
		Name.focus();
		return false;
	}
	if ((emailID.value=="Email")||(emailID.value=="")){
		alert("Please Enter Your Email ID");
		emailID.focus();
		return false;
	}
	if (echeck(emailID.value)==false){
		emailID.value="";
		emailID.focus();
		return false;
	}
	if ((Phone.value=="Phone")||(Name.value==""))
	{
		alert("Please Enter Your Phone Number");
		Phone.focus();
		return false;
	}
	if ((Msg.value=="Message")||(Msg.value==""))
	{
		alert("Please Enter Your Message");
		Msg.focus();
		return false;
	}
		if ((vcode.value=="Enter Code")||(vcode.value==""))
	{
		alert("Please Enter Verification Code");
		vcode.focus();
		return false;
	}
	return true;
 }
function setNameFocus(el)
		{
			el.value = '';
		}
function lostNameFocus(el)
	{
		if (el.value == '')
		{
			el.value = 'Name';
		}
	}
function setEmailFocus(el)
		{
			el.value = '';
		}
function lostEmailFocus(el)
	{
		if (el.value == '')
		{
			el.value = 'Email';
		}
	}
function setPhoneFocus(el)
		{
			el.value = '';
		}
function lostPhoneFocus(el)
	{
		if (el.value == '')
		{
			el.value = 'Telephone';
		}
	}
function setQueryFocus(el)
		{
			el.value = '';
		}
function lostQueryFocus(el)
	{
		if (el.value == '')
		{
			el.value = 'Message';
		}
	}
function setVerificationFocus(el)
		{
			el.value = '';
		}
function lostVerificationFocus(el)
	{
		if (el.value == '')
		{
			el.value = 'Enter Code';
		}
	}
	
//contact form

function ContactForm(){
	var emailID=document.contact.email;
	var fname=document.contact.fname;
	var lname=document.contact.lname;
	var Msg=document.contact.message;
	var Phone=document.contact.numeric;
	var vcode=document.contact.vcode;
	
	if (fname.value=="")
	{
		alert("Please Enter First Name");
		fname.focus();
		return false;
	}
	if (lname.value=="")
	{
		alert("Please Enter Last Name");
		lname.focus();
		return false;
	}
	if (emailID.value=="")
	{
		alert("Please Enter Your Email ID");
		emailID.focus();
		return false;
	}
	if (echeck(emailID.value)==false){
		emailID.value="";
		emailID.focus();
		return false;
	}
	if (Name.value=="")
	{
		alert("Please Enter Your Phone Number");
		Phone.focus();
		return false;
	}
	if (Msg.value=="")
	{
		alert("Please Enter Your Message");
		Msg.focus();
		return false;
	}
	if (vcode.value=="")
	{
		alert("Please Enter Verification Code");
		vcode.focus();
		return false;
	}
	return true;

 }
