// JavaScript Document
var ajax = new sack();

function getStates(sel,root){
	var country = sel.options[sel.selectedIndex].value;
	var state_or_province = document.getElementById('state_or_province');
	state_or_province.options.length = 0;	// Empty state select box
	if(country.length > 0){
		state_or_province.options[state_or_province.options.length] = new Option('Select','');
		var path = root + '../media/ajax/chain_select/state_province.php?country=' + country;
		//alert(path);
		ajax.requestFile = path;			// Specifying which file to get
		ajax.onCompletion = createStates;	// Specify function that will be executed after file has been found
		ajax.runAJAX();						// Execute AJAX function
	}else{
		state_or_province.options[state_or_province.options.length] = new Option('','');			
	}
}

function createStates(){
	var obj = document.getElementById('state_or_province');
	eval(ajax.response);	// Executing the response from Ajax as Javascript code	
}