//***********************************************************************
// Author: Veronique Molinari
//***********************************************************************


//**********************************************************
// populate State (if country = USA or Canada)
//**********************************************************


var provinceArray =  new Array("Select Province",
"Alberta",
"British Columbia",
"Manitoba",
"New Brunswick",
"Newfoundland",
"Northwest Territories",
"Nova Scotia",
"Ontario",
"Prince Edward Island",
"Quebec",
"Saskatchewan",
"Yukon");

var stateArray =  new Array("Select State",
"Alabama",
"Alaska",
"Arizona",
"Arkansas",
"California",
"Colorado",
"Connecticut",
"Delaware",
"Columbia",
"Florida",
"Georgia",
"Hawaii",
"Idaho",
"Illinois",
"Indiana",
"Iowa",
"Kansas",
"Kentucky",
"Louisiana",
"Maine",
"Maryland",
"Massachusetts",
"Michigan",
"Minnesota",
"Mississippi",
"Missouri",
"Montana",
"Nebraska",
"Nevada",
"New Hampshire",
"New Jersey",
"New Mexico",
"New York",
"North Carolina",
"North Dakota",
"Ohio",
"Oklahoma",
"Oregon",
"Pennsylvania",
"Rhode Island",
"South Carolina",
"South Dakota",
"Tennessee",
"Texas",
"Utah",
"Vermont",
"Virginia",
"Washington",
"West Virginia",
"Wisconsin",
"Wyoming");

function populatestate(inForm,selected,optionSelection) {  
if (selected == 'United States') {
	inForm.state.disabled= false;
	for (var i=0; i < stateArray.length; i++) {  
 		eval("inForm.state.options[i]=" + "new Option('" + stateArray[i] + "')"); 
		//alert(optionSelection + ":" + stateArray[i] + ":" + inForm.state.options[i].text);
		if(optionSelection !== undefined && optionSelection == stateArray[i]){
			//alert(optionSelection + ":" + stateArray[i] + ":" + inForm.state.options[i].text);
			inForm.state.options[i].selected = "1";
		}
  }  
}

else if (selected == 'Canada') {
	inForm.state.disabled= false;

	for (var i=0; i < provinceArray.length; i++) {
		eval("inForm.state.options[i]=" + "new Option('" + provinceArray[i] + "')");
		if(optionSelection !== undefined && optionSelection == provinceArray[i]){
			
			inForm.state.options[i].selected = "1";
		}
	}
	
		for (var i=provinceArray.length; i < stateArray.length; i++) {
		eval("inForm.state.options[i]=" + "new Option" + "");
	}
}

else {
		inForm.state.value= "";
		inForm.state.disabled= true;	
}		

if (selected == 'Other') {  
	newCountry = "";  while (newCountry == ""){ 
 		newCountry=prompt ("Please enter the name of your country.", ""); 
 	 }  
	if (newCountry != null) { 
 	inForm.country.options[(inForm.country.options.length-1)]=new Option(newCountry,newCountry,true,true);  
	inForm.country.options[inForm.country.options.length]=new Option('Other, not listed','Other');
	} 
}  

	if(inForm.country.options[0].text == 'Select country') {  
		inForm.country.options[0]= null;     
	} 
	
}    
