function isEmailAddr(email)
{
  var result = false
  var theStr = new String(email)
  var index = theStr.indexOf("@");
  if (index > 0)
  {
    var pindex = theStr.indexOf(".",index);
    if ((pindex > index+1) && (theStr.length > pindex+1))
	result = true;
  }
  return result;
}

function validate() {

if (document.Form1.username.value == "")
  {
    alert("Please enter your Username.");
    document.Form1.username.focus();
    return (false);
  }
  
if (document.Form1.password.value == "")
  {
    alert("Please enter your Password.");
    document.Form1.password.focus();
    return (false);
  }

if (document.Form1.company.value == "")
  {
    alert("Please enter your Name/Company.");
    document.Form1.company.focus();
    return (false);
  }

if (document.Form1.email.value == "")
  {
    alert("Please enter your Email address.");
    document.Form1.email.focus();
    return (false);
  }

  if (!isEmailAddr(document.Form1.email.value))
  {
    alert("Please enter a valid Email address.");
    document.Form1.email.focus();
    return (false);
  } 
  
  if (document.Form1.telephone_h2.value == "")
  {
    alert("Please enter your Telephone.");
    document.Form1.telephone_h2.focus();
    return (false);
  }
  
  if (document.Form1.telephone_h3.value == "")
  {
    alert("Please enter your Telephone.");
    document.Form1.telephone_h3.focus();
    return (false);
  }
  
  var checkOK = "0123456789";
  var checkStr = document.Form1.telephone_h1.value;
  var allValid = true;
  var decPoints = 0;
  var allNum = "";
  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 (ch == ".")
    {
      allNum += ".";
      decPoints++;
    }
    else if (ch != ",")
      allNum += ch;
  }
if (!allValid)
{
	alert("Please enter only numbers in the Phone field.");
	document.Form1.telephone_h1.focus();
    return false;
}

var checkOK = "0123456789";
  var checkStr = document.Form1.telephone_h2.value;
  var allValid = true;
  var decPoints = 0;
  var allNum = "";
  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 (ch == ".")
    {
      allNum += ".";
      decPoints++;
    }
    else if (ch != ",")
      allNum += ch;
  }
if (!allValid)
{
	alert("Please enter only numbers in  the Phone field.");
	document.Form1.telephone_h2.focus();
    return false;
}

var checkOK = "0123456789";
  var checkStr = document.Form1.telephone_h3.value;
  var allValid = true;
  var decPoints = 0;
  var allNum = "";
  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 (ch == ".")
    {
      allNum += ".";
      decPoints++;
    }
    else if (ch != ",")
      allNum += ch;
  }
if (!allValid)
{
	alert("Please enter only numbers in the Phone field.");
	document.Form1.telephone_h3.focus();
    return false;
}  
   
  if (document.Form1.city.value == "")
  {
    alert("Please enter the name of your City.");
    document.Form1.city.focus();
    return (false);
  }

var checkOK = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ ";
  var checkStr = document.Form1.city.value;
  var allValid = true;
  var decPoints = 0;
  var allNum = "";
  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 (ch == ".")
    {
      allNum += ".";
      decPoints++;
    }
    else if (ch != ",")
      allNum += ch;
  }
  if (!allValid)
  {
    alert("Please enter only alphabets in the City field.");
    document.Form1.city.focus();
    return (false);
  }

  if (document.Form1.city.value.length < 3)
  {
    alert("Please enter atleast 3 characters in the City field.");
    document.Form1.city.focus();
    return (false);
  }  

  var checkOK = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ ";
    var checkStr = document.Form1.state.value;
    var allValid = true;
    var decPoints = 0;
    var allNum = "";
    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 (ch == ".")
      {
        allNum += ".";
        decPoints++;
      }
      else if (ch != ",")
        allNum += ch;
    }
    if (!allValid)
    {
      alert("Please enter only alphabets in the State field.");
      document.Form1.state.focus();
      return (false);
    }
    
    if (document.Form1.postcode.value == "")
  {
    alert("Please enter Zip/Pincode.");
    document.Form1.postcode.focus();
    return (false);
  }

  if (document.Form1.postcode.value.length > 20)
  {
    alert("Please enter at the most 20 characters in the Zip/Pincode field.");
    document.Form1.postcode.focus();
    return (false);
  }   

if (document.Form1.siteurl.value == "")
{
	alert("Please enter your Site Url.")
	document.Form1.siteurl.focus();
	return false;
}   

a = document.Form1.accept.checked;

if (a==false)
{
	alert("Please accept the Terms of Use checkbox.");
	document.Form1.accept.focus() ;
	return false;
}

}