/*  ----------------------------------------------------------------------------
 * GLOBALS
 * -------------------------------------------------------------------------- */

var filterApplied = [];
var firstFilter = null; //filterOptions uses this value

var genericNoProductFoundErrorMssg = "No products matched your search criteria.";

// Global string for use in showResults and the back button feature
var stateCookieJSON = "";

// Which browser is in use?
IE5=NN6=false;

if(document.all)
{
	IE5=true;
}
else if(document.getElementById)
{
	NN6=true;
}

/* -----------------------------------------------------------------------------
 * 
 * Touch Systems PoW! Catalog XSLT Javascript Functions
 *
 * Below are functions related directly to the XML Transformation of the PoW!
 * Catalog for Touch Systems. It is assumed that these are used exclusively
 * by the XML Transformation, or by the user through interaction with the 
 * catalog. All are required for the TS PoW! Catalog.
 *
 * a1rx4zz 10-14-2009
 * -----------------------------------------------------------------------------
 */	

/**
 * Executes the "showResults()" function, if the enter key is pressed AND there
 * is at least one character in one of the prescribed filter form fields. 
 * This function causes the filtered search results to display when the 
 * enter key is pressed.
 *
 * @param {Event} e   The Javascript Event object.
 * @return {Boolean}   True    
 */
document.onkeydown=function(e)
{
	var evt=window.event || e //evt evaluates to window.event or inexplicit e object, depending on which one is defined
	if (evt.keyCode == "13") // this code indicates the "enter" key.
	{
		var doFilter = false;		
		var inputPartNumber = document.getElementById('partNumber');		
		var arrDimension = [];	 
			arrDimension.push(document.getElementById("viewAreaDiag"));
			arrDimension.push(document.getElementById("viewAreaWidth"));
			arrDimension.push(document.getElementById("viewAreaHeight"));
			arrDimension.push(document.getElementById("outerAreaDiag"));
			arrDimension.push(document.getElementById("outerAreaWidth"));
			arrDimension.push(document.getElementById("outerAreaHeight"));
		
		if (null != inputPartNumber)
		{
			if (inputPartNumber.value.length > 0)
			{
				doFilter = true; // there is a value in the part number field so turn on "doFilter"
			}
		}
		
		for (var i = 0; i < arrayLength(arrDimension); i++)
		{
			if (null != arrDimension[i])
			{
				if (arrDimension[i].value.length > 0)
				{
					doFilter = true;  // there is a value in this field so turn on "doFilter"
				}
			}	 
		}
		if (doFilter) // if true, it means that there is at least one field with a value, so showResults.
		{
			showResults();
		}
	}
}

/**
 * This utility function simply returns a given Array's length
 *
 * @param {Array} obj The given Array the length of which is desired.	          
 * @return {Integer}   The length of the given Array
 */
function arrayLength(obj) {
	if(obj[obj.length - 1] == null) {
		return obj.length - 1;
	}		
	return obj.length;
}

/**
 * This utility function "cleans" the results JSON object, trimming whitespace
 * out of the values stored therein. It fires off as part of the XML 
 * transformation of the item template, and scrubs these values for use by 
 * Javascript. (Note: in some cases, the XML generated by GSDB include 
 * whitespace at the beginnings or ends of values, which get inserted into
 * the results JSON object. This white space should be removed prior to 
 * the results' consumption by Javascript.
 *
 * @param {}		          
 * @return {Boolean}   True  
 */
function cleanUpResults() 
{
	for(var i=0; i<arrayLength(results); i++) 
	{
		results[i].id = trim(results[i].id);
		var sizes = trim(results[i].size);
		sizes = sizes.split(" (");
		results[i].size = sizes[0];
		results[i].sizeMilli = 0;
		if(sizes.length > 1) 
		{
			results[i].sizeMilli = sizes[1];
			results[i].sizeMilli = results[i].sizeMilli.substring(0,results[i].sizeMilli.length-1);
		}
		results[i].url = trim(results[i].url);
		results[i].aspectRatio = trim(results[i].aspectRatio);
		results[i].controller = trim(results[i].controller);
		results[i].controllerAvailable = trim(results[i].controllerAvailable);
		results[i].viewArea = trim(results[i].viewArea);
		results[i].viewAreaDiagInches = trim(results[i].viewAreaDiagInches);
		results[i].viewAreaDiagMM = trim(results[i].viewAreaDiagMM);
		results[i].viewAreaWidthInches = trim(results[i].viewAreaWidthInches);		
		results[i].viewAreaWidthMM = trim(results[i].viewAreaWidthMM);
		results[i].viewAreaHeightInches = trim(results[i].viewAreaHeightInches);
		results[i].viewAreaHeightMM = trim(results[i].viewAreaHeightMM);
		results[i].outerArea = trim(results[i].outerArea);
		results[i].outerAreaDiagonal = trim(results[i].outerAreaDiagonal);
		results[i].outerAreaDiagInches = trim(results[i].outerAreaDiagInches);
		results[i].outerAreaDiagMM = trim(results[i].outerAreaDiagMM);
		results[i].outerAreaWidthInches = trim(results[i].outerAreaWidthInches);
		results[i].outerAreaWidthMM = trim(results[i].outerAreaWidthMM);
		results[i].outerAreaHeightInches = trim(results[i].outerAreaHeightInches);
		results[i].outerAreaHeightMM = trim(results[i].outerAreaHeightMM);	
		results[i].cableLength = trim(results[i].cableLength);
		results[i].cableExit = trim(results[i].cableExit);
		results[i].protocolSerial = trim(results[i].protocolSerial);
		results[i].connector = trim(results[i].connector);
		results[i].screenSize = trim(results[i].screenSize);
		results[i].displayType = trim(results[i].displayType);		
	}
} // END cleanUpResults()


/**
 * Remove the cookie by setting ancient expiration date
 *
 * @param {String}	name	The cookie's name
 * @param {String}	path	The cookie's path value
 * @param {String}	domain	The cookie's domain value
 */
function deleteCookie(name,path,domain) 
{
    /*
	Example From "JavaScript and DHTML Cookbook"
	Published by O'Reilly & Associates
	Copyright 2003 Danny Goodman
	*/
	
	if (getCookie(name)) 
	{
        document.cookie = name + "=" +
            ((path) ? "; path=" + path : "") +
            ((domain) ? "; domain=" + domain : "") +
            "; expires=Thu, 01-Jan-70 00:00:01 GMT";
    }
} // END deleteCookie()


/**
 * Disables (grays-out) a given SELECT OPTION
 *
 * @param {Object}	node	the HTML Select element
 * @return {Boolean} true
 */	
function disableOptions(node) 
{
	for(var i=1;i<node.childNodes.length;i++) {
		if(node.childNodes[i].nodeName.toLowerCase() == "option") {
			var oGroup = document.createElement('optgroup');
			oGroup.style.color = '#D3D3D3';
			oGroup.style.fontStyle = 'normal';
			oGroup.label = node.childNodes[i].firstChild.nodeValue;
			node.replaceChild(oGroup,node.childNodes[i]);
		}
	}	
} // END disableOptions()




/**
 * Draws the list of characteristics.
 *
 * @param {Object}	chs 	JSON object containing the characteristics for display.
 * @param {String}	divID 	ID value for the DIV element used for displaying the characteristics.
 */	
 function displayCharacteristics(chs,divID)
 {	
	var myCell = document.getElementById(divID); // DIV element in which the characteristics will display.

	var precisionDiag = [];
	var precisionDiagValue = "";
	var preDiagFull = [];
	
	var precisionHeight = [];
	var precisionHeightValue = "";
	var preHeightFull = [];
	
	var precisionWidth = [];
	var precisionWidthValue = "";
	var preWidthFull = [];
	
	var glassThickness = [];
	var glassThicknessValue = "";
	var glassThicknessFull = [];
	
	preDiagFull[0] = "Precision Area Diagonal inches (mm)";
	preHeightFull[0] = "Precision Area Height inches (mm)";
	preWidthFull[0] = "Precision Area Width inches (mm)";
	glassThicknessFull[0] = "Glass Thickness inches (mm)";
	
	// Dump characteristics into an array for sorting...
	var chars = [];
	for (var i = 0; i < arrayLength(chs); i++)
	{
		if (trimWS(chs[i].name).toLowerCase() == trimWS("Precision Area Diagonal inches").toLowerCase())
		{
			var nameValuePair = [];
			nameValuePair[0] = "PADIN";
			nameValuePair[1] = trim(chs[i].value);
			precisionDiag.push(nameValuePair);
		}
		else if (trimWS(chs[i].name).toLowerCase() == trimWS("Precision Area Diagonal (mm)").toLowerCase())
		{
			var nameValuePair = [];
			nameValuePair[0] = "PADMM";
			nameValuePair[1] = trim(chs[i].value);
			precisionDiag.push(nameValuePair);
		}
		else if (trimWS(chs[i].name).toLowerCase() == trimWS("Precision Area Height inches").toLowerCase())
		{
			var nameValuePair = [];
			nameValuePair[0] = "PAHIN";
			nameValuePair[1] = chs[i].value;
			precisionHeight.push(nameValuePair);
		}
		else if (trimWS(chs[i].name).toLowerCase() == trimWS("Precision Area Height (mm)").toLowerCase())
		{
			var nameValuePair = [];
			nameValuePair[0] = "PAHMM";
			nameValuePair[1] = trim(chs[i].value);
			precisionHeight.push(nameValuePair);
		}
		else if (trimWS(chs[i].name).toLowerCase() == trimWS("Precision Area Width inches").toLowerCase())
		{
			var nameValuePair = [];
			nameValuePair[0] = "PAWIN";
			nameValuePair[1] = trim(chs[i].value);
			precisionWidth.push(nameValuePair);
		}
		else if (trimWS(chs[i].name).toLowerCase() == trimWS("Precision Area Width (mm)").toLowerCase())
		{
			var nameValuePair = [];
			nameValuePair[0] = "PAWMM";
			nameValuePair[1] = trim(chs[i].value);
			precisionWidth.push(nameValuePair);
		}
		else if (trimWS(chs[i].name).toLowerCase() == trimWS("Glass Thickness inches").toLowerCase())
		{
			var nameValuePair = [];
			nameValuePair[0] = "GTIN";
			nameValuePair[1] = trim(chs[i].value);
			glassThickness.push(nameValuePair);
		}
		else if (trimWS(chs[i].name).toLowerCase() == trimWS("Glass Thickness (mm)").toLowerCase())
		{
			var nameValuePair = [];
			nameValuePair[0] = "GTMM";
			nameValuePair[1] = trim(chs[i].value);
			glassThickness.push(nameValuePair);
		}
		else
		{
			var nameValuePair = [];
			nameValuePair[0] = chs[i].name;
			nameValuePair[1] = trim(chs[i].value);
			chars.push(nameValuePair);	
		}
	} // End loop through the characteristics	
	
	for (var i = 0; i < precisionDiag.length; i++)
	{
		if (precisionDiag[i][0] == "PADIN")
		{
			precisionDiagValue += " " + precisionDiag[i][1];
		}
		else if (precisionDiag[i][0] == "PADMM")
		{
			precisionDiagValue += " ("+precisionDiag[i][1]+")";	
		}
	}
	for (var i = 0; i < precisionHeight.length; i++)
	{
		if (precisionHeight[i][0] == "PAHIN")
		{
			precisionHeightValue += " " + precisionHeight[i][1];
		}
		else if (precisionHeight[i][0] == "PAHMM")
		{
			precisionHeightValue += " ("+precisionHeight[i][1]+")";	
		}
	}
	for (var i = 0; i < precisionWidth.length; i++)
	{
		if (precisionWidth[i][0] == "PAWIN")
		{
			precisionWidthValue += " " + precisionWidth[i][1];
		}
		else if (precisionWidth[i][0] == "PAWMM")
		{
			precisionWidthValue += " ("+precisionWidth[i][1]+")";	
		}
	}
	for (var i = 0; i < glassThickness.length; i++)
	{
		if (glassThickness[i][0] == "GTIN")
		{
			glassThicknessValue += " " + glassThickness[i][1];
		}
		else if (glassThickness[i][0] == "GTMM")
		{
			glassThicknessValue += " ("+glassThickness[i][1]+")";	
		}
	}
	
	// Make certain the (mm) appear at the END of this string
	if (precisionDiagValue.lastIndexOf(')') < precisionDiagValue.length)
 	{
		var pDmm = precisionDiagValue.substr(precisionDiagValue.indexOf('('), precisionDiagValue.lastIndexOf(')'));
		var pDin = precisionDiagValue.substr(precisionDiagValue.lastIndexOf(' '),precisionDiagValue.length);
		precisionDiagValue = pDin + " " + pDmm;
	}
	if (precisionHeightValue.lastIndexOf(')') < precisionHeightValue.length)
 	{
		var pHmm = precisionHeightValue.substr(precisionHeightValue.indexOf('('), precisionHeightValue.lastIndexOf(')'));
		var pHin = precisionHeightValue.substr(precisionHeightValue.lastIndexOf(' '),precisionHeightValue.length);
		precisionHeightValue = pHin + " " + pHmm;
	}
	if (precisionWidthValue.lastIndexOf(')') < precisionWidthValue.length)
 	{
		var pWmm = precisionWidthValue.substr(precisionWidthValue.indexOf('('), precisionWidthValue.lastIndexOf(')'));
		var pWin = precisionWidthValue.substr(precisionWidthValue.lastIndexOf(' '),precisionWidthValue.length);
		precisionWidthValue = pWin + " " + pWmm;
	}
	if (glassThicknessValue.lastIndexOf(')') < glassThicknessValue.length)
 	{
		var gTmm = glassThicknessValue.substr(glassThicknessValue.indexOf('('), glassThicknessValue.lastIndexOf(')'));
		var gTin = glassThicknessValue.substr(glassThicknessValue.lastIndexOf(' '),glassThicknessValue.length);
		glassThicknessValue = gTin + " " + gTmm;
	}
	
	preDiagFull[1] = precisionDiagValue;
	preHeightFull[1] = precisionHeightValue;
	preWidthFull[1] = precisionWidthValue;
	glassThicknessFull[1] = glassThicknessValue;
	
	chars.push(preDiagFull);
	chars.push(preHeightFull);
	chars.push(preWidthFull);
	chars.push(glassThicknessFull);
	
	// now, loop through the sorted array and build the display elements...
	for (var i = 0; i < chars.sort().length; i++)
	{
		var charDiv = document.createElement("DIV");
		charDiv.style.whiteSpace = "nowrap";
		var strongName = document.createElement("STRONG");
		var textValue = null;
		
		var rohsLink = document.createElement("A");
		
		if (chars[i][0].toLowerCase() == "EU RoHS Compliant".toLowerCase()) // Special handling for EU RoHS Compliant characteristic.
		{
			strongName.innerHTML = chars[i][0];
			// split the value into its parts...
			var splitValue = chars[i][1].split(delim);
			
			// Clean up the "comments" string for URL			
			var cleanedComments = escape(splitValue[2]); // will encode, but will miss commas and "tm"
			cleanedComments = cleanedComments.replace(/%u2122/g,"%26%238482%3b"); // will catch the "tm"
			cleanedComments = cleanedComments.replace(/,/gi,"%2C");	// will catch commas
			
			var url = "javascript:window.open('";
			url += "/wps/PA_1_RJH9U5230OM1002L6SL8OE00B2/jsp/html/JspView.jsp";
			url += "?c=RohsDisplay";
			url += "&amp;t=en_US_touch_systems_portal";
			url += "&amp;portleturi=/wps/PA_1_RJH9U5230OM1002L6SL8OE00B2";
			url += "&amp;region=EU";
			url += "&amp;rohsstatus=";
			url += "&amp;partnumber="+splitValue[1];
			url += "&amp;compliancedate= ";
			url += "&amp;comments="+escape(cleanedComments);
			url += "','rohs');void(0);"
			textValue = document.createTextNode(': ' + splitValue[0] + ' ');
			rohsLink.setAttribute("href",url);
			rohsLink.innerHTML="View Certificate";
		}
		
		else if (chars[i][0].toLowerCase() == "Sensor Drawing".toLowerCase()) // Special handling for Sensor Drawing characteristic.
		{
			strongName.innerHTML = chars[i][0];
			// split the value into its parts...
			var splitValue = chars[i][1].split(delim);
			
			var url = splitValue[0];
			textValue = document.createTextNode(': ');
			rohsLink.setAttribute("href",url);
			rohsLink.setAttribute("target","_blank");
			rohsLink.appendChild(document.createTextNode("PDF "+splitValue[1]+"K"));
		}
		else 
		{
			textValue = document.createTextNode(': ' + chars[i][1]);
			strongName.innerHTML = chars[i][0];
		}
		charDiv.className = "itemizedCharacteristics";
		
		
		charDiv.appendChild(strongName);
		charDiv.appendChild(textValue);
		if (chars[i][0]== "EU RoHS Compliant" && null != rohsLink)
		{
			charDiv.appendChild(rohsLink);	
		}
		if (chars[i][0] == "Sensor Drawing" && null != rohsLink)
		{
			charDiv.appendChild(rohsLink);	
		}
		
		myCell.appendChild(charDiv);
	}	
 }
 


/**
 * Enables a given SELECT OPTION
 *
 * @param {Object}	node	the HTML Select element
 * @param {String}	value	the value against which to compare an option, to see if it matches
 * @return {Boolean} true
 */	
function enableOption(node,value) 
{
	for(var i=0;i<node.childNodes.length;i++) {
		if(node.childNodes[i].nodeName.toLowerCase() == "optgroup" && node.childNodes[i].getAttribute("label") == value) {
			var clonedOption = document.createElement('option');
			var pvalue = value;
			if(pvalue == "-Select-") {
				pvalue = "";
			}
			clonedOption.value=pvalue;
			clonedOption.appendChild(document.createTextNode(value));
			node.replaceChild(clonedOption,node.childNodes[i]);		
		}
	}	
} // END enableOption()


/**
 * This utility function escapes comments using 
 * 3M special tm escape code.
 *
 * @param {String}	comments	the raw comments
 * @return {String} comments	the escaped comments
 */	
function escapeComments(comments) 
{
	comments = escape(comments);
	//3m's special tm escape code = %26%238482%3b
	comments = comments.replace(/%E2%84%A2/g,"%26%238482%3b");
	return comments;
}


/**
 * Selectively disables (filters) the available options based on user selections
 * and availability of filter matches in the given result rows.
 *
 * @param {Object}	option	the HTML Option element
 * @return {Boolean} true
 */	
function filterOptions(option) 
{
	var aspectRatioOptions = [];
	var controllerOptions = [];
	
	var size = document.getElementById("size").value;
	size = size.split("(")[0];
	
	var aspectRatio = document.getElementById("aspectRatio");
	var controller = document.getElementById("controller");
	var cableLength = document.getElementById("cableLength");
	var cableExit = document.getElementById("cableExit");
	var partNumber = document.getElementById("partNumber");
	
	if(firstFilter == null) {
		firstFilter = option.id;
	} else if(firstFilter == option.id) {
		if(firstFilter != "aspectRatio") {
			aspectRatio.selectedIndex = 0;
		}
		if(firstFilter != "controller") {
			controller.selectedIndex = 0;
		}
		if(firstFilter != "cableLength") {
			cableLength.selectedIndex = 0;
		}
		if(firstFilter != "cableExit") {
			cableExit.selectedIndex = 0;
		}
	}
	
	var aspectRatioSelected = null;
	if(aspectRatio.selectedIndex >= 0) {		
		aspectRatioSelected = aspectRatio.options[aspectRatio.selectedIndex].value;
		if(firstFilter != "aspectRatio" && option.id != "aspectRatio") {
			disableOptions(aspectRatio);
		}
	}
	var controllerSelected = null;
	if(controller.selectedIndex >= 0) {		
		controllerSelected = controller.options[controller.selectedIndex].value;
		if(firstFilter != "controller" && option.id != "controller") {
			disableOptions(controller);
		}
	}
	var cableLengthSelected = null;
	if(cableLength.selectedIndex >= 0) {		
		cableLengthSelected = cableLength.options[cableLength.selectedIndex].value;
		if(firstFilter != "cableLength" && option.id != "cableLength") {
			disableOptions(cableLength);
		}
	}
	var cableExitSelected = null;
	if(cableExit.selectedIndex >= 0) {		
		cableExitSelected = cableExit.options[cableExit.selectedIndex].value;
		if(firstFilter != "cableExit" && option.id != "cableExit") {
			disableOptions(cableExit);
		}
	}
	
	filterApplied[option.id] = true;
	for(var i=0; i<arrayLength(results); i++) {
		if((size == "" || ((results[i].size >= (parseFloat(size) - .75) && results[i].size <= (parseFloat(size) + .75)) || (results[i].sizeMilli >= (parseFloat(size) - .75) && results[i].sizeMilli <= (parseFloat(size) + .75)))) && (!filterApplied["aspectRatio"] || aspectRatioSelected == "" || aspectRatioSelected == results[i].aspectRatio) && (!filterApplied["controller"] || controllerSelected == "" || controllerSelected == results[i].controller) && (!filterApplied["cableLength"] || cableLengthSelected == "" || cableLengthSelected == results[i].cableLength) && (!filterApplied["cableExit"] || cableExitSelected == "" || cableExitSelected == results[i].cableExit)) {
			enableOption(aspectRatio,results[i].aspectRatio);
			enableOption(controller,results[i].controller);
			enableOption(cableLength,results[i].cableLength);
			enableOption(cableExit,results[i].cableExit);
		}
	}
	
	for(i=0;i<aspectRatio.options.length;i++) {
		if(aspectRatioSelected == aspectRatio.options[i].value) {
			aspectRatio.selectedIndex = i;
		}
	}
	for(i=0;i<controller.options.length;i++) {
		if(controllerSelected == controller.options[i].value) {
			controller.selectedIndex = i;
		}
	}
	for(i=0;i<cableLength.options.length;i++) {
		if(cableLengthSelected == cableLength.options[i].value) {
			cableLength.selectedIndex = i;
		}
	}
	for(i=0;i<cableExit.options.length;i++) {
		if(cableExitSelected == cableExit.options[i].value) {
			cableExit.selectedIndex = i;
		}
	}
} // END filterOptions()

	
/**
 * Filters a given result row, based on the selected filter options
 *
 * @param {Object}	fo	JSON object representing the given result row.
 * @return {Boolean} boolShowProduct	The result of the filter operation
 */
function filterResults(fo)
{
	var boolDisplayLegacy = fo.displayLegacy;
	var boolShowProduct = false;
	if	(
			(
				fo.partNumber == "" // Part Number Field is EMPTY
				&& 
				(
					(
						fo.size == "" 
						|| 
						(
							(
								fo.sizeResults >= (parseFloat(fo.size) - .75) 
								&&
								fo.sizeResults <= (parseFloat(fo.size) + .75)
							)
							||
							(
								fo.sizeMilli >= (parseFloat(fo.size) - 20)							
								&&
								fo.sizeMilli <= (parseFloat(fo.size) + 20)
							)
						)
					)
					&&
					(
						fo.aspectRatio == "" || fo.aspectRatio == fo.aspectRatioResults
					)
					&&
					(
						fo.controller == "" || fo.controller == fo.controllerResults
					)
					&& 
					(
						fo.cableLength == "" || fo.cableLength == fo.cableLengthResults
					) 
					&& 
					(
						fo.cableExit == "" || fo.cableExit == fo.cableExitResults
					)
					&& 
					(
						( 
							fo.viewAreaDiagInches == "" || isNumberInRange(fo.viewAreaDiagInches,fo.viewAreaDiagInchesResults,false)
						)
						||
						(
							fo.viewAreaDiagMM == "" || isNumberInRange(fo.viewAreaDiagMM,fo.viewAreaDiagMMResults,true)
						)							
					)
					&& 
					(
						(
							fo.viewAreaWidthInches == "" || isNumberInRange(fo.viewAreaWidthInches,fo.viewAreaWidthInchesResults,false)
						)
						||
						(
							fo.viewAreaWidthMM == "" || isNumberInRange(fo.viewAreaWidthMM,fo.viewAreaWidthMMResults,true)
						)
					)
					&& 
					(
						(
							fo.viewAreaHeightInches == "" || isNumberInRange(fo.viewAreaHeightInches,fo.viewAreaHeightInchesResults,false)
						)
						||
						(
							fo.viewAreaHeightMM == "" || isNumberInRange(fo.viewAreaHeightMM,fo.viewAreaHeightMMResults,true)
						)
					) 
					
					&& 
					(
						(
							fo.outerAreaDiagInches == "" || isNumberInRange(fo.outerAreaDiagInches,fo.outerAreaDiagInchesResults,false)
						)
						||
						(
							fo.outerAreaDiagMM == "" || isNumberInRange(fo.outerAreaDiagMM,fo.outerAreaDiagMMResults,true)
						)
					)
					&& 
					(
						(
							fo.outerAreaWidthInches == "" || isNumberInRange(fo.outerAreaWidthInches,fo.outerAreaWidthInchesResults,false)
						)
						||
						(
							fo.outerAreaWidthMM == "" || isNumberInRange(fo.outerAreaWidthMM,fo.outerAreaWidthMMResults,true)
						 )
					)
					&& 
					(
						(
							fo.outerAreaHeightInches == "" || isNumberInRange(fo.outerAreaHeightInches,fo.outerAreaHeightInchesResults,false)
						)
						||
						(
							fo.outerAreaHeightMM == "" || isNumberInRange(fo.outerAreaHeightMM,fo.outerAreaHeightMMResults,true)
						)
					)
				)
				
			) 
			|| // Part Number Field is NOT EMPTY
			(
				fo.partNumber != "" &&
				(fo.id.indexOf(trimWS(fo.partNumber)) >= 0 || fo.mmmid.indexOf(trimWS(fo.partNumber)) >= 0)				
			)
		)
	{			
		// Check is the status is "Obsolete", and if so, display ONLY when the boolDisplayLegacy is true!
		if (trimWS(fo.productStatus.toLowerCase()).indexOf('obsolete') >= 0 && !boolDisplayLegacy)
		{
			boolShowProduct = false;
		}
		else
		{
			boolShowProduct = true;
		}
	}
	return boolShowProduct;
} // END filterResults()


/**
 * Utility function to format ID number display
 *
 * @param {String}	strID	the String containing the ID number.
 * @return {String} resultStr	the formatted ID number as a String.
 */
function formatIDNumber(strID)
{
	// if the ID already includes the hyphen formatting, then just return it...
	if (strID.indexOf('-') > 0)
	{
		return strID;
	}
	
	// ...otherwise, add the hyphens.		
	var dash = "-";
	var resultStr = "";
	var slicedStrID_1 = strID.slice(0,2); // part 1
	var slicedStrID_2 = strID.slice(2,6); // part 2
	var slicedStrID_3 = strID.slice(6,10); // part 3
	var slicedStrID_4 = strID.slice(10,strID.length); // part 4
	resultStr = slicedStrID_1 + dash + slicedStrID_2 + dash + slicedStrID_3 + dash + slicedStrID_4;
	return resultStr;
} // END formatIDNumber()


/**
 * Primary function to retrieve cookie by name
 *
 * @param {String}	name	The cookie name
 * @return {String}	Result of getCookieVal() function
 */
function getCookie(name) 
{
    /*
	Example From "JavaScript and DHTML Cookbook"
	Published by O'Reilly & Associates
	Copyright 2003 Danny Goodman
	*/
	
	var arg = name + "=";
    var alen = arg.length;
    var clen = document.cookie.length;
    var i = 0;
    while (i < clen) 
	{
        var j = i + alen;
        if (document.cookie.substring(i, j) == arg) 
		{
            return getCookieVal(j);
        }
        i = document.cookie.indexOf(" ", i) + 1;
        if (i == 0) break; 
    }
    return null;
} // END getCookie()


/**
 * Utility function called by getCookie()
 *
 * @param {Number}  offset	Index of the beginning of the cookie value	
 * @return {String}	The unescaped cookie value
 */
function getCookieVal(offset) 
{
    /*
	Example From "JavaScript and DHTML Cookbook"
	Published by O'Reilly & Associates
	Copyright 2003 Danny Goodman
	*/
	
	var endstr = document.cookie.indexOf (";", offset);
    if (endstr == -1) 
	{
        endstr = document.cookie.length;
    }
    return unescape(document.cookie.substring(offset, endstr));
} // END getCookieVal()


/**
 * Utility function to retrieve a future expiration date in proper format;
 * pass three integer parameters for the number of days, hours,
 * and minutes from now you want the cookie to expire; all three
 * parameters required, so use zeros where appropriate
 *
 * @param {Number}	days	Number of days from now
 * @param {Number}	hours	Number of hours from now
 * @param {Number}	minutes	Number of minutes from now
 *
 * @return {Date}	The generated expiration date
 */
function getExpDate(days, hours, minutes) 
{
	/*
	Example From "JavaScript and DHTML Cookbook"
	Published by O'Reilly & Associates
	Copyright 2003 Danny Goodman
	*/
	
	var expDate = new Date();
	if (typeof days == "number" && typeof hours == "number" && typeof hours == "number") 
	{
		expDate.setDate(expDate.getDate() + parseInt(days));
		expDate.setHours(expDate.getHours() + parseInt(hours));
		expDate.setMinutes(expDate.getMinutes() + parseInt(minutes));
		return expDate.toGMTString();
	}
} // END getExpDate()


/**
 * This utility function determines whether or not the value from the filter field is
 * within some prescribe range above or below the value provided via the XML.
 *
 * @param {String} a	The value captured from the filter input
 * @param {String} b	The value for the given result row as provided by the XML data.
 * @param {Boolean} mm	If the value is to be measured in millimeters, this is true; if not, it is false.
 * @return {Boolean} boolResult
 */
function isNumberInRange(a,b,mm)
{
	var numRange = 0.75;
	if (mm) // measure in millimeters
	{
		numRange = 20; // reset the range amount.
	}
	
	var boolResult = false;	
	if (parseFloat(a) >= (parseFloat(b) - numRange) && parseFloat(a) <= (parseFloat(b) + numRange))
	{
		boolResult = true;
	}
	return boolResult;
} // END isNumberInRange()


/**
 * Stores the state value, as a JSON object, in a new cookie
 */
function savePageState()
{
	// Bundle up all filters and store in cookie	
	setCookie('isStateSaved',true);	
	setCookie('savedState',stateCookieJSON); // stateCookieJSON is global	
} // END savePageState()


/**
 * Store cookie value with optional details as needed
 *
 * @param {String} name		The cookie name
 * @param {String} value	The cookie value
 * @param {String} expires	The expiration date
 * @param {String} path		The path
 * @param {String} domain	The domain
 * @param {String} secure	
 *
 * @return {Boolean} true
 */
function setCookie(name, value, expires, path, domain, secure) 
{
    /*
	Example From "JavaScript and DHTML Cookbook"
	Published by O'Reilly & Associates
	Copyright 2003 Danny Goodman
	*/
	
	document.cookie = name + "=" + escape (value) +
        ((expires) ? "; expires=" + expires : "") +
        ((path) ? "; path=" + path : "") +
        ((domain) ? "; domain=" + domain : "") +
        ((secure) ? "; secure" : "");
} // END setCookie()


/**
 * Store cookie value with optional details as needed
 *
 * @param {String} imgSrc	the URL for the large product vision
 * @param {String} imgAlt	the IMAGE ALT attribtue value
 * @param {String} e	optional unused argument
 * @return {Boolean} true
 */
function showLargeImage(imgSrc,imgAlt,e) 
{
	var largeImageWrapper = document.getElementById("largeImageWrapper");
	
	if(largeImageWrapper == undefined) {
		var innerWrapper = document.getElementById("innerWrapper");
		largeImageWrapper = document.createElement("div");
		
		//find how much the page was scrolled
		var scrolledX, scrolledY;
		if( self.pageYoffset ) {
			scrolledX = self.pageXoffset;
			scrolledY = self.pageYoffset;
		} else if( document.documentElement && document.documentElement.scrollTop ) {
			scrolledX = document.documentElement.scrollLeft;
			scrolledY = document.documentElement.scrollTop;
		} else if( document.body ) {
			scrolledX = document.body.scrollLeft;
			scrolledY = document.body.scrollTop;
		}
		
		//find size of window
		var centerX, centerY;
		if( self.innerHeight ) {
			centerX = self.innerWidth;
			centerY = self.innerHeight;
		} else if( document.documentElement && document.documentElement.clientHeight ) {
			centerX = document.documentElement.clientWidth;
			centerY = document.documentElement.clientHeight;
		} else if( document.body ) {
			centerX = document.body.clientWidth;
			centerY = document.body.clientHeight;
		}
		
		//compute the top left coordinates
		var leftoffset = scrolledX + (centerX - 400) / 2;
		var topoffset = scrolledY + (centerY - 425) / 2;
					
		largeImageWrapper.id = "largeImageWrapper";
		largeImageWrapper.style.border = "1px solid #000000";
		largeImageWrapper.style.backgroundColor = "#FFFFFF";
		largeImageWrapper.style.position = "absolute";
		largeImageWrapper.style.top = topoffset + "px";
		largeImageWrapper.style.left = leftoffset + "px";
		largeImageWrapper.style.textAlign = "center";
		largeImageWrapper.style.paddingBottom = "4px";
		
		innerWrapper.appendChild(largeImageWrapper);
	}
								
	largeImageWrapper.innerHTML = "<img style='padding-bottom:4px;' src='" + imgSrc + "' alt='" + imgAlt + "' /><br /><a href='javascript:document.getElementById(\"innerWrapper\").removeChild(document.getElementById(\"largeImageWrapper\"));void(0);'>Close</a>&nbsp;";		
} // END showLargeImage()


/**
 * Displays the Filter inputs, then calls showResults()
 *
 *
 * @return {Boolean} true
 */
function showOptions() 
{
	//reset also calls this function
	firstFilter = null;
	
	filterApplied["size"] = false;
	filterApplied["aspectRatio"] = false;
	filterApplied["controller"] = false;
	filterApplied["cableLength"] = false;
	filterApplied["cableExit"] = false;	
	
	// hide any existing filters...
	document.getElementById("requestSize").style.display = "none";
	document.getElementById("requestAspectRatio").style.display = "none";
	document.getElementById("requestController").style.display = "none";
	document.getElementById("requestCableLength").style.display = "none";
	document.getElementById("requestCableExit").style.display = "none";
	document.getElementById("requestPartNumberLabel").style.display = "none";
	document.getElementById("requestPartNumber").style.display = "none";
	document.getElementById("requestButtons").style.display = "none";
	document.getElementById("theResults").innerHTML = "";
	
	var sizeOptions = [];
	var aspectRatioOptions = [];
	var controllerOptions = [];
	var cableLengthOptions = [];
	var cableExitOptions = [];
	var partNumberOptions = [];
	
	var sizeOptionsLength = 0;
	var aspectRatioOptionsLength = 0;
	var controllerOptionsLength = 0;
	var cableLengthOptionsLength = 0;
	var cableExitOptionsLength = 0;
	var partNumberOptionsLength = 0;
	
	
	var size = document.getElementById("size");
	var aspectRatio = document.getElementById("aspectRatio");
	var controller = document.getElementById("controller");
	var cableLength = document.getElementById("cableLength");
	var cableExit = document.getElementById("cableExit");
	var partNumber = document.getElementById("partNumber");
	var viewAreaDiag = document.getElementById("viewAreaDiag");
	var viewAreaWidth = document.getElementById("viewAreaWidth");
	var viewAreaHeight = document.getElementById("viewAreaHeight");
	var outerAreaDiag = document.getElementById("outerAreaDiag");
	var outerAreaWidth = document.getElementById("outerAreaWidth");
	var outerAreaHeight = document.getElementById("outerAreaHeight");
	
	size.value = "";
	viewAreaDiag.value = "";
	viewAreaWidth.value = "";
	viewAreaHeight.value = "";
	outerAreaDiag.value = "";
	outerAreaWidth.value = "";
	outerAreaHeight.value = "";
	aspectRatio.innerHTML = "";
	controller.innerHTML = "";
	cableLength.innerHTML = "";
	cableExit.innerHTML = "";
	partNumber.value = "";
			
	// Pre-populate select fields with appropriate options
	aspectRatio.options[0] = new Option("-Select-","");
	controller.options[0] = new Option("-Select-","");
	cableLength.options[0] = new Option("-Select-","");
	cableExit.options[0] = new Option("-Select-","");
	
	for(var i=0; i<arrayLength(results); i++) {
		if(results[i].aspectRatio != "") {
			if(aspectRatioOptions[results[i].aspectRatio.toLowerCase()] == undefined) {
				aspectRatio.options[aspectRatio.length] = new Option(results[i].aspectRatio, results[i].aspectRatio);
				aspectRatioOptions[results[i].aspectRatio.toLowerCase()] = 1;
				aspectRatioOptionsLength++;
			}
		}
		if(results[i].controller != "") {
			if(controllerOptions[results[i].controller.toLowerCase()] == undefined) {
				controller.options[controller.length] = new Option(results[i].controller, results[i].controller);
				controllerOptions[results[i].controller.toLowerCase()] = 1;
				controllerOptionsLength++;
			}
		}			
		if(results[i].cableLength != "") {
			if (IE5)
			{
				//
			}
			else if (NN6)
			{
				
				var strCurrentOptions = cableLength.options.toString();
				if (strCurrentOptions.indexOf(results[i].cableLength) <= -1)
				{
					cableLength.options[cableLength.options.length] = new Option(results[i].cableLength,results[i].cableLength);
				}
				
			}
			else
			{
			
			}
				cableLengthOptionsLength++;
		}
		if(results[i].cableExit != "") {
			if(cableExitOptions[results[i].cableExit.toLowerCase()] == undefined) {
				cableExit.options[cableExit.length] = new Option(results[i].cableExit, results[i].cableExit);
				cableExitOptions[results[i].cableExit.toLowerCase()] = 1;
				cableExitOptionsLength++;
			}
		}
		if(results[i].size != "") {
			sizeOptionsLength++;
		}
		if(results[i].id != "" || results[i].mmmid != "") {
			partNumberOptionsLength++;
		}
		
	}
	
	sortOptionsList(aspectRatio, null);
	sortOptionsList(controller, null);
	sortOptionsList(cableLength, sortCableLength);
	sortOptionsList(cableExit, sortCableExit);
	
	if(false) {
		document.getElementById("requestSize").style.display = "block";
	}		
	if(controllerOptionsLength > 1) {
		document.getElementById("requestController").style.display = "block";
	}
	
	if (true) {
		document.getElementById("requestAspectRatio").style.display = "block";
		
		// The three below must be extacted and registered with this script //
		document.getElementById("requestViewAreaDimensions").style.display = "block";
		document.getElementById("requestOuterAreaDimensions").style.display = "block";
	}		
	
	// These two cable-related filters not currenlty required...
	if(partNumberOptionsLength >= 1) { // At least one child has a part number, so provide the search field for PNM.
		document.getElementById("requestPartNumberLabel").style.display = "block";
		document.getElementById("requestPartNumber").style.display = "block";
	}
	
	if(sizeOptionsLength > 1 || aspectRatioOptionsLength  > 1 || controllerOptionsLength  > 1 || cableLengthOptionsLength  > 1 || cableExitOptionsLength  > 1) {
		document.getElementById("requestButtons").style.display = "block";
	} else {
		document.getElementById("resultsTable").style.display = "none";
		showResults();
	}
	if (getCookie('isStateSaved'))
	{
		showResults();	
	}
} // END showOptions()

/**
 * Generates the results table   
 */
function showResults() 
{		
	var size = ""; 	
	var viewAreaDiagInches = "";
	var viewAreaDiagMM = "";
	var viewAreaWidthInches = "";
	var viewAreaWidthMM = "";
	var viewAreaHeightInches = "";
	var viewAreaHeightMM = "";
	var outerAreaDiagInches = "";
	var outerAreaDiagMM = "";
	var outerAreaWidthInches = "";
	var outerAreaWidthMM = "";
	var outerAreaHeightInches = "";
	var outerAreaHeightMM = "";
	var aspectRatio = "";
	var controller = "";
	var cableLength = "";
	var cableExit = "";
	var partNumber = ""; 
	
	// Back button functionality relies on the filters stored in a cookie.
	var isStateSaved = getCookie('isStateSaved');
	
	if (isStateSaved) // the saved state cookie is set to true, so get the page state
	{
		// First DESTROY the isStateSaved cookie!
		deleteCookie('isStateSaved'); 
		
		// Next, get the state cookie.
		var stateCookieString = getCookie('savedState');

		// Clear out the (global) JSON string holding the state!
		stateCookieJSON = "";		
		
		// Turn the cookie value (String) into a JSON object...
		var stateCookie = eval( "(" + stateCookieString + ")" );

		// Now, assign the state cookie values to the filter variables.
		size = stateCookie.size;
		viewAreaDiagInches = stateCookie.viewAreaDiagInches;
		viewAreaDiagMM = stateCookie.viewAreaDiagMM;
		viewAreaWidthInches = stateCookie.viewAreaWidthInches;
		viewAreaWidthMM = stateCookie.viewAreaWidthMM;
		viewAreaHeightInches = stateCookie.viewAreaHeightInches;
		viewAreaHeightMM = stateCookie.viewAreaHeightMM;
		outerAreaDiagInches = stateCookie.outerAreaDiagInches;
		outerAreaDiagMM = stateCookie.outerAreaDiagMM;
		outerAreaWidthInches = stateCookie.outerAreaWidthInches;
		outerAreaWidthMM = stateCookie.outerAreaWidthMM;
		outerAreaHeightInches = stateCookie.outerAreaHeightInches;
		outerAreaHeightMM = stateCookie.outerAreaHeightMM;
		aspectRatio = stateCookie.aspectRatio;
		controller = stateCookie.controller;
		cableLength = stateCookie.cableLength;
		cableExit = stateCookie.cableExit;
		partNumber = stateCookie.partNumber; 
		
		// Lastly, we need to replenish the form fields with the values stored in the page state
		if (null != document.getElementById("size"))
		{
			document.getElementById("size").value = size;	
		}
		if (null != document.getElementById("viewAreaDiag"))
		{
			document.getElementById("viewAreaDiag").value = viewAreaDiagInches;	
		}
		if (null != document.getElementById("viewAreaWidth"))
		{
			document.getElementById("viewAreaWidth").value = viewAreaWidthInches;	
		}
		if (null != document.getElementById("viewAreaHeight"))
		{
			document.getElementById("viewAreaHeight").value = viewAreaHeightInches;	
		}
		if (null != document.getElementById("outerAreaDiag"))
		{
			document.getElementById("outerAreaDiag").value = outerAreaDiagInches;	
		}
		if (null != document.getElementById("outerAreaWidth"))
		{
			document.getElementById("outerAreaWidth").value = outerAreaWidthInches;	
		}
		if (null != document.getElementById("outerAreaHeight"))
		{
			document.getElementById("outerAreaHeight").value = outerAreaHeightInches;	
		}
		if (null != document.getElementById("partNumber"))
		{
			document.getElementById("partNumber").value = partNumber;	
		}
		
		//... we need to filterOptions() for the SELECT fields!
		if (null != document.getElementById("aspectRatio"))
		{
			var objAR = document.getElementById("aspectRatio");
			for (var i = 0; i < objAR.options.length; i++ )
			{
				if (aspectRatio != "" && objAR.options[i].value == aspectRatio)
				{
					objAR.options[i].selected = "selected";
					filterOptions(objAR);
				}
			}	
		}
		if (null != document.getElementById("controller"))
		{
			var objAR = document.getElementById("controller");
			for (var i = 0; i < objAR.options.length; i++ )
			{
				if (controller != "" && objAR.options[i].value == controller)
				{
					objAR.options[i].selected = "selected";
					filterOptions(objAR);
				}
			}	
			
		}
		if (null != document.getElementById("cableLength"))
		{
			var objAR = document.getElementById("cableLength");
			for (var i = 0; i < objAR.options.length; i++ )
			{
				if (cableLength != "" && objAR.options[i].value == cableLength)
				{
					objAR.options[i].selected = "selected";
					filterOptions(objAR);
				}
			}	
			
		}
		if (null != document.getElementById("cableExit"))
		{
			var objAR = document.getElementById("cableExit");
			for (var i = 0; i < objAR.options.length; i++ )
			{
				if (cableExit != "" && objAR.options[i].value == cableExit)
				{
					objAR.options[i].selected = "selected";
					filterOptions(objAR);
				}
			}	
			
		}
		// ...finally, destroy savedState cookie..
		deleteCookie('savedState'); 
		
	}
	else // The page state was NOT saved, so set the filter variables to the form field values!
	{
		size = document.getElementById("size").value;	
		viewAreaDiagInches = document.getElementById("viewAreaDiag").value;
		viewAreaDiagMM = document.getElementById("viewAreaDiag").value;
		viewAreaWidthInches = document.getElementById("viewAreaWidth").value;
		viewAreaWidthMM = document.getElementById("viewAreaWidth").value;
		viewAreaHeightInches = document.getElementById("viewAreaHeight").value;
		viewAreaHeightMM = document.getElementById("viewAreaHeight").value;
		outerAreaDiagInches = document.getElementById("outerAreaDiag").value;
		outerAreaDiagMM = document.getElementById("outerAreaDiag").value;
		outerAreaWidthInches = document.getElementById("outerAreaWidth").value;
		outerAreaWidthMM = document.getElementById("outerAreaWidth").value;
		outerAreaHeightInches = document.getElementById("outerAreaHeight").value;
		outerAreaHeightMM = document.getElementById("outerAreaHeight").value;
		
		var aspectRatioObj = document.getElementById("aspectRatio");
		if(aspectRatioObj.options.length > 0) {
			aspectRatio = aspectRatioObj.options[aspectRatioObj.selectedIndex].value;
		} 
		
		var controllerObj = document.getElementById("controller");
		if(controllerObj.options.length > 0) {
			controller = controllerObj.options[controllerObj.selectedIndex].value;
		} 
		
		var cableLengthObj = document.getElementById("cableLength");
		if(cableLengthObj.options.length > 0) {
			cableLength = cableLengthObj.options[cableLengthObj.selectedIndex].value;
		}
		
		var cableExitObj = document.getElementById("cableExit");
		if(cableExitObj.options.length > 0) {
			cableExit = cableExitObj.options[cableExitObj.selectedIndex].value;
		} 
				
		partNumber = document.getElementById("partNumber").value; 		
	}
	
	// In all cases, reset the global string for the CURRENT state as a JSON string.	
	stateCookieJSON = "{'size':'"+ size +"','viewAreaDiagInches':'"+ viewAreaDiagInches +"','viewAreaDiagMM':'"+ viewAreaDiagMM +"','viewAreaWidthInches':'"+ viewAreaWidthInches +"','viewAreaWidthMM':'"+ viewAreaWidthMM +"','viewAreaHeightInches':'"+ viewAreaHeightInches +"','viewAreaHeightMM':'"+ viewAreaHeightMM +"','outerAreaDiagInches':'"+ outerAreaDiagInches +"','outerAreaDiagMM':'"+ outerAreaDiagMM +"','outerAreaWidthInches':'"+ outerAreaWidthInches +"','outerAreaWidthMM':'"+ outerAreaWidthMM +"','outerAreaHeightInches':'"+ outerAreaHeightInches +"','outerAreaHeightMM':'"+ outerAreaHeightMM +"','aspectRatio':'"+ aspectRatio +"','controller':'"+ controller +"','cableLength':'"+ cableLength +"','cableExit':'"+ cableExit +"','partNumber':'"+ partNumber +"'}";
	
	// Now, generate the results table...					
	var output = "<table class='qProducts' border='0' cellpadding='0' cellspacing='0' width='100%'><tr>";
	var columns = 0;
	
	output += "<th><span>Viewing Area Dimension</span><br /><br />D = Diagonal<br />W = Width<br />H = Height</th>";
	columns++;
	output += "<th><span>Outer Area Dimension</span><br /><br />D = Diagonal<br />W = Width<br />H = Height</th>";
	columns++;
	output += "<th><span>Controllers Available</span><br /><br />UC = USB<br />SC = Serial</th>";
	columns++;
	output += "<th><span>Aspect Ratio</span></th>";
	columns++;
	output += "<th><span>Cable Length<br />inches (mm)</span></th>";
	columns++;
	output += "<th><span>Cable Exit</span></th>";	
	columns++;
	output += "<th><span>Where to Buy</span></th></tr>";
	
	var shown = false;
	
	/*
	 * NOTE: prior to looping through all filtered row results, we must sort the results
	 * according to each row's STATUS value. The order of stati is defined below.
	 */
	// The status sort order... These values may change according to customer's rules!!
	var mySortOrder = new Array('Recommended Product','Alternate Product', 'Obsolete Product');
	
	/* Assign to results the return from the sortResultsByStatus function. Pass in to this function  
	 * the results AND the array containing the sort order...
	 */
	var origCnt = results.length;
	results = sortResultsByStatus(results,mySortOrder);		
	var sortedCnt = results.length;
	
	/* Determine whether or not to display legacy products.
	 * If any of these fields is populated, then do NOT dispaly
	 * the legacy products!
	 */
	var boolDisplayLegacy = true;
	if (
		viewAreaDiagInches != "" ||
		viewAreaDiagMM != "" ||
		viewAreaWidthInches != "" ||
		viewAreaWidthMM != "" ||
		viewAreaHeightInches != "" ||
		viewAreaHeightMM != "" ||
		outerAreaDiagInches != "" ||
		outerAreaDiagMM != "" ||
		outerAreaWidthInches != "" ||
		outerAreaWidthMM != "" ||
		outerAreaHeightInches != "" ||
		outerAreaHeightMM != "" ||
		aspectRatio != "" ||
		controller != ""
	)
	{
		boolDisplayLegacy = false;	
	}
	
	// with the newly sorted results... loop through, filter, then display as a table row.		
	for(var i=0; i<arrayLength(results); i++) 
	{
		// Add ALL registered FILTERS to this JSON object, for use in filterResults() function
		var jsonFilterOpts = {"partNumber":partNumber,
								"size":size,
								"sizeResults":results[i].size,
								"sizeMilli":results[i].sizeMilli,
								"aspectRatio":aspectRatio,
								"aspectRatioResults":results[i].aspectRatio,
								"controller":controller,
								"controllerResults":results[i].controller,
								"cableLength":cableLength,
								"cableLengthResults":results[i].cableLength,
								"cableExit":cableExit,
								"cableExitResults":results[i].cableExit,
								"viewAreaDiagInches":viewAreaDiagInches,
								"viewAreaDiagInchesResults":results[i].viewAreaDiagInches,
								"viewAreaDiagMM":viewAreaDiagMM,
								"viewAreaDiagMMResults":results[i].viewAreaDiagMM,
								"viewAreaWidthInches":viewAreaWidthInches,	
								"viewAreaWidthInchesResults":results[i].viewAreaWidthInches,
								"viewAreaWidthMM":viewAreaWidthMM,
								"viewAreaWidthMMResults":results[i].viewAreaWidthMM,
								"viewAreaHeightInches":viewAreaHeightInches,
								"viewAreaHeightInchesResults":results[i].viewAreaHeightInches,
								"viewAreaHeightMM":viewAreaHeightMM,
								"viewAreaHeightMMResults":results[i].viewAreaHeightMM,
								"outerAreaDiagInches":outerAreaDiagInches,
								"outerAreaDiagInchesResults":results[i].outerAreaDiagInches,
								"outerAreaDiagMM":outerAreaDiagMM,
								"outerAreaDiagMMResults":results[i].outerAreaDiagMM,
								"outerAreaWidthInches":outerAreaWidthInches,
								"outerAreaWidthInchesResults":results[i].outerAreaWidthInches,
								"outerAreaWidthMM":outerAreaWidthMM,
								"outerAreaWidthMMResults":results[i].outerAreaWidthMM,
								"outerAreaHeightInches":outerAreaHeightInches,
								"outerAreaHeightInchesResults":results[i].outerAreaHeightInches,
								"outerAreaHeightMM":outerAreaHeightMM,
								"outerAreaHeightMMResults":results[i].outerAreaHeightMM,
								"mmmid":formatIDNumber(results[i].mmmid),
								"displayLegacy":boolDisplayLegacy,
								"productStatus":results[i].productStatus,
								"id":results[i].id };
		
		// Display the FILTERED result rows, based on the selected filter options
		if(filterResults(jsonFilterOpts)) 
		{
			var productStatusValue = "";
			var privacyReferenceValue = "";
			
			if(null != results[i].privacyReference && results[i].privacyReference != "")
			{
				privacyReferenceValue = "("+results[i].privacyReference+")&nbsp;";
			}
			
			if(null != results[i].productStatus && results[i].productStatus.toLowerCase().indexOf('obsolete') >= 0)
			{
				productStatusValue = "-&nbsp;Legacy Product (contact 3M for availability)<br />";
			}
			else if(null != results[i].productStatus && results[i].productStatus.toLowerCase().indexOf('recommended') >= 0)
			{
				productStatusValue = "-&nbsp;<b>"+results[i].productStatus+"</b><br />";
			}
			else if (null == results[i].productStatus || results[i].productStatus == "")
			{
				productStatusValue = "";
			}
			else
			{
				productStatusValue = "-&nbsp;"+results[i].productStatus+"<br />";
			}
			
			output += "<tr><td colspan=\"" + (columns + 2) + "\" style=\"background-color: lightblue; line-height: 18px;\">";
			output += "<b>3M ID: ";
			if (null != results[i].id && results[i].id != "" && (results[i].id.substring(0,2) != "98"))
			{
				output += "<a href='" + results[i].url + "' onclick='savePageState()'>" + results[i].id + "</a></b>&nbsp;("+ formatIDNumber(results[i].mmmid) + ")&nbsp;"+ privacyReferenceValue + productStatusValue;
			}
			else
			{
				output += "<a href='" + results[i].url + "' onclick='savePageState()'>" + formatIDNumber(results[i].mmmid) + "</a></b>&nbsp;"+ privacyReferenceValue + productStatusValue;
			}
			output += "</td></tr>";
			shown = true;
			output += "<tr>";			
			if(results[i].size != "" || results[i].viewArea != "" || results[i].viewAreaDiagInches != "" || results[i].viewAreaDiagMM != "" || results[i].viewAreaWidthInches != "" || results[i].viewAreaWidthMM != "" || results[i].viewAreaHeightInches != "" || results[i].viewAreaHeightMM != "") {
				
					output += "<td style='font-size: 10px;font-family: Verdana, Arial, Helvetica, sans-serif; white-space: nowrap;'>D: " + results[i].viewAreaDiagInches + "\" (" + results[i].viewAreaDiagMM + " mm)<br />W: " + results[i].viewAreaWidthInches + "\" (" + results[i].viewAreaWidthMM + " mm)<br />H: " + results[i].viewAreaHeightInches + "\" (" + results[i].viewAreaHeightMM + " mm)</td>";
				
			}
			else
			{
				output += "<td>&#160;</td>";	
			}
			if(results[i].outerArea != "" || results[i].outerAreaDiagonal != "" || results[i].outerAreaDiagInches != "" || results[i].outerAreaDiagMM != "" || results[i].outerAreaWidthInches != "" || results[i].outerAreaWidthMM != "" || results[i].outerAreaHeightInches != "" || results[i].outerAreaHeightMM != "") {
				
					output += "<td style='font-size: 10px;font-family: Verdana, Arial, Helvetica, sans-serif; white-space: nowrap;'>D: " + results[i].outerAreaDiagInches + "\" (" + results[i].outerAreaDiagMM + " mm)<br />W: " + results[i].outerAreaWidthInches + "\" (" + results[i].outerAreaWidthMM + " mm)<br />H: " + results[i].outerAreaHeightInches + "\" (" + results[i].outerAreaHeightMM + " mm)</td>";
				
			}
			else
			{
				output += "<td>&#160;</td>";	
			}
			if(results[i].protocolSerial != "") {
				if(results[i].protocolSerial != "")
					output += "<td style='font-size: 10px;font-family: Verdana, Arial, Helvetica, sans-serif;'>" + results[i].protocolSerial + "</td>";
				else
					output += "<td>&#160;</td>";
			}
			if(results[i].connector != "") {
				if(results[i].connector != "")
					output += "<td style='font-size: 10px;font-family: Verdana, Arial, Helvetica, sans-serif;'>" + results[i].connector + "</td>";
				else
					output += "<td>&#160;</td>";
			}
			if(results[i].screenSize != "") {
				if(results[i].screenSize != "")
					output += "<td style='font-size: 10px;font-family: Verdana, Arial, Helvetica, sans-serif;'>" + results[i].screenSize + "</td>";
				else
					output += "<td>&#160;</td>";
			}
			if(results[i].displayType != "") {
				if(results[i].displayType != "")
					output += "<td style='font-size: 10px;font-family: Verdana, Arial, Helvetica, sans-serif;'>" + results[i].displayType + "</td>";
				else
					output += "<td>&#160;</td>";
			}
			if(results[i].controllerAvailable != "") {
				if(results[i].controllerAvailable != "")
					output += "<td style='font-size: 10px;font-family: Verdana, Arial, Helvetica, sans-serif;'>" + results[i].controllerAvailable + "</td>";
				else
					output += "<td>&#160;</td>";
			}
			if(results[i].aspectRatio != "") {
				if(results[i].aspectRatio != "")
					output += "<td style='font-size: 10px;font-family: Verdana, Arial, Helvetica, sans-serif;'>" + results[i].aspectRatio + "</td>";
				else
					output += "<td>&#160;</td>";	
			}				
			if(results[i].cableLengthInches != "" || results[i].cableLengthMM != "") {

					output += "<td style='font-size: 10px;font-family: Verdana, Arial, Helvetica, sans-serif; white-space: nowrap;'>" + results[i].cableLengthInches + "\" (" +results[i].cableLengthMM + " mm)" + "</td>";
			}
			else
			{
					output += "<td>&#160;</td>";	
			}
			if(results[i].cableExit != "") {
				if(results[i].cableExit != "")
					output += "<td style='font-size: 10px;font-family: Verdana, Arial, Helvetica, sans-serif;'>" + results[i].cableExit + "</td>";
				else
					output += "<td>&#160;</td>";
			}
			
			
			output += "<td style='font-size: 10px;font-family: Verdana, Arial, Helvetica, sans-serif;'><select onchange=\"if(this[this.selectedIndex].value != '')window.open(this[this.selectedIndex].value,'distro','height=465,width=800,scrollbars=yes');\"><option value=''>Select a Region</option><option value='/wps/portal/3M/en_US/TouchSystems/TouchScreen/Solutions/DistributorInventory/?soloMode=true&amp;part=" + results[i].id + "'>US Distribution</option><option value=''></option><option value='http://selector.3m.com/selector/us/en/creative_communications/touch/wtb/ss.asp?FAM=TouchSys&SORD=104&LL=sys&FT_104=193&FT_107=0'>Africa</option><option value='http://selector.3m.com/selector/us/en/creative_communications/touch/wtb/ss.asp?FAM=TouchSys&SORD=104+105&LL=sys&FT_104=401&FT_105=424'>America - Central</option><option value='http://selector.3m.com/selector/us/en/creative_communications/touch/wtb/ss.asp?FAM=TouchSys&SORD=104+105&LL=sys&FT_104=401&FT_105=425'>America - North</option><option value='http://selector.3m.com/selector/us/en/creative_communications/touch/wtb/ss.asp?FAM=TouchSys&SORD=104+105&LL=sys&FT_104=401&FT_105=421'>America - South</option><option value='http://selector.3m.com/selector/us/en/creative_communications/touch/wtb/ss.asp?FAM=TouchSys&SORD=104&LL=sys&FT_104=202&FT_107=0'>Asia</option><option value='http://selector.3m.com/selector/us/en/creative_communications/touch/wtb/ss.asp?FAM=TouchSys&SORD=104+105&LL=sys&FT_104=401&FT_105=423'>Caribbean</option><option value='http://selector.3m.com/selector/us/en/creative_communications/touch/wtb/ss.asp?FAM=TouchSys&SORD=104&LL=sys&FT_104=181&FT_107=0'>Europe</option><option value='http://selector.3m.com/selector/us/en/creative_communications/touch/wtb/ss.asp?FAM=TouchSys&SORD=104&LL=sys&FT_104=194&FT_107=0'>Middle East</option><option value='http://selector.3m.com/selector/us/en/creative_communications/touch/wtb/ss.asp?FAM=TouchSys&SORD=104&LL=sys&FT_104=212&FT_107=0'>Pacific</option></select></td></tr>";
		}
		jsonProdOpts = null;
	}
	
	if(!shown && arrayLength(results) > 0) 
	{
		output += "<tr><td colspan='" + (columns + 2) + "' style='font-size: 10px;font-family: Verdana, Arial, Helvetica, sans-serif;'>"+ genericNoProductFoundErrorMssg +" Please contact your <a href='http://solutions.3m.com/wps/portal/3M/en_US/3MTouchSystems/TS/CustomerSupport/ContactUs/' target='_blank'>regional 3M Touch Systems representative</a>.</td></tr>";		
	}
	
	output += "</table>";
	document.getElementById("theResults").innerHTML = output;
	
} // END showResults()


/**
 * Sorts the SELECT OPTIONS for the given ID.
 *
 * @param {String} id  The unsorted, raw results array
 * @param {String} func the custom sort function name
 * @return {Boolean} true
 */
function sortOptionsList(id, func) 
{
	arrTexts = new Array();
	
	for(var i=0; i<id.length; i++)  {
		arrTexts[i] = id.options[i].value;
	}
	
	if(func != null) {
		arrTexts.sort(func);
	} else {
		arrTexts.sort();
	}	
	
	for(var i=0; i<id.length; i++)  {
		id.options[i].text = arrTexts[i];
		if(id.options[i].text == "") id.options[i].text = "-Select-";
		id.options[i].value = arrTexts[i];
	}
} // END sortOptionsList()


/**
 * Sorts the results array according to pre-defined status order.
 *
 * @param {Array} arrResults  The unsorted, raw results array
 * @param {Array} arrSortOrder The sorted array of Status types
 * @return {Array} sortedResults The sorted results array
 */
function sortResultsByStatus(arrResults,arrSortOrder)
{ 
	var sortedResults = [];
	var arrNoStatus = [];
	
	// First, store all results with NO STATUS in a new array!		
	for (var i = 0; i<arrayLength(arrResults); i++)
	{
		if (!arrResults[i].productStatus || arrResults[i].productStatus == "")
		{
			arrNoStatus.push(arrResults[i]);
		}
	}
	
	// Next, store all results WITH a status in a new array, in the correct sort order!
	for (var j = 0; j<arrayLength(arrSortOrder); j++)
	{
		for (var k = 0; k<arrayLength(arrResults); k++)
		{
			
			if (null != arrResults[k].productStatus 
				&& trimWS(arrResults[k].productStatus.toLowerCase()).indexOf(trimWS(arrSortOrder[j].toLowerCase())) >= 0)
			{
				sortedResults.push(arrResults[k]);
			}
		}
	}
	
	// Finally, concatinate and return the sorted results.
	sortedResults.concat(arrNoStatus);
	return sortedResults.concat(arrNoStatus);
} // END sortResultsByStatus()


/**
 * Utility function for removing whitespace from the ENDS of a given String
 *
 * @param {String} str  The raw String
 * @return {String} str The trimmed String
 */
function trim(str) {
	var	str = str.replace(/^\s\s*/, ''), ws = /\s/, i = str.length;
	while (ws.test(str.charAt(--i)));
	return str.slice(0, i + 1);
} // END trim()


/**
 * Utility function for removing ALL whitespace from a given String
 *
 * @param {String} str  The raw String
 * @return {String} str The trimmed String
 */
function trimWS(str)
{	
	return str.replace(/\s+/g, '');
} // END trimWS()
	



/* ----------------------------------------------------------------------------------------
 * ----------------------------------------------------------------------------------------
 * Below are LEGACY FUNCTIONS that are NOT USED in Touch Systems PoW! XSLT
 *
 * It is assumed that this JS file MAY be used by Touch System pages
 * outside of the Touch Systems PoW! Catalog, therefore, removal of these
 * functions MAY cause regression bugs in sites outside of the TS PoW!
 * Catalog. 
 *
 * However, these functions may be removed if/when it is proven that they are not
 * used elsewhere in Touch Stystems.
 *
 * a1rx4zz 10-14-2009
 * ----------------------------------------------------------------------------------------
 * ----------------------------------------------------------------------------------------
 */ 

//the request a quote/information calls this upon submit
function checkAndSetUrl(theForm) 
{
	var theElements = theForm.elements;
	var theAction = "";
	for(var i=0;i<theElements.length;i++) {
		if(theElements[i].type == "checkbox" && theElements[i].checked){
			theAction += theElements[i].value + ",";	
		}
	}
	if(theAction == "") {
		return false;
	} else {
		theAction = theAction.substring(0,theAction.length - 1);
		theForm.action += theAction;
	}		
	return true;
}

function formatCableLength(strLength)
{
	var resultStr = "";
	var millimeters = " mm";
	var inches = "\"";

	var slicedStrLengthBeginIn = strLength.slice(0,(strLength.indexOf('(')-1)); // String beginning to one before the "("...
	var slicedStrLengthBeginMM = strLength.slice((strLength.indexOf('(') -1),strLength.indexOf(')')); // from one before the "(" to the ")"...
	var slicedStrLengthEndMM = strLength.slice(strLength.indexOf(')'),strLength.length); // from the ")" to the end...
	
	resultStr = slicedStrLengthBeginIn + inches + slicedStrLengthBeginMM + millimeters + slicedStrLengthEndMM;
	return resultStr;
}
	
function getCookieValue(name) {
	var crumbs = document.cookie.split("; ");
	for(var i=0;i<crumbs.length;i++) {
		if(crumbs[i].indexOf(name + "=") == 0) {
			return crumbs[i].substring(crumbs[i].indexOf("=")+1,crumbs[i].length);
		}
	}
	return null;
}
	
function getUrlNid() {
	var urlParts = String(document.location).split('?');
	if(urlParts.length == 2) {
		var nidParts = urlParts[1].split('=');
		if(nidParts.length == 2) {
			return(nidParts[1]);
		}
	}
	return null;
}

function preFill() 
{
	var nid = getUrlNid();
	
	var partNumber = getCookieValue(nid+"partNumber")
	var size = getCookieValue(nid+"size")
	var aspectRatio = getCookieValue(nid+"aspectRatio")
	var controller = getCookieValue(nid+"controller")
	var cableLength = getCookieValue(nid+"cableLength")
	var cableExit = getCookieValue(nid+"cableExit")
	var show = false;
	
	if(partNumber != null) {
		show = true;
		var partNumberObj = document.getElementById("cableLength");
		partNumberObj.value = partNumber;
		filterOptions(partNumberObj);
	}
	if(size != null) {
		show = true;
		var sizeObj = document.getElementById("size");
		sizeObj.value = size;
		filterOptions(sizeObj);
	}
	if(aspectRatio != null) {
		show = true;
		var aspectRatioObj = document.getElementById("aspectRatio");
		aspectRatioObj.selectedIndex = aspectRatio;
		filterOptions(aspectRatioObj);
	}	
	if(controller != null) {
		show = true;
		var controllerObj = document.getElementById("controller");
		controllerObj.selectedIndex = controller;
		filterOptions(controllerObj);
	}
	if(cableLength != null) {
		show = true;
		var cableLengthObj = document.getElementById("cableLength");
		cableLengthObj.selectedIndex = cableLength;
		filterOptions(cableLengthObj);
	}
	if(cableExit != null) {
		show = true;
		var cableExitObj = document.getElementById("cableExit");
		cableExitObj.selectedIndex = cableExit;
		alert(cableExit);
		alert(cableExitObj[cableExitObj.selectedIndex].value);
		filterOptions(cableExitObj);
	}
	if(show) {	
		showResults();
	}
}

function related(whichDiv,incoming,limit) 
{	
	var primaryArray = incoming.split(';');
	var secondArray = [];
	var html = "";
	var shown = 0;
	for (i=0;i<primaryArray.length;i++) {
		secondArray = primaryArray[i].split(',');
		if(secondArray.length == 3 && ((secondArray[2] == "show" && shown < 2) || !limit)) {
			html += "<a href='?PC_7_RJH9U52308F8102RKCHBJT2831_nid=" + secondArray[0] + "1CTX145TGXgl'>";
			html += secondArray[1];
			html += "</a><br />";
			shown++;
		}		
	} // end for i
	eval("document.getElementById('"+whichDiv+"Parts').innerHTML = html");
} //close function

function showDataDocuments(list, singleName) 
{
	var listShown = [];
	var useSingleName = false;
	var check = 0;
	for(var i=0;i<arrayLength(list);i++) {
		if(listShown[list[i].checkValue] == undefined) {
			listShown[list[i].checkValue] = 1;
			check++;
		}
	}
	
	if(check == 1) {
		useSingleName = true;
	}
	
	listShown = [];
	for(var i=0;i<arrayLength(list);i++) {
		if(listShown[list[i].checkValue] == undefined) {
			document.write('<a target="_blank" href="' + list[i].hrefUrl + '">');
			document.write(useSingleName ? singleName : list[i].hrefDisplay); 
			document.write('</a>' + list[i].size + '<br />');
			listShown[list[i].checkValue] = 1;
		}
	}
}

function showDiv(what,which,numdivs) 
{// PATHS FOR ON AND OFF IMAGES
//	TURN OFF ALL LAYERS AND/OR TABS
	for(i=0;i<numdivs;i++) 
	{
		if(IE5) eval("document.all."+what+i+".style.display='none'");
		if(NN6) eval("document.getElementById('"+what+i+"').style.display='none'");

		if (what == "qtable") 
		{
			document.getElementById("tab"+i).style.backgroundImage='url(/3MContentRetrievalAPI/BlobServlet?assetId=1180604440746&assetType=MMM_Image&blobAttribute=ImageFile)';
		}
	}

//	GO BACK THROUGH AND TURN ON THE DESIRED LAYER AND/OR TABS
	if(IE5) eval("document.all."+what+which+".style.display='block'");
	if(NN6) eval("document.getElementById('"+what+which+"').style.display='inline'");

	if (what == "qtable") 
	{
		document.getElementById("tab"+which).style.backgroundImage='url(/3MContentRetrievalAPI/BlobServlet?assetId=1180604440746&assetType=MMM_Image&blobAttribute=ThumbnailImage)';
	}
}

function showDocument(list, heading) 
{
	var listShown = [];
	document.write('<tr><td align="center" style="border-bottom:0 !important;padding-bottom:0px !important;">&nbsp</td><td class="texttwo" style="border-bottom:0 !important;padding-bottom:0px !important;"><h3>' + heading + '</h3></td></tr>');
	for(var i=0;i<arrayLength(list);i++) {
		if(listShown[list[i].checkValue] == undefined) {
			document.write('<tr><td align="center" style="border-bottom:0 !important;padding-bottom:0px !important;padding-top:0px !important;">');
			document.write('<input type="checkbox" name="PC_7_RJH9U52308F8102RKCHBJT2831_id" value="' + list[i].checkValue + '"/>');
			document.write('</td><td class="texttwo" style="border-bottom:0 !important;padding-bottom:0px !important;padding-top:0px !important;"><div class="genInfo">');
			document.write('<a target="_blank" href="' + list[i].hrefUrl + '">' + list[i].hrefDisplay + '</a>' + list[i].size);
			document.write('</div></td></tr>');
			
			listShown[list[i].checkValue] = 1;
		}
	}
}

function showGraphic3dModels() 
{
	var attributes;
	for(var i=0;i<arrayLength(graphic3dModels);i++) {
		if(graphic3dModels[i].processed == undefined) {
			document.write('<tr valign="top"><td width="40%">' + graphic3dModels[i].id +', 3D, ' + graphic3dModels[i].revision + '</td>');
			attributes = [];
			for(var j=0;j<arrayLength(graphic3dModels);j++) {
				if(graphic3dModels[i].id == graphic3dModels[j].id) {
					if(graphic3dModels[j].full.toLowerCase().indexOf("iges") != -1) {
						attributes["iges"] = graphic3dModels[j];
					} else if(graphic3dModels[j].full.toLowerCase().indexOf("step") != -1) {
						attributes["step"] = graphic3dModels[j];
					} else if(graphic3dModels[j].full.toLowerCase().indexOf("parasolid") != -1) {
						attributes["parasolid"] = graphic3dModels[j];
					}
					graphic3dModels[j].processed = true;	
				}
			}
			document.write('<td nowrap="nowrap" width="20%">');
			if(attributes["iges"] != undefined) {
				document.write('<input type="checkbox" class="checkbox" name="PC_7_RJH9U5230GE3E02LECIE20KMT3_id" value="' + attributes["iges"].checkValue + '">&#160;<a target="_blank" href="' + attributes["iges"].docSrc + '">IGES</a>&#160;(' + attributes["iges"].size + ')');
			}
			document.write('</td><td nowrap="nowrap" width="20%">');
			if(attributes["step"] != undefined) {
				document.write('<input type="checkbox" class="checkbox" name="PC_7_RJH9U5230GE3E02LECIE20KMT3_id" value="' + attributes["step"].checkValue + '">&#160;<a target="_blank" href="' + attributes["step"].docSrc + '">STEP</a>&#160;(' + attributes["step"].size + ')');
			}
			document.write('</td><td nowrap="nowrap" width="20%">');
			if(attributes["parasolid"] != undefined) {
				document.write('<input type="checkbox" class="checkbox" name="PC_7_RJH9U5230GE3E02LECIE20KMT3_id" value="' + attributes["parasolid"].checkValue + '">&#160;<a target="_blank" href="' + attributes["parasolid"].docSrc + '">PARASOLID</a>&#160;(' + attributes["parasolid"].size + ')');
			}
			document.write('</td></tr>');
		}
	}
}

function showIntroDocuments(list) 
{
	var listShown = [];
	for(var i=0;i<arrayLength(list);i++) {
		if(listShown[list[i].checkValue] == undefined) {
			document.write('<a target="_blank" href="' + list[i].hrefUrl + '">' + list[i].hrefDisplay + '</a>' + list[i].size + '<br />');
			listShown[list[i].checkValue] = 1;
		}
	}
}

function sortCableExit(a, b) 
{
	var temp = a.split(":");
	if(temp.length > 0) {
		a = temp[0];
	}
	
	temp = b.split(":");
	if(temp.length > 0) {
		b = temp[0];
	}
	return (a-b);
}

function sortCableLength(a, b) 
{ 
	var temp = a.split(" ");
	if(temp.length > 0) {
		a = temp[0];
	}
	
	temp = b.split(" ");
	if(temp.length > 0) {
		b = temp[0];
	}
	return (a-b); 
}

//	TOGGLE VISIBILITY OF TEXT - NOT RELATED TO TAB
function toggle(id)
{ 
  if (document.getElementById(id).style.display =="none"){
  document.getElementById(id).style.display ="";}
  else {document.getElementById(id).style.display = "none";}
}