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() {

var radioSelected = false;
  for (i = 0;  i < document.Form1.level.length;  i++)
  {
    if (document.Form1.level[i].checked)
        radioSelected = true;
  }
  if (!radioSelected)
  {
    alert("Please select the Membership option.");
    document.Form1.level[0].focus();
    return (false);
  }

if (document.Form1.firstname.value == "")
{
	alert("Please enter your First Name.")
	document.Form1.firstname.focus();
	return false;
}

var checkOK = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ ";
  var checkStr = document.Form1.firstname.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 First Name field.");
    document.Form1.firstname.focus();
    return (false);
  }

if (document.Form1.lastname.value == "")
{
	alert("Please enter your Last Name.")
	document.Form1.lastname.focus();
	return false;
}

var checkOK = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ ";
  var checkStr = document.Form1.lastname.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 Last Name field.");
    document.Form1.lastname.focus();
    return (false);
  }
  
  if (document.Form1.address.value == "")
  {
    alert("Please enter your Address.");
    document.Form1.address.focus();
    return (false);
  }  
  
  if (document.Form1.address.value.length > 150)
  {
    alert("Please enter at the most 150 characters in the Address 1 field.");
    document.Form1.address.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.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.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.hear.value == "")
{
	alert("Please enter from where did you hear about us.");
	document.Form1.hear.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.username.value == "")
  {
    alert("Please enter the Username.");
    document.Form1.username.focus();
    return (false);
  }
  
if (document.Form1.username.value.length < 6)
  {
    alert("Please enter atleast 6 characters in Username field.");
    document.Form1.username.focus();
    return (false);
  }  
  
if (document.Form1.password.value == "")
  {
    alert("Please enter the Password.");
    document.Form1.password.focus();
    return (false);
  }
  
if (document.Form1.password.value.length < 6)
  {
    alert("Please enter atleast 6 characters in Password field.");
    document.Form1.password.focus();
    return (false);
  }  

if (document.Form1.password.value != document.Form1.confirm_pass.value)
  {
    alert("Confirm Password and Password field does not match.");
    document.Form1.confirm_pass.focus();
    return (false);
  }       

  var radioSelected = false;
  for (i = 0;  i < document.Form1.gender.length;  i++)
  {
    if (document.Form1.gender[i].checked)
        radioSelected = true;
  }
  if (!radioSelected)
  {
    alert("Please select one of the Gender options.");
    document.Form1.gender[0].focus();
    return (false);
  }
  
  if(document.Form1.day.value == "")
{
	alert("Please select the day of your Birthday.");
	document.Form1.day.focus();
  	return false;
}

  if(document.Form1.month.value == "")
{
	alert("Please select the Month of your Birthday.");
	document.Form1.month.focus();
  	return false;
}

  if(document.Form1.year.value == "")
{
	alert("Please select the Year of your Birthday.");
	document.Form1.year.focus();
  	return false;
}

  var radioSelected = false;
  for (i = 0;  i < document.Form1.maritalstatus.length;  i++)
  {
    if (document.Form1.maritalstatus[i].checked)
        radioSelected = true;
  }
  if (!radioSelected)
  {
    alert("Please tell about your Marital Status.");
    document.Form1.maritalstatus[0].focus();
    return (false);
  }
  
  var radioSelected = false;
  for (i = 0;  i < document.Form1.engage.length;  i++)
  {
    if (document.Form1.engage[i].checked)
        radioSelected = true;
  }
  if (!radioSelected)
  {
    alert("Please tell about your Engagement.");
    document.Form1.engage[0].focus();
    return (false);
  }  

if(document.Form1.hobbies.value == "")
{
	alert("Please enter your Hobbies.");
	document.Form1.hobbies.focus();
  	return false;
}

if(document.Form1.hobbies.value.length > 150)
{
	alert("Please enter at the most 150 characters in Hobbies.");
	document.Form1.hobbies.focus();
  	return false;
}
  
  var radioSelected = false;
  for (i = 0;  i < document.Form1.Children.length;  i++)
  {
    if (document.Form1.Children[i].checked)
        radioSelected = true;
  }
  if (!radioSelected)
  {
    alert("Please tell about your Children.");
    document.Form1.Children[0].focus();
    return (false);
  }
  
  if (document.Form1.Children[0].checked == true)
  {  
  var radioSelected = false;
  for (i = 0;  i < document.Form1.WithChild.length;  i++)
  {
    if (document.Form1.WithChild[i].checked)
        radioSelected = true;
  }
  if (!radioSelected)
  {
    alert("Please tell whether your Children live with you.");
    document.Form1.WithChild[0].focus();
    return (false);
  }  
  }
  
  if(document.Form1.Height.value == "")
{
	alert("Please enter your Height.");
	document.Form1.Height.focus();
  	return false;
}

var checkOK = "0123456789.";
  var checkStr = document.Form1.Height.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 Height field.");
	document.Form1.Height.focus();
    return false;
}

if(document.Form1.Weight.value == "")
{
	alert("Please enter your Weight.");
	document.Form1.Weight.focus();
  	return false;
}

if(document.Form1.Build.value == "")
{
	alert("Please select your Build and Complexion.");
	document.Form1.Build.focus();
  	return false;
}

 var radioSelected = false;
  for (i = 0;  i < document.Form1.physical.length;  i++)
  {
    if (document.Form1.physical[i].checked)
        radioSelected = true;
  }
  if (!radioSelected)
  {
    alert("Please tell about your Physical Appearance.");
    document.Form1.physical[0].focus();
    return (false);
  }
  
  var radioSelected = false;
  for (i = 0;  i < document.Form1.health.length;  i++)
  {
    if (document.Form1.health[i].checked)
        radioSelected = true;
  }
  if (!radioSelected)
  {
    alert("Please tell about your State of Health.");
    document.Form1.health[0].focus();
    return (false);
  }
  
  if (document.Form1.Complexion.value == "")
{
	alert("Please select your Complexion.")
	document.Form1.Complexion.focus();
	return false;
}
  
  if((document.Form1.Disability.value == "Yes") && (document.Form1.YesDisabled.value == ""))
  {
	alert("Please specify your Disability.");
	document.Form1.YesDisabled.focus();
  	return false;
  }
  
  if(document.Form1.Education.value == "")
{
	alert("Please select your Education.");
	document.Form1.Education.focus();
  	return false;
}
  
  if(document.Form1.Occupation.value == "")
{
	alert("Please select your Occupation.");
	document.Form1.Occupation.focus();
  	return false;
}

  if(document.Form1.profession.value == "")
{
	alert("Please enter your Profession.");
	document.Form1.profession.focus();
  	return false;
}
  
   var radioSelected = false;
  for (i = 0;  i < document.Form1.live_family.length;  i++)
  {
    if (document.Form1.live_family[i].checked)
        radioSelected = true;
  }
  if (!radioSelected)
  {
    alert("Please tell about your Family.");
    document.Form1.live_family[0].focus();
    return (false);
  }
  
   var radioSelected = false;
  for (i = 0;  i < document.Form1.home_o.length;  i++)
  {
    if (document.Form1.home_o[i].checked)
        radioSelected = true;
  }
  if (!radioSelected)
  {
    alert("Please tell about Home Ownership.");
    document.Form1.home_o[0].focus();
    return (false);
  }
  
  if(document.Form1.income.value == "")
{
	alert("Please select your Annual Income.");
	document.Form1.income.focus();
  	return false;
}
  
  var radioSelected = false;
  for (i = 0;  i < document.Form1.abroad.length;  i++)
  {
    if (document.Form1.abroad[i].checked)
        radioSelected = true;
  }
  if (!radioSelected)
  {
    alert("Please tell whether you would like to settle Abroad.");
    document.Form1.abroad[0].focus();
    return (false);
  }
  
  if ((document.Form1.abroad[0].checked == true) && (document.Form1.Abroad_Y.value == ""))
  {
	alert("Please specify where would you like to settle.")
	document.Form1.Abroad_Y.focus();
	return (false);
  }
  
  var radioSelected = false;
  for (i = 0;  i < document.Form1.looking_for.length;  i++)
  {
    if (document.Form1.looking_for[i].checked)
        radioSelected = true;
  }
  if (!radioSelected)
  {
    alert("Please tell what are you looking for.");
    document.Form1.looking_for[0].focus();
    return (false);
  }
  
  var radioSelected = false;
  for (i = 0;  i < document.Form1.visitor.length;  i++)
  {
    if (document.Form1.visitor[i].checked)
        radioSelected = true;
  }
  if (!radioSelected)
  {
    alert("Please tell whether you would consider a visitor.");
    document.Form1.visitor[0].focus();
    return (false);
  }
  
  if ((document.Form1.visitor[0].checked == true) && (document.Form1.visitor_Y.value == ""))
  {
	alert("Please specify which visitor would you consider.")
	document.Form1.visitor_Y.focus();
	return (false);
  }
  
  var radioSelected = false;
  for (i = 0;  i < document.Form1.Alcohol.length;  i++)
  {
    if (document.Form1.Alcohol[i].checked)
        radioSelected = true;
  }
  if (!radioSelected)
  {
    alert("Please tell whether you Drink alcohol.");
    document.Form1.Alcohol[0].focus();
    return (false);
  }
  
  var radioSelected = false;
  for (i = 0;  i < document.Form1.Smoker.length;  i++)
  {
    if (document.Form1.Smoker[i].checked)
        radioSelected = true;
  }
  if (!radioSelected)
  {
    alert("Please tell whether you Smoke.");
    document.Form1.Smoker[0].focus();
    return (false);
  }
  
  var radioSelected = false;
  for (i = 0;  i < document.Form1.FoodType.length;  i++)
  {
    if (document.Form1.FoodType[i].checked)
        radioSelected = true;
  }
  if (!radioSelected)
  {
    alert("Please tell what type of Food do you have.");
    document.Form1.FoodType[0].focus();
    return (false);
  }
  
  if((document.Form1.Religion.value == "") && (document.Form1.OtherReligion.value == ""))
{
	alert("Please enter your Religion.");
	document.Form1.Religion.focus();
  	return false;
}

if((document.Form1.Religion.value != "Other") && (document.Form1.OtherReligion.value != ""))
{
	alert("Please enter only one Religion.");
	document.Form1.Religion.focus();
  	return false;
}

if((document.Form1.Culture.value == "") && (document.Form1.OtherCulture.value == ""))
{
	alert("Please enter your Culture.");
	document.Form1.Culture.focus();
  	return false;
}

if((document.Form1.Culture.value != "Other") && (document.Form1.OtherCulture.value != ""))
{
	alert("Please enter only one Culture.");
	document.Form1.Culture.focus();
  	return false;
}

if((document.Form1.Caste.value == "") && (document.Form1.OtherCaste.value == ""))
{
	alert("Please enter your Caste.");
	document.Form1.Caste.focus();
  	return false;
}

if((document.Form1.Caste.value != "Other") && (document.Form1.OtherCaste.value != ""))
{
	alert("Please enter only one Caste.");
	document.Form1.Caste.focus();
  	return false;
}
}