// Array to associate states and provinces with store names
var storesArray=[
	["Canada",[
		["Alberta",["Safeway"]],
		["British Columbia",["Safeway"]],
		["Saskatchewan",["Safeway"]],
		["Ontario",["Safeway"]],
		["Manitoba",["Safeway"]]]]
		
		
];

// Array to hold countries, states, and provinces
var locationArray=[
	["Canada",["Alberta","British Columbia","Saskatchewan","Manitoba","Ontario","Quebec"]]
];

// Function to populate dropdown lists based on user selections
// - Required arguments:
// - selectObj: a select form field object to be populated with new options
// - optionsArray: an array containing the new option values for the select form field object
//   (the optionsArray may contain arrays as values -- see comments below)
function buildOptions(selectObj,optionsArray){
	// Clear existing options from the select form field
	clearOptions(selectObj);
	// Populate the select form field with options from the options array
	// - The for loop checks to see if the optionsArray value is itself an array
	// - If so, it uses the first value in the nested array (position [0]) as the new option value
	// - Otherwise, it uses the original optionsArray value
	for(var i=0;i<optionsArray.length;i++){selectObj.options[i+1]=optionsArray[i].constructor.toString().indexOf("Array")==-1?new Option(optionsArray[i],optionsArray[i]):new Option(optionsArray[i][0],optionsArray[i][0])}
}
// Clear existing options from the select form fields
function clearOptions(){for(var i=0;i<arguments.length;i++){arguments[i].length=1}}
