// adjust size of sections for the RMC70
$('#instructions').css({'width': '180px'});
$('#hardwarecolumn').css({'width': '400px'});
$('#rmcimage tr:eq(0), .slot').css({'height': '178px'});

//Define arrays describing the possible card choices
var arrCardName = new Array(22);
var arrCardImage = new Array(22);
var arrCardDescription = new Array(22);
var arrCardCode = new Array(22);
var arrCardWeight = new Array(22);
var arrCardURL = new Array(22);
var	arrCardWidth = new Array(22);

//Define array describing what is currently selected in the slots
var arrSlotCode = new Array(6);

//constants
var CARD_WEIGHT = 1;
var CARD_DESCRIPTION = 2;
var CARD_NAME = 3;
var CARD_IMAGE = 4;
var CARD_URL = 5;
var CARD_WIDTH = 7;

var DEFAULT_INSTRUCTIONS = "Create the motion controller of your choice by clicking on a module, then choosing " + 
							"a module from the list that appears in this location. <br/>" + 
							"<br/>Request a quote for the controller you create by clicking 'Quote Me' below.";

var CARD_IMG_LOC = "/rmcquote/images/quoteme70/";
var DELETE_CARD = "DELETE";
var CANCEL_SELECTION = "Return to General Instructions";

//Card data
arrCardCode[0] = "CHOICE";
arrCardName[0] = "Expand the RMC70";
arrCardImage[0] = CARD_IMG_LOC + "choices70exp.gif";
arrCardDescription[0] = "Expansion modules add analog reference inputs, quadrature inputs or discrete I/O. Up to 4 expansion modules can be added to the RMC70.\n\nClick a module in the Add Module list to add an expansion module.";
arrCardURL[0] = ""
arrCardWeight[0] = 0;
arrCardWidth[0] = 62;

arrCardCode[1] = "RMC75S";
arrCardName[1]	= "Serial";
arrCardImage[1] = CARD_IMG_LOC + "RMC75S.jpg";
arrCardDescription[1] = "This module provides a cost-effective interface to a wide variety of host systems.	Both response time and messaging performance vary by PLC.";
arrCardURL[1] = "http://www.deltamotion.com/pdf/rmc70datasheet.pdf";
arrCardWeight[1] = 1;
arrCardWidth[1] = 54;		

arrCardCode[2] = "RMC75P";
arrCardName[2]	= "PROFIBUS-DP";
arrCardImage[2] = CARD_IMG_LOC + "RMC75P.jpg";
arrCardDescription[2] = "PROFIBUS is one of the fastest industrial fieldbuses in terms of control data response times.	Messaging performance varies by PLC.";
arrCardURL[2] = "http://www.deltamotion.com/pdf/rmc70datasheet.pdf";
arrCardWeight[2] = 2;
arrCardWidth[2] = 54;		

arrCardCode[3] = "RMC75E";
arrCardName[3] = "Ethernet";
arrCardImage[3] = CARD_IMG_LOC + "RMC75E.jpg";
arrCardDescription[3] = "Ethernet is often the best choice for ease-of-use and offers the highest data throughput.	Response times vary by protocol, but some, such as Allen-Bradley's EtherNet/IP, are quite deterministic.";
arrCardURL[3] = "http://www.deltamotion.com/pdf/rmc70datasheet.pdf";
arrCardWeight[3] = 3;
arrCardWidth[3] = 54;		

		
arrCardCode[4] = "RMC75D";
arrCardName[4]	= "";
arrCardImage[4] = "";
arrCardDescription[4] = "";
arrCardURL[4] = "";
arrCardWeight[4] = 4;
arrCardWidth[4] = 54;				

arrCardCode[5] = "RMC75?";
arrCardName[5]	= "";
arrCardImage[5] = "";
arrCardDescription[5] = "";
arrCardURL[5] = "";
arrCardWeight[5] = 5;
arrCardWidth[5] = 54;				
		
arrCardCode[6] = "MA1";
arrCardName[6]	= "MA1";
arrCardImage[6] = CARD_IMG_LOC + "MA1.jpg";
arrCardDescription[6] = "This one-axis module (-MA1) interfaces with one magnetostrictive displacement transducer (MDT) linear position feedback device with RS422 Start/Stop, PWM and SSI output or one SSI encoder and provides one analog control output.";
arrCardURL[6] = "http://www.deltamotion.com/pdf/rmc70datasheet.pdf";
arrCardWeight[6] = 6;
arrCardWidth[6] = 77;						

arrCardCode[7] = "MA2";
arrCardName[7]	= "MA2";
arrCardImage[7] = CARD_IMG_LOC + "MA2.jpg";
arrCardDescription[7] = "This two-axis module (-MA2) interfaces with two magnetostrictive displacement transducer (MDT) linear position feedback devices with RS422 Start/Stop, PWM and SSI output or SSI encoders and provides two analog control outputs.";
arrCardURL[7] = "http://www.deltamotion.com/pdf/rmc70datasheet.pdf";
arrCardWeight[7] = 17;
arrCardWidth[7] = 77;						

arrCardCode[8] = "AA1";
arrCardName[8]	= "AA1";
arrCardImage[8] = CARD_IMG_LOC + "AA1.jpg";
arrCardDescription[8] = "This one-axis module (-AA1) interfaces to one analog position, pressure or force feedback device for position, pressure, or force control and provides an analog control output.\n\nNotice that position-pressure or position-force control requires the AP2 expansion module.";
arrCardURL[8] = "http://www.deltamotion.com/pdf/rmc70datasheet.pdf";
arrCardWeight[8] = 8;
arrCardWidth[8] = 77;						
		
arrCardCode[9] = "AA2";
arrCardName[9]	= "AA2";
arrCardImage[9] = CARD_IMG_LOC + "AA2.jpg";
arrCardDescription[9] = "This two-axis module (-AA2) interfaces to two analog position, pressure or force feedback devices for position, pressure, or force control and provides two analog control outputs.\n\nNotice that position-pressure or position-force control requires the AP2 expansion module.";
arrCardURL[9] = "http://www.deltamotion.com/pdf/rmc70datasheet.pdf";
arrCardWeight[9] = 9;
arrCardWidth[9] = 77;						

arrCardCode[10] = "QA1";
arrCardName[10]	= "QA1";
arrCardImage[10] = CARD_IMG_LOC + "QA1.jpg";
arrCardDescription[10] = "This one-axis module interfaces with a quadrature encoder and provides an analog control output for closed loop control.\n\nThe QA module only supports 5V differential (RS-422) signals.";
arrCardURL[10] = "http://www.deltamotion.com/pdf/rmc70datasheet.pdf";
arrCardWeight[10] = 10;
arrCardWidth[10] = 77;

arrCardCode[11] = "QA2";
arrCardName[11]	= "QA2";
arrCardImage[11] = CARD_IMG_LOC + "QA2.jpg";
arrCardDescription[11] = "This two-axis module interfaces with two quadrature encoders and provides two analog control outputs for closed loop control.\n\nThe QA module only supports 5V differential (RS-422) signals.";
arrCardURL[11] = "http://www.deltamotion.com/pdf/rmc70datasheet.pdf";
arrCardWeight[11] = 11;
arrCardWidth[11] = 77;								

arrCardCode[12] = "??1";
arrCardName[12]	= "";
arrCardImage[12] = "";
arrCardDescription[12] = "This module (-QST) provides stepper control.	The quadrature encoder inputs can be used for axis feedback or for position reference (gearing).";
arrCardURL[12] = "http://www.deltamotion.com/pdf/rmc70datasheet.pdf";
arrCardWeight[12] = 12;
arrCardWidth[12] = 77;								

arrCardCode[13] = "??2";
arrCardName[13]	= "";
arrCardImage[13] = CARD_IMG_LOC + "13.gif";
arrCardDescription[13] = "This module (-H) interfaces to analog position or pressure feedback devices for position, pressure, or position/pressure control.	Pressure inputs can be used together with position inputs on this or other I/O modules to provide position/pressure control.	Pressure control requires the RMC101 CPU.";
arrCardURL[13] = "http://www.deltamotion.com/pdf/rmc70datasheet.pdf";
arrCardWeight[13] = 13;
arrCardWidth[13] = 77;								

arrCardCode[14] = "A2";
arrCardName[14]	= "A2";
arrCardImage[14] = CARD_IMG_LOC + "A2.jpg";
arrCardDescription[14] = "This expansion module (-A2) provides two analog reference inputs for position, pressure or force.\n\nIf you need a pressure or force input for position-pressure or position-force control, use the AP2 expansion module instead.";
arrCardURL[14] = "http://www.deltamotion.com/pdf/rmc70datasheet.pdf";
arrCardWeight[14] = 14;
arrCardWidth[14] = 51;								

arrCardCode[15] = "AP2";
arrCardName[15]	= "AP2";
arrCardImage[15] = CARD_IMG_LOC + "AP2.jpg";
arrCardDescription[15] = "This expansion module (-AP2) provides two analog inputs for pressure or force. The AP2 is required for position-pressure and position-force control.";
arrCardURL[15] = "http://www.deltamotion.com/pdf/rmc70datasheet.pdf";
arrCardWeight[15] = 15;
arrCardWidth[15] = 51;		

arrCardCode[16] = "D8";
arrCardName[16]	= "D8";
arrCardImage[16] = CARD_IMG_LOC + "D8.jpg";
arrCardDescription[16] = "This expansion module (-D8) provides 8 discrete I/O points. Each I/O point can be programmed to be an input or an output.";
arrCardURL[16] = "http://www.deltamotion.com/pdf/rmc70datasheet.pdf";
arrCardWeight[16] = 16;
arrCardWidth[16] = 62;										

arrCardCode[17] = "Q1";
arrCardName[17]	= "Q1";
arrCardImage[17] = CARD_IMG_LOC + "Q1.jpg";
arrCardDescription[17] = "This expansion module (-Q1) provides a quadrature reference input. The quadrature encoder input can be used for position reference (gearing).\n\nMax two Q1 modules per RMC70.";
arrCardURL[17] = "http://www.deltamotion.com/pdf/rmc70datasheet.pdf";
arrCardWeight[17] = 17;
arrCardWidth[17] = 51;										

arrCardCode[18] = "exp?";
arrCardName[18] = "Expand the RMC";
arrCardImage[18] = CARD_IMG_LOC + "choices70exp.gif";
arrCardDescription[18] = "These controllers are factory configured to have one communication, one CPU, and one to four I/O modules, providing up to 8 axes.	Almost any combination can be specified to fit almost any application: linear or rotary, position, pressure, or position/pressure control.	Click as indicated above to expand the controller.";
arrCardURL[18] = ""
arrCardWeight[18] = 18;
arrCardWidth[18] = 51;										

arrCardCode[19] = "BLANK";
arrCardName[19]	= "";
arrCardImage[19] = "";
arrCardDescription[19] = "";
arrCardURL[19] = ""
arrCardWeight[19] = 19;
arrCardWidth[19] = 51;										

//Hmm, don't think I'm using this.	Delete later.
arrCardCode[20] = "DELETE";
arrCardName[20]	= "DELETE";
arrCardImage[20] = "";
arrCardDescription[20] = "";
arrCardURL[20] = "";
arrCardWeight[20] = 20;
arrCardWidth[20] = 0;										

arrCardCode[21] = "EMPTY";
arrCardName[21]	= "Empty Slot";
arrCardImage[21] = CARD_IMG_LOC + "empty.gif";
arrCardDescription[21] = "";
arrCardURL[21] = "";
arrCardWeight[21] = 21;
arrCardWidth[21] = 0;										

//Assign initial values to the slots.
arrSlotCode[0] = arrCardCode[3];
arrSlotCode[1] = arrCardCode[6];
arrSlotCode[2] = arrCardCode[0];
arrSlotCode[3] = arrCardCode[21];
arrSlotCode[4] = arrCardCode[21];
arrSlotCode[5] = arrCardCode[21];

function QuoteMe(sPartNo,type)
{
	var i,j;
	var sExpCurr = ["","","",""];
	var arrPartExp = ["","","",""];		//stores expansion module part nos
	var arrNumExp = [0,0,0,0];		//stores number of each expansion module in arrPartExp
	var bFlgAdded = false;
	var sParts;
	
	//get base module qty and part no
	sParts = "(1)	" + sPartNo.slice(0,10);

	//Parse exps from part no
	var index, lastindex;
	index = 10;
	lastindex=10;

	//parse the part number for the exp modules
	index = sPartNo.indexOf("-",index);
	if ( index != -1 )
	{
		i=0;
		while(index != -1)
		{
			index = sPartNo.indexOf("-",lastindex+1);
			if ( index != -1 )
			{
				sExpCurr[i] = sPartNo.slice(lastindex+1,index);
				lastindex = index;
				i++;
			}
		}
		sExpCurr[i] = sPartNo.slice(lastindex+1);
	}

	//determine which exp modules and how many of each
	for ( i = 0; i < 4 ; i++ )
	{
		bFlgAdded = false;
		for ( j = 0; j < 4 && bFlgAdded == false; j++ )
		{
			if ((sExpCurr[i] != "") && (arrNumExp[j] == 0 || arrPartExp[j] == sExpCurr[i] ))
			{
				arrPartExp[j] = sExpCurr[i];
				arrNumExp[j] ++;
				bFlgAdded = true;
			}
		}
	}

	//add expansion module part nos to parts string
	for ( i= 0; i < 3; i++ )
	{
		if (arrPartExp[i] != "")
		{
			sParts += "\\n(" + arrNumExp[i] + ")	" + "EXP70-" + arrPartExp[i];
		}
	}

	//open the Quoteme page with the formatted string			
	/*Uncomment the following line of code to turn on passing the "type" parameter to the form */ 
	//OpenWindow("/rmcquote/quoteme.php?" + sParts + "&type=" + type);
	window.location.href = "/rmcquote/quoteme.php?" + sParts + "&type=" + type
	
	/*Comment the following line of code to turn on passing the "type" parameter to the form */
	//OpenWindow("/rmcquote/quoteme.php?" + sPartNo);
}

function InitCards()
{
	var i;
	
	for (i = 0; i < arrSlotCode.length; i++)
	{
		switch (i)
		{
			case 0:
				lyrWrt("imgslot" + i, "<img src=\"" + GetCardInfo(arrSlotCode[i], CARD_IMAGE) + "\" border=\"0\" width=\"54\" height=\"178\">");
				break;
			case 1:
				lyrWrt("imgslot" + i, "<img src=\"" + GetCardInfo(arrSlotCode[i], CARD_IMAGE) + "\" border=\"0\" width=\"77\" height=\"178\">");
				break;				
			default:
				if (arrSlotCode[i] != "EMPTY") {
					lyrWrt("imgslot" + i, "<img src=\"" + GetCardInfo(arrSlotCode[i], CARD_IMAGE) + "\" border=\"0\" width=\"" + GetCardInfo(arrSlotCode[i], CARD_WIDTH) + "\" height=\"178\">");
				}
		}
	}

	//Point to Slot 0 and display info
	SetSlotPointer(0, -1)
	lyrWrt("txtName",GetCardInfo(arrSlotCode[0], CARD_NAME));
	
	DisplayCardChoices(0);
	
	ShowPartNos(GetPartNo());	
}

function ResetAppControls()
{
	$('#txtDescription').text(GetCardInfo("RMC75E", CARD_DESCRIPTION));
}

function OpenWindow(url,name)
{
	var newwindow;
	newwindow = window.open(url, name);
	newwindow.focus();
}

/************************************************************************************
*Writes out information using the correct syntax for the specific browser
************************************************************************************/
function lyrWrt(element,text) 
{
	document.getElementById(element).innerHTML = text;
}

/************************************************************************************
*Given the code, will search through the card information and return the requested data
************************************************************************************/
function GetCardInfo(code, info)
{
	var i;
	var val;
	val = "";
	for (i = 0; i < arrCardCode.length; i++)
	{
		if (code == arrCardCode[i])
		{
			//Values used instead of variable label to account for Netscape 4.x bug
			switch (info)
			{
				case CARD_WEIGHT:
					val = arrCardWeight[i];	break;
				case CARD_DESCRIPTION:
					val = arrCardDescription[i]; break;
				case CARD_NAME:
					val = arrCardName[i]; break;
				case CARD_IMAGE:
					val = arrCardImage[i]; break;
				case CARD_URL:
					val = arrCardURL[i]; break;
				case CARD_WIDTH:
					val = arrCardWidth[i]; break;
				default:
			}
		}
	
	}
	return (val);

}


/************************************************************************************
*Given the slot, displays all the valid card choices
************************************************************************************/
function DisplayCardChoices(slot)
{
	var val;
	var SlotHRef;
	var i,j;
	var numQ1s;
	var iLowSlot;
	var iHighSlot;
	var bDIODisable;
				
	bDIODisable = false;

	//Set slot pointer
	SetSlotPointer(slot, -1)
	
	$('#txtDescription').text(GetCardInfo(arrSlotCode[slot], CARD_DESCRIPTION));

	lyrWrt("moreinfo", "&nbsp;");
	
	if ("" != GetCardInfo(arrSlotCode[slot], CARD_URL))
		lyrWrt("moreinfo", "<a href=\"javascript:OpenWindow('" + GetCardInfo(arrSlotCode[slot], CARD_URL) + "','moreinfo');\">GET MORE INFO</a>");

	if (arrSlotCode[slot] == "CHOICE") {
		val = "<strong>Add Module:</strong><br/>"; 
	}
	else {
		val = "<strong>Replace Module<br/>With:</strong><br/>"; 
	}

	switch (parseInt(slot))
	{
		//CPU module
		case 0:
			iLowSlot = 1;
			iHighSlot = 3;
			lyrWrt("txtName","Base Module: " + arrSlotCode[slot] + " (" + GetCardInfo(arrSlotCode[slot], CARD_NAME) + ")");
			break;
			
		//Axis module
		case 1:
			iLowSlot = 6;
			iHighSlot = 11;
			lyrWrt("txtName","Axis Module: " + arrSlotCode[slot]);
			break;		
		//Expansion module
		default:
			iLowSlot = 14;
			iHighSlot = 17;
			if (arrSlotCode[slot] == "CHOICE") {
				lyrWrt("txtName",GetCardInfo(arrSlotCode[slot], CARD_NAME));
			}
			else {
				lyrWrt("txtName","Expansion Module: " + arrSlotCode[slot]);
			}
			break;
	}
	
	//count the number of Q1 expansion modules for limiting to 2.
	numQ1s = 0;
	for (i = 0; i < arrSlotCode.length; i++)
	{
		if (arrSlotCode[i] == "Q1")
		{
			numQ1s++;
		}				
	}
	
	//List all the avaliable modules for the slot
	for (i = iLowSlot; i <= iHighSlot; i++)
	{
		if (!(arrCardCode[i] == "Q1" && numQ1s >= 2))
		{
			SlotHRef = "javascript:InsertCard(" + slot + ", \"" + arrCardCode[i] + "\");";
			val += "<a href='" + SlotHRef + "'>" + GetCardInfo(arrCardCode[i], CARD_NAME) + "</a><br/>";
		}
	}

	//Write out "Delete: link at bottom when required
	if ((arrSlotCode[slot] != arrCardCode[0]) && (slot != 0) && (slot != 1))
	{
		SlotHRef = "javascript:InsertCard(" + slot + ", \"" + DELETE_CARD + "\");";
		val += "<br/><a href='" + SlotHRef + "'>" + DELETE_CARD + "</a><br/>";
	}
	lyrWrt("instructions", val);
}
		
/************************************************************************************
*Moves the slot pointer
************************************************************************************/
function SetSlotPointer(slot,iNewCard)
{
	for (i = 0; i < arrSlotCode.length; i++)
	{
		if (arrSlotCode[i] != "EMPTY") {
			lyrWrt("slotpointer" + i, "<img src=/rmcquote/images/common/emptyslotarrowwhite.gif>");
		}
	}
				
	//Set the correct if not -1.	-1 means to just reset the pointers, but do not
	//set the arrow position.
	if ((-1 != slot) && (-1 != iNewCard))
		lyrWrt("slotpointer" + slot, "<img src=/rmcquote/images/common/slotarrow.gif>");
	else 
		if (-1 == iNewCard)
			lyrWrt("slotpointer" + slot, "<img src=/rmcquote/images/common/slotarrow.gif>");

	//Display Get More Info URL
	if ("" != GetCardInfo(arrSlotCode[slot], CARD_URL))
		lyrWrt("moreinfo", "<a href=\"javascript:OpenWindow('" + GetCardInfo(arrSlotCode[slot], CARD_URL) + "','moreinfo');\">GET MORE INFO</a>");
}

/************************************************************************************
*Performs act of inserting the new card and applying all business rules.
************************************************************************************/
function InsertCard(slot, iNewCard)
{
	//Delete the card
	if (iNewCard == DELETE_CARD)
	{
		//shift module codes to left one.
		for ( i= slot; i < arrSlotCode.length-1; i++ ) {
			arrSlotCode[i] = arrSlotCode[i+1];
		}
		//last card must be either EMPTY or CHOICE
		if ( arrSlotCode[arrSlotCode.length-2] != "CHOICE" && arrSlotCode[arrSlotCode.length-2] != "EMPTY") {
			arrSlotCode[arrSlotCode.length-1] = "CHOICE";
		}
		else {
			arrSlotCode[arrSlotCode.length-1] = "EMPTY";
		}
		//redraw images.
		for ( i= 2; i < arrSlotCode.length; i++ ) {
			if ( arrSlotCode[i] != "EMPTY") {
				lyrWrt("imgslot" + i, "<img src=\"" + GetCardInfo(arrSlotCode[i], CARD_IMAGE) + "\" border=\"0\" width=\"" + GetCardInfo(arrSlotCode[i], CARD_WIDTH) + "\" height=\"178\">");
			}
			else {
				lyrWrt("imgslot" + i, "");
			}
		}
	}
	else //Insert a card //(if delete options exist:) if (iNewCard != CANCEL_SELECTION && iNewCard != DELETE_CARD )
	{
		arrSlotCode[slot] = iNewCard;
				
		switch (slot)
		{
			case 0:
				lyrWrt("imgslot" + slot, "<img src=\"" + GetCardInfo(arrSlotCode[slot], CARD_IMAGE) + "\" border=\"0\" width=\"" + GetCardInfo(arrSlotCode[slot], CARD_WIDTH) + "\" height=\"178\">");
				break;
			case 1:
				lyrWrt("imgslot" + slot, "<img src=\"" + GetCardInfo(arrSlotCode[slot], CARD_IMAGE) + "\" border=\"0\" width=\"" + GetCardInfo(arrSlotCode[slot], CARD_WIDTH) + "\" height=\"178\">");
				break;				
			default:
				if (arrSlotCode[slot] != "EMPTY")
				{
					lyrWrt("imgslot" + slot, "<img src=\"" + GetCardInfo(arrSlotCode[slot], CARD_IMAGE) + "\" border=\"0\" width=\"" + GetCardInfo(arrSlotCode[slot], CARD_WIDTH) + "\" height=\"178\">");
				}
		}
		
		$('#txtDescription').text(GetCardInfo(iNewCard, CARD_DESCRIPTION));
	
		if (slot < (arrSlotCode.length - 1) )
		{
			//If the next slot is "EMPTY", then set to card choice message
			if ( arrSlotCode[slot + 1] == "EMPTY" )
			{
				arrSlotCode[slot + 1] = "CHOICE";
				lyrWrt("imgslot" + (slot+1), "<img src=\"" + GetCardInfo("CHOICE", CARD_IMAGE) + "\" border=\"0\">");
			}
		}
	}

	ShowPartNos(GetPartNo());
	DisplayCardChoices(slot);
}

/************************************************************************************
*Generates the part number
************************************************************************************/
function GetPartNo()
{
	var i;
	var sPartNo;

	sPartNo = "";

	//create base module part no
	sPartNo += arrSlotCode[0] + "-";
	sPartNo += arrSlotCode[1];

	//add exp modules to partno
	for ( i= 2; i < arrSlotCode.length; i++ )
	{
		if ( arrSlotCode[i] != "EMPTY" && arrSlotCode[i] != "CHOICE")
		{
			sPartNo += "-" + arrSlotCode[i];
		}
	}

	return (sPartNo);
}

/************************************************************************************
*Displays Parts required
************************************************************************************/
function ShowPartNos(sPartNo)
{
	var i,j;
	var sExpCurr = ["","","",""]
	var arrPartExp = ["","","",""];		//stores expansiuon module part nos
	var arrNumExp = [0,0,0,0];		//stores number of each expansion module in arrPartExp
	var bFlgAdded = false;
	var sTablePartNos ="";
	var sNumParts = "";

	//base module part number
	sTablePartNos = "<div>" + sPartNo.slice(0,10) + "</div>";
	sNumParts = "<div>1</div>"

	//Parse exps from part number
	var index, lastindex;
	index = 10;
	lastindex=10;

	//parse the part number for the exp modules
	index = sPartNo.indexOf("-",index);
	if ( index != -1 )
	{
		i=0;
		while(index != -1)
		{
			index = sPartNo.indexOf("-",lastindex+1);
			if ( index != -1 )
			{
				sExpCurr[i] = sPartNo.slice(lastindex+1,index);
				lastindex = index;
				i++;
			}
		}
		sExpCurr[i] = sPartNo.slice(lastindex+1);
	}

	//determine which exp modules and how many of each
	for ( i = 0; i < 4 ; i++ )
	{
		bFlgAdded = false;
		for ( j = 0; j < 4 && bFlgAdded == false; j++ )
		{
			if ((sExpCurr[i] != "") && (arrNumExp[j] == 0 || arrPartExp[j] == sExpCurr[i] ))
			{
				arrPartExp[j] = sExpCurr[i];
				arrNumExp[j] ++;
				bFlgAdded = true;
			}
		}
	}

	//add expansion module part numbers to part number
	for ( i= 0; i < 4; i++ )
	{
		{
			if (arrPartExp[i] != "") {
				sTablePartNos += "<div>" + "EXP70-" + arrPartExp[i] + "</div>";
			}
			else {
				sTablePartNos += "<div>&nbsp;</div>";
			}
			
			if (arrNumExp[i] == 0) {
				sNumParts 		+= "<div>&nbsp;</div>";
			}
			else {				
				sNumParts 		+= "<div>" + arrNumExp[i] + "</div>";
			}
		}
	}
	
	lyrWrt("partno", sTablePartNos);
	lyrWrt("partqty", sNumParts);
	
	return;
}
