<!-- Copyright (c) 2005 by Cisco Systems, Inc. -->
// smartports.js - will create the Smartports panel for Macchiato devices.
// Macchiato-24-Full-PoE
// Macchiato-24-PoE-4
// Macchiato-24-RPS
// Macchiato-8

function createDevice(deviceType, uiPortDataArr) {
	var device = null;
	
   	if(deviceType == null)
		return device;
	//**** update with actual device IDs
	//Macchiato-24-Full-PoE, Macchiato-24-PoE-4, Macchiato-24-RPS
	if(deviceType == "WS-CE500-24TT" || deviceType == "WS-CE500-24LC" || deviceType == "WS-CE500-24PC") {
		device = new Macchiato24(uiPortDataArr);
	} else if(deviceType == "WS-CE500G-12TC") {
		device = new Macchiato8(uiPortDataArr);
	} 
}

function Macchiato24(uiPortDataArr) {
	portCount = uiPortDataArr.length;
	document.writeln('<tr><td colspan= "26" height="3" bgcolor="#f4f4f4">');
   	document.writeln('</td></tr>')
	document.writeln('<tr>');
	writeSpaceCell();
	for (var portId = 0; portId < portCount -2 ; portId++) {
  		// This is extra space between port 12 and 13
		if( (portId) % 12 == 0) {
			document.writeln('<td nowrap width="10" bgcolor="#f4f4f4">&nbsp;</td>');
		}
		if ( portId % 2 ==0) {
			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();
		document.writeln('<td nowrap width="10" bgcolor="#f4f4f4">&nbsp;</td>');
		document.writeln('<td nowrap width="21" bgcolor="#f4f4f4">&nbsp;</td>');
		document.writeln('<td nowrap width="10" bgcolor="#f4f4f4">&nbsp;</td>');
		document.writeln('<td nowrap width="21" bgcolor="#f4f4f4">&nbsp;</td>');
		
		writeSpaceCell();	writeSpaceCell();	writeSpaceCell();
		document.writeln('<td nowrap width="10" bgcolor="#f4f4f4">&nbsp;</td>');
		document.writeln('</tr>');
		
	    document.writeln('<tr><td colspan= "26" height="5" bgcolor="#f4f4f4"></td></tr>');

	   document.writeln('<tr>');
		writeSpaceCell();
								  
	    for (var portId = 0; portId < portCount-2 ; portId++) {
	  		// This is extra space between port 12 and 13
			if( (portId) % 12 == 0) {
				document.writeln('<td nowrap width="10" bgcolor="#f4f4f4">&nbsp;</td>');
			}
			if ( portId % 2 != 0) {
				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();
		
		for (var portId = portCount - 2; portId < portCount ; portId++) {
			document.writeln('<td nowrap width="10" bgcolor="#f4f4f4">&nbsp;</td>');
			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();
		document.writeln('<td nowrap width="10" bgcolor="#f4f4f4">&nbsp;</td>');
		document.writeln('</tr>');
	    document.writeln('<tr><td colspan= "26" height="5" bgcolor="#f4f4f4"></td></tr>');
}

function Macchiato8(uiPortDataArr) {
	portCount = uiPortDataArr.length;
	document.writeln('<tr><td colspan= "27" height="3" bgcolor="#f4f4f4">');
   	document.writeln('</td></tr>')
	document.writeln('<tr>');
	writeSpaceCell();	writeSpaceCell();	writeSpaceCell();	writeSpaceCell();
	for (var portId = 0; portId < 8 ; 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();
		
		for (var portId = portCount - 4; portId < portCount ; portId++) {
			document.writeln('<td nowrap width="10" bgcolor="#f4f4f4">&nbsp;</td>');
			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= "27" height="5" bgcolor="#f4f4f4"></td></tr>');
}

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

function isExtVlanSupported() {
	return true;
}

function getMaxVlans() {
  	return 250;	
}