function SetStateCode(state) {

document.Form.State.value = state;

}

function GetStateOptions(country) {



var list = document.Form.State;

list.options.length = 0;

list.options[list.options.length] = new Option('-- No Selection --','0',true,true);

switch (country)

{

case 'USA':

list.options[list.options.length] = new Option('Alabama','AL');

list.options[list.options.length] = new Option('Alaska','AK');

list.options[list.options.length] = new Option('Arizona','AZ');

list.options[list.options.length] = new Option('Arkansas','AR');

list.options[list.options.length] = new Option('California','CA');

list.options[list.options.length] = new Option('Colorado','CO');

list.options[list.options.length] = new Option('Connecticut','CT');

list.options[list.options.length] = new Option('Delaware','DE');

list.options[list.options.length] = new Option('Florida','FL');

list.options[list.options.length] = new Option('Georgia','GA');

list.options[list.options.length] = new Option('Guam','GU');

list.options[list.options.length] = new Option('Hawaii','HI');

list.options[list.options.length] = new Option('Idaho','ID');

list.options[list.options.length] = new Option('Illinois','IL');

list.options[list.options.length] = new Option('Indiana','IN');

list.options[list.options.length] = new Option('Iowa','IA');

list.options[list.options.length] = new Option('Kansas','KS');

list.options[list.options.length] = new Option('Kentucky','KY');

list.options[list.options.length] = new Option('Louisiana','LA');

list.options[list.options.length] = new Option('Maine','ME');

list.options[list.options.length] = new Option('Maryland','MD');

list.options[list.options.length] = new Option('Massachusetts','MA');

list.options[list.options.length] = new Option('Michigan','MI');

list.options[list.options.length] = new Option('Minnesota','MN');

list.options[list.options.length] = new Option('Mississippi','MS');

list.options[list.options.length] = new Option('Missouri','MO');

list.options[list.options.length] = new Option('Montana','MT');

list.options[list.options.length] = new Option('Nebraska','NE');

list.options[list.options.length] = new Option('Nevada','NV');

list.options[list.options.length] = new Option('New Hampshire','NH');

list.options[list.options.length] = new Option('New Jersey','NJ');

list.options[list.options.length] = new Option('New Mexico','NM');

list.options[list.options.length] = new Option('New York','NY');

list.options[list.options.length] = new Option('North Carolina','NC');

list.options[list.options.length] = new Option('North Dakota','ND');

list.options[list.options.length] = new Option('Ohio','OH');

list.options[list.options.length] = new Option('Oklahoma','OK');

list.options[list.options.length] = new Option('Oregon','OR');

list.options[list.options.length] = new Option('Pennsylvania','PA');

list.options[list.options.length] = new Option('Puerto Rico','PR');

list.options[list.options.length] = new Option('Rhode Island','RI');

list.options[list.options.length] = new Option('South Carolina','SC');

list.options[list.options.length] = new Option('South Dakota','SD');

list.options[list.options.length] = new Option('Tennessee','TN');

list.options[list.options.length] = new Option('Texas','TX');

list.options[list.options.length] = new Option('Utah','UT');

list.options[list.options.length] = new Option('Vermont','VT');

list.options[list.options.length] = new Option('Virgin Islands','VI');

list.options[list.options.length] = new Option('Virginia','VA');

list.options[list.options.length] = new Option('Washington','WA');

list.options[list.options.length] = new Option('Washington DC','DC');

list.options[list.options.length] = new Option('West Virginia','WV');

list.options[list.options.length] = new Option('Wisconsin','WI');

list.options[list.options.length] = new Option('Wyoming','WY');

break;



case 'CAN':

list.options[list.options.length] = new Option('Alberta','AB');



list.options[list.options.length] = new Option('British Columbia','BC');

list.options[list.options.length] = new Option('Manitoba','MB');

list.options[list.options.length] = new Option('New Brunswick','NB');

list.options[list.options.length] = new Option('New Foundland','NF');

list.options[list.options.length] = new Option('Northwest Territories','NT');

list.options[list.options.length] = new Option('Nova Scotia','NS');

list.options[list.options.length] = new Option('Nunavut','NU');

list.options[list.options.length] = new Option('Ontario','ON');

list.options[list.options.length] = new Option('Prince Edward Island','PE');

list.options[list.options.length] = new Option('Quebec','QC');

list.options[list.options.length] = new Option('Saskatchewan','SK');

list.options[list.options.length] = new Option('Yukon','YK');

break;

default:

break;

}

}



var check = 0;

function control() {

 //var noms = new Array("Name","Email","Telephone","Country");

if (document.Form.Name.value=="") {alert("Field \"Name\" is required. ");

document.Form.Name.focus(); 

return false;}

/*if (document.Form.Address.value=="") {alert("Field \"Street address\" is required. ");

document.Form.Address.focus(); 

return false;}

if (document.Form.City.value=="") {alert("Field \"City\" is required. ");

document.Form.City.focus();

return false;}

if (document.Form.Telephone.value=="") {alert("Field \"Telephone\" is required. ");

document.Form.Telephone.focus();

return false;}*/

if (document.Form.Country.selectedIndex == 0) {alert("Field \"Country\" is required. ");return false;}

if ((document.Form.Country.value=="Canada" || document.Form.Country.value=="United States")&&document.Form.State.selectedIndex == 0) {alert("Field \"State\" is required. ");return false;}

if (document.Form.Email.value=="") {alert("Field \"Email\" is required. ");

document.Form.Email.focus();

return false;}

//How do you heard about us ?



var radio_choice = false;
if (document.Form.HearAboutUs2.value !="")
{

document.Form.HearAboutUs.value = document.Form.HearAboutUs2.value;
radio_choice = true;
}
else
radio_choice = false;


for (counter = 0; counter < document.Form.HearAboutUs.length; counter++)
{

if (document.Form.HearAboutUs[counter].checked )
radio_choice = true; 
}

if (!radio_choice)
{
 
alert("The section How did you hear about us is required")
return false;
}

//return false;}

return emailCheck();



   //Check URL



//document.Form.State.value = document.Form.Country.text;





return true;



}


//Functon to check other filed in the section "How did you hear about Us ?"


function checkfield() {
for (counter = 0; counter < document.Form.HearAboutUs.length; counter++)
{

document.Form.HearAboutUs[counter].checked = false;

}
}


function chk(emailStr) {

  var emailPat=/^(.+)@(.+)$/

  var specialChars="\\(\\)<>@,;:\\\\\\\"\\.\\[\\]"

  var validChars="\[^\\s" + specialChars + "\]"

  var quotedUser="(\"[^\"]*\")"

  var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/

  var atom=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)

    return false

  

  var user=matchArray[1]

  var domain=matchArray[2]

  

  if (user.match(userPat)==null)

   return false

  

  var IPArray=domain.match(ipDomainPat)

  if (IPArray!=null) {

    for (var i=1;i<=4;i++) {

      if (IPArray[i]>255)

        return false

    }

    return true

  }

  

  var domainArray=domain.match(domainPat)

  if (domainArray==null)

    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>3) {

    return false

  }

  

  if (len<2)

    return false

  

  return true;

}



function emailCheck() {

  var emailStr = document.Form.Email.value;

  if (chk(emailStr))

    return true;

	

  else

    alert('!!! INVALID EMAIL !!!');

	return false;

}







function changevlue()

{

document.Form.Country.options[document.Form.Country.selectedIndex].value = document.Form.Country.options[document.Form.Country.selectedIndex].text;

if (document.Form.Country.value=="Canada" || document.Form.Country.value=="United States"){
document.Form.State.options[document.Form.State.selectedIndex].value = document.Form.State.options[document.Form.State.selectedIndex].text+" ("+document.Form.State.options[document.Form.State.selectedIndex].value+")";
}
else
document.Form.State.options[document.Form.State.selectedIndex].value ="";


}
