
/*
 * AJAX Functions
 */

myAjax = '';

function getModels()
{
	$('ajax_indicator').style.display = 'block';
	var url = 'ws/xml.models.php';
	var params = 'mfg=' + $F('mfg');
	myAjax = new Ajax.Request( url, { method: 'get', parameters: params, onComplete: showModels });
}

function showModels(originalRequest)
{
	var ajaxResponse = Try.these(
		function() { return new DOMParser().parseFromString(originalRequest.responseText, 'text/xml'); },
		function() { var xmldom = new ActiveXObject('Microsoft.XMLDOM'); xmldom.loadXML(originalRequest.responseText); return xmldom; }
	);
	current_child = ajaxResponse.getElementsByTagName('content').item(0);
	$('modelselection').innerHTML = current_child.childNodes.item(0).data;
	$('searchresults').innerHTML = '';
	$('searchresult_panel').style.display = 'none';	
	$('ajax_indicator').style.display = 'none';
}

function getDetails(ord, dir)
{
	$('ajax_indicator').style.display = 'block';
	if(eval(ord != null))
		ord = '&ord=' + ord;
	else
		ord = '';
	if(eval(dir != null))
		dir = '&dir=' + dir;
	else
		dir = '';		
	var url = 'ws/xml.details.php';
	var params = 'mfg=' + $F('mfg') + '&mod=' + $F('mod') + ord + dir;
	myAjax = new Ajax.Request( url, { method: 'get', parameters: params, onComplete: showDetails });
}

function searchDetails(ord, dir)
{
	$('ajax_indicator').style.display = 'block';
	if(eval(ord != null))
		ord = '&ord=' + ord;
	else
		ord = '';
	if(eval(dir != null))
		dir = '&dir=' + dir;
	else
		dir = '';		
	var url = 'ws/xml.details.php';
	var params = 'mfg=' + $F('mfg') + '&s=' + $F('s') + ord + dir;
	myAjax = new Ajax.Request( url, { method: 'get', parameters: params, onComplete: showDetails });
}

function showUnsupportedPhones()
{
	$('ajax_indicator').style.display = 'block';
	var url = 'ws/xml.unsupported.php';
	var params = 'mfg=' + $F('mfg');
	myAjax = new Ajax.Request( url, { method: 'get', parameters: params, onComplete: showDetails });
}

function showDetails(originalRequest)
{
	var ajaxResponse = Try.these(
		function() { return new DOMParser().parseFromString(originalRequest.responseText, 'text/xml'); },
		function() { var xmldom = new ActiveXObject('Microsoft.XMLDOM'); xmldom.loadXML(originalRequest.responseText); return xmldom; }
	);
	current_child = ajaxResponse.getElementsByTagName('content').item(0);
	$('searchresults').innerHTML = current_child.childNodes.item(0).data;
	$('searchresult_panel').style.display = 'block';	
	$('ajax_indicator').style.display = 'none';
}

function clearDetails()
{
	$('searchresults').innerHTML = '';
	$('searchresult_panel').style.display = 'none';
	$('ajax_indicator').style.display = 'none';
}