var ajax = new Array();

function selectme (fort,el,val){
	//fort=formid, el = element, val = value
	for(i=0; i<document.forms[fort].elements[el].length;i++){
		if(document.forms[fort].elements[el].options[i].value == val ){
			document.forms[fort].elements[el].options[i].selected="selected";
		}
	}
}

function getListCity(sel)
{
	var countryCode = sel.options[sel.selectedIndex].value;
	document.getElementById('sel_city').options.length = 0;	
	if (document.getElementById('sel_venue')){
		document.getElementById('sel_venue').options.length = 0;
	}
	if(countryCode.length>0){
		var index = ajax.length;
		ajax[index] = new sack();
		
		ajax[index].requestFile = '/x/ajax/ajax_list.php?list_name=city&code='+countryCode;	// Specifying which file to get
		ajax[index].onCompletion = function(){ createListCity(index) };	// Specify function that will be executed after file has been found
		ajax[index].runAJAX();		// Execute AJAX function
	}
}

function createListCity(index)
{
	var obj = document.getElementById('sel_city');
	eval(ajax[index].response);	// Executing the response from Ajax as Javascript code	
}

function getListVenue(sel)
{
	var cityCode = sel.options[sel.selectedIndex].value;
	document.getElementById('sel_venue').options.length = 0;	// Empty venue select box
	if(cityCode.length>0){
		var index = ajax.length;
		ajax[index] = new sack();
		
		ajax[index].requestFile = '/x/ajax/ajax_list.php?list_name=venue&code='+cityCode;	// Specifying which file to get
		ajax[index].onCompletion = function(){ createListVenue(index) };	// Specify function that will be executed after file has been found
		ajax[index].runAJAX();		// Execute AJAX function
	}
}

function createListVenue(index)
{
	var obj = document.getElementById('sel_venue');
	eval(ajax[index].response);	// Executing the response from Ajax as Javascript code	
}
	
