var whatForm, whatTo, whatText, whatCountry;

function showFields(number) {
	whatCountry = document.form1.selectName1.value;
	if (whatCountry == 'USA') {
		document.form1.selectName2.style.display = 'block'; 
		reshow(number)
	} else if (whatCountry == 'Canada') {
		document.form1.selectName2.style.display = 'block';
		document.form1.selectName3.style.display = 'none'; 
		reshow(number)
	} else {
		document.form1.selectName2.style.display = 'none'; 
		document.form1.selectName3.style.display = 'none';
	}	
}

function reshow(number) {
	whatCountry = document.form1.selectName1.value;
	whatFrom = document.form1.elements['selectName' + number];
	number++;
	whatTo = document.form1.elements['selectName' + number];
	for (var i = whatTo.length;i > 0;i--)
		whatTo.options[0] = null;
	whatText = whatFrom.options[whatFrom.selectedIndex].text;
	showLink(number);
	whatTo.options[0].selected = true;
	if (number == 2)
		reshow(2);
	return false;
	}
	function showLink(number) {
		if (number == 2)
			showLink2()
		else if (number == 3)
			showLink3();
	}
	function showLink2() {
		if (whatText == 'USA') {
			opt('USALL','All US States');
			opt('USANE','North East - NH, VT, MA, CT, RI, NY');
			opt('USAMA','Mid Atlantic - NJ, PA, VA, WV, DE, WA, MD');
			opt('USASE','South East - NC, SC, GA, FL');
			opt('USASW','South West - AZ, UT, NM, NV');
			opt('USAMW','Mid West - NE, CO, MT, ND, SD, WY, ID, KS');
			opt('USANC','North Central - MI, IN, OH, KY, IL, WI, MN, IA');
			opt('USASC','South Central - TN, AL, AR, MS, MO, LA, OK, TX');
			opt('USAW','West - CA, OR, WA, AK, HI');
		}
		if (whatText == 'Canada') {
			opt('CAALL','All Canada');
			opt('AB','Alberta');
			opt('BC','British Columbia');
			opt('MB','Manitoba');
			opt('NB','New Brunswick');
			opt('NL','Newfoundland/Labrador');
			opt('NT','Northwest Territories');
			opt('NS','Nova Scotia');
			opt('NU','Nunavut');
			opt('ON','Ontario');
			opt('PE','Prince Edward Island');
			opt('QC','Quebec');
			opt('SK','Saskatchewan');
			opt('YT','Yukon Territory');
		}
	}
	function showLink3(text) {
		if (whatCountry == 'Canada') {
			opt('','--');
		}
		if (whatText == 'All US States') {
			opt('','--');
		}			
		if (whatText == 'North East - NH, VT, MA, CT, RI, NY') {
			document.form1.selectName3.style.display = 'block';
			opt('USNE','All North East');
			opt('ME','Maine');
			opt('NH','New Hampshire');
			opt('VT','Vermont');
			opt('MA','Massachusetts');
			opt('CT','Connecticut');
			opt('RI','Rhode Island');
			opt('NY','New York');
		}
		if (whatText == 'Mid Atlantic - NJ, PA, VA, WV, DE, WA, MD') {
			document.form1.selectName3.style.display = 'block';
			opt('USMA','All Mid Atlantic');
			opt('NJ','New Jersey');
			opt('PA','Pennsylvania');
			opt('VA','Virginia');
			opt('WV','West Virginia');
			opt('DE','Delaware');
			opt('DC','Washington DC');
			opt('MD','Maryland');
		}
		if (whatText == 'South East - NC, SC, GA, FL') {
			document.form1.selectName3.style.display = 'block';
			opt('USSE','All South East');
			opt('NC','North Carolina');
			opt('SC','South Carolina');
			opt('GA','Georgia');
			opt('FL','Florida');
		}
		if (whatText == 'South West - AZ, UT, NM, NV') {
			document.form1.selectName3.style.display = 'block';
			opt('USSW','All South West');
			opt('AZ','Arizona');
			opt('UT','Utah');
			opt('NM','New Mexico');
			opt('NV','Nevada');
		}
		if (whatText == 'Mid West - NE, CO, MT, ND, SD, WY, ID, KS') {
			document.form1.selectName3.style.display = 'block';
			opt('USMW','All Mid West');
			opt('NE','Nebraska');
			opt('CO','Colorado');
			opt('MT','Montana');
			opt('ND','North Dakota');
			opt('SD','South Dakota');
			opt('WY','Wyoming');
			opt('ID','Idaho');
			opt('KS','Kansas');
		}
		if (whatText == 'North Central - MI, IN, OH, KY, IL, WI, MN, IA') {
			document.form1.selectName3.style.display = 'block';
			opt('USNC','All North Central');
			opt('MI','Michigan');
			opt('IN','Indiana');
			opt('OH','Ohio');
			opt('KY','Kentucky');
			opt('IL','Illinois');
			opt('WI','Wisconsin');
			opt('MN','Minnesota');
			opt('IA','Iowa');
		}
		if (whatText == 'South Central - TN, AL, AR, MS, MO, LA, OK, TX') {
			document.form1.selectName3.style.display = 'block';
			opt('USSC','All South Central');
			opt('TN','Tennessee');
			opt('AL','Alabama');
			opt('AR','Arkansas');
			opt('MS','Mississippi')
			opt('MO','Missouri');
			opt('LA','Louisiana');
			opt('OK','Oklahoma');
			opt('TX','Texas');
		}
		if (whatText == 'West - CA, OR, WA, AK, HI') {
			document.form1.selectName3.style.display = 'block';
			opt('USW','All West');
			opt('CA','California');
			opt('OR','Oregon');
			opt('WA','Washington');
			opt('AK','Alaska');
			opt('HI','Hawaii');
		}
	}
	function opt(href,text) {
		var optionName = new Option(text, href, false, false)
		var length = whatTo.length;
		whatTo.options[length] = optionName;
	}