

// test arrays for keeping location information
/*var country 	= new Array("Canada", 1, "Japan", 2, "Russia", 3);
var province	= new Array(
							new Array(1, "British Columbia", 1),
							new Array(1, "Ontario", 2),
							new Array(2, "Nara", 3),
							new Array(2, "Chiba", 4),
							new Array(3, "Russia", 5)
						)
var city			= new Array(
							new Array(1, "Vancouver", 1),
							new Array(1, "Richmond", 2),
							new Array(2,"Toronto", 3),
							new Array(3,"Koriyama", 4),
							new Array(3,"Tenkawa", 5),
							new Array(3,"Yoshino", 6),
							new Array(4,"Tokyo", 7),
							new Array(5,"St. Petersberg", 8),
							new Array(5,"Moscow", 9)
						)
*/
function create_country() {
	// create the select element
	var select = document.getElementById('country');//document.createElement('select');
	if (select) {
		select.innerHTML = '';	// clear out any old nodes
		create_option(select,'',"-- Select A Country --",'')

		for(var i = 0;2*i < country.length; i++){
			// create the option element
			create_option(select,country[2*i + 1],country[2*i],sel_country);
		}
	}
}

function create_province(pCountry) {
	// create the select element
	var select = document.getElementById('province');//document.createElement('select');
	if (select) {
	// clear the other children
	select.innerHTML = '';
	create_option(select,'',"-- Select A State --",'')

	if (pCountry == null | pCountry == '') {
		// disable the select if the country is empty;
		select.disabled = true;
	} else {
		select.disabled = false;
		for(var i = 0;i < province.length; i++){
			// create the option element
			var temp		= province[i];
			if (temp[0] == pCountry) {
				// ERROR: this will cause an error if the elements are sorted by ID instead of alphabetically
				// for a country that has provinces but allows the field to be empty
				//alert(temp[1] != '');
				if (temp[1] != '') { 								// testing for null province
					create_option(select,temp[2],temp[1], sel_province);
					create_city();
					select.style.display = '';
				} else {
					create_city(temp[2]);
					select.style.display = 'none';
				}
			}
		}
	}
	}
}

function create_city(pProvence) {
	// create the select element
	var select = document.getElementById('city');//document.createElement('select');
	if (select) {
	// clear the other children
	select.innerHTML = '';
	create_option(select,'',"-- Select A City --",'')

	if (pProvence == null | pProvence == '') {
		// disable the select if the country is empty;
		select.disabled = true;
	} else {
		select.disabled = false;
		for(var i = 0;i < city.length; i++){
			// create the option element
			var temp					= city[i];
			if (temp[0] == pProvence) {
				create_option(select,temp[2],temp[1], sel_city);
			}
		}
	}
	}
}

function create_option(parent, val, display, selValue) {
	var option 			= document.createElement('option');
	option.value 		= val;
	option.innerHTML 	= display;
	if (val == selValue) { option.selected = true; }
	// add the option element to the dropdown
	parent.appendChild(option);
}

function create_all(){
	create_country();create_province(sel_country);create_city(sel_province);
}

function do_paging(pageNum) {
	// set the hidden page number
	document.getElementById('page').value = pageNum;

	// submit the form
    //- updated by Dmitri 03/03/2005
	//document.getElementById('form').submit();
    document.forms['LocationForm'].submit();

	// return false to keep the link from going anywhere
	return false;
}