
//var formsetup=false

var c215 = [
["-- Select a State --", ""],
["Armed Forces Africa","AE"],
["Armed Forces Americas","AA"],
["Armed Forces Canada","AE"],
["Armed Forces Europe","AE"],
["Armed Forces Middle East","AE"],
["Armed Forces Pacific","AP"],
["Alabama","AL"],
["Alaska","AK"],
["Arizona","AZ"],
["Arkansas","AR"],
["California","CA"],
["Colorado","CO"],
["Connecticut","CT"],
["Delaware","DE"],
["District of Columbia","DC"],
["Florida","FL"],
["Georgia","GA"],
["Hawaii","HI"],
["Idaho","ID"],
["Illinois","IL"],
["Indiana","IN"],
["Iowa","IA"],
["Kansas","KS"],
["Kentucky","KY"],
["Louisiana","LA"],
["Maine","ME"],
["Maryland","MD"],
["Massachusetts","MA"],
["Michigan","MI"],
["Minnesota","MN"],
["Mississippi","MS"],
["Missouri","MO"],
["Montana","MT"],
["Nebraska","NE"],
["Nevada","NV"],
["New Hampshire","NH "],
["New Jersey","NJ"],
["New Mexico","NM"],
["New York","NY"],
["North Carolina","NC"],
["North Dakota","ND"],
["Ohio","OH"],
["Oklahoma","OK"],
["Oregon","OR"],
["Pennsylvania","PA"],
["Puerto Rico","PR"],
["Rhode Island","RI"],
["South Carolina","SC"],
["South Dakota","SD"],
["Tennessee","TN"],
["Texas","TX"],
["Utah","UT"],
["Vermont","VT"],
["Virginia","VA"],
["Washington","WA"],
["West Virginia","WV"],
["Wisconsin","WI"],
["Wyoming","WY"]]

var c37 = [
["-- Select a State --", ""],
["Alberta","AB"],
["British Columbia","BC"],
["Manitoba","MB"],
["New Brunswick","NB"],
["Newfoundland and Labrador","NL"],
["Northwest Territories","NT"],
["Nova Scotia","NS"],
["Nunavut Territory","NU"],
["Ontario","ON"],
["Prince Edward Island","PE"],
["Quebec","QC"],
["Saskatchewan","SK"],
["Yukon Territory","YT"]]


function getStatesGeneric(arrname,toidx,psi,psv,countrycomboidx,txtidx)
{
	/*
	OVERVIEW
	Mark Faulk
	2009/3/26
	This function receives these vars:
	
	arrname=the array holding the values to insert into the select
	toidx=id of the state select box (combobox, dropdown box, etc. - blah, too many names!)
	psi=preselind=preselected index
	psv=preselval=preselected value
	countrycomboidx=id of the associated country dropdown
	txtidx=id of the associated txtbox (for other countries)
	
	It tries to eval the arrname (c215 for US states, c37 for Canadian provinces, etc.) to see if it exists.
	
	If it doesn't, throws an err and control goes to the catch. The catch will then show the state textbox and hide the state dropdown since there are no associated states found for the country chosen.
	
	If the state is found, it will hide the state textbox and show the state dropdown. It then calls flipnfill to fill in the state values.
	
	OLD DOCUMENTATION:
	this function checks to see if the array exists. If it doesn't, it will either set the state box to empty or to the textbox
	*/
	var flg=0

	try
	{
		if(!eval(arrname))
		{
			throw "err1";
		}
		
	}
	catch(er)
	{
		var ertxt=''
		ertxt=er.toString()
		//alert(ertxt)
		//alert(ertxt.toLowerCase().indexOf('error'))
		//alert(txtidx)
		flg=1
		if(ertxt.toLowerCase().indexOf('error')>-1)
		{
			//show the state textbox
			showhidebox(txtidx,1,1)
			showhidebox(toidx,0,0)

			gebid(toidx).selectedIndex=0
			
		}
		

		if(gebid(countrycomboidx).selectedIndex==0 || gebid(countrycomboidx).selectedIndex==3) //use this line if the country has a "select one" option as index 0
		//if(gebid('VIC_Country').selectedIndex==2) //use this option if the country does not have "select one" as index 0
		{
			//Select One or the divider (----) was selected
			showhidebox(txtidx,0,0)
			showhidebox(toidx,1,1)
			
			gebid(toidx).length=null
			gebid(toidx)[0]=new Option('Select a country','',true,true)
		}

	}
	//alert(flg)
	if(flg==0)
	{
		//show dropdown
		if(gebid(toidx).style.visibility=='hidden')
		{
			showhidebox(txtidx,0,0)
			showhidebox(toidx,1,1)
		}
		//the last value, true, = showselectone
		flipnfill(arrname,gebid(toidx),psi,psv,true)
	}

}




