
var xmlGetDeviceInfo;
var xmlUpdateDevice;
var noAJAXtext = 'Please note: This site is using AJAX technology, which is currently unsupported by your browser.';

/////// XMLHTTP Object ///////
function GetXmlHttpObject(){
	var xmlHttp=null;
	try{
	    // Firefox, Opera 8.0+, Safari
	    xmlHttp=new XMLHttpRequest();
	    }
	catch (e){
	    // Internet Explorer
		try{
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
			}
			catch (e){
				xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
				}
			}
	return xmlHttp;
	}

function ajax_getDeviceInfo(){
	if (xmlGetDeviceInfo.readyState == 4) {
		if (xmlGetDeviceInfo.status == 200){
		    document.getElementById("updating").innerHTML = '';
			document.getElementById("show_device_info").innerHTML = '';
			document.getElementById("show_device_info").innerHTML = xmlGetDeviceInfo.responseText;
			}
		}
	else{document.getElementById("updating").innerHTML = "<span style='text-align:center; font-weight:bold; font-family:Arial;'>Searching...</span>";}
	}

function ajax_getUpdateDeviceInfo() {
    if (xmlUpdateDevice.readyState == 4) {
		if (xmlUpdateDevice.status == 200){
            ajax_createDeviceList(xmlUpdateDevice.responseText);
			}
		}
    }

function ajax_createDeviceList(rtxt) {
    var oList;
	oList = document.platform.elements["device_a"];
    oList.options.length=0;
    oList.options[0] = new Option("-- Device Name --", "", true, false);
    if (rtxt!='') {
        var arrSplit = rtxt.split("|");
        for(var i = 0; i<arrSplit.length-1; i++){
           oList.options[i + 1] = new Option(arrSplit[i], arrSplit[i]);
        }
    }
}
    
function ajax_getDevice(drop_1, drop_2, drop_3, fID){
	if(typeof(xmlGetDeviceInfo) != 'object'){
		xmlGetDeviceInfo=GetXmlHttpObject();
			if (xmlGetDeviceInfo==null){
		    	alert (noAJAXtext);
			    return;
			    }
		    }
	var url="/downloadcenter/get_platform_info.php";
	url=url+"?manufacturer="+drop_1;
	url=url+"&platform="+drop_2;
	url=url+"&device="+drop_3;
	url=url+"&id="+fID;	
	url=url+"&sid="+Math.random();
	xmlGetDeviceInfo.open("GET",url,true);
	xmlGetDeviceInfo.onreadystatechange=ajax_getDeviceInfo;
	xmlGetDeviceInfo.send(null);
	}

function ajax_updateDevice(fID) {
    var s_manufact;
    var s_os;
    if(typeof(xmlUpdateDevice) != 'object'){
		xmlUpdateDevice=GetXmlHttpObject();
			if (xmlUpdateDevice==null){
		    	alert (noAJAXtext);
			    return;
			    }
		    }
	s_manufact = document.platform.manufacturer_a.options[document.platform.manufacturer_a.options.selectedIndex].value;
	s_os = document.platform.platform_a.options[document.platform.platform_a.options.selectedIndex].value;
	
	var url="/downloadcenter/get_device_info.php";    
    url=url+"?manufacturer="+s_manufact;
    url=url+"&platform="+s_os;
	url=url+"&id="+fID;	
	url=url+"&sid="+Math.random();
	xmlUpdateDevice.open("GET",url,true);
	xmlUpdateDevice.onreadystatechange=ajax_getUpdateDeviceInfo;
	xmlUpdateDevice.send(null);
	}
