   var temp;
   temp = false;
   
	function B1_onclick() 
	{
		temp = getinfo_Validator(this)
		if(temp==true)
		{
				x=document.getinfo.submit();
		}
		else
		return(temp);
    }
	
	function B2_onclick() 
	{
	document.getinfo.name.focus(); 
	}


function getinfo_Validator(getinfo)
{
  if (document.getinfo.name.value == "")
  {
    alert("Please enter a Your Name");
    document.getinfo.name.focus();
    return (false);
  }
  if (document.getinfo.name.value.length > 50)
  {
    alert("Please enter at most 50 characters in the \"NAME\" field.");
   document. getinfo.name.focus();
    return (false);
  }
  var checkOK = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz \t\r\n\f";
  var checkStr = document.getinfo.name.value;
  var allValid = true;
  for (i = 0;  i < checkStr.length;  i++)
  {
    ch = checkStr.charAt(i);
    for (j = 0;  j < checkOK.length;  j++)
      if (ch == checkOK.charAt(j))
        break;
    if (j == checkOK.length)
    {
      allValid = false;
      break;
    }
  }
  if (!allValid)
  {
    alert("Please enter only letter and whitespace characters in the \"NAME\" field.");
    document.getinfo.name.focus();
    return (false);
  }

  if (document.getinfo.designation.value.length > 50)
  {
    alert("Please enter at most 50 characters in the \"DESIGNATION\" field.");
    document.getinfo.designation.focus();
    return (false);
  }
  var checkOK = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz., \t\r\n\f";
  var checkStr = document.getinfo.designation.value;
  var allValid = true;
  for (i = 0;  i < checkStr.length;  i++)
  {
    ch = checkStr.charAt(i);
    for (j = 0;  j < checkOK.length;  j++)
      if (ch == checkOK.charAt(j))
        break;
    if (j == checkOK.length)
    {
      allValid = false;
      break;
    }
  }
  if (!allValid)
  {
    alert("Please enter only letter and whitespace characters in the \"DESIGNATION\" field.");
    document.getinfo.designation.focus();
    return (false);
  }

  if (document.getinfo.company.value.length > 50)
  {
    alert("Please enter at most 50 characters in the \"COMPANY\" field.");
   document. getinfo.company.focus();
    return (false);
  }
  var checkOK = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz \t\r\n\f";
  var checkStr = document.getinfo.company.value;
  var allValid = true;
  for (i = 0;  i < checkStr.length;  i++)
  {
    ch = checkStr.charAt(i);
    for (j = 0;  j < checkOK.length;  j++)
      if (ch == checkOK.charAt(j))
        break;
    if (j == checkOK.length)
    {
      allValid = false;
      break;
    }
  }
  if (!allValid)
  {
    alert("Please enter only letter and whitespace characters in the \"COMPANY\" field.");
    document.getinfo.company.focus();
    return (false);
  }
  
    if (document.getinfo.business.value.length > 50)
  {
    alert("Please enter at most 50 characters in the \"Nature of Business\" field.");
    document.getinfo.city.focus();
    return (false);
  }
     //EMAIL ADDRESS VALIDATION
  
	var VarEmail = document.getinfo.email.value
	
	if (document.getinfo.email.value == "")
  {
    alert("Please enter Your Email ID");
    document.getinfo.email.focus();
    return (false);
  }
  if (document.getinfo.email.value.length > 50)
  {
    alert("Please enter at most 50 characters Email Address.");
    document.getinfo.email.focus();
    return (false);
  }     
  
	if (VarEmail.value!="")
    {
      var emailStr;
	  emailStr=VarEmail
	 
	var emailPat=/^(.+)@(.+)$/
	var specialChars="\\(\\)<>@,;:\\\\\\\"\\.\\[\\]"
	var validChars="\[^\\s" + specialChars + "\]"
	var firstChars=validChars
	var quotedUser="(\"[^\"]*\")"
	var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/
	var atom="(" + firstChars + validChars + "*" + ")"
	var word="(" + atom + "|" + quotedUser + ")"
	var userPat=new RegExp("^" + word + "(\\." + word + ")*$")
	var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$")
	var matchArray=emailStr.match(emailPat)
	if (matchArray==null) 
   {
   	 alert("Email address seems to be incorrect (check @ and .'s)")
	 document.getinfo.email.focus();
	 return false;
    }
	var user=matchArray[1]
	var domain=matchArray[2]
	if (user.match(userPat)==null) 
	   {
    alert("The username doesn't seem to be valid.")
	document.getinfo.email.focus();
    return false;    
   }
	var IPArray=domain.match(ipDomainPat)
	if (IPArray!=null) 
    {
    for (var i=1;i<=4;i++) 
       {
	 if (IPArray[i]>255) 
              {
 	         alert("Destination IP address is invalid!")
			 document.getinfo.email.focus();
	         return false;
	       }
        }   
}

var domainArray=domain.match(domainPat)
if (domainArray==null) {
	alert("The domain name doesn't seem to be valid.")
	document.getinfo.email.focus();
	    return false;
}

var atomPat=new RegExp(atom,"g")
var domArr=domain.match(atomPat)
var len=domArr.length
if (domArr[domArr.length-1].length<2 || 
    domArr[domArr.length-1].length>4) {
  
   alert("The address must end in a three-letter domain, or two-letter country, or four-letter domain")
   document.getinfo.email.focus();
   return false;
}

if (domArr[domArr.length-1].length==2 && len<3) {
   var errStr="This address ends in two characters, which is a country"
   errStr+=" code.  Country codes must be preceded by "
   errStr+="a hostname and category (like com, co, pub, pu, etc.)"
   alert(errStr)
   document.getinfo.email.focus();
   return false;
}

  if (domArr[domArr.length-1].length==3 && len<2) 
  {
     var errStr="This address is missing a hostname!"
	 document.getinfo.email.focus();
     alert(errStr)
     return false;
  }
}
   if (document.getinfo.phone.value == "")
  {
    alert("Please enter valid Phone Number.");
    document.getinfo.phone.focus();
    return (false);
  }  
   if (document.getinfo.phone.value.length > 20)
  {
    alert("Please enter valid digits in the \"Phone Number\" field.");
    document.getinfo.phone.focus();
    return (false);
  }  
  var checkOK = "0123456789-()- \t\r\n\f";
  var checkStr = document.getinfo.phone.value;
  var allValid = true;
  for (i = 0;  i < checkStr.length;  i++)
  {
    ch = checkStr.charAt(i);
    for (j = 0;  j < checkOK.length;  j++)
      if (ch == checkOK.charAt(j))
        break;
    if (j == checkOK.length)
    {
      allValid = false;
      break;
    }
  }
  if (!allValid)
  {
    alert("Please enter only digit, whitespace and \"()-\" characters in the \"Phone\" field.");
    document.getinfo.phone.focus();
    return (false);
  }    
  
  if (document.getinfo.fax.value.length > 20)
  {
    alert("Please enter valid digits in the \"Fax Number\" field.");
    document.getinfo.fax.focus();
    return (false);
  }  
  var checkOK = "0123456789-()- \t\r\n\f";
  var checkStr = document.getinfo.fax.value;
  var allValid = true;
  for (i = 0;  i < checkStr.length;  i++)
  {
    ch = checkStr.charAt(i);
    for (j = 0;  j < checkOK.length;  j++)
      if (ch == checkOK.charAt(j))
        break;
    if (j == checkOK.length)
    {
      allValid = false;
      break;
    }
  }
  if (!allValid)
  {
    alert("Please enter only digit, whitespace and \"()-\" characters in the \"fax\" field.");
    document.getinfo.fax.focus();
    return (false);
  }    
   return (true);
}
