// JavaScript Document

var http;
var mySelectedBrand 		= "";
var mySelectedModel 		= "";
var global_installType  	= "";
var AppListArray			= new Array;
var enableTemplate			= false;

http = getHTTPObject();

function goHome()
{
	parent.location = ClientURL;
	self.close();
}

function sendRequest(type, ua)
{
	var url = "";
	if (type == "browser")
	{
		url = "getPDAdevice_details.jsp?lang=" + lang;
	}
	else if (type == "device")
	{
		url = "device_details.jsp?ua=" + ua + "&lang=" + lang;
	}
	else
	{
		url = "";
	}
	http.open("POST", url , true);
	http.onreadystatechange = function()
	{
		if(http.readyState == 4 )
		{
			processXML( http.responseXML, type);
		}
	};
	http.send("");
}

function processXML( results, type )
{
	var nodeList;
	var response;
	if (type == "browser")
	{
		//statusChange("loading");
		// Get the request Parameteres of the affiliate tracking
		nodeList = results.getElementsByTagName('requestParams');
		DownloadStamp = nodeList[0].childNodes[0].nodeValue;
		// Get the nodeList for the rest of the XML
		nodeList = results.getElementsByTagName('suite');
		// Check to make sure there is only one suite Element returned
		if (nodeList.length != 0 && nodeList.length < 2)
		{
			// Get the text for download link.
			nodeList = results.getElementsByTagName('displayName');
			linkText = nodeList[0].childNodes[0].nodeValue
			// Get the file name for the download link
			nodeList = results.getElementsByTagName('component');
			linkFile = nodeList[0].getAttribute("id");
			// Get the installable value for the download link
			//nodeList = results.getElementsByTagName('installable');
			//installable = nodeList[0].childNodes[0].nodeValue;
		}
		// if there are no suite elements check for the error elements
		else if (results.getElementsByTagName('error').length != 0)
		{
			nodeList = results.getElementsByTagName('error');
			if (nodeList[0].nodeName == "error")
			{
				data = nodeList[0].getAttribute("id");
				if (data != null || data != "")
				{
					if ( data == "LS01" )
					{
						error = "System Error: Error Code (01)<br/><br/>There was a problem connecting to the server.<br/><br/>Please contact customer support.";
					}
					else if (data == "LS02" )
					{
						error = "System Error: Error Code (02)<br/><br/>There was no response from the server.<br/><br/>Please contact customer support.";						
					}
					else
					{
						error = "System Error: Error Code ("+data+")<br/><br/>An unknown error has occurred.<br/><br/>Please contact customer support.";
					}
				}
				else
				{
					error = "System Error: Error Code (Unknown)<br/><br/>An unknown error has occurred.<br/><br/>Please contact customer support.";
				}
			}
		}
		// If there are no elements at all then create a error message
		else
		{
			error = "System Error: <br/><br/>Download configuration error.<br/><br/>Please contact customer support."
		}
	}
	// Process the XML data received after selecting a device.
	else if (type == "device")
	{
		processDeviceXML(results);
	}
}

function processDeviceXML(results)
{
	var i 						= 0;			// Counter
	var j						= 0;			// Counter
	var g						= 0;			// Counter
	var d						= 0;			// Counter
	var h						= 0;			// Counter
	var ArrayLength				= 0;			// The length apps array
	
	var install 				= false;		// Installable value
	var guidFound 				= false;		// if the guid is found in the array
	var isDisplayName			= false;		// check if I have the correct xml data.
	
	var dependsValue			= "";			// The <depends> 	value of the current suite
	var guidValue				= "";			// The <guid> 		value of the current suite
	var suiteType				= "application";// The <suiteType>	value of the current suite
	var suiteTypeFound			= false;
	var displayName				= "";			
	var displayCat				= "";
	var installable				= false;
	
	var availableGameList 		= "";			// List of games support by the selected device
	var notAvaiableGamesList 	= "";			// List of games not supported by the selected device
	
	var suitesNodeList			= null;			// DOM Node - Gets the suites
	var componentsNodeList		= null;			// DOM Node - Gets component XML data from the current suite
	var dependcyNodeList		= null;			// DOM Node - Gets depends guid from the current suite
	var guidNodeList			= null;			// DOM Node - Gets guid XML data from each suite
	var hidesNodeList			= null;
	var displayCatNodeList		= null;
	var suiteTypeNodeList		= null;			// DOM Node - Gets guid XML data from each suite
	
	var hidesArray				= new Array;

	var tempDisGroup = "";
	var tempDisHeader = "";
	var strIndex = null;

	// Set the DOM Node Lists
	suitesNodeList 		= results.getElementsByTagName('suite');
	guidNodeList		= results.getElementsByTagName('guid');
	dependsNodeList		= results.getElementsByTagName('depends');
	hidesNodeList		= results.getElementsByTagName('hides');
		
	// Collect all the guid element data from each suite and store it in the array
	for(h; h < hidesNodeList.length; h++)
	{
		hidesArray[h] = hidesNodeList[h].childNodes[0].nodeValue;
	}

	if (suitesNodeList.length !=0)	// See if there are suites for the selected device
	{
		for (i;i<suitesNodeList.length;i++)	// Loop through the suites
		{
			if(suitesNodeList[i].hasChildNodes())	// Check the current suite for child nodes
			{
				var currentDisplayNameNodeList  = suitesNodeList[i].getElementsByTagName('displayName')				
				var currentComponentsNodeList 	= suitesNodeList[i].getElementsByTagName('component')
				var currentGuidNodeList			= suitesNodeList[i].getElementsByTagName('guid')		// Create a list of the depends for the current suite
				var currentDisplayCatNodeList	= suitesNodeList[i].getElementsByTagName('displayCategory');
				var currentSuiteTypeNodeList	= suitesNodeList[i].getElementsByTagName('suiteType');
				var currentInstallNodeList		= suitesNodeList[i].getElementsByTagName('installable');

				if (currentDisplayNameNodeList.length!=0)
				{
					displayName = currentDisplayNameNodeList[0].childNodes[0].nodeValue;
				}
				if (currentGuidNodeList.length!=0)
				{
					guidValue = currentGuidNodeList[0].childNodes[0].nodeValue;
				}
				if (currentDisplayCatNodeList.length!=0)
				{
					displayCat	= currentDisplayCatNodeList[0].childNodes[0].nodeValue;
				}
				if (currentInstallNodeList.length!=0)
				{
					installable	= Boolean(currentInstallNodeList[0].childNodes[0].nodeValue);
				}
				if (currentSuiteTypeNodeList.length!=0)
				{
					// Any suiteType other than "web" overrides the "web" suiteType.
					if ( !suiteTypeFound || (suiteType == "web"))
					{
						suiteType = currentSuiteTypeNodeList[0].childNodes[0].nodeValue;
						suiteTypeFound = true;
					}
					
					if (suiteType == "web")
					{
						enableTemplate = true;
					}
				}
				
				if (displayName != "")
				{
					guidFound = guidSearch(guidValue, hidesArray);
					if (guidFound == false)
					{
						if (currentComponentsNodeList.length !=0)	// Check to see if there are componenets
						{
							if (installable == true)
							{
								createGrouping(displayCat, displayName)
							}
						}
						else
						{
							createGrouping(displayCat, displayName)
						}
					}
					else
					{
						guidFound = false
					}
				}
			}
		}
		displayMessage(suiteType);
	}
	else
	{
		displayMessage("")
	}
}
function createGrouping(dc, dn)
{
	var ArrayLength 	= 0;
	var tempDisGroup	= "";
	var tempDisHeader	= "";
	if (dc != "")
	{
		tempDisGroup = getAppGroup(dc);
		tempDisHeader = getAppHeader(dc);
	}
	ArrayLength = AppListArray.length
	if (ArrayLength == 0)
	{
		AppListArray[ArrayLength] = {"AppName":dn, "AppGroup":tempDisGroup, "AppHeader":tempDisHeader} // Added it to the available games list
	}
	else
	{
		AppListArray[ArrayLength] = {"AppName":dn, "AppGroup":tempDisGroup, "AppHeader":tempDisHeader} // Added it to the available games list
		ArrayLength++;
	}

}
function guidSearch(guidValue, hidesArray)
{
	var result = false
	for (d=0; d < hidesArray.length; d++)
	{
		if (guidValue == hidesArray[d])
		{
			result = true
		}
	}
	return result
}
function getAppGroup(dc)
{
	var index
	var group
	index = dc.indexOf("|");
	if (index != -1)
	{
		group = dc.substring(0, index);
	}
	return group
}
function getAppHeader(dc)
{
	var index
	var header
	index = dc.indexOf("|");
	if (index != -1)
	{
		header = dc.substring(index+1, dc.length); 
	}	
	return header
}
function sortByGroup(a, b) 
{
    var x = a.AppGroup.toLowerCase();
    var y = b.AppGroup.toLowerCase();
    return ((x < y) ? -1 : ((x > y) ? 1 : 0));
}

function parseTemplate(template)
{
	var OTAUrl, tmpUrl, loc;
	if ( enableTemplate && (typeof(template) == "string"))
	{
		// split the URL for easier display
		OTAUrl = OTAexURL;
		if (OTAexURL.length > 35)
		{
			tempUrl = OTAexURL.slice(0,34);
			loc = tempUrl.lastIndexOf("/");
			if (loc > 0)
			{
				OTAUrl = OTAexURL.slice(0,loc) + "<br>" + OTAexURL.slice(loc,OTAexURL.length);
			}
			else
			{
				OTAUrl = tempUrl + "<br>" + OTAexURL.slice(34,OTAexURL.length);
			}
		}
		
		template = template.replace(/\$Property\$/g,Property);
		template = template.replace(/\$URL\$/g,OTAUrl);
	}
	return template;
}


function displayMessage(suiteType)
{
	var response 					= "";
	var appList						= "";
	var appHeader					= "";
	var tempAvailableGamesList 		= "";
	var tempNotAvailableGamesList 	= "";
	var currentAppHeader			= "";
	var tempAppHeader				= "";
	var error						= "";
	var index						= 0;
	var startSliceIndex				= 0;
	var endSliceIndex				= 0;
	var containerIndex				= 0;
	
	var arrangedArray				= new Array();
	var containerArray				= new Array();

	var currentAppGroup = "";
	var tempAppGroup = "";

	if (OTAexURL == "" || linkFile == "" || DownloadStamp == "" || linkText == "")
	{
		error = "System Error: <br/><br/>Download configuration error.<br/><br/>Please contact customer support."
	}
	if (error == "" || error == null)
	{
		// Check the number of apps current in the list. If there is only 1 element then display it.
		if (AppListArray.length == 1)
		{
			if (AppListArray[0].AppHeader != "")
			{
				appHeader = "<span id=\"AppHeader\">"+AppListArray[0].AppHeader+"</span><br/><br/>";
			}
			appList = appHeader+"&#8226; "+parseTemplate(AppListArray[0].AppName)+"<br/>";
		}
		else if (AppListArray.length != 0)
		{
			AppListArray.sort(sortByGroup); 							// Sort the app list by group number
			currentAppGroup = AppListArray[0].AppGroup;					// Initalize the current app group 
			for (i=0;i<AppListArray.length;i++)							// Loop through the app list 
			{
				if (currentAppGroup == AppListArray[i].AppGroup)
				{
					arrangedArray[index] = AppListArray[i];  			// Added to the arraged array if they're the same
				}
				else
				{
					containerArray[containerIndex] = arrangedArray;  	// Added the arraranged array to the container array
					containerIndex++;								
					arrangedArray = new Array();						// Start a new arranged array to store the group of apps
					index = 0;											// Be sure to set the index to zero so you don't over write data
					arrangedArray[index] = AppListArray[i];				// now app the current app list group to the arranged array
				}
				currentAppGroup = AppListArray[i].AppGroup				// set the current app group
				index++;												// increase the index of the arranged array
			}
			containerArray[containerIndex] = arrangedArray;				// The last group of apps is now added to the container array
		}
		
		var temp;
		var result = "";
		if (containerArray.length !=0)
		{
			for (var c = 0;c < containerArray.length; c++)
			{
				temp = containerArray[c];
				if (temp.length != 0)
				{
					for (i=0;i<temp.length;i++)
					{
						//result += temp[i].AppGroup + ", " + temp[i].AppHeader + ", " + temp[i].AppName+"\n";
						if (temp[i].AppHeader == "")
						{
							appList += "&#8226; "+parseTemplate(temp[i].AppName)+"<br/>";
						}
						else
						{
							if (appHeader != temp[i].AppHeader)
							{
								appList += "<br/>"+temp[i].AppHeader +"<br/><br/>"
								appList+= "&#8226; "+parseTemplate(temp[i].AppName)+"<br/>";
							}
							else
							{
								appList+= "&#8226; "+parseTemplate(temp[i].AppName)+"<br/>";							
							}
							appHeader = temp[i].AppHeader;
						}
					}
				}
			}
		}
		
		if (suiteType == "application")
		{
			if (global_installType == "cradled" )
			{
				response = JS_DEVICE_IS_PDA + "<br/><br/>";
				response += appList;
				response += "<br/>" + JS_PROCEED_TO_STEP2;
				response += "<br/><br/><a href=\""+LaunchURL+"/redirect.jsp?Nav=pda&lang=" + lang + "&brand="+mySelectedBrand+"&model="+mySelectedModel+"\"";
				response += "onmouseover=\"changeImages(\'LS_step2\', \'" + langDir + "/images/LS_step2-over.jpg\'); return true;\""
				response += "onmouseout=\"changeImages(\'LS_step2\', \'" + langDir + "/images/LS_step2.jpg\'); return true;\"";
				response += "onmousedown=\"changeImages(\'LS_step2\', \'" + langDir + "/images/LS_step2-over.jpg\'); return true;\"";
				response += "onmouseup=\"changeImages(\'LS_step2\', \'" + langDir + "/images/LS_step2-over.jpg\'); return true;\">"
				response += "<img name=\"LS_step2\" src=\"" + langDir + "/images/LS_step2.jpg\" width=\"94\" height=\"49\" border=\"0\" alt=\"\"></a>";
			}
			else if (global_installType == "sms" )
			{
				response = JS_DEVICE_IS_PHONE + "<br/><br/>";
				response += appList;
				response += "<br/><br/>" + JS_PROCEED_TO_STEP2;
				response += "<br/><br/><a href=\""+LaunchURL+"/redirect.jsp?Nav=phone&lang=" + lang + "\"";
				response += "onmouseover=\"changeImages(\'LS_step2\', \'" + langDir + "/images/LS_step2-over.jpg\'); return true;\""
				response += "onmouseout=\"changeImages(\'LS_step2\', \'" + langDir + "/images/LS_step2.jpg\'); return true;\"";
				response += "onmousedown=\"changeImages(\'LS_step2\', \'" + langDir + "/images/LS_step2-over.jpg\'); return true;\"";
				response += "onmouseup=\"changeImages(\'LS_step2\', \'" + langDir + "/images/LS_step2-over.jpg\'); return true;\">";
				response += "<img name=\"LS_step2\" src=\"" + langDir + "/images/LS_step2.jpg\" width=\"94\" height=\"49\" border=\"0\" alt=\"\"></a>";
			}

		}
		if (suiteType == "web")
		{
			if (global_installType == "cradled" )
			{
				response = JS_DEVICE_IS_PDA + "<br/><br/>";
				response += appList;
			}
			else if (global_installType == "sms" )
			{
				response = JS_DEVICE_IS_PHONE + "<br/><br/>";
				response += appList;
			}
			else if (global_installType == "web" )
			{
				response = JS_DEVICE_IS_WEB + "<br/><br/>";
				response += appList;
				response += "<br/><a href=\"Javascript:goHome();\">" + JS_BACK_TO +" "+Property+"</a>";
			}
		}
		if (suiteType == "none")
		{
			if (global_installType == "cradled" )
			{
				response = JS_DEVICE_IS_PDA + "<br/><br/>";
				response += appList;
				response += "<br/><a href=\"Javascript:goHome();\">" + JS_BACK_TO +" "+Property+"</a>";
			}
			else if (global_installType == "sms" )
			{
				response = JS_DEVICE_IS_PHONE + "<br/><br/>";
				response += appList;
				response += "<br/><a href=\"Javascript:goHome();\">" + JS_BACK_TO +" "+Property+"</a>";
			}
			else if (global_installType == "web" )
			{
				response = JS_DEVICE_IS_WEB + "<br/><br/>";
				response += appList;
				response += "<br/><a href=\"Javascript:goHome();\">" + JS_BACK_TO +" "+Property+"</a>";
			}
		}
		AppListArray = new Array();
	}
	else
	{
		response = error
	}
	if(global_installType != "" && suiteType == "")
	{
		var response = "";
		if (global_installType == "sms")
		{
			response = JS_DEVICE_IS_PHONE + "<br/>";
		}
		else if (global_installType == "cradled")
		{
			response = JS_DEVICE_IS_PDA + "<br/>";
		}
		response += "<br/>" + JS_DEVICE_UNSUPPORTED + "<br/><br/>" + JS_PLEASE_UPGRADE;
		response += "<br/><br/><a href=\"Javascript:goHome();\">" + JS_BACK_TO + " "+Property+"</a>";			
	}
	document.getElementById("deviceDLMessage").innerHTML = response;
}

function getHTTPObject() 
{
	var xmlhttp;
	try {
		xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
		IE = true;
	} 
	catch (e) {
		try {
			xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
			IE = true;
		} 
		catch (E) {
			xmlhttp = false;
		}
	}
	if (!xmlhttp && typeof XMLHttpRequest != 'undefined') 
	{
		try {
			xmlhttp = new XMLHttpRequest();
		} 
		catch (e) {
			xmlhttp = false;
		}
	}
	return xmlhttp;
}

// Display Brands for the customer support form
function getSupportBrands()
{
	var x;
	var BrandDivContent;
	var previousBrand
	previousBrand = "";
	x = bindings.length;

	BrandDivContent = "<select name='brand' onChange='getSupportModels();' style='width:150px; overflow:hidden'><option value=''>" + JS_SELECT_BRAND + "</option>";
	if (x != 0)
	{	
		for (i=0; i<x; i++)
		{
			if (previousBrand != bindings[i].brand)
			{
				BrandDivContent = BrandDivContent + "<option value='"+bindings[i].brand+"'>"+bindings[i].brand+"</option>";
				previousBrand = bindings[i].brand;
			}
			
		}
	}
	BrandDivContent = BrandDivContent + "</select>";
	document.getElementById("BrandDisplay").innerHTML = BrandDivContent;
}
// Display Models for the customer support form
function getSupportModels()
{
	var SelectedBrand = ""
	var ModelDivContent = "";
	var x;
	x = bindings.length;
	SelectedBrand = document.Device.brand.value
	if (x != 0)
	{	
		if (SelectedBrand != "")
		{
			ModelDivContent = "<select name='modelselect' style='width:150px; overflow:hidden'>";
			ModelDivContent = ModelDivContent+"<option value=''>" + JS_SELECT_MODEL + "</option>"
			ModelDivContent = ModelDivContent+"<option value='viewall'>" + JS_DO_NOT_KNOW + "</option>"
			
			for (i=0; i<x; i++)
			{
				if (SelectedBrand == bindings[i].brand)
				{
					ModelDivContent = ModelDivContent + "<option value='"+bindings[i].model+"'>"+bindings[i].model+"</option>";
				}
			}
			ModelDivContent = ModelDivContent+"</select>";
			document.getElementById("ModelDisplay").innerHTML = ModelDivContent;
		}
	}
}

function getBrands()
{
	var x;
	var BrandDivContent;
	var previousBrand
	previousBrand = "";
	x = bindings.length;
	BrandDivContent = "<select name='brand' onChange='getModels();' style='width:150px; overflow:hidden'><option value=''>" + JS_SELECT_BRAND + "</option>";
	if (x != 0)
	{	
		for (i=0; i<x; i++)
		{
			if (previousBrand != bindings[i].brand)
			{
				BrandDivContent = BrandDivContent + "<option value='"+bindings[i].brand+"'>"+bindings[i].brand+"</option>";
				previousBrand = bindings[i].brand
			}
		}
	}
	BrandDivContent = BrandDivContent + "</select>";
	document.getElementById("BrandDisplay").innerHTML = BrandDivContent;
}

function getModels()
{
	var SelectedBrand = ""
	var ModelDivContent = "";
	var x;
	x = bindings.length;
	SelectedBrand = document.Device.brand.value
	if (SelectedBrand != "")
	{
		ModelDivContent = "<select name='model' onChange='displayDetails();' style='width:150px; overflow:hidden'>";
		ModelDivContent = ModelDivContent+"<option value=''>" + JS_SELECT_MODEL + "</option>"
		ModelDivContent = ModelDivContent+"<option value='viewall'>" + JS_DO_NOT_KNOW + "</option>"
		
		for (i=0; i<x; i++)
		{
			if (SelectedBrand == bindings[i].brand)
			{
				ModelDivContent = ModelDivContent + "<option value='"+bindings[i].model+"'>"+bindings[i].model+"</option>";
			}
		}
		ModelDivContent = ModelDivContent+"</select>";
		document.getElementById("ModelDisplay").innerHTML = ModelDivContent;
	}
}

function displayDetails()
{
	var SelectedBrand = ""
	var SelectedModel = ""
	var displayDivContent = "";
	var x;
	var i;
	var tableCounter = 0

	x = bindings.length;	
	SelectedBrand = document.Device.brand.value
	SelectedModel = document.Device.model.value

	if (SelectedBrand != "")
	{
		if (SelectedModel != "")
		{
			if (SelectedModel == "viewall")
			{
				displayDivContent = "<br/><table align=\"center\" width=\"300\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">";
				for (i=0; i<x; i++)
				{
 					if (SelectedBrand == bindings[i].brand)
					{
					
						if (tableCounter == 0)
						{
							displayDivContent = displayDivContent+"<tr>";
						}
						displayDivContent = displayDivContent+"<td align=\"center\" width=\"200\">";
						displayDivContent = displayDivContent+"<a href='#' OnClick=\"getDeviceDetails('"+SelectedBrand+"', '"+bindings[i].model+"', '"+bindings[i].image+"', '"+bindings[i].ua+"', '"+bindings[i].install+"'); \">";
						displayDivContent = displayDivContent+"<img src='"+OTAexURL+"/image?imageName="+bindings[i].image+"' border='0' /></a>";
						displayDivContent = displayDivContent+"<a href='#' OnClick=\"getDeviceDetails('"+SelectedBrand+"', '"+bindings[i].model+"', '"+bindings[i].image+"', '"+bindings[i].ua+"', '"+bindings[i].install+"'); \">";
						displayDivContent = displayDivContent+"<br>"+bindings[i].brand+" "+bindings[i].model;
						displayDivContent = displayDivContent+"</a><br/><br/>";
						displayDivContent = displayDivContent+"</td>";
						tableCounter++;
						if (tableCounter == 2)
						{
							displayDivContent = displayDivContent+"</tr>"
							tableCounter = 0;
						}
					}
				}
				displayDivContent = displayDivContent+"</table><br/><br/>&nbsp;";
				document.getElementById("deviceInformation").innerHTML = displayDivContent;
			}
			else
			{	
				for (i=0; i<x; i++)
				{	
					if (SelectedBrand == bindings[i].brand)
					{
						if (SelectedModel == bindings[i].model)
						{
							getDeviceDetails(SelectedBrand, SelectedModel, bindings[i].image, bindings[i].ua, bindings[i].install)
						}
					}
				}
			}
		}
		else
		{
			document.getElementById("deviceInformation").innerHTML = "<br>" + JS_ERR_SELECT_MODEL + "<br>";
		}
	}
	else
	{
		document.getElementById("deviceInformation").innerHTML = "<br>" + JS_ERR_SELECT_BRAND + "<br>";
	}	
}

function getDeviceDetails(brand, model_, image, ua, install)
{
	var url = "";
	var urlSms = "";
  	var CurrentSeletedmodel = document.Device.model.value;
	
	global_installType = install;
	
	if (CurrentSeletedmodel != model_)
	{
		var modelListIndex = document.Device.model.length;
	  	for (i=0;i<modelListIndex;i++)
	  	{
	  		if (model_ == document.Device.model[i].value)
			{
	 			document.Device.model[i].selected = true;
			}
	 	}  
  	}
	if (global_installType == "cradled")
	{
		popDisplay("download",brand, model_, image, ua);
	}
	else if (global_installType == "sms")
	{
		popDisplay("sms",brand, model_, image, ua);
	}
	else if (global_installType == "web")
	{
		popDisplay("web",brand, model_, image, ua);
	}
	else
	{
		popDisplay("none",brand, model_, image, ua);
	}
}

function popDisplay(msg, brand, model_, image, ua)
{
	var message = "";
	var supported = "";
	var displayType = "";
	
	mySelectedBrand = brand;
	mySelectedModel = model_;

	document.getElementById("deviceInformation").innerHTML = "";
	if (msg == "download")
	{
		message =  "<div id='deviceDLMessage'>" + JS_LOADING + "<br/><br/><img src='images/status.gif'/></div>";
		sendRequest("device", ua)
	}
	else if (msg == "sms")
	{
		message = "<div id='deviceDLMessage'>" + JS_LOADING + "<br/><br/><img src='images/status.gif'/></div>";
		sendRequest("device", ua)
	}
	else if (msg == "web")
	{
		message = "<div id='deviceDLMessage'>" + JS_LOADING + "<br/><br/><img src='images/status.gif'/></div>";
		sendRequest("device", ua)
	}
	if (msg == "none")
	{
		message = "<div id='deviceDLMessage'>" + JS_DEVICE_UNSUPPORTED + "<br/><br/>" + JS_PLEASE_UPGRADE + "<br/><br/><a href=\"Javascript:goHome();\">" + JS_BACK_TO + " "+Property+"</a></div>";
	}
	DeviceDisplayDiv = "<div id='deviceImgDisplay'><img src='"+OTAexURL+"/image?imageName="+image+"'><br/><br/>"+brand+" "+model_+"</div>";
	DeviceDisplayDiv = DeviceDisplayDiv + message;
	document.getElementById("deviceInformation").innerHTML=DeviceDisplayDiv+"<br/><br/>&nbsp;";
}