// Global variables:

var bReqPend = false;  // Used by AddItem2Cart to track whether or not a request is pending.
var t=null;
var iT=null;
var noSpecPage = 'There is no Specification Page for this Product';

function AddItem2Cart(oForm)
        {
         /*---------------------------------------------------------------------------------------------------------------*\
         | AddItem2Cart - Add selected item to shopping cart  (Subroutine).                                                |
         |                                                                                                                 |
         | Gather all the form elements associated with the selected item and send them off to the server as a POST type   |
         | request via an AJAX call.  Wait for a response, if the item was successfully added the response text will begin |
         | with "SUCCESS:", followed by the new shopping cart subtotal, which can be pasted onto the page in the dedicated |
         | display area, otherwise we'll get something else.                                                               |
         |                                                                                                                 |
         | Entry Parameters: oForm = form object.                                                                          |
         |                                                                                                                 |
         |          Returns: None.                                                                                         |
         |                                                                                                                 |
         | Globals Affected: None.                                                                                         |
         |                                                                                                                 |
         | Calls - External: createRequest, open, send, WriteDebugMsg.                                                     |
         |                                                                                                                 |
         |         Internal: EncodeFormElements, HideElement, UnhideElement.                                               |
         |                                                                                                                 |
         |          Library: alert, getElementById, getElementByTagName, setTimeout, split, substr.                        |
         \*---------------------------------------------------------------------------------------------------------------*/

         var sProdId = oForm.id.substr(5);
		 
		 var sOptionCheck = true;		 
		 var sOptionAlert = '';		 
		 var sOptionGroup = document.getElementById("optionGroup" + sProdId).childNodes;
		 
		 for (sOption in sOptionGroup)
		 {
			if (sOptionGroup[sOption].nodeName=='SELECT')
			{
				if(sOptionGroup[sOption].value=='none')
				{
					sOptionCheck = false;
					sOptionAlert += "Please " + sOptionGroup[sOption].options[sOptionGroup[sOption].selectedIndex].text + " before adding to cart" + "\n";
				}
				else if(sOptionGroup[sOption].options[sOptionGroup[sOption].selectedIndex].disabled==true)
				{
					sOptionCheck = false;
					sOptionAlert = "You have selected an option that is currently out of stock." + "\n";
				}
			}
		 }
		 
	if (sOptionCheck == false)
		 {
			 alert(sOptionAlert);
		 }
	else
		 {

         WriteDebugMsg("CALL", 200, "AddItem2Cart(" + oForm.id + ")");

         if (true == bReqPend)
           {
            WriteDebugMsg("EXIT", 200, "AddItem2Cart(): {true}  (Req pending)");

            return(true);
           }

         bReqPend = true;


         // Prepare form data for sending to server:

         var sPostData = EncodeFormElements(oForm);

         var sUrl      = "/cgi-bin/store/commerce.cgi";
         var sMethod   = "post";
         var oRequest  = zXmlHttp.createRequest();
		 
		 // Hide the 'Buy Now' button:

         WriteDebugMsg("INFO", 200, "AddItem2Cart() sProdID='" + sProdId + "'");

         var sDivId = "BUTTON_" + sProdId;

         HideElement(sDivId);


         // Show the 'Adding to cart' message:

         sDivId = "MSG_" + sProdId;

         WriteDebugMsg("INFO", 200, "AddItem2Cart() sDivId='" + sDivId + "'");

         document.getElementById(sDivId).innerHTML = "Adding ...";

         UnHideElement(sDivId);


         // Take away the document's ability to be clicked:

         var oOrigClickHandler = document.onclick;

         document.onclick = function ()
                                    {
                                     WriteDebugMsg("CALL", 200, "AddItem2Cart: OCH()");


                                     WriteDebugMsg("EXIT", 200, "AddItem2Cart: OCH()");

                                     return(true);
                                    };


         // Create function to receive and process AJAX response:

         WriteDebugMsg("INFO", 200, "AddItem2Cart: Issuing POST Request to server.");

         oRequest.onreadystatechange = function ()
                                               {
                                                if (4 != oRequest.readyState)
                                                  {
                                                   return;
                                                  }


                                                // AJAX response complete, re- enable clicking:

                                                if (200 != oRequest.status)
                                                  {
//                                                   alert("Server Error: " + oRequest.statusText);

                                                   bReqPend = false;

                                                   return;
                                                  }

                                                document.onclick = oOrigClickHandler;


                                                // Got a valid response, response text should contain 'SUCCESS:subtotal', get
                                                // and separate them:

                                                WriteDebugMsg("INFO", 200, "AddItem2Cart(): (ORC) server response = " + oRequest.responseText);

                                                var sProdId = oForm.id.substr(5);

                                                var sSpanId = "MSG_" + sProdId;

                                                var sRspTxt = oRequest.responseText.split(":");

                                                bReqPend = false;

                                                if ("SUCCESS" == sRspTxt[0])
                                                  {
                                                   // Update cart subtotal display:

                                                   document.getElementById('CartSubTotDisp').innerHTML = sRspTxt[1];
                                                   document.getElementById('cartSubTot').value         = sRspTxt[1];

                                                   setCookie("CartSubTot", sRspTxt[1], "1");


                                                   // Display 'added to cart' message, for a while then re-hide it:

                                                   var sCmdStr = "HideElement('" + sSpanId + "')";

                                                   document.getElementById(sSpanId).innerHTML = "Finished!";


                                                   // Re-show 'Buy Now' button:

                                                   UnHideElement(sSpanId);

                                                   setTimeout(sCmdStr, 1000);

                                                   var sCmdStr2 = "UnHideElement('" + "BUTTON_" + sProdId + "')";

                                                   setTimeout(sCmdStr2, 1000);

                                                   return;
                                                  }

                                                if ("FAILURE" == sRspTxt[0])
                                                  {
                                                   alert(sRspTxt[1]);


                                                   // Re-show 'Buy Now' button:

                                                   HideElement(sSpanId);

                                                   UnHideElement("BUTTON_" + sProdId);

                                                   return;
                                                  }

                                                if ("OOS" == sRspTxt[0])
                                                  {
                                                   alert("We're sorry, but this item is currently out of stock.\nIt will be available on " + sRspTxt[1] + ".");


                                                   // Re-show 'Buy Now' button:

                                                   HideElement(sSpanId);

                                                   UnHideElement("BUTTON_" + sProdId);

                                                   return;
                                                  }


                                                WriteDebugMsg("INFO", 200, "AddItem2Cart: Rsp = " + oRequest.responseText);

                                                alert("There was a problem with your selection.");
                                               };


         // Try to send request to the server:

         try {
              WriteDebugMsg("INFO", 200, "AddItem2Cart(): open(" + sMethod + ", " + sUrl + ", true");

              oRequest.open(sMethod, sUrl, true);
             }

         catch (oError)
              {
               alert("xZmlHttp.open error (URL: " + sUrl + ")");

               document.onclick = oOrigClickHandler;
              }


         try {
              WriteDebugMsg("INFO", 200, "AddItem2Cart(): SetRqHdr()");

              oRequest.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
             }

         catch (oError)
              {
               alert("xZmlHttp.srq error (URL: " + sUrl + ")");

               document.onclick = oOrigClickHandler;
              }


         try {
              WriteDebugMsg("INFO", 200, "AddItem2Cart(): send()");

              oRequest.send(sPostData);
             }

         catch (oError)
              {
               alert("xZmlHttp.send error (URL: " + sUrl + ")");

               document.onclick = oOrigClickHandler;
              }


         WriteDebugMsg("EXIT", 200, "AddItem2Cart()");

        }
		
         return(true);
		 
		}

function AppendCartID()
        {
         WriteDebugMsg("CALL", 100, "AppendCartID(): " + document.getElementById('PrevPage').value);

         var sLink = document.getElementById('PrevPage').value;

         if (sLink=='')
           {
            WriteDebugMsg("INFO", 100, "AppendCartID():  No PrevPage Value");

            sLink="/cgi-bin/store/index.cgi?action=DispPage&Page2Disp=%2Fled_prods.htm";
		   }
          
         WriteDebugMsg("INFO", 100, "AppendCartID():  sLink = " + sLink);

         document.getElementById('shopMore').href = sLink;

         WriteDebugMsg("EXIT", 100, "AppendCartID()");
        }


function CheckEnter(e, sElement)
{
	if(e && e.which)
	{ 
		e = e
		characterCode = e.which 
	}
	else
	{
		e = event
		characterCode = e.keyCode 
	}
	
	if(characterCode == 13)
	{
		sElement.focus(); 
		return false
	}
	else
	{
		return true
	}
}


function DisableElement(sElementId)
        {
         WriteDebugMsg("CALL", 200, "DisableElement(" + sElementId + ")");

         document.getElementById(sElementId).disabled = true;

         WriteDebugMsg("EXIT", 200, "DisableElement()");
        }

function DispPage(sPage)
        {
         WriteDebugMsg("CALL", 100, "DispPage(" + sPage + ")");

         document.getElementById('Page2Disp').value = sPage;

         document.getElementById('cart').submit();

         WriteDebugMsg("EXIT", 100, "DispPage() {FALSE}");

         return(false);
        }

function DoApplyChanges(sElementId, remove)
        {
			
		 if (remove)
		 {
			 document.getElementById("EditQuan"+sElementId).value=0; 
		 }
         WriteDebugMsg("CALL", 100, "DoApplyChanges()");

         var sTargetUrl = document.getElementById('cartForm').getAttributeNode("action").value;

         WriteDebugMsg("INFO", 100, "a=" + sTargetUrl);

         var sNewTarget = sTargetUrl.replace("https", "http");

         document.getElementById('cartForm').getAttributeNode("action").value = sNewTarget;

         document.getElementById('action').value = 'ApplyCartChanges';
		 
         sElementId = "EditQuan" + sElementId;

         var sValue = document.getElementById(sElementId).value;

         if ("" != sValue)
           {
            if (true != ValidateField("vNumeric", sValue))
              {
               ForceFocus(sElementId);
              }
             else
                 {
                  document.getElementById('cartForm').submit();
                 }
          }	          

         WriteDebugMsg("EXIT", 100, "DoApplyChanges()");
        }

function EnableApplyButton(sElementId)
        {
         WriteDebugMsg("CALL", 200, "EnableApplyButton(" + sElementId + ")");

         sElementId = "EditQuan" + sElementId;

         var sValue = document.getElementById(sElementId).value;

         WriteDebugMsg("INFO", 200, "EnableApplyButton(): val=" + sValue);


         if ("" != sValue)
           {
            if (true != ValidateField("vNumeric", sValue))
              {
               ForceFocus(sElementId);

               HideElement('ApplyChangesDiv');
              }
             else
                 {
                  ChkCartForm();
                 }
          }

         WriteDebugMsg("EXIT", 200, "EnableApplyButton()");
        }

function EnableElement(sElementId)
        {
         WriteDebugMsg("CALL", 200, "EnableElement(" + sElementId + ")");

         document.getElementById(sElementId).disabled = false;

         WriteDebugMsg("EXIT", 200, "EnableElement()");
        }

function EncodeFormElement(oElement)
        {
         WriteDebugMsg("CALL", 200, "EncodeFormElement(" + oElement.name + ", " + oElement.value + ")");

         var sRV = encodeURIComponent(oElement.name);

         if ("" != oElement.value)
           {
            sRV += "=" + encodeURIComponent(oElement.value);
           }

         WriteDebugMsg("EXIT", 200, "EncodeFormElement() {" + sRV + "}");

         return(sRV);
        }

function EncodeFormElements(oForm)
        {
         WriteDebugMsg("CALL", 200, "EncodeFormElements(" + oForm.id + " (" + oForm.elements.length + " elements))");

         var aEncodedElements = new Array();

         for (var iElementNdx=0; iElementNdx<oForm.elements.length; ++iElementNdx)
            {
             var oElement = oForm.elements[iElementNdx];


             var sType = "undefined";

             if ("undefined" != typeof(oElement.type))
               {
                sType = oElement.type;
               }

             WriteDebugMsg("INFO", 200, "EncodeFormElements(): Element type =" + sType);

             switch (sType)
                   {
                    case "button":
                    case "reset":
                    case "submit":
                        {
                         // No-op.
                        }
                        break;

                    case "checkbox":
                    case "radio":
                        {
                         if (true == oElement.checked)
                           {
                            aEncodedElements.push(EncodeFormElement(oElement));
                           }
                        }
                        break;

                    default:
                            {
                             aEncodedElements.push(EncodeFormElement(oElement));
                            }
                            break;
                   }
            }

         var sRV = aEncodedElements.join("&");

         WriteDebugMsg("EXIT", 200, "EncodeFormElements() {" + sRV + "}");

         return(sRV);
        }

function ForceFocus(sElementId)
        {
         var sCmdStr = "document.getElementById('" + sElementId + "').focus()";

         setTimeout(sCmdStr, 10);
        }

function getDocumentHeight()
        {
         var iHeight = 0;

         if ('number' == typeof(window.innerHeight))
           {
            // Non-IE

            iHeight = window.innerHeight;
           }
          else if (document.documentElement && document.documentElement.clientHeight)
                 {
                  // IE 6+ in 'standards compliant mode'

                  iHeight = document.documentElement.clientHeight;
                 }
                else if (document.body && document.body.clientHeight)
                    {
                     // IE 4 compatible

                     iHeight = document.body.clientHeight;
                    }

         return(iHeight);
        }

function getDocumentWidth()
        {
         var iWidth = 0;

         if ('number' == typeof(window.innerWidth))
           {
            // Non-IE

            iWidth = window.innerWidth;
           }
          else if (document.documentElement && document.documentElement.clientWidth)
                 {
                  // IE 6+ in 'standards compliant mode'

                  iWidth = document.documentElement.clientWidth;
                 }
                else if (document.body && document.body.clientWidth)
                       {
                        // IE 4 compatible

                        iWidth = document.body.clientWidth;
                       }

         return(iWidth);
        }

function GetLinkCoords(sLinkId)
        {
         WriteDebugMsg("CALL", 200, "GetLinkCoords(" + sLinkId + ")");

         if (document.getElementById)
           {
            var anchor = document.getElementById(sLinkId);

            var coords = {x: 0, y: 0};

            while (anchor)
                 {
                  coords.x += anchor.offsetLeft;
                  coords.y += anchor.offsetTop;

                  anchor = anchor.offsetParent;
                 }

            WriteDebugMsg("EXIT", 200, "GetLinkCoords(): {x=" + coords.x + " y=" + coords.y + "}");

            return(coords);
           }
        }

function GetElementOfEvent(eEvent)
        {
         //WriteDebugMsg("CALL", 300, "> GetElementOfEvent(" + ("undefined" != typeof(eEvent.type) ? eEvent.type : "undefined type") + ")" );
		 
         var targ;

         if (!eEvent)
           {
            var eEvent = window.event;
           }

         if (eEvent.target)
           {
            targ = eEvent.target;
           }
          else
              {
               if (eEvent.srcElement)
                 {
                  targ = e.srcElement;
                 }
              }

         if (3 == targ.nodeType)
           {
            targ = targ.parentNode;
           }

         WriteDebugMsg("EXIT", 300, "GetElementOfEvent(): Got 'ENTER' in a " + targ.tagName + " element with id='" + targ.id + "'.");

         return(targ)
        }

function GetNextElement(oField)
        {
         WriteDebugMsg("CALL", 300, "GetNextElement(" + oField.id + ")");

         var fieldFound = false;

         var oForm = oField.form;

         if (!oForm)
           {
            WriteDebugMsg(
                          "INFO", 300,
                          "GetNextElement(): " + oField.id + ":" + oField.name + ":"
                                               + ("undefined" != typeof(oField.type) ? oField.type : "undefined type")
                                               + " has no form?"
                         );

            return(null);
           }

         for (var e = 0; e < oForm.elements.length; ++e)
            {
             if (fieldFound && oForm.elements[e].type != 'hidden')
               {
                break;
               }

             if (oField == oForm.elements[e])
               {
                fieldFound = true;
               }
            }

         WriteDebugMsg("EXIT", 300, "< GetNextElement() {" + oForm.elements[e % oForm.elements.length] + "}");

         return(oForm.elements[e % oForm.elements.length]);
        }

function getScrollX()
        {
         var iScrollX = 0;

         if (window.pageXOffset)
           {
            iScrollX = window.pageXOffset;
           }
          else if (document.documentElement && document.documentElement.scrollLeft)
                 {
                  iScrollX = document.documentElement.scrollLeft;
                 }
                else if (document.body && document.body.scrollLeft)
                       {
                        iScrollX = document.body.scrollLeft;
                       }

         return(iScrollX);
        }

function getScrollY()
        {
         var iScrollY = 0;

         if (window.pageYOffset)
           {
            iScrollY = window.pageYOffset;
           }
          else if (document.documentElement && document.documentElement.scrollTop)
                 {
                  iScrollY = document.documentElement.scrollTop;
                 }
                else if (document.body && document.body.scrollTop)
                       {
                        iScrollY = document.body.scrollTop;
                       }

         return(iScrollY);
        }

function GotoStore(sProduct, sDispCat)
        {
         WriteDebugMsg("CALL", 100, "GotoStore(" + sProduct + ", " + sDispCat + ")");

         document.getElementById('product').value = sProduct;
         document.getElementById('DispCat').value = sDispCat;

         document.getElementById('cart').action = "/cgi-bin/store/commerce.cgi"

         document.getElementById('cart').submit();

         WriteDebugMsg("EXIT", 100, "GotoStore() {FALSE}");

         return(false);
        }

function HideElement(sElementId)
        {
         WriteDebugMsg("CALL", 200, "HideElement(" + sElementId + ")");

         document.getElementById(sElementId).style.visibility = "hidden";
         document.getElementById(sElementId).style.display    = "none";

         WriteDebugMsg("EXIT", 200, "HideElement()");
        }


function InitCartLink(sCartID)
        {
         WriteDebugMsg("CALL", 100, "InitCartLink(" + sCartID + ")");

         //document.getElementById('CartSubTotLink').href = "/cgi-bin/store/commerce.cgi?action=DispCart"

         if ("undefined" != typeof(document.getElementById('cartSubTot')))
           {
            if (document.getElementById('cartSubTot').value)
              {
               if ("0" != document.getElementById('cartSubTot').value)
                 {
                  document.getElementById('CartSubTotDisp').innerHTML = document.getElementById('cartSubTot').value;

                  WriteDebugMsg("EXIT", 100, "InitCartLink() {FALSE} - subtot on form");

                  return(false);
                 }
              }
           }

         var sUrl     = "/cgi-bin/store/commerce.cgi?action=GetCartSubTotal"
         var sMethod  = "get";
         var oRequest = zXmlHttp.createRequest();


         // Take away the document's ability to be clicked:

         var oOrigClickHandler = document.onclick;

         document.onclick = function ()
                                    {
                                     return(true);
                                    };

         WriteDebugMsg("INFO", 200, "InitCartLink: Issuing GET Request to server.");

         oRequest.onreadystatechange = function ()
                                               {
                                                if (4 == oRequest.readyState)
                                                  {
                                                   document.onclick = oOrigClickHandler;

                                                   WriteDebugMsg("INFO", 200, "InitCartLink(): (ORC) server response = " + oRequest.status);

                                                   if (200 == oRequest.status)
                                                     {
                                                      WriteDebugMsg("INFO", 200, "InitCartLink(): (ORC) server rsp txt = " + oRequest.responseText);

                                                      document.getElementById('CartSubTotDisp').innerHTML = oRequest.responseText;

                                                      document.getElementById('cartSubTot').value = oRequest.responseText

                                                      setCookie("CartSubTot", oRequest.responseText, "1");
                                                     }
                                                    else
                                                        {
//                                                         alert("Server Error: " + oRequest.statusText);
                                                        }
                                                  }
                                               };

         try {
              WriteDebugMsg("INFO", 200, "InitCartLink(): open(" + sMethod + ", " + sUrl + ", true");

              oRequest.open(sMethod, sUrl, true);
             }

         catch (oError)
              {
               alert("xZmlHttp.open error (URL: " + sUrl + ")");

               document.onclick = oOrigClickHandler;
              }


         try {
              WriteDebugMsg("INFO", 200, "InitCartLink(): send()");

              oRequest.send(null);
             }

         catch (oError)
              {
               alert("xZmlHttp.send error (URL: " + sUrl + ")");

               document.onclick = oOrigClickHandler;
              }


         WriteDebugMsg("EXIT", 100, "InitCartLink() {FALSE}");

         return(false);
        }

function InitBackLinks(aBackLinks)
        {
         /*----------------------------------------------------------*\
         | InitLinks - Initialize page links  (Subroutine).           |
         |                                                            |
         | Entry Parameters: BackLinks = array of LinkInfo object(s). |
         |                                                            |
         |          Returns: None.                                    |
         |                                                            |
         | Globals Affected: None.                                    |
         |                                                            |
         | Calls - External: WriteDebugMsg.                           |
         |                                                            |
         |         Internal: InitCartLink.                            |
         |                                                            |
         |          Library: encodeURIComponent, getElementById.      |
         \*----------------------------------------------------------*/

         WriteDebugMsg("CALL", 200, "InitBackLinks");

         var sLink = "";

         for (var iLinkNdx=0; iLinkNdx<aBackLinks.length; ++iLinkNdx)
            {
             WriteDebugMsg("INFO", 200, "InitLinks(): " + aBackLinks[iLinkNdx].sLinkId + " " + aBackLinks[iLinkNdx].sLinkURL);

             if (iLinkNdx == aBackLinks.length - 1)
               {
                sLink += '<a class="backlinklast" href=\"/cgi-bin/store/index.cgi?action=DispPage'
				+ '&Page2Disp=' + encodeURIComponent(aBackLinks[iLinkNdx].sLinkURL) + '\">'
                      + aBackLinks[iLinkNdx].sLinkId + '</a>';
               }
              else
                  {
                   sLink += '<a class="backlink" href=\"/cgi-bin/store/index.cgi?action=DispPage'
				   + '&Page2Disp=' + encodeURIComponent(aBackLinks[iLinkNdx].sLinkURL) + '\">'
                         + aBackLinks[iLinkNdx].sLinkId + '</a>';
                  }

             if (aBackLinks.length > 0 && iLinkNdx != aBackLinks.length - 1)
               {
                sLink += "&#8594;";
               }
            }

         WriteDebugMsg("INFO", 200, "InitBackLinks(): sLink=" + sLink);

         if ("undefined" != typeof(document.getElementById('BackLink')))
           {
            document.getElementById('BackLink').innerHTML = sLink;
           }
		   
		 convertLinks();

         WriteDebugMsg("EXIT", 200, "InitBackLinks");
        }

function InitLegacyLinks(aLinks)
        {
         /*------------------------------------------------------*\
         | InitLegacyLinks - Initialize page links  (Subroutine). |
         |                                                        |
         | Entry Parameters: Links = array of LinkInfo object(s). |
         |                                                        |
         |          Returns: None.                                |
         |                                                        |
         | Globals Affected: None.                                |
         |                                                        |
         | Calls - External: WriteDebugMsg.                       |
         |                                                        |
         |         Internal: InitCartLink.                        |
         |                                                        |
         |          Library: encodeURIComponent, getElementById.  |
         \*------------------------------------------------------*/

         WriteDebugMsg("CALL", 200, "InitLegacyLinks");

         // Enable global onkeypress handler for <ENTER> to <TAB> handling:

         //document.onkeypress = ConvertEnter2Tab;

         if (document.layers)
           {
            document.captureEvents(Event.KEYPRESS);
           }


         for (var iLinkNdx=0; iLinkNdx<aLinks.length; ++iLinkNdx)
            {
             WriteDebugMsg("INFO", 200, "InitLinks(): " + aLinks[iLinkNdx].sLinkId + " " + aLinks[iLinkNdx].sLinkURL);

             var sLink = aLinks[iLinkNdx].sLinkURL;

             document.getElementById(aLinks[iLinkNdx].sLinkId).href = sLink;
            }

         InitCartLink(document.getElementById('CartID').value);

         WriteDebugMsg("EXIT", 200, "InitLegacyLinks");
        }

function InitLinks(aLinks)
        {
         /*------------------------------------------------------*\
         | InitLinks - Initialize page links  (Subroutine).       |
         |                                                        |
         | Entry Parameters: Links = array of LinkInfo object(s). |
         |                                                        |
         |          Returns: None.                                |
         |                                                        |
         | Globals Affected: None.                                |
         |                                                        |
         | Calls - External: WriteDebugMsg.                       |
         |                                                        |
         |         Internal: InitCartLink.                        |
         |                                                        |
         |          Library: encodeURIComponent, getElementById.  |
         \*------------------------------------------------------*/

         WriteDebugMsg("CALL", 200, "InitLinks(): " + aLinks.length + " links");

         for (var iLinkNdx=0; iLinkNdx<aLinks.length; ++iLinkNdx)
            {
             WriteDebugMsg("INFO", 200, "InitLinks(): " + aLinks[iLinkNdx].sLinkId + " " + aLinks[iLinkNdx].sLinkURL);
			 if (window.location.protocol == "https:")
			 {
				var sLink = "http://www.superbrightleds.com/cgi-bin/store/index.cgi?action=DispPage&Page2Disp="
                       + encodeURIComponent(aLinks[iLinkNdx].sLinkURL) 
			 }
			 else
			 {
				 var sLink = "/cgi-bin/store/index.cgi?action=DispPage&Page2Disp="
                       + encodeURIComponent(aLinks[iLinkNdx].sLinkURL)
			 }

             try { document.getElementById(aLinks[iLinkNdx].sLinkId).href = sLink; }
			 catch(err) { }
            }
			
		 if (document.getElementById('CartID')) {
         InitCartLink(document.getElementById('CartID').value); }		 
		 

         WriteDebugMsg("EXIT", 200, "InitLinks");
        }

function InitProdForm(aLinks)
        {
         /*---------------------------------------------------------------------------------------*\
         | InitProdForm - Initialize product form  (Subroutine).                                   |
         |                                                                                         |
         | Entry Parameters: Links = array of LinkInfo object(s).                                  |
         |                                                                                         |
         |          Returns: None.                                                                 |
         |                                                                                         |
         | Globals Affected: None.                                                                 |
         |                                                                                         |
         | Calls - External: appendChild, createElement, createRequest, open, send, WriteDebugMsg. |
         |                                                                                         |
         |         Internal: InitLinks.                                                            |
         |                                                                                         |
         |          Library: getElementById, getElementByTagName.                                  |
         \*---------------------------------------------------------------------------------------*/

         WriteDebugMsg("CALL", 200, "InitProdForm");

         // Enable global onkeypress handler for <ENTER> to <TAB> handling:

         //document.onkeypress = ConvertEnter2Tab;

         if (document.layers)
           {
            document.captureEvents(Event.KEYPRESS);
           }


         if (!document.getElementById('CartID'))
           {
            WriteDebugMsg("INFO", 200, "InitProdForm(): Page accessed via direct URL");

            // Get a shopping Cart:

            var sUrl     = "/cgi-bin/store/getcartid.cgi"
            var sMethod  = "get";
            var oRequest = zXmlHttp.createRequest();


            // Take away the document's ability to be clicked:

            var oOrigClickHandler = document.onclick;

            document.onclick = function ()
                                       {
                                        return(true);
                                       };

            WriteDebugMsg("INFO", 200, "InitProdForm(): Issuing GET Request to server.");

            oRequest.onreadystatechange = function ()
                                                  {
                                                   if (4 != oRequest.readyState)
                                                     {
                                                      return;
                                                     }

                                                   document.onclick = oOrigClickHandler;

                                                   WriteDebugMsg(
                                                                 "INFO", 200,
                                                                 "InitProdForm():  (ORC) server rsp = " +
                                                                 oRequest.status
                                                                );

                                                   if (200 != oRequest.status)
                                                     {
//                                                      alert("Server Error: " + oRequest.statusText);

                                                      return;
                                                     }


                                                   var sCartId = oRequest.responseText;

                                                   WriteDebugMsg(
                                                                 "INFO", 200,
                                                                 "InitProdForm(): (ORC) server txt = " +
                                                                 sCartId
                                                                );

                                                   var oForm = document.createElement('form');

                                                   oForm.action = '/index.cgi';
                                                   oForm.id     = 'CartForm';
                                                   oForm.method = 'post';
                                                   oForm.name   = 'cart';

                                                   document.getElementsByTagName("body")[0].appendChild(oForm);


                                                   var oInput = document.createElement('input');

                                                   oInput.id    = 'CartID';
                                                   oInput.name  = 'cart_id';
                                                   oInput.type  = 'hidden';
                                                   oInput.value = sCartId;

                                                   oForm.appendChild(oInput);


                                                   oInput = document.createElement('input');

                                                   oInput.id    = 'action';
                                                   oInput.name  = 'action';
                                                   oInput.type  = 'hidden';
                                                   oInput.value = 'DispPage';

                                                   oForm.appendChild(oInput);


                                                   oInput = document.createElement('input');

                                                   oInput.id    = 'Page2Disp';
                                                   oInput.name  = 'Page2Disp';
                                                   oInput.type  = 'hidden';
                                                   oInput.value = '/led_prods.htm';

                                                   oForm.appendChild(oInput);


                                                   oInput = document.createElement('input');

                                                   oInput.id    = 'product';
                                                   oInput.name  = 'product';
                                                   oInput.type  = 'hidden';
                                                   oInput.value = '/led_prods.htm';

                                                   oForm.appendChild(oInput);


                                                   oInput = document.createElement('input');

                                                   oInput.id    = 'DispCat';
                                                   oInput.name  = 'DispCat';
                                                   oInput.type  = 'hidden';
                                                   oInput.value = 'all';

                                                   oForm.appendChild(oInput);

                                                   InitLinks(aLinks);
                                                  };

            try {
                 WriteDebugMsg("INFO", 200, "IL(): open(" + sMethod + ", " + sUrl + ", true");

                 oRequest.open(sMethod, sUrl, true);
                }

            catch (oError)
                 {
                  alert("xZmlHttp.open error (URL: " + sUrl + ")");

                  document.onclick = oOrigClickHandler;
                 }


            try {
                 WriteDebugMsg("INFO", 200, "IL(): send()");

                 oRequest.send(null);
                }

            catch (oError)
                 {
                  alert("xZmlHttp.send error (URL: " + sUrl + ")");

                  document.onclick = oOrigClickHandler;
                 }

           }
          else
              {
               WriteDebugMsg("INFO", 200, "InitProdForm(): Page accessed via CGI");


              }

          InitLinks(aLinks);

          WriteDebugMsg("EXIT", 200, "InitProdForm()");
         }

function IsElementHidden(oElement)
        {
         WriteDebugMsg("CALL", 300, "> IsElementHidden(" + oElement.id + ":" + oElement.name + ":" + oElement.type + ")");

         if (oElement)
           {
            WriteDebugMsg("INFO", 300, "&nbsp;&nbsp;IsElementHidden(): parent = " + oElement.parentNode.tagName.toLowerCase());

            var sParentName = oElement.parentNode.tagName.toLowerCase();

            if ("div" == sParentName)
              {
               if ('hidden' == oElement.parentNode.style.visibility)
                 {
                  WriteDebugMsg("EXIT", 300, "IsElementHidden() {true} hidden field in div)");

                  return(true);
                 }

               WriteDebugMsg("INFO", 300, "IsElementHidden() className =" + oElement.parentNode.className);

               if ("controls" == oElement.parentNode.className || "button_area" == oElement.parentNode.className || "values" == oElement.parentNode.className)
                 {
                  if ('hidden' == oElement.parentNode.parentNode.style.visibility)
                    {
                     WriteDebugMsg("EXIT", 300,  "IsElementHidden() {true} (hidden table button)");

                     return(true);
                    }
                 }
              }

            if ("span" == sParentName)
              {
               WriteDebugMsg("INFO", 300, "IsElementHidden(): parent = " + oElement.parentNode.parentNode.tagName.toLowerCase());

               if ("div" == oElement.parentNode.parentNode.tagName.toLowerCase())
                 {
                  WriteDebugMsg("INFO", 300, "IsElementHidden(): parent = " + oElement.parentNode.parentNode.style.visibility);

                  if ('hidden' == oElement.parentNode.parentNode.style.visibility)
                    {
                     WriteDebugMsg("EXIT", 300, "IsElementHidden() {true} (hidden field in span)");

                     return(true);
                    }
                 }
              }
           }

         WriteDebugMsg("EXIT", 300, "IsElementHidden() {false}");

         return(false);
        }

function IsFileName(sString)
        {
         if (0 == sString.length)
           {
            return(false);
           }

         for (var i=0; i<sString.length; ++i)
            {
             if (-1 == ("_-0123456789abcdefghijklmnopqrstuvwxyz").indexOf(sString.charAt(i).toLowerCase()))
               {
                return(false);
               }
            }

         return(true);
        }

function IsNumeric(sString)
        {
         if (0 == sString.length)
           {
            return(false);
           }

         for (var i=0; i<sString.length; ++i)
            {
             if (-1 == ("0123456789").indexOf(sString.charAt(i)))
               {
                return(false);
               }
            }

         return(true);
        }

function LinkInfo(sLinkId, sLinkURL)
        {
         /*------------------------------------------------------------------*\
         | LinkInfo - Create an instance of a LinkInfo object  (Constructor). |
         |                                                                    |
         | Entry Parameters: LinkID  = Link ID.                               |
         |                   LinkURL = URL to page.                           |
         |                                                                    |
         |          Returns: Instance of a LinkInfo object.                   |
         |                                                                    |
         | Globals Affected: None.                                            |
         |                                                                    |
         | Calls - External: None.                                            |
         |                                                                    |
         |         Internal: None.                                            |
         |                                                                    |
         |          Library: None.                                            |
         \*------------------------------------------------------------------*/

         this.sLinkId  = sLinkId;
         this.sLinkURL = sLinkURL;
        }

function RUSure(sPhrase)
        {
         WriteDebugMsg("CALL", 200, "> RUSure(" + sPhrase + ")");

         if (confirm(sPhrase))
           {
            WriteDebugMsg("INFO" , 200, "< RUSure() {true}");

            return(true);
           }

         WriteDebugMsg("EXIT", 200, "< RUSure() {false}");

         return(false);
        }

function ScrollWindow(coords, iOffset)
        {
         WriteDebugMsg("CALL", 300, "ScrollWindow(" + coords.x + ", " + coords.y + ", " + iOffset + ")");

         if (coords.y != 0)
           {
            window.scrollTo(0, coords.y - iOffset);
           }

         WriteDebugMsg("EXIT", 300, "ScrollWindow()");
        }


function ShowA2C(sBgColor, sBorderColor, sProduct, sDispCat, sCartID, sWidth, sHeight, sTemplateFile)
        {
         /*---------------------------------------------------------------------------------------------------------*\
         | ShowA2C - Show 'Add to Cart' popover  (Subroutine).                                                       |
         |                                                                                                           |
         | Display popover containing products for purchase according to the Product and Display categories provided |
         | by the caller, along with buttons pertaining thereto, using either a default or caller supplied template  |
         | file (name) to dynamically generate the content display.                                                  |
         |                                                                                                           |
         | The popover is populated using AJAX methods.                                                              |
         |                                                                                                           |
         | Entry Parameters: sBgColor      = Background color, #rrggbb | default                            REQUIRED |
         |                   sBorderColor  = Border color,     #rrggbb | default                            REQUIRED |
         |                   sProduct      = Product category name string.                                  REQUIRED |
         |                   sDispCat      = Display category string.                                       REQUIRED |
         |                   sCartID       = Cart ID string (use document.getElementById('CartID').value).  REQUIRED |
         |                   sWidth        = Popover width  (pixels).                                       OPTIONAL |
         |                   sHeight       = Popover height (pixels).                                       OPTIONAL |
         |                   sTemplateFile = Name of template file (productPage.inc if omitted).            OPTIONAL |
         |                                   Width and height required in order to specify sTemplateFile.            |
         |                                                                                                           |
         |          Returns: false (always, to prevent triggering following a link when attached to an onclick       |
         |                          handler in an <a> tag).                                                          |
         | Globals Affected: None.                                                                                   |
         |                                                                                                           |
         | Calls - External: createRequest, hide, open, send, setContent, show, Vignette, WriteDebugMsg.             |
         |                                                                                                           |
         |         Internal: None.                                                                                   |
         |                                                                                                           |
         |          Library: alert, getScrollX, getScrollY, parseInt, typeof.                                        |
         \*---------------------------------------------------------------------------------------------------------*/

         WriteDebugMsg(
                       "CALL",
                        100,
                        "ShowA2C(" + sBgColor      + ", "
                                   + sBorderColor  + ", "
                                   + sProduct      + ", "
                                   + sDispCat      + ", "
                                   + sCartID       + ", "
                                   + sWidth        + ", "
                                   + sHeight       + ", "
                                   + sTemplateFile + ")"
                      );

         var iHeight = parseInt('300');

         if ("undefined" != typeof(sHeight))
           {
            iHeight = sHeight;
           }


         var iWidth = parseInt('520');

         if ("undefined" != typeof(sWidth))
           {
            iWidth = sWidth;
           }


         var sTemplateFName = "productPage.inc";

         if ("undefined" != typeof(sTemplateFile))
           {
            sTemplateFName = sTemplateFile;
           }

         if (sTemplateFile == "gtnp" || sTemplateFile == "gtnp2")
           {sTemplateFName = "productPage.inc";}

         // If the popover 'already exists', hide it:

         WriteDebugMsg("INFO", 100, "ShowA2C() POt = " + typeof(oPopover));

         if ("undefined" != typeof(oPopover))
           {
            if (null != oPopover.bgDiv)
              {
               WriteDebugMsg("INFO", 100, "ShowA2C() POtbd != null");

               oPopover.remove();
              }
           }

         oPopover = new Vignette(sBgColor, sBorderColor, iWidth, iHeight, 0, 0, false);

         // Set the x and y positions,

         // var iNewX = (Math.floor((getDocumentWidth()  / 2) + getScrollX()) - Math.floor(oPopover.mainW / 2));
         // var iNewY = (Math.floor((getDocumentHeight() / 2) + getScrollY()) - Math.floor(oPopover.mainH / 2));

         var iNewX = getScrollX() + 45;
         var iNewY = getScrollY() + 55;

         WriteDebugMsg("INFO", 200, "P/O @ " + iNewX + ", " + iNewY);

         if (iNewY < 55)
           {
            iNewY = 55;
           }

         oPopover.setContent("<br /><div class='dispProdMessage' align='center'>Obtaining product list, standby . . .</div><br />");

         oPopover.show(iNewX, iNewY);

         var sUrl = "/cgi-bin/store/commerce.cgi?action=DispPopover&product="
                  + sProduct + "&DispCat=" + sDispCat + "&cart_id=" + sCartID + "&TemplateFile=" + sTemplateFName;

         var sMethod  = "get";
         var oRequest = zXmlHttp.createRequest();


         // Take away the document's ability to be clicked:

         var oOrigClickHandler = document.onclick;

         document.onclick = function ()
                                    {
                                     return(true);
                                    };

         WriteDebugMsg("INFO", 200, "ShowA2C: Issuing GET Request to server.");

         oRequest.onreadystatechange = function ()
                                               {
                                                if (4 != oRequest.readyState)
                                                  {
                                                   return;
                                                  }

                                                document.onclick = oOrigClickHandler;

                                                WriteDebugMsg("INFO", 200, "ShowA2C(): ORC server response = " + oRequest.status);

                                                if (200 != oRequest.status)
                                                  {
//                                                   alert("Server Error: " + oRequest.statusText);

                                                   return;
                                                  }

                                                oPopover.setContent(oRequest.responseText);
                                               };

         try {
              WriteDebugMsg("INFO", 200, "ShowA2C(): open(" + sMethod + ", " + sUrl + ", true");

              oRequest.open(sMethod, sUrl, true);
             }

         catch (oError)
              {
               alert("xZmlHttp.open error (URL: " + sUrl + ")");

               document.onclick = oOrigClickHandler;
              }


         try {
              WriteDebugMsg("INFO", 200, "ShowA2C(): send()");

              oRequest.send(null);
             }

         catch (oError)
              {
               alert("xZmlHttp.send error (URL: " + sUrl + ")");

               document.onclick = oOrigClickHandler;
              }


         WriteDebugMsg("EXIT", 100, "ShowA2C() {false}");

         return(false);
        }

function ValidateField(sType, sValue)
        {
         WriteDebugMsg("CALL", 200, "ValidateField(" + sType + ", " + sValue + ")");

         var  bRetVal = true;

         switch (sType)
               {
                case "vFName":
                    {
                     if (false == IsFileName(sValue))
                       {
                        alert("File names may contain only 'A=Z', 'a-z', '0-9', '_' and/or '-'");

                        bRetVal = false;
                       }
                    }
                    break;

                case "vNumeric":
                    {
                     if (false == IsNumeric(sValue))
                       {
                        alert("Value must be a number.");

                        bRetVal = false;
                       }
                    }
                    break;

                default:
                        {
                         WriteDebugMsg("INFO", 200, "ValidateField(): Unrecognized field type!");
                        }
               }

         WriteDebugMsg("EXIT", 200, "ValidateField()  {" + (bRetVal == true ? "true" : "false") + "}");

         return(bRetVal);
        }

function UnHideElement(sElementId)
        {
         WriteDebugMsg("CALL", 200, "UnHideElement(" + sElementId + ")");

         document.getElementById(sElementId).style.visibility = "visible";
         document.getElementById(sElementId).style.display    = "block";

         WriteDebugMsg("EXIT", 200, "UnHideElement()");
        }

function createPopover(sBgColor, sBorderColor, sWidth, sHeight, sContent)
{
        // If the popover 'already exists', hide it:

         if ("undefined" != typeof(oPopover))
           {
            if (null != oPopover.bgDiv)
              {
               oPopover.remove();
              }
           }
		   
         oPopover = new Vignette(sBgColor, sBorderColor, sWidth, sHeight, 0, 0, false);

         var iNewX = getScrollX() + (getDocumentWidth() - sWidth)/2;
         var iNewY = getScrollY() + (getDocumentHeight() - sHeight)/2;

         if (iNewY < 20)
           {
            iNewY = 20;
           }
		   
         oPopover.show(iNewX, iNewY);

         oPopover.setContent('<div align="right" style="margin-right:5px"><a href="javascript:void(0);" onclick="oPopover.remove(); return(false);"><img src="/images/graphics/buttons/close.gif" name="closeButton" border="0" alt="Close" /></a></div>' +  sContent);         

}

function getCookie(c_cart)
        {
                if (document.cookie.length>0)
                        {
                                c_start=document.cookie.indexOf(c_cart + "=");
                                if (c_start!=-1)
                                {
                                        c_start=c_start + c_cart.length+1;
                                        c_end=document.cookie.indexOf(";",c_start);
                                        if (c_end==-1) c_end=document.cookie.length;
                                        return unescape(document.cookie.substring(c_start,c_end));
                                }
                        }
                return 0;
        }

function checkCookie(cart)
        {
                cart=getCookie('cart');
                if (cart!=null && cart!="")
                        {
                                return cart;
                        }
                else
                        return 0;
        }

function get_cookie(sName)
        {
         WriteDebugMsg("CALL", 100, "getCookie(" + sName + ")");

         var results = document.cookie.match('(^|;) ?' + sName + '=([^;]*)(;|$)');

         if (results)
           {
            WriteDebugMsg("EXIT", 100, "getCookie() " + unescape(results[2]));

            return(unescape(results[2]));
           }

         WriteDebugMsg("EXIT", 100, "getCookie() NULL");

         return(null);
        }

function setCookie(sName, sValue, sExpiredays)
        {
         WriteDebugMsg("CALL", 100, "setCookie(" + sName + ", " + sValue + ", " + sExpiredays + ")");

         var exdate = new Date();

         exdate.setDate(exdate.getDate() + parseInt(sExpiredays));

         var sCookie = sName + "=" + escape(sValue)
                     + ((sExpiredays == null) ? "" : ";expires=" + exdate.toGMTString())
                     + ";path=/;domain=" + window.location.hostname;

         document.cookie = sCookie;

         WriteDebugMsg("EXIT", 100, "setCookie() '" + sCookie + "'");
        }

function thumbSelect( sImageUrl, sMoreInfoUrl, sDispCat, sIsDefault, sPage, tNum, sInfo)
        {
                        var currentUrl = decodeURIComponent(location.href);
                        if (currentUrl.indexOf('/specs/') != -1 && currentUrl.indexOf(sMoreInfoUrl) == -1) {
							if (sMoreInfoUrl.indexOf('.pdf') != -1) {
								window.open(sMoreInfoUrl); }
                        	else if (sMoreInfoUrl.indexOf('.htm') == -1 && sMoreInfoUrl.indexOf('.html') == -1) {
                            	defaultThumb(); }
                            else {
                                window.location.href="/cgi-bin/store/index.cgi?action=DispPage&Page2Disp=" + encodeURIComponent(sMoreInfoUrl)}}
                        else {
                        var sImageName = 'large' + tNum;
                        var sMoreInfoID = 'Table' + tNum + '-MI';
                        var sSpanId = 'Table' + tNum + '-BN';
                        var sInfoId = 'Table' + tNum + '-IT' + sInfo;
                        var sBodyText = 'Table' + tNum + '-IT';
                        var sDC = 'Table' + tNum + '-DC';
						var sProdCat = ''
                document.images[sImageName].src = sImageUrl;
                document.getElementById(sDC).value = sDispCat;
                        if (sIsDefault == "yes")
                        {
                                document.getElementById(sMoreInfoID).style.display="inline";
                                document.getElementById(sMoreInfoID).href="javascript://";
                                document.getElementById(sMoreInfoID).onclick=function onclick(event) { alert("Please Click Thumbnails First"); };
                                document.getElementById(sMoreInfoID).firstChild.onmouseup=function onmouseup(event) { xpe(this,1); };
                                document.getElementById(sMoreInfoID).firstChild.onmousedown=function onmousedown(event) { xpe(this,2); };
                                document.getElementById(sMoreInfoID).firstChild.onmouseover='';
                                document.getElementById(sMoreInfoID).firstChild.onmouseout='';
                                document.getElementById(sMoreInfoID).firstChild.src="/images/graphics/buttons/btmi_1.gif";
                                document.getElementById(sMoreInfoID).firstChild.title="Please Click Thumbnails First";

                        }
                        if (sIsDefault == "no")
                        {
                                document.getElementById(sMoreInfoID).style.display="inline";
                                document.getElementById(sMoreInfoID).onclick="";
                                                        if (currentUrl.indexOf('/specs/') != -1) {
                                document.getElementById(sMoreInfoID).firstChild.onmouseup=function onmouseup(event) { xpe(this,40); };
                                                        document.getElementById(sMoreInfoID).firstChild.onmousedown=function onmousedown(event) { xpe(this,41); };
                                                        document.getElementById(sMoreInfoID).firstChild.onmouseover=function onmouseover(event) { xpe(this,39); };
                                                        document.getElementById(sMoreInfoID).firstChild.onmouseout=function onmouseout(event) { xpe(this,40); };
                                                        document.getElementById(sMoreInfoID).firstChild.src="/images/graphics/buttons/btgb_0.gif";
                                                        document.getElementById(sMoreInfoID).firstChild.title="Go Back to Main Product Page";
                                                                sMoreInfoUrl=document.getElementById('filehandler').src;
                                                                sMoreInfoUrl=sMoreInfoUrl.substr(sMoreInfoUrl.lastIndexOf('/'), sMoreInfoUrl.length);
                                                        }
                                                        else {
                                                                document.getElementById(sMoreInfoID).firstChild.onmouseup=function onmouseup(event) { xpe(this,0); };
                                document.getElementById(sMoreInfoID).firstChild.onmousedown=function onmousedown(event) { xpe(this,2); };
                                document.getElementById(sMoreInfoID).firstChild.onmouseover=function onmouseover(event) { xpe(this,1); };
                                document.getElementById(sMoreInfoID).firstChild.onmouseout=function onmouseout(event) { xpe(this,0); };
                                document.getElementById(sMoreInfoID).firstChild.src="/images/graphics/buttons/btmi_0.gif";
                                document.getElementById(sMoreInfoID).firstChild.title="Click for More Product Info";
                                                        }
								if (sMoreInfoUrl.indexOf('.pdf')!=-1)
								{
									document.getElementById(sMoreInfoID).href=sMoreInfoUrl;
									document.getElementById(sMoreInfoID).target="_blank";
								}
								else
								{
								if (document.getElementById(sMoreInfoID).rel) sProdCat = "&category=" + document.getElementById('product').value;
		                        else sProdCat = "";
                                document.getElementById(sMoreInfoID).href = "/cgi-bin/store/index.cgi?action=DispPage" + sProdCat + "&Page2Disp=" + encodeURIComponent(sMoreInfoUrl);
								document.getElementById(sMoreInfoID).target="";
								}

                        }
                        if (sIsDefault == "nmi")
                        {
                                try { document.getElementById(sMoreInfoID).style.display="none"; }
                                catch(err) {}
                        }

                        if (sInfo != 'no')
                        {
                        var lineheight = document.getElementById(sBodyText).childNodes[0];
                        while (lineheight.nodeType != 1) {
                        lineheight = lineheight.nextSibling; }
                        lineheight.style.lineHeight='normal';
                        var bHeight = parseInt(document.getElementById(sBodyText).parentNode.parentNode.style.height) - 2;
                        var bHeight2= parseInt(document.getElementById(sBodyText).parentNode.style.height);
                        var bH;
                        var timer;
                        var t=0;

                        for (i=9;i>=0;i--)
                        {
                                bH = Math.round(.1 * i * bHeight2);
                                timer = (10 - i) * 40;
                                t = setTimeout("changeText('" + sBodyText + "', '" + bH + "')", timer);
                        }
                        t = setTimeout("document.getElementById('" + sBodyText + "').innerHTML=document.getElementById('" + sInfoId + "').innerHTML;", 440);
                        for (j=1;j<=10;j++)
                        {
                                bH = Math.round(.1 * j * bHeight);
                                timer = (j * 40) + 440;
                                t = setTimeout("changeText('" + sBodyText + "', '" + bH + "')", timer);
                        }

                        }
                        }
        }

                function changeText (sBodyText, bH)
                {
                        document.getElementById(sBodyText).parentNode.style.height=bH + "px";
                        var vertAlign = Math.round((bH - parseInt(document.getElementById(sBodyText).offsetHeight)) / 2);
                        document.getElementById(sBodyText).style.marginTop=vertAlign + "px";
                }
				
				function changeImage(sImageName, sImageUrl)
				{
					document.getElementById(sImageName).src=sImageUrl;
				}


function titleHover(title, mouseaction)
{
	if(mouseaction=='over'){
	title.style.overflow="visible"
	title.style.width="auto";
	if (title.offsetWidth <= 50)
	  { title.style.width="44px"; }
	title.style.border="1px dotted #FFFFFF";
	title.style.borderBottom="none"; }
	else {
	title.style.overflow="hidden";
	title.style.width="44px";
	title.style.border="1px solid #ACACAC";
	title.style.borderBottom="none"; }
}

function ptProductSelect( sImageUrl, sMoreInfoUrl, sDispCat, sIsDefault, sProdCat, tNum, sInfo, sMorePhotos)
  {
	var currentUrl = decodeURIComponent(location.href);
	if (sProdCat) 
	    sProdCat = '&category=' + sProdCat;
	  else 
	    sProdCat = '';
	if (currentUrl.indexOf('/specs/') != -1 && currentUrl.indexOf(sMoreInfoUrl) == -1)
	{
	  if (sMoreInfoUrl.indexOf('.pdf') != -1) 
	  {
		window.open(sMoreInfoUrl); 
	  }
	  else if (sMoreInfoUrl.indexOf('.htm') == -1 && sMoreInfoUrl.indexOf('.html') == -1)
	  {
	    alert(noSpecPage);
	  }
	  else 
	  {
	    window.location.href="/cgi-bin/store/index.cgi?action=DispPage" + sProdCat + "&Page2Disp=" + encodeURIComponent(sMoreInfoUrl)
	  }
    }
	else 
	{
	  var sImageName = 'large' + tNum;
	  var sMoreInfoID = 'Table' + tNum + '-MI';
	  var sSpanId = 'Table' + tNum + '-BN';
	  var sInfoId = 'Table' + tNum + '-IT' + sInfo;
	  var sBodyText = 'Table' + tNum + '-IT';
	  var sDC = 'Table' + tNum + '-DC';
	  var sTitles = 'Table' + tNum + '-TT';
	  var sTitleId = 'Table' + tNum + '-TT' + sInfo;
	  var sMainText = 'Table' + tNum + '-MT';
	  var sThumbs = 'Table' + tNum + '-TH';
	  var allThumbs = document.getElementById(sThumbs);
	  var sExpand = 'Table' + tNum + '-EX';
	  var sMorePhotosID = 'Table' + tNum + '-MP';
	  var mPhotoButton = document.getElementById(sMorePhotosID);
	  if (mPhotoButton)
	  {
		mPhotoButton.style.display='none';
		if (sMorePhotos && sMorePhotos > 0 && currentUrl.indexOf('/specs/') == -1)
		{
			if (sMorePhotos > 1)
			{
			  mPhotoButton.childNodes[0].innerHTML = sMorePhotos;
			  mPhotoButton.childNodes[1].innerHTML = sMorePhotos;
			}
			else
			{
			  mPhotoButton.childNodes[0].innerHTML = "";
			  mPhotoButton.childNodes[1].innerHTML = "";
			}
			if (sMorePhotos >= 10)
			{
			  mPhotoButton.childNodes[0].style.marginLeft = "2px";
			  mPhotoButton.childNodes[1].style.marginLeft = "0";			
			}
			else
			{
			  mPhotoButton.childNodes[0].style.marginLeft = "12px";
			  mPhotoButton.childNodes[1].style.marginLeft = "10px";	
			}
			var topOffSet = 32;
			if (document.getElementById(sMorePhotosID).previousSibling)
			  { topOffSet += 12; }
			var mtop = parseInt(document.getElementById('large'+tNum).offsetHeight) - topOffSet;
			mPhotoButton.style.marginTop=mtop + 'px';
			var toStr = "document.getElementById('" + sMorePhotosID + "').style.display='block'";
			iT = setTimeout(toStr, 440);
		}
	  }
	  if (currentUrl.indexOf('/pt/') != -1)
	  {
		allThumbs.style.display="none";
		document.getElementById(sMainText).style.display="none";
		if (document.getElementById(sExpand)) {
		  document.getElementById(sExpand).style.display="none"; }
	  }
	  else if (currentUrl.indexOf('/specs/') != -1)
	  {
		var defaultThumb = allThumbs.childNodes[(allThumbs.childNodes.length - 1)];
		while (defaultThumb.nodeType!=1)
		{ defaultThumb = defaultThumb.previousSibling; }		
	    defaultThumb.style.display="none";
	  }	
      callChangeImage(sImageName, sImageUrl, sProdCat, sMoreInfoUrl)
	  document.getElementById(sDC).value = sDispCat;
	  if (sIsDefault == "yes")
	  {
		document.getElementById(sMoreInfoID).style.display="inline";
		document.getElementById(sMoreInfoID).href="javascript://";
		document.getElementById(sMoreInfoID).onclick=function onclick(event) { thumbnailAlert(); };
		document.getElementById(sMoreInfoID).firstChild.onmouseup=function onmouseup(event) { xpe(this,1); };
		document.getElementById(sMoreInfoID).firstChild.onmousedown=function onmousedown(event) { xpe(this,2); };
		document.getElementById(sMoreInfoID).firstChild.onmouseover='';
		document.getElementById(sMoreInfoID).firstChild.onmouseout='';
		document.getElementById(sMoreInfoID).firstChild.src="/images/graphics/buttons/btmi_1.gif";
		document.getElementById(sMoreInfoID).firstChild.title="Please Click Thumbnails or Tabs First";
		document.getElementById(sImageName).onclick=function onclick(event) { thumbnailAlert(); };
		document.getElementById(sImageName).style.cursor="pointer";
  
	  }
	  if (sIsDefault == "no")
	  {
		document.getElementById(sMoreInfoID).style.display="inline";
		document.getElementById(sMoreInfoID).onclick="";
		if (currentUrl.indexOf('/specs/') != -1) 
		{
		  document.getElementById(sMoreInfoID).style.display="none";
		  document.getElementById(sImageName).onclick="";
		  document.getElementById(sImageName).style.cursor="default";
		}
		else 
		{
		  document.getElementById(sMoreInfoID).firstChild.onmouseup=function onmouseup(event) { xpe(this,0); };
		  document.getElementById(sMoreInfoID).firstChild.onmousedown=function onmousedown(event) { xpe(this,2); };
		  document.getElementById(sMoreInfoID).firstChild.onmouseover=function onmouseover(event) { xpe(this,1); };
		  document.getElementById(sMoreInfoID).firstChild.onmouseout=function onmouseout(event) { xpe(this,0); };
		  document.getElementById(sMoreInfoID).firstChild.src="/images/graphics/buttons/btmi_0.gif";
		  document.getElementById(sMoreInfoID).firstChild.title="Click for More Product Info";
		  if (sMoreInfoUrl.indexOf('.pdf') != -1) 
		  {
			document.getElementById(sImageName).onclick=function onclick() { window.open(sMoreInfoUrl); };
		  }
		  else
		  {
		  	document.getElementById(sImageName).onclick=function onclick() { window.location.href="/cgi-bin/store/index.cgi?action=DispPage" + sProdCat + "&Page2Disp=" + encodeURIComponent(sMoreInfoUrl)+ "#photos"; };
		  }
		  document.getElementById(sImageName).style.cursor="pointer";
		}
		if (sMoreInfoUrl.indexOf('.pdf')!=-1)
		{

		  document.getElementById(sMoreInfoID).href=sMoreInfoUrl;
		  document.getElementById(sMoreInfoID).target="_blank";
		}
		else
		{
		  document.getElementById(sMoreInfoID).href = "/cgi-bin/store/index.cgi?action=DispPage" + sProdCat + "&Page2Disp=" + encodeURIComponent(sMoreInfoUrl);
		  document.getElementById(sMoreInfoID).target="";
		}
  
	  }
	  if (sIsDefault == "nmi")
	  {
		try { document.getElementById(sMoreInfoID).style.display="none"; }
		catch(err) {}
		document.getElementById(sImageName).onclick="";
		document.getElementById(sImageName).style.cursor="default";
	  }
  
	  if (sInfo != 'no')
	  {
		var allTitles = document.getElementById(sTitles).childNodes;
		for (x in allTitles)
		{
		  if (allTitles[x].nodeType == 1)
		  {	
              if (currentUrl.indexOf('/pt/') != -1)
			  {
			    allTitles[x].style.display="none";
			  }
			  else if (currentUrl.indexOf('/specs/') != -1)
			  {
				  if (allTitles[x].className=="ptTabMain")
				  {
					 allTitles[x].style.display="none";
				  }
			  }
			  allTitles[x].style.width="44px";
			  allTitles[x].style.backgroundColor="#565558";
			  allTitles[x].style.color="#FFFFFF";
			  allTitles[x].style.height="17px";
			  allTitles[x].style.fontSize="9px";
			  allTitles[x].style.fontWeight="normal";
			  allTitles[x].style.overflow="hidden";
			  allTitles[x].style.textDecoration="none";
			  allTitles[x].style.border="1px solid #ACACAC";
			  allTitles[x].style.borderBottom="none";
			  allTitles[x].onmouseover=function onmouseover(event) { titleHover(this, 'over'); };
			  allTitles[x].onmouseout=function onmouseover(event) { titleHover(this, 'out'); };
		  }
		}	
		changeTitle(sTitleId, currentUrl);
		if (currentUrl.indexOf('/pt/') != -1)
		{
		  changeInfoText(sInfoId, sBodyText, sSpanId);
		}
		else
		{
		  var opacity;
		  var timer;
		  if (t) clearTimeout(t);
		  for (i=9;i>=0;i--)
		  {
			opacity = (.1 * i);
			timer = (10 - i) * 40;
			t = setTimeout("changeInfoTextHeight('" + sBodyText + "', '" + opacity + "', '" + sSpanId + "')", timer);
		  }
		  t = setTimeout("changeInfoText('" + sInfoId + "', '" + sBodyText + "', '" + sSpanId + "')", 440);
		  for (j=1;j<=10;j++)
		  {
			opacity = (.1 * j);
			timer = (j * 40) + 440;
			t = setTimeout("changeInfoTextHeight('" + sBodyText + "', '" + opacity + "', '" + sSpanId + "')", timer);
		  }
		}
  
	  }
	}
  }

  function changeInfoTextHeight (sBodyText, opacity, sSpanId)
  {
	var ieopacity="alpha(opacity=" + (opacity * 100) + ");";
	document.getElementById(sBodyText).style.opacity=opacity;
	document.getElementById(sBodyText).style.filter=ieopacity;
	document.getElementById(sSpanId).style.opacity=opacity;
	document.getElementById(sSpanId).style.filter=ieopacity;
	if (opacity == 1) { document.getElementById(sBodyText).style.filter=null; }
  }
  
  function changeInfoText (sInfoId, sBodyText, sSpanId)
  {
	  	
		var ptInfoTexts = document.getElementById(sBodyText).childNodes;
		for (itNumber in ptInfoTexts)
		{
			if (ptInfoTexts[itNumber].nodeType==1)
			  {
			    ptInfoTexts[itNumber].style.display="none";
			  }
		}
		document.getElementById(sInfoId).style.display='block';
  }
  
  function callChangeImage(sImageName, sImageUrl, sProdCat, sMoreInfoUrl)
  {
	if (document.getElementById(sImageName).nodeName=="DIV") {
	document.getElementById(sImageName).style.backgroundImage="url(/images/graphics/table/1px.jpg)";
	iT = setTimeout("changeBakImage('" + sImageName + "', '" + sImageUrl + "')", 440);  
	}
	else {
	document.getElementById(sImageName).src="/images/graphics/table/1px.jpg";
	iT = setTimeout("changeImage('" + sImageName + "', '" + sImageUrl + "')", 440); } 
  }
  
  function changeBakImage(sImageName, sImageUrl)
  {
	  document.getElementById(sImageName).style.backgroundImage="url("+sImageUrl+")";
  }
  
  function changeImage(sImageName, sImageUrl)
  {
	  document.getElementById(sImageName).src=sImageUrl;
  }
  
  function changeTitle(sTitleId, currentUrl)
  {
	var title = document.getElementById(sTitleId);
	if (title)
	{
	  title.style.width="auto";	  
	  title.style.backgroundColor="#656668";
	  title.style.color="#FFFFFF";
	  title.style.overflow="visible";
	  title.style.height="18px";
	  title.style.fontSize="11px";
	  title.style.fontWeight="bold";
	  title.style.border="1px solid #FFFFFF";
	  title.style.borderBottom="none";
	  title.style.display="block";
	  if (title.offsetWidth <= 50 && currentUrl.indexOf('/pt/') == -1)
		{ title.style.width="44px"; }
	  title.onmouseover="";
	  title.onmouseout=""; 
	}
  }

function goToMoreInfo(pt_num, photos)
{
	var moreInfoID = 'Table' + pt_num + '-MI';
	if(!photos) { photos = ''; }
	if (document.getElementById(moreInfoID))
	{
		window.location=document.getElementById(moreInfoID).href+photos;
	}
	else
	{
		document.getElementById('large'+pt_num).style.cursor="default";
	}
}
  
function showProductTable(pt_id, pt_num, pt_height, pt_pinfo, pt_dc, pt_image, pt_new)
{
        var pt_infoID = 'Table'+pt_num+'-IT';
        var pt_pInfoID = 'Table'+pt_num+'-IT'+pt_pinfo;
		var pt_pTitleID = 'Table'+pt_num+'-TT'+pt_pinfo;
		var pt_pMainTitleID = 'Table'+pt_num+'-TT0';
        var pt_moreinfoID = 'Table'+pt_num+'-MI';
        var pt_dcID = 'Table'+pt_num+'-DC';
        var pt_imageID = 'large'+pt_num;
		var pt_dImageID = 'Table'+pt_num+'-DI';
        var pt_page = document.getElementById('filehandler').src;
        pt_page=pt_page.slice(pt_page.lastIndexOf('/'));
        var pt_html = '<div style="clear:both;padding-top:10px;">' + window.frames["filehandler"].document.getElementById(pt_id).innerHTML + '</div>';
        pt_html=pt_html.replace(new RegExp(/>[^\w]+?</g),'><') + '<p style="clear:both;margin:0;color:white;">Click on the thumbnails or tabs in the Product Table above to switch between the different Product Specification Pages</p>';
        document.getElementById('showTable').parentNode.style.height=pt_height;
        document.getElementById("showTable").innerHTML=pt_html;
		document.getElementById(pt_infoID).className="ptDefaultText";
        document.getElementById(pt_infoID).innerHTML=document.getElementById(pt_pInfoID).innerHTML;
		if (pt_new==1)
		{
		  document.getElementById(pt_pMainTitleID).style.display="none"; 
		  changeTitle(pt_pTitleID);
		}
		else
		{
		  var pt_info_height = parseInt(document.getElementById(pt_infoID).parentNode.parentNode.style.height) - 2;
		  var pt_aligninfo = Math.round((pt_info_height - parseInt(document.getElementById(pt_infoID).offsetHeight)) / 2);
		  document.getElementById(pt_infoID).style.marginTop=pt_aligninfo + "px";
		}		
        document.images[pt_imageID].src = pt_image;
        document.getElementById(pt_dcID).value = pt_dc;
        document.getElementById(pt_moreinfoID).style.display="inline";
        document.getElementById(pt_moreinfoID).onclick="";
        document.getElementById(pt_moreinfoID).firstChild.onmouseup=function onmouseup(event) { xpe(this,40); };
        document.getElementById(pt_moreinfoID).firstChild.onmousedown=function onmousedown(event) { xpe(this,41); };
        document.getElementById(pt_moreinfoID).firstChild.onmouseover=function onmouseover(event) { xpe(this,39); };
        document.getElementById(pt_moreinfoID).firstChild.onmouseout=function onmouseout(event) { xpe(this,40); };
        document.getElementById(pt_moreinfoID).firstChild.src="/images/graphics/buttons/btgb_0.gif";
        document.getElementById(pt_moreinfoID).firstChild.title="Go Back to Main Product Page";
        document.getElementById(pt_moreinfoID).href = "/cgi-bin/store/index.cgi?action=DispPage&Page2Disp=" + encodeURIComponent(pt_page)
		if (document.getElementById(pt_dImageID))
		{
		    document.getElementById(pt_dImageID).style.display="none";
		}
}

function showProductTableNoTS(pt_id, pt_num, pt_height, pt_new)
{
        var pt_moreinfoID = 'Table'+pt_num+'-MI';
        var pt_page = document.getElementById('filehandler').src;
        pt_page=pt_page.slice(pt_page.lastIndexOf('/'));
        var pt_html = '<div style="clear:both;padding-top:15px;">' + window.frames["filehandler"].document.getElementById(pt_id).innerHTML + '</div>';
        pt_html=pt_html.replace(new RegExp(/>[^\w]+?</g),'><');
        document.getElementById('showTable').parentNode.style.height=pt_height;
        document.getElementById("showTable").innerHTML=pt_html;
        document.getElementById(pt_moreinfoID).style.display="inline";
        document.getElementById(pt_moreinfoID).onclick="";
        document.getElementById(pt_moreinfoID).firstChild.onmouseup=function onmouseup(event) { xpe(this,40); };
        document.getElementById(pt_moreinfoID).firstChild.onmousedown=function onmousedown(event) { xpe(this,41); };
        document.getElementById(pt_moreinfoID).firstChild.onmouseover=function onmouseover(event) { xpe(this,39); };
        document.getElementById(pt_moreinfoID).firstChild.onmouseout=function onmouseout(event) { xpe(this,40); };
        document.getElementById(pt_moreinfoID).firstChild.src="/images/graphics/buttons/btgb_0.gif";
        document.getElementById(pt_moreinfoID).firstChild.title="Go Back to Main Product Page";
        document.getElementById(pt_moreinfoID).href = "/cgi-bin/store/index.cgi?action=DispPage&Page2Disp=" + encodeURIComponent(pt_page)
}

function thumbnailAlert()
{
        alert("Please Select a Product by clicking on Thumbnails or Tabs First");
}

function defaultThumb(tNum, sImageUrl)
{
        alert("There is no specification page for this Thumbnail.");
}

function highlightRow(row, mouseaction)
{
	    var cols = row.childNodes;
        if (mouseaction == "hover")
        {
                for (each in cols)
                {
                        if (cols[each].nodeType == 1) {
                        try { cols[each].style.backgroundColor="#C7C7C7"; }
                        catch(err) {}}
                }
        }
        if (mouseaction == "out")
        {
                for (each in cols)
                {
                        if (cols[each].nodeType == 1) {
                        try {
                        cols[each].style.backgroundColor="#EFEFEF";  }
                        catch(err) {}}
                }
        }
}

function highlight(row, mouseaction)
{
	    var cols = row.childNodes;
        if (mouseaction == "hover")
        {
                for (each in cols)
                {
                        if (cols[each].nodeType == 1) {
                        try { cols[each].style.backgroundColor="#666666"; }
                        catch(err) {}}
                }
        }
        if (mouseaction == "out")
        {
                for (each in cols)
                {
                        if (cols[each].nodeType == 1) {
                        try {
                                if (cols[each].className=="darker") {
                                        cols[each].style.backgroundColor="#888888"; }
                                else {
                                        cols[each].style.backgroundColor="#999999"; }
                                }
                        catch(err) {}}
                }
        }
}

function preloadImages(aImgs)
{
        var Images = new Array();
        for (x=0; x<aImgs.length; x++)
        {
        Images[x] = new Image()
        Images[x].src = aImgs[x];
        }
}

function updatePrice(option, productID)
{
    var totalPriceIncrease = 0;
    var eachSelectPriceIncrease = 0;
    var priceID = "price" + productID;
    var totalID = "total" + productID;
    var originalPrice = parseFloat(document.getElementById(priceID).value.substr(2, document.getElementById(priceID).value.length));
    for (p=0; p<option.parentNode.childNodes.length; p++)
    {
        if (option.parentNode.childNodes[p].nodeName=="SELECT")
        {
            eachSelectPriceIncrease = parseFloat(option.parentNode.childNodes[p].value.substr((option.parentNode.childNodes[p].value.indexOf("|")+1), option.parentNode.childNodes[p].value.length));
            if (eachSelectPriceIncrease > 0) 
            { 
                totalPriceIncrease=parseFloat(totalPriceIncrease+eachSelectPriceIncrease);
            }
        }
    }
    var newPrice = originalPrice + totalPriceIncrease;
    newPrice = newPrice.toFixed(2);
    if(document.getElementById(totalID).innerHTML != "$ " + newPrice)
    {
        document.getElementById(totalID).innerHTML = "<span style='line-height:16px;font-size:9px;'>Updating price...</span>";
        if (t) clearTimeout(t);
        t = setTimeout("animatePrice('" + totalID + "', '" + newPrice + "')", 1200);
		var operator = "-";
		var thisSelectPriceIncrease = parseFloat(option.value.substr((option.value.indexOf("|")+1), option.value.length));
		if (!thisSelectPriceIncrease) thisSelectPriceIncrease=0.00;
		var thisSelectOptions=option.options;
		var priceDifference=0.00;
		var eachOptionPrice = 0.00;
		for (o=1; o<thisSelectOptions.length; o++)
		{
			operator = "-";
			eachOptionPrice = parseFloat(thisSelectOptions[o].value.substr((thisSelectOptions[o].value.indexOf("|")+1), thisSelectOptions[o].value.length));
			if (!eachOptionPrice) eachOptionPrice=0.00;
			priceDifference = parseFloat(eachOptionPrice - thisSelectPriceIncrease);
			if (Math.abs(priceDifference)==priceDifference)
			{
				operator="+";
			}
			priceDifference = Math.abs(priceDifference).toFixed(2);
			if (priceDifference==0.00)
			{
				if (thisSelectOptions[o].text.indexOf('(')!=-1)
				{
					thisSelectOptions[o].text=thisSelectOptions[o].text.slice(0, (thisSelectOptions[o].text.indexOf('(')));
				}
			}
			else
			{
				if (thisSelectOptions[o].text.indexOf('(')!=-1) 
				{
					thisSelectOptions[o].text=thisSelectOptions[o].text.slice(0, (thisSelectOptions[o].text.indexOf('(')+1)) + operator + " $ " + priceDifference + ")"; 
				}
				else 
				{
					thisSelectOptions[o].text=thisSelectOptions[o].text + " (" + operator + " $ " + priceDifference + ")";
				}
			}
		}
    }
}

function animatePrice(totalID, newPrice)
{    
    document.getElementById(totalID).innerHTML = "$ " + newPrice;
}

function convertLinks()
{
	var linksToConvert = document.getElementsByName("convertLink");
	var urlToEncode = '';
	var sProdCat = '';
	for (x=0; x<linksToConvert.length; x++)
	{
		if (linksToConvert[x].rel) sProdCat = "&category=" + document.getElementById('product').value;
		else sProdCat = "";
		if (linksToConvert[x].href.indexOf('cgi-bin') == -1)
		{
		  urlToEncode = linksToConvert[x].href.substring((linksToConvert[x].href.indexOf('.com')+4));
		  if (window.location.protocol == "https:")
			 {
				 urlToEncode = "http://www.superbrightleds.com/cgi-bin/store/index.cgi?action=DispPage" + sProdCat + "&Page2Disp=" + encodeURIComponent(urlToEncode);
			 }
		  else
		     {
				 urlToEncode = "/cgi-bin/store/index.cgi?action=DispPage" + sProdCat + "&Page2Disp=" + encodeURIComponent(urlToEncode);
			 }
		  linksToConvert[x].href = urlToEncode;
		}
	}
	
    if (document.getElementById('CartID')) {
    InitCartLink(document.getElementById('CartID').value); }
}

function convertBackButtons(anchorLink)
{
  var backbuttons = document.getElementsByName('backButtons');
  for (x = 0; x<backbuttons.length; x++)
  {	
	if (backbuttons[x].href.indexOf('#') != -1)
	{
		anchorLink = backbuttons[x].href.substring((backbuttons[x].href.indexOf('#')+1));
	}
	backbuttons[x].href="/cgi-bin/store/index.cgi?action=DispPage&Page2Disp=" + encodeURIComponent(aBackLinks[aBackLinks.length-2].sLinkURL);
	if (anchorLink) backbuttons[x].href += '#' + anchorLink;
  }
}

// ShadowBox supplement Code
    var shadowGallery = new Array(); 
	function shadowViewer(tableNo, y, iOpen)
	{
		if(y || y==0)
		{
			var newShadowGallery = new Array();
			newShadowGallery.push(shadowGallery[tableNo][y]);
			for (x=0; x<shadowGallery[tableNo].length; x++)
			{	   
			   if (x != y)
			   {
				   newShadowGallery.push(shadowGallery[tableNo][x]);
			   }
			}
			if (iOpen)
			{
			  Shadowbox.open(newShadowGallery);
			}
			else
			{
			  document.getElementById('large'+tableNo).style.cursor="pointer";
			  document.getElementById('large'+tableNo).onclick = function onclick(event) { Shadowbox.open(newShadowGallery) };
			}
		}
		else
		{
			document.getElementById('large'+tableNo).style.cursor="default";
			document.getElementById('large'+tableNo).onclick = "javascript://";
		}
		
	} 

// JavaScript for tooltips

  function showToolTip(content, n, s)
  {
	  content.nextSibling.style.display="block";
	  var top = parseInt(content.nextSibling.style.top);
	  if (top < 0) {
	  	if (/MSIE (\d+\.\d+);/.test(navigator.userAgent)){ //test for MSIE x.x;
			var ieversion=new Number(RegExp.$1) // capture x.x portion and store as a number
 			if (ieversion<8) {
	 			top = 0 - (content.nextSibling.offsetHeight);
				content.nextSibling.style.top=top + "px"; } 		
		}
	  }
	  if (content.nextSibling.style.top == "") {
	  	if (/MSIE (\d+\.\d+);/.test(navigator.userAgent)){ //test for MSIE x.x;
			var ieversion=new Number(RegExp.$1) // capture x.x portion and store as a number
 			if (ieversion<8) {
	 			top = content.height + "px"; }
 			else {
 				top = "0px"; }
 		content.nextSibling.style.top=top;
		}
  	  }
	  if (s=="show"){
	  content.nextSibling.style.display="block";
	  omout = content.onmouseout;
	  omover = content.onmouseover;
	  if (n=="lock")
	  {	content.onmouseout="";
	  	content.onmouseover="";
		content.nextSibling.childNodes[0].style.display="block";}
	  else
	  { content.onmouseout=omout; }}
	  else { 
		content.nextSibling.style.display="none";
	  }
	  if (s=="hide")
	  {
	  	content.nextSibling.style.display="none";
		content.nextSibling.childNodes[0].style.display="none";
	  	content.onmouseout=omout;
		content.onmouseover=omover;
	  }
  }
  
  function showNavBar(content, n, s)
  {
	  var navAnchors = document.getElementById("navbar").childNodes[1].childNodes;
	  var navCount = 0;
	  var aCount = 0;
	  for (each in navAnchors)
	  {
		  try {
		  if (navAnchors[aCount].nodeName=="a" || navAnchors[aCount].nodeName=="A")
		  	{
				navAnchors[aCount].nextSibling.style.top=(navCount * 24) + 'px';
				navCount ++;
			}
		  }
		  catch(err) {}
		  aCount ++;
	  }
	  if (s=="show"){
	  content.nextSibling.style.display="block";
	  omout = content.onmouseout;
	  omover = content.onmouseover;
	  if (n=="lock")
	  {	content.onmouseout="";
	  	content.onmouseover="";
		content.nextSibling.childNodes[0].style.display="block";}
	  else
	  { content.onmouseout=omout; }}
	  else { 
		content.nextSibling.style.display="none";
	  }
	  if (s=="hide")
	  {
	  	content.nextSibling.style.display="none";
		content.nextSibling.childNodes[0].style.display="none";
	  	content.onmouseout=omout;
		content.onmouseover=omover;
	  }
  }
  
  function MM_swapImgRestore() { //v3.0
   var i,x,a=document.MM_sr; for (i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
  }

  function MM_preloadImages() { //v3.0
   var d=document; if (d.images)
    {
    if (!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for (i=0; i<a.length; i++)
     if (a[i].indexOf("#")!=0)
      {
      d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];
      }
    }
  }

  function MM_findObj(n, d) { //v4.01
   var p,i,x;  if (!d) d=document;if ((p=n.indexOf("?"))>0&&parent.frames.length)
    {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);
    }
   if (!(x=d[n])&&d.all) x=d.all[n];for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
   for (i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
   if (!x && d.getElementById) x=d.getElementById(n);return x;
  }

  function MM_swapImage() { //v3.0
   var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for (i=0;i<(a.length-2);i+=3)
    if ((x=MM_findObj(a[i]))!=null)
     {
     document.MM_sr[j++]=x; if (!x.oSrc) x.oSrc=x.src;x.src=a[i+2];
     }
  }
  
//=============================================Button Code=============================================
var ImgAry =
   [
    'mi_0.gif',	//0
    'mi_1.gif',	//1
    'mi_0.gif',	//2
    'spab_0.gif',		//3
    'spab_1.gif',		//4
    'spab_0.gif',		//5
    'install_1.gif',	//6
    'install_0.gif',	//7
    'install_2.gif',	//8
	'a_0.gif',		//9
	'a_1.gif',		//10
	'cbbp_0.gif',		//11
	'cbbp_1.gif',		//12
	'identify_0.gif',	//13
	'identify_1.gif',	//14
	'coolwarm_0.gif',	//15
	'coolwarm_1.gif',	//16
	'cross_0.gif',		//17
	'cross_1.gif',		//18
	'close_0.gif',		//19
	'close_1.gif',		//20
	'ledprods_0.gif',	//21
	'ledprods_1.gif',	//22
	'ledprods_2.gif',	//23
	'siteindex_0.gif',	//24
	'siteindex_1.gif',	//25
	'siteindex_2.gif',	//26
	'infopol_0.gif',	//27
	'infopol_1.gif',	//28
	'infopol_2.gif',	//29
	'ledprc_0.gif',		//30
	'ledprc_1.gif',		//31
	'ledprc_2.gif',		//32
	'ledspecs_0.gif',	//33
	'ledspecs_1.gif',	//34
	'ledspecs_2.gif',	//35
	'scart_0.gif',		//36
	'scart_1.gif',		//37
	'cart_2.gif',		//38
	'gb_1.gif',	//39
	'gb_0.gif',	//40
	'gb_0.gif',	//41
	'email_0.gif',		//42
	'email_1.gif',		//43
	'email_2.gif',		//44
	'ce_1.gif',	//45
	'ce_0.gif',	//46
	'pdf_0.gif',	    //47
	'pdf_1.gif',	    //48
	'ce_1.gif',	//49
	'ce_0.gif',  	//50
	'e_1.gif',		//51
	'e_0.gif',  	//52
	'upload_0.gif',  	//53
	'upload_1.gif',		//54
	'upload_2.gif'  	//55
   ];

var SRCAry = [];


for (var zxc0 = 0; zxc0 < ImgAry.length; ++zxc0)
   {
    SRCAry[zxc0] = new Image();

    SRCAry[zxc0].src = '/images/graphics/buttons/bt' + ImgAry[zxc0];
   }


function xpe(obj, img)
        {
         obj.src = SRCAry[img].src;
        }
		
//=============================================Table Code=============================================
function tableVariables(height, image_width, body_width, thumb_amount, table_id)
{
	h = height;	
	iw = image_width;
	bw = body_width;
	if (thumb_amount == 0) {
		tw = (30 + bw + iw); }
	else {
		tw = (70 + bw + iw); }
	tnp = Math.round(((height-32)/thumb_amount));
	tableID=table_id;
	
	ptImageWidth = image_width;
	ptImageHeight = height;
	ptThumbHeight = (37 * thumb_amount);
	if (ptImageHeight < ptThumbHeight) {
	    ptImageHeight = ptThumbHeight+2; }
	ptTextWidth = body_width;
	ptTextHeight = ptImageHeight - 28;
	if (thumb_amount == 0) {
		ptThumbWidth = 0; }
	else {
		ptThumbWidth = 44; }
	ptOuterWidth = ptTextWidth + ptImageWidth + ptThumbWidth + 30;
	ptInnerWidth = ptOuterWidth - 30;
	ptOuterHeight = ptImageHeight + 40;

    ltContentHeight = height;
	ltContentWidth = image_width;
	ltWidth = image_width + 200;	
}
function beforeInfo()
{
document.write('<div id="' + tableID + '" style="height:' + (h + 15) + 'px;clear:both;"><div class="productTable" style="width:' + tw + 'px;" ><table style="width:15px" cellspacing="0"><tr><td class="ttl"></td></tr><tr><td class="tl" style="height:' + (h - 30) + 'px"></td></tr><tr><td class="tbl"></td></tr></table><table style="width:' + bw + 'px"cellspacing="0"><tr><td class="tt"></td></tr><tr><td class="bodytext" style="height:' + (h - 12) + 'px">');
}
function beforeImage()
{
document.write('</td></tr><tr><td class="tb"></td></tr></table><table style="width:' + iw + 'px" cellspacing="0"><tr><td class="tt"></td></tr><tr><td class="body" style="height:' + (h - 40) + 'px;background:url(/images/graphics/loadimage.gif) center center no-repeat;background-color:#2E2E2E;">');
}
function beforeButtons()
{
document.write('</td></tr><tr><td class="body" style="height:28px;padding:0;" >');
}
function beforeThumbnails()
{
document.write('</td></tr><tr><td class="tb"></td></tr></table><table style="width:54px" cellspacing="0"><tr><td class="ttfr" style="width:39px"></td><td class="ttr"></td></tr><tr><td class="tfr" colspan="2" style="height:' + (h - 30) + 'px" valign="top"><table class="thumbnails" cellspacing="0" style="width:54px"><tr><td valign="middle">');
}
function beforeProductThumbnails()
{
document.write('</td></tr><tr><td class="tb"></td></tr></table><table style="width:54px" cellspacing="0"><tr><td class="ttfr" style="width:39px"></td><td class="ttr"></td></tr><tr><td class="tfr" colspan="2" style="height:' + (h - 30) + 'px" valign="top"><table class="thumbnails" cellspacing="0" style="width:54px"><tr><td valign="middle"><span style="font-size:9px;color:#BFBFBF;">Products</span></td></tr><tr><td valign="middle">');
}
function betweenThumbnails()
{
document.write('</td></tr><tr><td valign="middle">');
}
function beforePhotoThumbnails()
{
document.write('</td></tr><tr><tr><td valign="middle"><span style="font-size:9px;color:#BFBFBF;">Photos</span></td></tr><td valign="middle">');
}
function beforeDefaultThumbnails()
{
document.write('</td></tr><tr><tr><td valign="middle"><span style="font-size:9px;color:#BFBFBF;">Default</span></td></tr><td valign="middle">');
}
function endTable()
{
document.write('</td></tr></table></td></tr><tr><td class="tbfr" style="width:39px"></td><td class="tbr"></td></tr></table></div></div>');
}

function noThumbs()
{
document.write('</td></tr><tr><td class="tb"></td></tr></table><table style="width:15px" cellspacing="0"><tr><td class="ttr"></td></tr><tr><td class="tr" style="height:' + (h - 30) + 'px"></td></tr><tr><td class="tbr"></td></tr></tr></table></div></div>');
}
function beforeBody()
{
document.write('<div id="' + tableID + '"><div class="productTable" style="height:' + (h + 10) + 'px;padding:5px 0;width:' + tw + 'px;" ><table style="width:15px" cellspacing="0"><tr><td class="ttl"></td></tr><tr><td class="tl" style="height:' + (h - 30) + 'px"></td></tr><tr><td class="tbl"></td></tr></table><table style="width:' + bw + 'px"cellspacing="0"><tr><td class="tt"></td></tr><tr><td style="background-color:#2E2E2E;height:' + (h - 12) + 'px">');
}
function startBorder()
{
	document.write('<div class="border1"><div class="border2"><div class="border3"><div class="border4"><div class="border5">');
}
function endBorder()
{
	document.write('</div></div></div></div></div>');
}

function ptText()
{
	document.write('<div id="' + tableID + '"><div class="pt" style="width:' + ptOuterWidth + 'px;height:' + ptOuterHeight + 'px;"><div class="ptTopLeft"></div><div class="ptTop" style="width:' + ptInnerWidth + 'px;"></div><div class="ptTopRight"></div><div class="ptLeft" style="height:' + ptImageHeight + 'px;"></div><div class="ptBody" style="height:' + ptImageHeight + 'px;width:' + ptInnerWidth + 'px;"><div class="ptText" style="width:' + ptTextWidth + 'px;"><div style="height:' + ptTextHeight + 'px;padding-right:12px;">');
}

function ptButtons(tc, pc, nmi)
{
	if(tc)
	{
	  var currentUrl = decodeURIComponent(location.href);
	  document.write('</div><div class="ptButtons"><div id="Table' + tc + '-BN"><a href="javascript://" onclick="return(ShowA2C(\'default\', \'default\', \'' + pc + '\', document.getElementById(\'Table' + tc + '-DC\').value, document.getElementById(\'CartID\').value, \'580\', \'300\'));"><img alt="Click to buy" onmouseover=\'xpe(this,4);\' onmouseout=\'xpe(this,3);\' src="/images/graphics/buttons/btspab_0.gif" name="vb67faa" border="0" /></a>');
	  if(nmi)
	  {
	    if(nmi!='nmi' && currentUrl.indexOf('/specs/') == -1)
		{
  		  document.write('<a href="' + nmi + '" id="Table' + tc + '-MI" name="convertLink" rel="' + pc + '"><img onmouseover=\'xpe(this,1);\' onmouseout=\'xpe(this,0)\' src="/images/graphics/buttons/btmi_0.gif" name="vbr7faa" border="0" alt="More Info" title="Click for more information about this product" /></a>');
		}
	  }
	  else
	  {
	    document.write('<a href="javascript://" id="Table' + tc + '-MI" onclick="thumbnailAlert();"><img src="/images/graphics/buttons/btmi_1.gif" name="vbr7faa" border="0" alt="More Info" title="Please Click Thumbnails First" /></a>');
	  }
	  document.write('</div>');
	}
	else
	{
	  document.write('</div><div class="ptButtons">');
	}
}

function ptImage()
{
	var currentUrl = decodeURIComponent(location.href);
	if (currentUrl.indexOf('/specs/') != -1 || currentUrl.indexOf('/pt/') != -1)
	{
		document.write('</div><div class="ptButtons"><a name="backButtons" href="javascript:history.go(-1);"><img onmouseover=\'xpe(this,39);\' onmouseout=\'xpe(this,40);\' onmouseup=\'xpe(this,40);\' onmousedown=\'xpe(this,41);\' src="/images/graphics/buttons/btgb_0.gif" border="0" alt="Go Back" title="Go Back to the Product Page" /></a></div></div><div class="ptImage" style="width:' + ptImageWidth + 'px;height:' + ptImageHeight + 'px;">');
	}
	else
	{
		document.write('</div></div><div class="ptImage" style="width:' + ptImageWidth + 'px;height:' + ptImageHeight + 'px;">');
	}
}

function ptThumbnails(multProds)
{
	var currentUrl = decodeURIComponent(location.href);
	if (multProds && currentUrl.indexOf('/pt/') == -1)
	{
		  document.write('</div><div class="ptThumbnails"><img alt="select products" src="/images/graphics/table/selectproducts.jpg" class="select" />');
	}
	else
	{
		document.write('</div><div class="ptThumbnails">');
	}
}

function ptEnd(multProds)
{
	var currentUrl = decodeURIComponent(location.href);
	if (currentUrl.indexOf('/specs/') != -1 && multProds > 0)
	{
	  document.write('</div></div><div class="ptRight" style="height:' + ptImageHeight + 'px;"></div><div class="ptBottomLeft"></div><div class="ptBottom" style="width:' + ptInnerWidth + 'px;"></div><div class="ptBottomRight"></div></div><div style="clear:both;"></div></div><p style="margin:0;color:white;font-size:10px;width:100%;text-align:center;">Click on the thumbnails or tabs in the Product Table above to switch between the different Product Specification Pages</p>');	
	}
	else
	{
	  document.write('</div></div><div class="ptRight" style="height:' + ptImageHeight + 'px;"></div><div class="ptBottomLeft"></div><div class="ptBottom" style="width:' + ptInnerWidth + 'px;"></div><div class="ptBottomRight"></div></div><div style="clear:both;"></div></div>');
	}
	
}