function fillCategory(){ 
 // this function is used to fill the category list on load
addOption(document.drop_list.Category, "ASCII", "ASCII", "");
addOption(document.drop_list.Category, "Modbus TCP Server", "Modbus TCP Server", "");
addOption(document.drop_list.Category, "Modbus TCP Client", "Modbus TCP Client", "");
addOption(document.drop_list.Category, "Raw TCP", "Raw TCP", "");
addOption(document.drop_list.Category, "Compact", "Compact", "");
addOption(document.drop_list.Category, "Control", "Control", "");
addOption(document.drop_list.Category, "PLC", "PLC", "");
addOption(document.drop_list.Category, "AS 400", "AS 400", "");
addOption(document.drop_list.Category, "PLC5E", "PLC5E", "");
addOption(document.drop_list.Category, "SLC5/05", "SLC5/05", "");
addOption(document.drop_list.Category, "MicroLogix", "MicroLogix", "");
addOption(document.drop_list.Category, "FlexLogix", "FlexLogix", "");
addOption(document.drop_list.Category, "BACnet", "BACnet", "");
addOption(document.drop_list.Category, "Modbus RTU Master", "Modbus RTU Master", "");
addOption(document.drop_list.Category, "Modbus RTU Slave", "Modbus RTU Slave", "");
addOption(document.drop_list.Category, "Ethernet/IP Tag Client", "Ethernet/IP Tag Client", "");
addOption(document.drop_list.Category, "Ethernet/IP Client", "Ethernet/IP Client", "");
addOption(document.drop_list.Category, "Ethernet TCP", "Ethernet TCP", "");
addOption(document.drop_list.Category, "DeviceNet Slave", "DeviceNet Slave", "");
}

function SelectSubCat(){
// ON selection of category this function will work

removeAllOptions(document.drop_list.SubCat);
addOption(document.drop_list.SubCat, "", "==Choose One==", "");

if(document.drop_list.Category.value == 'ASCII'){
addOption(document.drop_list.SubCat,"PLC", "PLC");
addOption(document.drop_list.SubCat,"Compact", "Compact");
addOption(document.drop_list.SubCat,"Control", "Control");
addOption(document.drop_list.SubCat,"FlexLogix", "FlexLogix");
addOption(document.drop_list.SubCat,"SLC5/05", "SLC5/05");
addOption(document.drop_list.SubCat,"PLC-5", "PLC-5");
addOption(document.drop_list.SubCat,"Modbus TCP Server", "Modbus TCP Server");
addOption(document.drop_list.SubCat,"Modbus RTU", "Modbus RTU");
addOption(document.drop_list.SubCat,"Ethernet TCP", "Ethernet TCP");
}
if(document.drop_list.Category.value == 'Modbus TCP Server'){
addOption(document.drop_list.SubCat,"BACnet", "BACnet", "");
addOption(document.drop_list.SubCat,"ASCII", "ASCII", "");
}
if(document.drop_list.Category.value == 'Modbus TCP Client'){
addOption(document.drop_list.SubCat,"ASCII", "ASCII");
addOption(document.drop_list.SubCat,"RAW TCP", "RAW TCP");
addOption(document.drop_list.SubCat,"Modbus RTU Slaves", "Modbus RTU Slaves", "");
addOption(document.drop_list.SubCat,"BACnet", "BACnet", "");
}
if(document.drop_list.Category.value == 'Raw TCP'){
addOption(document.drop_list.SubCat,"PLC", "PLC");
addOption(document.drop_list.SubCat,"Modbus TCP Client", "Modbus TCP Client");
}
if(document.drop_list.Category.value == 'Compact'){
addOption(document.drop_list.SubCat,"ASCII", "ASCII");
}
if(document.drop_list.Category.value == 'Control'){
addOption(document.drop_list.SubCat,"ASCII", "ASCII");
}
if(document.drop_list.Category.value == 'PLC'){
addOption(document.drop_list.SubCat,"ASCII", "ASCII");
addOption(document.drop_list.SubCat,"BACnet", "BACnet");
addOption(document.drop_list.SubCat,"Raw TCP", "Raw TCP");
}
if(document.drop_list.Category.value == 'AS 400'){
addOption(document.drop_list.SubCat,"PLC5E", "PLC5E");
addOption(document.drop_list.SubCat,"SLC505", "SLC505");
addOption(document.drop_list.SubCat,"MicroLogix", "MicroLogix");
}
if(document.drop_list.Category.value == 'PLC5E'){
addOption(document.drop_list.SubCat,"DeviceNet Master", "DeviceNet Master");
addOption(document.drop_list.SubCat,"AS 400", "AS 400");
addOption(document.drop_list.SubCat,"ASCII", "ASCII");
}
if(document.drop_list.Category.value == 'SLC5/05'){
addOption(document.drop_list.SubCat,"DeviceNet Master", "DeviceNet Master");
addOption(document.drop_list.SubCat,"ASCII", "ASCII");
addOption(document.drop_list.SubCat,"AS 400", "AS 400");
}
if(document.drop_list.Category.value == 'MicroLogix'){
addOption(document.drop_list.SubCat,"DeviceNet Master", "DeviceNet Master");
addOption(document.drop_list.SubCat,"AS 400", "AS 400");
}
if(document.drop_list.Category.value == 'FlexLogix'){
addOption(document.drop_list.SubCat,"ASCII", "ASCII");
}
if(document.drop_list.Category.value == 'BACnet'){
addOption(document.drop_list.SubCat,"PLC", "PLC");
addOption(document.drop_list.SubCat,"Modbus TCP Server", "Modbus TCP Server");
addOption(document.drop_list.SubCat,"Modbus TCP Client", "Modbus TCP Client");
addOption(document.drop_list.SubCat,"Modbus RTU Slave", "Modbus RTU Slave");
addOption(document.drop_list.SubCat,"Ethernet/IP Tag Client", "Ethernet/IP Tag Client");
}
if(document.drop_list.Category.value == 'Modbus RTU Master'){
addOption(document.drop_list.SubCat,"ASCII", "ASCII");
}
if(document.drop_list.Category.value == 'Modbus RTU Slave'){
addOption(document.drop_list.SubCat,"DeviceNet Master", "DeviceNet Master");
addOption(document.drop_list.SubCat,"BACnet", "BACnet");
}
if(document.drop_list.Category.value == 'Ethernet/IP Tag Client'){
addOption(document.drop_list.SubCat,"BACnet", "BACnet");
addOption(document.drop_list.SubCat,"DeviceNet Slave", "DeviceNet Slave");
}
if(document.drop_list.Category.value == 'Ethernet/IP Client'){
addOption(document.drop_list.SubCat,"DeviceNet Slave", "DeviceNet Slave");
addOption(document.drop_list.SubCat,"Modbus RTU Slave", "Modbus RTU Slave");
}
if(document.drop_list.Category.value == 'Ethernet TCP'){
addOption(document.drop_list.SubCat,"ASCII", "ASCII");
}
if(document.drop_list.Category.value == 'DeviceNet Slave'){
addOption(document.drop_list.SubCat,"Ethernet/IP Tag Client", "Ethernet/IP Tag Client");
addOption(document.drop_list.SubCat,"Ethernet/IP Client", "Ethernet/IP Client");
addOption(document.drop_list.SubCat,"Modbus RTU Slave", "Modbus RTU Slave");
}

}
////////////////// 

function removeAllOptions(selectbox)
{
	var i;
	for(i=selectbox.options.length-1;i>=0;i--)
	{
		//selectbox.options.remove(i);
		selectbox.remove(i);
	}
}


function addOption(selectbox, value, text )
{
	var optn = document.createElement("OPTION");
	optn.text = text;
	optn.value = value;

	selectbox.options.add(optn);
}
