
// Various State Data
var lists = new Array();
// USA
lists['US']    = new Array();
lists['US'][0] = new Array(
	'Select Your State',
	'Alaska',
	'Alabama',
	'Arkansas',
	'Arizona',
	'California',
	'Colorado',
	'Connecticut',
	'District of Columbia',
	'Delaware',
	'Florida',
	'Georgia',
	'Hawaii',
	'Idaho',
	'Illinois',
	'Indiana',
	'Iowa',
	'Kansas',
	'Kentucky',
	'Louisiana',
	'Maine',
	'Maryland',
	'Massachusetts',
	'Michigan',
	'Minnesota',
	'Mississippi',
	'Missouri',
	'Montana',
	'North Carolina',
	'North Dakota',
	'Nebraska',
	'New Hampshire',
	'Nevada',
	'New Jersey',
	'New Mexico',
	'New York',
	'Ohio',
	'Oklahoma',
	'Oregon',
	'Pennsylvania',
	'Rhode Island',
	'South Carolina',
	'South Dakota',
	'Tennessee',
	'Texas',
	'Utah',
	'Vermont',
	'Virginia',
	'Washington',
	'West Virginia',
	'Wisconsin',
	'Wyoming',
	'Armed Forces Africa',
	'Puerto Rico',
	'Virgin Islands',
	'Armed Forces Americas',
	'Armed Forces Canada',
	'Armed Forces Europe',
	'Armed Forces Middle East',
	'Armed Forces Pacific',
	'Guam');
lists['US'][1] = new Array(
	'NULL',
	'AK',
	'AL',
	'AR',
	'AZ',
	'CA',
	'CO',
	'CT',
	'DC',
	'DE',
	'FL',
	'GA',
	'HI',
	'ID',
	'IL',
	'IN',
	'IA',
	'KS',
	'KY',
	'LA',
	'ME',
	'MD',
	'MA',
	'MI',
	'MN',
	'MS',
	'MO',
	'MT',
	'NC',
	'ND',
	'NE',
	'NH',
	'NV',
	'NJ',
	'NM',
	'NY',
	'OH',
	'OK',
	'OR',
	'PA',
	'RI',
	'SC',
	'SD',
	'TN',
	'TX',
	'UT',
	'VT',
	'VA',
	'WA',
	'WV',
	'WI',
	'WY',
	'AE',
	'PR',
	'VI',
	'AA',
	'AE',
	'AE',
	'AE',
	'AP',
	'GU');

// Canada
lists['CA']    = new Array();
lists['CA'][0] = new Array(
	'Select Your Province',
	'Alberta',
	'British Columbia',
	'Manitoba',
	'New Brunswick',
	'Newfoundland',
	'Northwest Territories',
	'Nova Scotia',
	'Ontario',
	'Prince Edward Island',
	'Quebec',
	'Saskatchewan',
	'Yukon'
);
lists['CA'][1] = new Array(
	'NULL',
	'AB',
	'BC',
	'MB',
	'NB',
	'NF',
	'NT',
	'NS',
	'ON',
	'PE',
	'PQ',
	'SK',
	'YT'
);

// Mexico
lists['MX']    = new Array();
lists['MX'][0] = new Array(
	'Select Your State',
	'Aguasealientes',
	'Baja California',
	'Baja California Sur',
	'Campeche',
	'Chiapas',
	'Chihuahua',
	'Coahuila',
	'Colima',
	'Distrito Federal',
	'Durango',
	'Guanajuanto',
	'Guerrero',
	'Hidalgo',
	'Jalisco',
	'Mexico',
	'Michoacan',
	'Morelos',
	'Nayarit',
	'Nuevo Leon',
	'Oaxaca',
	'Puebla',
	'Queretaro',
	'Quintana Roo',
	'San Luis Potosi',
	'Sinaloa',
	'Sonora',
	'Tabasco',
	'Tamaulipas',
	'Tlaxcala',
	'Veracruz',
	'Yucatan',
	'Zacatecas'
);
lists['MX'][1] = new Array(
	'NULL',
	'AG',
	'BC',
	'BS',
	'CM',
	'CS',
	'CH',
	'CO',
	'CL',
	'DF',
	'DG',
	'GT',
	'GR',
	'HG',
	'JA',
	'MX',
	'MI',
	'MO',
	'NA',
	'NL',
	'OA',
	'PU',
	'QT',
	'QR',
	'SL',
	'SI',
	'SO',
	'TB',
	'TM',
	'TL',
	'VE',
	'YU',
	'ZA'
);

// This function goes through the options for the given
// drop down box and removes them in preparation for
// a new set of values

function emptyList( box ) {
	// Set each option to null thus removing it
	while ( box.options.length ) box.options[0] = null;
}

// This function assigns new drop down options to the given
// drop down box from the list of lists specified

function fillList( box, arr, presel ) {
	// arr[0] holds the display text
	// arr[1] are the values
	
	preselected = 0
	
	for ( i = 0; i < arr[0].length; i++ ) {

		// Create a new drop down option with the
		// display text and value from arr

		option = new Option( arr[0][i], arr[1][i] );

		// Add to the end of the existing options

		box.options[box.length] = option;
		
		// save the preselected index
		if (presel == arr[1][i]) preselected = i;
	}

	// Preselect option 0
	//if (presel == 'null' || presel == 'NULL') preselected = 0;

	box.selectedIndex=preselected;
}


// This function performs a drop down list option change by first
// emptying the existing option list and then assigning a new set

function changeList( box, slave, presel, redir) {

	// Isolate the appropriate list by using the value
	// of the currently selected option
	if (box.selectedIndex) {
		listVal = box.options[box.selectedIndex].value;
	} else {
		listVal	= box.value;
	}

	if (redir && (listVal != "CA") && (listVal != "MX") && (listVal != "US") && slave) {
		document.addresses.redir.value=redir;
		document.addresses.submit();
		return;
	} else if (redir && !slave && ((listVal == "CA") || (listVal == "MX") || (listVal == "US"))) {
		document.addresses.redir.value=redir;
		document.addresses.submit();
		return;
	}
	if ((listVal != "CA") && (listVal != "MX")) {
		listVal = 'US';
	} 
	list = lists[listVal];

	// Next empty the slave list
	if (slave) { emptyList( slave ); }

	// Then assign the new list values

	if (slave) { fillList( slave, list, presel ); }
	
	
}



