<!-- Copyright (c) 2004 by Cisco Systems, Inc. -->
// smartports.js - Will create the frontPanel for 2950 devices.
// <include a list of SKUs here>

function createDevice(deviceType, uiPortDataArr) {
	var device = null;
   //	alert ("deviceType is:" + deviceType);
   	if(deviceType == null)
		return device;
	if(deviceType == "WS-C2970G-24TS-E") {
		device = new WSC2970G24TSE(uiPortDataArr);
	} else if(deviceType == "WS-C2970G-24T-E") {
		device = new WSC2970G24TE(uiPortDataArr);
	} 
}

/*
 *  This is unit tested.
 */

function WSC2970G24TE(uiPortDataArr) {

	portCount = uiPortDataArr.length;
	document.writeln('\
				  <tr><td colspan= "25" height="3" bgcolor="#f4f4f4">')
   	document.writeln('\
				  </td></tr>')	  
	document.writeln('\
	  						<tr>')
	writeSpaceCell();
	for (var portId = 0; portId < portCount ; portId++) {
  		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(); writeSpaceCell();
	document.writeln('\
			  </tr>')
	document.writeln('\
			  <tr><td colspan= "25" height="5" bgcolor="#f4f4f4">')
	document.writeln('\
			  </td></tr>')				  				  
   	document.writeln('\
			  <tr>')
	writeSpaceCell();
							  
	for (var portId = 0; portId < portCount ; portId++) {
		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(); writeSpaceCell();                             
	document.writeln('\
		  </tr>')
	document.writeln('\
			  <tr><td colspan= "25" height="5" bgcolor="#f4f4f4">')
	document.writeln('\
			  </td></tr>')			
}


/*
 *  This is unit tested.
 */

function WSC2970G24TSE(uiPortDataArr) {

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


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

function isExtVlanSupported() {
	return true;
}

function getMaxVlans() {
  	return 250;	
}
