function validate()
{
	if(document.forms[0].email.value=="")
	{
	  alert("Enter your email");
	  document.forms[0].email.focus();
	  return false;
	}
	else
	{
     if(echeck(document.forms[0].email.value)==false)
      {
       document.forms[0].email.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.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 mailfocus()
{
	document.forms[0].email.value="";
}

function validate1()
{

	 if(document.getElementById("cardno").value=="")
	  {
	    alert("Enter Card No");
	    document.getElementById("cardno").focus();
	    return false;
	  }

	 if(document.getElementById("expdate").value=="")
	  {
	    alert("Enter expiry date");
	    document.getElementById("expdate").focus();
	    return false;
	  }
	  
	 if(document.getElementById("cardname").value=="")
	  {
	    alert("Enter Card Name");
	    document.getElementById("cardname").focus();
	    return false;
	  }

	 if(document.getElementById("signature").value=="")
	  {
	    alert("Enter Signature");
	    document.getElementById("signature").focus();
	    return false;
	  }	

	 if(document.getElementById("cname").value=="")
	  {
	    alert("Enter Name");
	    document.getElementById("cname").focus();
	    return false;
	  }

	 if(document.getElementById("company").value=="")
	  {
	    alert("Enter Company Name");
	    document.getElementById("company").focus();
	    return false;
	  }

	 if(document.getElementById("city").value=="")
	  {
	    alert("Enter your City");
	    document.getElementById("city").focus();
	    return false;
	  }
	  
	 if(document.getElementById("zip").value=="")
	  {
	    alert("Enter Zip Code");
	    document.getElementById("zip").focus();
	    return false;
	  }
	  
	 if(document.getElementById("email1").value=="")
	  {
	    alert("Enter Email");
	    document.getElementById("email1").focus();
	    return false;
	  }	
	 else
	  {
	     var re = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/
	     if (!document.getElementById("email1").value.match(re))
	        {
	          alert("Invalid email1 address");
	          document.getElementById("email1").select();
	          return (false);
	        }
	  }

	 if(document.getElementById("phone").value=="")
	  {
	    alert("Enter your phone");
	    document.getElementById("phone").focus();
	    return false;
	  }
	  /*else
	  {
	    phoneRe = /^(\+\d{1,3} ?)?(\(\d{1,5}\)|\d{1,5}) ?\d{3} ?\d{0,7}$/
	    if (!document.getElementById("phone").value.match(phoneRe))
	    	{
	    	   alert("Invalid Phone number \n use any of following format \n +1 (123) 123 4567 or 02312 345 5467 56 or +44 (123) 123 4567 \n or +44 (123) 123 4567 ext 123 or +44 (20) 789 4567");
	    	   document.getElementById("phone").select();
	    	   return (false);
	        }
	  }*/
	  
}

