// Country/State Changer

function RefreshStates(country, statelookup, selectedState) {
statelookup.selectedIndex=0
if (country.options[country.selectedIndex].value=='US') //-- United States
   {
   statelookup.length           = 61
    statelookup.options[ 0].value="";	statelookup.options[ 0].text="Select a State"	
	statelookup.options[ 1].value="AL";	statelookup.options[ 1].text="Alabama"
	statelookup.options[ 2].value="AK";	statelookup.options[ 2].text="Alaska"
	statelookup.options[ 3].value="AS";	statelookup.options[ 3].text="American Samoa"
	statelookup.options[ 4].value="AZ";	statelookup.options[ 4].text="Arizona"
	statelookup.options[ 5].value="AR";	statelookup.options[ 5].text="Arkansas"
	statelookup.options[ 6].value="CA";	statelookup.options[ 6].text="California"
	statelookup.options[ 7].value="CO";	statelookup.options[ 7].text="Colorado"
	statelookup.options[ 8].value="CT";	statelookup.options[ 8].text="Connecticut"
	statelookup.options[ 9].value="DE";	statelookup.options[ 9].text="Delaware"
	statelookup.options[10].value="DC";	statelookup.options[10].text="District Of Columbia"
	statelookup.options[11].value="FM";	statelookup.options[11].text="Fed. States Of Micronesia"
	statelookup.options[12].value="FL";	statelookup.options[12].text="Florida"
	statelookup.options[13].value="GA";	statelookup.options[13].text="Georgia"
	statelookup.options[14].value="GU";	statelookup.options[14].text="Guam"
	statelookup.options[15].value="HI";	statelookup.options[15].text="Hawaii"
	statelookup.options[16].value="ID";	statelookup.options[16].text="Idaho"
	statelookup.options[17].value="IL";	statelookup.options[17].text="Illinois"
	statelookup.options[18].value="IN";	statelookup.options[18].text="Indiana"
	statelookup.options[19].value="IA";	statelookup.options[19].text="Iowa"
	statelookup.options[20].value="KS";	statelookup.options[20].text="Kansas"
	statelookup.options[21].value="KY";	statelookup.options[21].text="Kentucky"
	statelookup.options[22].value="LA";	statelookup.options[22].text="Louisiana"
	statelookup.options[23].value="ME";	statelookup.options[23].text="Maine"
	statelookup.options[24].value="MH";	statelookup.options[24].text="Marshall Islands"
	statelookup.options[25].value="MD";	statelookup.options[25].text="Maryland"
	statelookup.options[26].value="MA";	statelookup.options[26].text="Massachusetts"
	statelookup.options[27].value="MI";	statelookup.options[27].text="Michigan"
	statelookup.options[28].value="MN";	statelookup.options[28].text="Minnesota"
	statelookup.options[29].value="MS";	statelookup.options[29].text="Mississippi"
	statelookup.options[30].value="MO";	statelookup.options[30].text="Missouri"
	statelookup.options[31].value="MT";	statelookup.options[31].text="Montana"
	statelookup.options[32].value="NE";	statelookup.options[32].text="Nebraska"
	statelookup.options[33].value="NV";	statelookup.options[33].text="Nevada"
	statelookup.options[34].value="NH";	statelookup.options[34].text="New Hampshire"
	statelookup.options[35].value="NJ";	statelookup.options[35].text="New Jersey"
	statelookup.options[36].value="NM";	statelookup.options[36].text="New Mexico"
	statelookup.options[37].value="NY";	statelookup.options[37].text="New York"
	statelookup.options[38].value="NC";	statelookup.options[38].text="North Carolina"
	statelookup.options[39].value="ND";	statelookup.options[39].text="North Dakota"
	statelookup.options[40].value="MP";	statelookup.options[40].text="North. Mariana Islands"
	statelookup.options[41].value="OH";	statelookup.options[41].text="Ohio"
	statelookup.options[42].value="OK";	statelookup.options[42].text="Oklahoma"
	statelookup.options[43].value="OR";	statelookup.options[43].text="Oregon"
	statelookup.options[44].value="PW";	statelookup.options[44].text="Palau"
	statelookup.options[45].value="PA";	statelookup.options[45].text="Pennsylvania"
	statelookup.options[46].value="PR";	statelookup.options[46].text="Puerto Rico"
	statelookup.options[47].value="RI";	statelookup.options[47].text="Rhode Island"
	statelookup.options[48].value="SC";	statelookup.options[48].text="South Carolina"
	statelookup.options[49].value="SD";	statelookup.options[49].text="South Dakota"
	statelookup.options[50].value="TN";	statelookup.options[50].text="Tennessee"
	statelookup.options[51].value="TX";	statelookup.options[51].text="Texas"
	statelookup.options[52].value="TT";	statelookup.options[52].text="Trust Territories"
	statelookup.options[53].value="UT";	statelookup.options[53].text="Utah"
	statelookup.options[54].value="VT";	statelookup.options[54].text="Vermont"
	statelookup.options[55].value="VI";	statelookup.options[55].text="Virgin Islands"
	statelookup.options[56].value="VA";	statelookup.options[56].text="Virginia"
	statelookup.options[57].value="WA";	statelookup.options[57].text="Washington"
	statelookup.options[58].value="WV";	statelookup.options[58].text="West Virginia"
	statelookup.options[59].value="WI";	statelookup.options[59].text="Wisconsin"
	statelookup.options[60].value="WY";	statelookup.options[60].text="Wyoming"
    //document.getElementById('statelookup').disabled = true;
	}
else if (country.options[country.selectedIndex].value=='CA') //-- Canada
   { statelookup.length=14  
    statelookup.options[ 0].value="";	statelookup.options[ 0].text="Select a Province"
	statelookup.options[ 1].value="AB";	statelookup.options[ 1].text="Alberta"
	statelookup.options[ 2].value="BC";	statelookup.options[ 2].text="British Columbia"
	statelookup.options[ 3].value="MB";	statelookup.options[ 3].text="Manitoba"
	statelookup.options[ 4].value="NB";	statelookup.options[ 4].text="New Brunswick"
	statelookup.options[ 5].value="NF";	statelookup.options[ 5].text="Newfoundland"
	statelookup.options[ 6].value="NT";	statelookup.options[ 6].text="Northwest Territories"
	statelookup.options[ 7].value="NS";	statelookup.options[ 7].text="Nova Scotia"
	statelookup.options[ 8].value="NU";	statelookup.options[ 8].text="Nunavut"
	statelookup.options[ 9].value="ON";	statelookup.options[ 9].text="Ontario"
	statelookup.options[10].value="PE";	statelookup.options[10].text="Prince Edward Island"
	statelookup.options[11].value="QC";	statelookup.options[11].text="Quebec"
	statelookup.options[12].value="SK";	statelookup.options[12].text="Saskatchewan"
	statelookup.options[13].value="YT";	statelookup.options[13].text="Yukon Territory"
    //document.getElementById('statelookup').disabled = true;
	}
else if (country.options[country.selectedIndex].value=='UK') //-- UK - United Kingdom
   {statelookup.length=5  
    statelookup.options[ 0].value="";	statelookup.options[ 0].text="Select a Division"
	statelookup.options[ 1].value="EN";	statelookup.options[ 1].text="England"
	statelookup.options[ 2].value="SC";	statelookup.options[ 2].text="Scotland"
	statelookup.options[ 3].value="WA";	statelookup.options[ 3].text="Wales"
	statelookup.options[ 4].value="NI";	statelookup.options[ 4].text="Northern Ireland"
    //document.getElementById('statelookup').disabled = true;
   }
else if (country.options[country.selectedIndex].value=='AU') //-- AU - Australlia
   {statelookup.length=9  
    statelookup.options[ 0].value="";	statelookup.options[ 0].text="Select a State/Territory"
	statelookup.options[ 1].value="ACT";	statelookup.options[ 1].text="Australian Capital Territory"
	statelookup.options[ 2].value="NSW";	statelookup.options[ 2].text="New South Wales"
	statelookup.options[ 3].value="NT";	statelookup.options[ 3].text="Northern Territory"
	statelookup.options[ 4].value="QLD";	statelookup.options[ 4].text="Queensland" 
	statelookup.options[ 5].value="SA";	statelookup.options[ 5].text="South Australia"
	statelookup.options[ 6].value="TAS";	statelookup.options[ 6].text="Tasmania"
	statelookup.options[ 7].value="VIC";	statelookup.options[ 7].text="Victoria"
	statelookup.options[ 8].value="WA";	statelookup.options[ 8].text="Western Australia"
    //document.getElementById('statelookup').disabled = true;
   }
else if (country.options[country.selectedIndex].value=='NZ') //-- NZ - New Zealand
   {statelookup.length=17  
    statelookup.options[ 0].value="";	  statelookup.options[ 0].text="Select a Province"
	statelookup.options[ 1].value="AUK";	statelookup.options[ 1].text="Auckland"
	statelookup.options[ 2].value="BOP";	statelookup.options[ 2].text="Bay of Plenty"
	statelookup.options[ 3].value="CAN";	statelookup.options[ 3].text="Canterbury"
	statelookup.options[ 4].value="GIS";	statelookup.options[ 4].text="Gisborne" 
	statelookup.options[ 5].value="HKB";	statelookup.options[ 5].text="Hawke's Bay"
	statelookup.options[ 6].value="MBH";	statelookup.options[ 6].text="Marlborough"
	statelookup.options[ 7].value="MWT";	statelookup.options[ 7].text="Manawatu-Wanganui"
	statelookup.options[ 8].value="NSN";	statelookup.options[ 8].text="Nelson"
	statelookup.options[ 9].value="NTL";	statelookup.options[ 9].text="Northland"
	statelookup.options[ 10].value="OTA";	statelookup.options[ 10].text="Otago"
	statelookup.options[ 11].value="STL";	statelookup.options[ 11].text="Southland"
	statelookup.options[ 12].value="TAS";	statelookup.options[ 12].text="Tasman"
	statelookup.options[ 13].value="TKI";	statelookup.options[ 13].text="Taranaki"
	statelookup.options[ 14].value="WGN";	statelookup.options[ 14].text="Wellington"
	statelookup.options[ 15].value="WKO";	statelookup.options[ 15].text="Waikato"
	statelookup.options[ 16].value="WTC";	statelookup.options[ 16].text="West Coast"
    //document.getElementById('state').disabled = true;
   }

else if (country.options[country.selectedIndex].value=='CL') //-- CL
{statelookup.length=14  
statelookup.options[ 0].value="";	  statelookup.options[ 0].text="Select a Region"
	statelookup.options[ 1].value="CL-AI"; statelookup.options[ 1].text="Aisen del General Carlos Ibanez del Campo"
	statelookup.options[ 2].value="CL-AN"; statelookup.options[ 2].text="Antofagasta"
	statelookup.options[ 3].value="CL-AR"; statelookup.options[ 3].text="Araucania"
	statelookup.options[ 4].value="CL-AT"; statelookup.options[ 4].text="Atacama"
	statelookup.options[ 5].value="CL-BI"; statelookup.options[ 5].text="Bio-Bio"
	statelookup.options[ 6].value="CL-CO"; statelookup.options[ 6].text="Coquimbo"
	statelookup.options[ 7].value="CL-LI"; statelookup.options[ 7].text="Libertador General Bernardo O'Higgins"
	statelookup.options[ 8].value="CL-LL"; statelookup.options[ 8].text="Los Lagos"
	statelookup.options[ 9].value="CL-MA"; statelookup.options[ 9].text="Magallanes"
	statelookup.options[ 10].value="CL-ML"; statelookup.options[ 10].text="Maule"
	statelookup.options[ 11].value="CL-RM"; statelookup.options[ 11].text="Region Metropolitana de Santiago"
	statelookup.options[ 12].value="CL-TA"; statelookup.options[ 12].text="Tarapaca"
	statelookup.options[ 13].value="CL-VS"; statelookup.options[ 13].text="Valparaiso"
 //document.getElementById('state').disabled = true;
}

else if (country.options[country.selectedIndex].value=='ZA') //-- ZA - South Africa
{statelookup.length=10  
 statelookup.options[ 0].value="";	  statelookup.options[ 0].text="Select a Province"
	statelookup.options[ 1].value="EC";	statelookup.options[ 1].text="Eastern Cape"
	statelookup.options[ 2].value="FS";	statelookup.options[ 2].text="Free State"
	statelookup.options[ 3].value="GP";	statelookup.options[ 3].text="Gauteng"
	statelookup.options[ 4].value="KZ";	statelookup.options[ 4].text="KwaZulu-Natal" 
	statelookup.options[ 5].value="LP";	statelookup.options[ 5].text="Limpopo"
	statelookup.options[ 6].value="MP";	statelookup.options[ 6].text="Mpumalanga"
	statelookup.options[ 7].value="NC";	statelookup.options[ 7].text="Northern Cape"
	statelookup.options[ 8].value="NW";	statelookup.options[ 8].text="North West"
	statelookup.options[ 9].value="WC";	statelookup.options[ 9].text="Western Cape"
}
else if (country.options[country.selectedIndex].value=='IE') //-- IE - Ireland
{statelookup.length=5  
 statelookup.options[ 0].value="";	  statelookup.options[ 0].text="Select a Province"
	statelookup.options[ 1].value="C";	statelookup.options[ 1].text="Connaught"
	statelookup.options[ 2].value="L";	statelookup.options[ 2].text="Leinster"
	statelookup.options[ 3].value="M";	statelookup.options[ 3].text="Munster"
	statelookup.options[ 4].value="U";	statelookup.options[ 4].text="Ulster" 
}
else if (country.options[country.selectedIndex].value=='OTHER') //-- Other
   {statelookup.length=1  
    statelookup.options[ 0].value="";	statelookup.options[ 0].text="Please Enter Below" 
    document.getElementById('statelookup').value="";
    //document.getElementById('statelookup').disabled = false;
   }
else	
    {	
	statelookup.length=1;
	statelookup.options[ 0].value="";	statelookup.options[ 0].text="Please Enter Below"
    //document.getElementById(statelookup).value="";
		statelookup.disabled = false; 
    }

  //Sets value on Return
	if(selectedState!=''){
		  var is_array = selectedState.split(",");
	  for (var i=0; i<statelookup.options.length; i++){
	      for (var loop=0; loop<is_array.length; loop++){//Loops through array if found for multi select drop downs
		         if (statelookup.options[i].value==is_array[loop]){
		            statelookup.options[i].selected = true;
		          }
	
	      } 
	    }
	  }
    
}

