<!-- Copyright (c) 2004-2005 by Cisco Systems, Inc. -->
// smartports.js - Will create the frontPanel for Halberd devices.
// <include a list of SKUs here>
// Halberd 1 - OS-371098HP00-24T-E or 371098-001
// Halberd 2 - WS-CBS3020-HPQ

function createDevice(deviceType, uiPortDataArr) {
	var device = null;
	if(deviceType.indexOf("OS-371098HP00-24T-E") != -1 || deviceType.indexOf("371098-001") != -1) {
   		device = new OSCHGESM24TE(uiPortDataArr);
	}
	else if(deviceType.indexOf("WS-CBS3020-HPQ") != -1) {
		device = new WSCBS3020HPQ(uiPortDataArr);
	}
}

function OSCHGESM24TE(uiPortDataArr) {
	portCount = uiPortDataArr.length;
	for (var portId = 0; portId < 18; portId++)
		uiPortDataArr[portId].macro = MACRO_NULL;
	
	document.writeln('<tr><td colspan= "18" height="3" bgcolor="#f4f4f4"></td></tr>');
	document.writeln('<tr>')
	writeSpaceCell();writeSpaceCell();writeSpaceCell();writeSpaceCell();
	
	for (var portId = portCount-1; portId >= portCount-2; portId--) {
		document.writeln('\
			<td align="center" width="21" bgcolor="#f4f4f4"><font style="font-size:9px"\
			face="Helvetica">', getPortLabel(uiPortDataArr[portId].portName), '<br>\
			</font><a href="javascript:void(0)"\
			onMouseOver="showPortInfo(\'', portId, '\', \'', uiPortDataArr[portId].portName, '\', \'', uiPortDataArr[portId].vlan, '\')"\
			onMouseOut="resetPort(); hideLayerWrapper(2000); raise(\'', portId, '\')"\
			onMouseDown="lower(\'', portId, '\', \'', uiPortDataArr[portId].macro, '\')"\
			onMouseUp="window.status=\'\'; return true"\
			onClick="toggle(\'', portId, '\', \'', uiPortDataArr[portId].macro, '\'); return false"><img\
			src="', cellImages[0][uiPortDataArr[portId].macro].src, '"\
			border="0"\
			width="21" height="21" name="cell', '_', portId, '"></a></td>');
		document.writeln('<td width="5" height="5" bgcolor="#f4f4f4"></td>');
	}
	writeSpaceCell(); writeSpaceCell(); writeSpaceCell(); writeSpaceCell();
	
	for (var portId = portCount-3; portId >= portCount-4; portId--) {
		document.writeln('\
			<td align="center" width="21" bgcolor="#f4f4f4"><font style="font-size:9px"\
			face="Helvetica">', getPortLabel(uiPortDataArr[portId].portName), '<br>\
			</font><a href="javascript:void(0)"\
			onMouseOver="showPortInfo(\'', portId, '\', \'', uiPortDataArr[portId].portName, '\', \'', uiPortDataArr[portId].vlan, '\')"\
			onMouseOut="resetPort(); hideLayerWrapper(2000); raise(\'', portId, '\')"\
			onMouseDown="lower(\'', portId, '\', \'', uiPortDataArr[portId].macro, '\')"\
			onMouseUp="window.status=\'\'; return true"\
			onClick="toggle(\'', portId, '\', \'', uiPortDataArr[portId].macro, '\'); return false"><img\
			src="', cellImages[0][uiPortDataArr[portId].macro].src, '"\
			border="0"\
			width="21" height="21" name="cell', '_', portId, '"></a></td>');
	}
	
	writeSpaceCell(); writeSpaceCell();writeSpaceCell();writeSpaceCell();
	document.writeln('</tr>');
	
	document.writeln('<tr><td colspan= "18" height="5" bgcolor="#f4f4f4"></td></tr>');
	
	document.writeln('<tr>');
	writeSpaceCell();writeSpaceCell();writeSpaceCell();writeSpaceCell();
	document.writeln('<td colspan="8" bgcolor="#f4f4f4"></td>');
	
	for (var portId = portCount-5; portId >= portCount-6 ; portId--) {
		document.writeln('\
			<td align="center" width="21" bgcolor="#f4f4f4"><a href="javascript:void(0)"\
			onMouseOver="showPortInfo(\'', portId, '\', \'', uiPortDataArr[portId].portName, '\', \'', uiPortDataArr[portId].vlan, '\')"\
			onMouseOut="resetPort(); hideLayerWrapper(2000); raise(\'', portId, '\')"\
			onMouseDown="lower(\'', portId, '\', \'', uiPortDataArr[portId].macro, '\')"\
			onMouseUp="window.status=\'\'; return true"\
			onClick="toggle(\'', portId, '\', \'', uiPortDataArr[portId].macro, '\'); return false"><img\
			src="', cellImages[0][uiPortDataArr[portId].macro].src, '"\
			border="0"\
			width="21" height="21" name="cell', '_', portId, '"></a><br>\
			<font style="font-size:9px" face="Helvetica">', getPortLabel(uiPortDataArr[portId].portName), '\
			</td>');
	}
	writeSpaceCell();writeSpaceCell();writeSpaceCell();writeSpaceCell();
	document.writeln('</tr>')
	document.writeln('<tr><td colspan= "18" height="5" bgcolor="#f4f4f4"></td></tr>')		
}

function WSCBS3020HPQ(uiPortDataArr) {
	portCount = uiPortDataArr.length;
	for (var portId = 0; portId < 16; portId++)
		uiPortDataArr[portId].macro = MACRO_NULL;
	
	document.writeln('<tr><td colspan= "12" height="3" bgcolor="#f4f4f4"></td></tr>');
	document.writeln('<tr>')
	writeSpaceCell();writeSpaceCell();writeSpaceCell();writeSpaceCell();
	
	for (var portId = 16; portId < portCount; portId++) {
		if(portId % 2 == 0) {
			//condition to check if last two ports in halberd2 are acting as - internal or external, if internal hide the port
			if((portId == 22 || portId == 23) && uiPortDataArr[portId].macro == MACRO_NULL) {
				document.writeln('<td align="center" bgcolor="#f4f4f4"></td>');
			}
			else {
				document.writeln('\
					<td align="center" width="21" bgcolor="#f4f4f4"><font style="font-size:9px"\
					face="Helvetica">', getPortLabel(uiPortDataArr[portId].portName), '<br>\
					</font><a href="javascript:void(0)"\
					onMouseOver="showPortInfo(\'', portId, '\', \'', uiPortDataArr[portId].portName, '\', \'', uiPortDataArr[portId].vlan, '\')"\
					onMouseOut="resetPort(); hideLayerWrapper(2000); raise(\'', portId, '\')"\
					onMouseDown="lower(\'', portId, '\', \'', uiPortDataArr[portId].macro, '\')"\
					onMouseUp="window.status=\'\'; return true"\
					onClick="toggle(\'', portId, '\', \'', uiPortDataArr[portId].macro, '\'); return false"><img\
					src="', cellImages[0][uiPortDataArr[portId].macro].src, '"\
					border="0"\
					width="21" height="21" name="cell', '_', portId, '"></a></td>');
			}
		}
	}
	
	writeSpaceCell(); writeSpaceCell();writeSpaceCell();writeSpaceCell();
	document.writeln('</tr>');
	
	document.writeln('<tr><td colspan= "12" height="5" bgcolor="#f4f4f4"></td></tr>');
	
	document.writeln('<tr>');
	writeSpaceCell();writeSpaceCell();writeSpaceCell();writeSpaceCell();
	
	for (var portId = 16; portId < portCount ; portId++) {
		if(portId % 2 != 0) {
			if((portId == 22 || portId == 23) && uiPortDataArr[portId].macro == MACRO_NULL) {
				document.writeln('<td align="center" bgcolor="#f4f4f4"></td>');
			}
			else {
				document.writeln('\
					<td align="center" width="21" bgcolor="#f4f4f4"><a href="javascript:void(0)"\
					onMouseOver="showPortInfo(\'', portId, '\', \'', uiPortDataArr[portId].portName, '\', \'', uiPortDataArr[portId].vlan, '\')"\
					onMouseOut="resetPort(); hideLayerWrapper(2000); raise(\'', portId, '\')"\
					onMouseDown="lower(\'', portId, '\', \'', uiPortDataArr[portId].macro, '\')"\
					onMouseUp="window.status=\'\'; return true"\
					onClick="toggle(\'', portId, '\', \'', uiPortDataArr[portId].macro, '\'); return false"><img\
					src="', cellImages[0][uiPortDataArr[portId].macro].src, '"\
					border="0"\
					width="21" height="21" name="cell', '_', portId, '"></a><br>\
					<font style="font-size:9px" face="Helvetica">', getPortLabel(uiPortDataArr[portId].portName), '\
					</td>');
			}
		}
	}
	writeSpaceCell();writeSpaceCell();writeSpaceCell();writeSpaceCell();
	document.writeln('</tr>')
	document.writeln('<tr><td colspan= "12" height="5" bgcolor="#f4f4f4"></td></tr>')
}

function getPortLabel(intName) {
	var intNumber = intName.substring(intName.indexOf('/')+1);
	return parseInt(intNumber)
}

function isExtVlanSupported() {
	return true;
}

function getMaxVlans() {
      return 250;
}
