// JScript File
 
function OnLoad()
{
    DeviceListLoad();
} 
 
function DeviceListLoad()
{
 var NetworkDeviceList="";
 var DevCount;
 var CheckStatus = false;
				
 for(DevCount=0; DevCount<deviceCount; DevCount++)
 {
    NetworkDeviceList += "<div><div class=\"Network_0\"><input type=\"radio\" name=\"Network_Device\"";
    if(!CheckStatus)
    {
        NetworkDeviceList += " checked=\"checked\"";
        CheckStatus = true;
    }
    NetworkDeviceList += " onclick=\"OnRadioClick(event)\" id=\"" + IPAddress[DevCount] + "\"><b><label>" + ModelName[DevCount] + "</label></b></div>";
    NetworkDeviceList += "<div class=\"Network_1\">IP Address: " + IPAddress[DevCount] + "</div>";
    NetworkDeviceList += "<div class=\"Network_1\">Hardware Address: " + MACAddress[DevCount] + "</div>";
    NetworkDeviceList += "<div class=\"Network_1\">Host Name: " + HostName[DevCount] + "</div></div>";
 }   
    
 if(deviceCount == 0)
 {   
    NetworkDeviceList += "<div><div class=\"Network_0\"><input type=\"radio\" name=\"Network_Device\" checked=\"checked\"";
 }
 else
 {
    NetworkDeviceList += "<div><div class=\"Network_0\"><input type=\"radio\" name=\"Network_Device\"";
 }
 
 NetworkDeviceList += "onclick=\"OnRadioClick(event)\" id=\"DeviceNotInList\"><b><label>" + DeviceNotFoundText + "</label></b></div></div>";   
 DeviceList.innerHTML = NetworkDeviceList;
 Highlight();
 return NetworkDeviceList;
}

function OnRadioClick(event)
{
   Highlight();
   if(event.srcElement.id != "DeviceNotInList")
   {
       for(DevCount=0; DevCount<deviceCount; DevCount++)
       {
        if(event.srcElement.id == IPAddress[DevCount])
        {
           parent.document.getElementById("SelectedDevice").value = IPAddress[DevCount] + "-" + HostName[DevCount] + "-" + MACAddress[DevCount];
        }
       }
   }
   else
   {
        parent.document.getElementById("SelectedDevice").value = event.srcElement.id;
   }    
}

function Highlight() {
	var inputs = DeviceList.getElementsByTagName("div");
	for (var i=0;i<inputs.length;i++) {
		inputs[i].style.backgroundColor = "";
	}
	var inputs = DeviceList.getElementsByTagName("input");
	for (var i=0;i<inputs.length;i++) {
		if(inputs[i].checked)
		{
		  	   inputs[i].parentNode.parentNode.style.backgroundColor = "#9cf";
		}
	}
}
