var lists = new Array();

// First set of text and values
lists['CA']    = new Array();
	lists['CA'][0] = new Array(
		'-- Select Province --',
		'Alberta',
		'British Columia',
		'Manitoba',
		'New Brunswick',
		'Newfoundland',
		'Northwest Territories',
		'Nova Scotia',
		'Nunavut',
		'Ontario',
		'Prince Edward Island',
		'Quebec',
		'Saskatchewan',
		'Yukon Territory'
	);
	lists['CA'][1] = new Array(
		'',
		'AB',
		'BC',
		'MB',
		'NB',
		'NF',
		'NT',
		'NS',
		'NU',
		'ON',
		'PE',
		'QC',
		'SK',
		'YT'
);

// Second set of text and values
lists['US']    = new Array();
	lists['US'][0] = new Array(
		'-- Select State --',
		'Alabama',
		'Alaska',
		'Arkansas',
		'Arizona',
		'California',
		'Colorado',
		'Connecticut',
		'Dist Of Col',
		'Delaware',
		'Florida',
		'Georgia',
		'Hawaii',
		'Iowa',
		'Idaho',
		'Illinois',
		'Indiana',
		'Kansas',
		'Kentucky',
		'Louisiana',
		'Massachusetts',
		'Maryland',
		'Maine',
		'Michigan',
		'Minnesota',
		'Missouri',
		'Mississippi',
		'Montana',
		'North Carolina',
		'North Dakota',
		'Nebraska',
		'New Hampshire',
		'New Jersey',
		'New Mexico',
		'Nevada',
		'New York',
		'Ohio',
		'Oklahoma',
		'Oregon',
		'Pennsylvania',
		'Rhode Island',
		'South Carolina',
		'South Dakota',
		'Tennessee',
		'Texas',
		'Utah',
		'Virginia',
		'Vermont',
		'Washington',
		'Wisconsin',
		'West Virginia',
		'Wyoming'
	);
	lists['US'][1] = new Array(
		'',
		'AK',
		'AL',
		'AR',
		'AZ',
		'CA',
		'CO',
		'CT',
		'DC',
		'DE',
		'FL',
		'GA',
		'HI',
		'IA',
		'ID',
		'IL',
		'IN',
		'KS',
		'KY',
		'LA',
		'MA',
		'MD',
		'ME',
		'MI',
		'MN',
		'MO',
		'MS',
		'MT',
		'NC',
		'ND',
		'NE',
		'NH',
		'NJ',
		'NM',
		'NV',
		'NY',
		'OH',
		'OK',
		'OR',
		'PA',
		'RI',
		'SC',
		'SD',
		'TN',
		'TX',
		'UT',
		'VA',
		'VT',
		'WA',
		'WI',
		'WV',
		'WY'
);
	
// Third set of text and values
lists['other']    = new Array();
	lists['other'][0] = new Array(
		'Not Applicable'
	);
	lists['other'][1] = new Array(
		'N/A'
);

// Fourth set of text and values
lists['empty']    = new Array();
	lists['empty'][0] = new Array(
		'-- Select Country First --'
	);
	lists['empty'][1] = new Array(
		''
);

// 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 ) {
	// arr[0] holds the display text
	// arr[1] are the values

	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;
	}

	// Preselect option 0

	box.selectedIndex=0;
}

// 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) {
	// Isolate the appropriate list by using the value
	// of the currently selected option

	list = lists[box.options[box.selectedIndex].value];
	value = box.options[box.selectedIndex].value;

	// Next empty the slave list

	emptyList(box.form.state);

	// Then assign the new list values
	if(value!="US" && value!="CA" && value!="empty") {
		list = lists["other"];
	}
	
	fillList(box.form.state, list);
}

// This function goes through the options for the given
// drop down box and removes them in preparation for
// a new set of values

function emptyMailingList( 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 fillMailingList( box, arr ) {
	// arr[0] holds the display text
	// arr[1] are the values

	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;
	}

	// Preselect option 0

	box.selectedIndex=0;
}

// This function performs a drop down list option change by first
// emptying the existing option list and then assigning a new set

function changeMailingList(box) {
	// Isolate the appropriate list by using the value
	// of the currently selected option

	list = lists[box.options[box.selectedIndex].value];

	// Next empty the slave list

	emptyMailingList(box.form.mailingState);

	// Then assign the new list values

	fillMailingList(box.form.mailingState, list);
}

function disableNewAddress() {
	document.form.newAddress.disabled= true;
	document.form.postalCode.disabled= true;
	document.form.city.disabled= true;
	document.form.state.disabled= true;
	document.form.country.disabled= true;
	document.form.saveNewAddress.disabled= true;
}

function enableNewAddress() {
	document.form.newAddress.disabled= false;
	document.form.postalCode.disabled= false;
	document.form.city.disabled= false;
	document.form.state.disabled= false;
	document.form.country.disabled= false;
	document.form.saveNewAddress.disabled= false;
}