function get_element(sId) {
	var oEl = document.getElementById(sId);
	if (oEl != null) {
		return oEl;
	} else {
		return false;
	}	
}

function setSecondary(sVal, sDestinationId, sAction) {
	get_ajax_request(sVal, sDestinationId, sAction, 'lists.php?option=' + sVal);
}

function get_ajax_request(sOption, sDestinationId, sAction, sUrl)
{
	if (window.XMLHttpRequest) 
	{
		 var xmlhttp = new XMLHttpRequest();
	} 
	else if (window.ActiveXObject) 
	{
		var xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
	}
	else 
	{
		var xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
	}
	
	xmlhttp.open("GET", sUrl, true);
	xmlhttp.onreadystatechange = function() {
		if (xmlhttp.readyState==4) {
			perform_return_action(sOption, sDestinationId, sAction, xmlhttp.responseXML);
		}
	}
	xmlhttp.send(null);
}

function perform_return_action(sOption, sDestinationId, sAction, sResponse) {
    var xmlDocument = sResponse;
	
	switch(sAction) {
	case 'poplist': populate_select_list(sDestinationId, xmlDocument.getElementsByTagName('item'));	break;
	}	 
}

function populate_select_list(sId, aOptions) {
	oElement = get_element(sId);
	if (oElement) {
		oElement.options.length = 0;
		
		if (aOptions.length > 0) {
			oElement.options[0] = new Option('-- Please Select --','');
			for(var i=0;i<aOptions.length;i++) {
				oElement.options[i + 1] = new Option(aOptions[i].firstChild.data,aOptions[i].firstChild.data);
			} 			
		}
	}
}
