loadScript('info');
loadScript('main');
loadScript('shop');
loadScript('oos');

var tableColor1='#eeeecc';
var tableColor2='#ffffcc';

function antInfo(ty) {
  if (ty == 'directional')
    document.write('This uni-directional antenna must be pointed in the direction of the television transmitters for optimum performance. ');
  document.write('Visit ');
  document.write('<A href="#" class="descLink" onclick="goHref(\'http://www.antennaweb.org\'); return false;" target="_blank">antennaweb.org</A>');
  document.write(' for more details. ');
}

function cartForm(formName,cmd,partNo) {
  if (formName != '-1')
    document.write('<FORM name="'+formName+'" id="add" action="/shopCart.html" method="get">');
  document.write('<INPUT type="hidden" name="cmd" value="add">');
  document.write('<INPUT type="hidden" name="sku" value="'+partNo+'">');
}

function descImage(org) {
  var height='55',alt='',link='';
  switch(org) {
    case 'approved': img='approved.gif'; alt='Cable/Satellite Operator Approved'; break;
    case 'csa': img='csa.jpg'; link='http://en.wikipedia.org/wiki/Canadian_Standards_Association'; alt='CSA Listed'; break;
    case 'ce': img='ce.jpg'; link='http://en.wikipedia.org/wiki/CE_mark'; alt='CE Listed'; break;
    case 'etl': img='etl.jpg'; link='http://en.wikipedia.org/wiki/ETL_SEMKO'; alt='ETL Compliant'; break;
    case 'fcc': img='fcc.jpg'; link='http://en.wikipedia.org/wiki/Federal_Communications_Commission'; alt='FCC Compliant'; break;
    case 'hdmi': img='hdmix.jpg'; height='35'; link='http://www.hdmi.org'; alt='Supports HDMI Connection'; break;
    case 'linux': img='linux.gif'; alt='LINUX Compatable'; break;
    case 'lw': img='lifetimeWarranty.jpg'; link='/mfWarranty.html'; alt='Lifetime Warranty'; break;
    case 'mac': img='mac.gif'; alt='MAC Compatable'; break;
    case 'pc': img='pc.gif'; alt='PC Compatable'; break;
    case 'rohs': img='rohs.jpg'; link='http://en.wikipedia.org/wiki/RoHS'; alt='RoHS Compliant'; break;
    case 'sun': img='sun.gif'; alt='SUN Compatable'; break;
    case 'weee': img='weee.gif'; link='http://en.wikipedia.org/wiki/Waste_Electrical_and_Electronic_Equipment_Directive'; alt='WEEE Compliant'; break;
    case 'ul': img='ul.jpg'; link='http://en.wikipedia.org/wiki/Underwriters_Laboratories'; alt='UL Listed'; break;
    default: img=org; break;
  }
  document.write('<A href="#" onclick="goHref(\''+link+'\'); return false;"><IMG src="/images/'+img+'"');
  if (height > 0)
    document.write(' height="'+height+'"');
  document.write(' border="0" title="'+alt+'"></A>&nbsp;&nbsp;');
}

function descLink(link,text) {
  if (link.substring(0,4) != 'http')
    link = '/'+link+'.html';
  document.write('<A href="#" class="descLink" onclick="goHref(\''+link+'\'); return false;">'+text+'</A>');
}

function descSearch(sp,text) {
  link = '/find.html?sp='+sp+'&fc=99';
  document.write('<A href="'+xLink+'" class="descLink" onclick="goHref(\''+link+'\'); return false;">'+text+'</A>');
}

function getRoman(sz,pn,um) {
  var rn=new Array('IIII','V','XXXX','L','CCCC','D','MMMM');
  var i=0,d=0,x=0,r='';
  var str=sz+'';
  if ((sz == 1) && (checkType(xUm) != -1))
    pn += 'I';
  else if (sz != 1) {
    for (i = 0; i < rn.length; i++) { x = rn[i].length + 1; d = sz % x; r = rn[i].substr(0,d) + r; sz = (sz - d) / x; }
    r = r.replace(/DCCCC/g,'CM');
    r = r.replace(/CCCC/g,'CD');
    r = r.replace(/LXXXX/g,'XC');
    r = r.replace(/XXXX/g,'XL');
    r = r.replace(/VIIII/g,'IX');
    r = r.replace(/IIII/g,'IV');
    pn += r;
    if (str.indexOf(".5") != -1)
      pn += 'S';
  }
  return(pn);
}

function googleForm(formName,formType,partNo,partDesc,partImage,partPrice,partWeight,partShip) {
  if (formType == 'add') {
    document.write('<INPUT class="product-title" value="'+partNo+' - '+partDesc+'" type="hidden">');
    document.write('<INPUT class="product-url" value="'+webAddress+'/'+partNo.substring(0,8)+'.html" type="hidden">');
    document.write('<INPUT class="product-image" value="'+imgPath+'/'+partImage+'" type="hidden">');
    document.write('<INPUT class="product-price" value="'+(partPrice * 1).toFixed(2)+'" type="hidden">');
    document.write('<INPUT class="product-weight" value="'+(partWeight * 1).toFixed(2)+'" type="hidden">');
    document.write('<INPUT class="product-shipping');
    if (xOvsz <= 0)
      document.write('-first');
    document.write('" value="'+(1 * partShip).toFixed(2)+'" type="hidden">');
  }
  else if (formType == 'click') {
    document.write('<FORM name="'+formName+'" action="https://checkout.google.com/api/checkout/v2/checkoutForm/Merchant/'+googleID+'" method="post" target="_top">');
    document.write('<INPUT type="hidden" name="item_name_1" value="'+partNo+'">');
    document.write('<INPUT type="hidden" name="item_description_1" value="'+partDesc+'">');
    document.write('<INPUT type="hidden" name="item_quantity_1" value="1">');
    document.write('<INPUT type="hidden" name="item_price_1" value="'+partPrice+'">');
    document.write('<INPUT type="hidden" name="item_weight" value="'+partWeight+'">');
    document.write('<INPUT type="hidden" name="ship_method_name_1" value="Standard Shipping">');
    document.write('<INPUT type="hidden" name="ship_method_price_1" value="'+partShip+'">');
    document.write('<INPUT type="hidden" name="continue_url" value="'+urlAddress+'/main.html?page=shopBack">');
    document.write('<INPUT type="hidden" name="edit_url" value="'+urlAddress+'/main.html">');
    document.write('<INPUT type="hidden" name="ship_method_currency_1" value="USD">');
    document.write('<INPUT type="hidden" name="_charset_" value="utf-8">');
  }
}

function loadScript(s) {
  document.write('<SCRIPT type="text/javascript" src="/support-files/'+s+'.js"></SCRIPT>');
}

function noReturn() {
  document.write('<BR><B>Ships from manufacturer. Non-returnable. Contact manufacturer for warranty service. Allow 7-10 additional days for delivery.</B>');
}

function optChange(fn,pn,pos) {
  var s='';
  s = pn+'-'+pos; if (checkStock(s,xPath4) == -1) { showAlert('Option [ '+fn+' ] is sold out.'); return; }
  s = xOptDesc+' [Option: '+fn+']';
  if (document['paypalz'].elements != undefined) document['paypalz'].elements['item_name'].value = s;
  if (document['googlez'].elements != undefined) document['googlez'].elements['item_description_1'].value = s;
}

function paypalForm(formName,partNo,partDesc,partPrice,partWeight,partShip) {
  var y='';
  document.write('<FORM name="'+formName+'" action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_top">');
  document.write('<INPUT type="hidden" name="cmd" value="_xclick">');
  document.write('<INPUT type="hidden" name="quantity" value="1">');
  document.write('<INPUT type="hidden" name="business" value="'+paypalID+'">');
//  document.write('<INPUT type="hidden" name="image_url" value="'+coLogoPaypal+'">');
  document.write('<INPUT type="hidden" name="item_number" value="'+partNo+'">');
  document.write('<INPUT type="hidden" name="item_name" value="'+partDesc+'">');
  document.write('<INPUT type="hidden" name="amount" value="'+(1 * partPrice).toFixed(2)+'">');
  document.write('<INPUT type="hidden" name="weight" value="'+(1 * partWeight).toFixed(2)+'">');
  document.write('<INPUT type="hidden" name="weight_unit" value="lbs">');
  if (xOvsz > 0)
    document.write('<INPUT type="hidden" name="shipping" value="'+(partShip * 1).toFixed(2)+'">');
  if (readCookie('skip') == 'N') {
    document.write('<INPUT type="hidden" name="first_name" value="'+readCookie('firstname')+'">');
    document.write('<INPUT type="hidden" name="last_name" value="'+readCookie('lastname')+'">');
    document.write('<INPUT type="hidden" name="address1" value="'+readCookie('addr1')+'">');
    document.write('<INPUT type="hidden" name="address2" value="'+readCookie('addr2')+'">');
    document.write('<INPUT type="hidden" name="city" value="'+readCookie('city')+'">');
    xZip = readCookie('zip');
    xState = getState(xZip);
    document.write('<INPUT type="hidden" name="state" value="'+xState+'">');
    document.write('<INPUT type="hidden" name="zip" value="'+xZip+'">');
    document.write('<INPUT type="hidden" name="country" value="US">');
    if (readCookie('pmt') == 'C')
      document.write('<INPUT type="hidden" name="email" value="">');
    else
      document.write('<INPUT type="hidden" name="email" value="'+readCookie('email')+'">');
    y = readCookie('phone');
    document.write('<INPUT type="hidden" name="night_phone_a" value="'+y.substring(0,3)+'">');
    document.write('<INPUT type="hidden" name="night_phone_b" value="'+y.substring(3,6)+'">');
    document.write('<INPUT type="hidden" name="night_phone_c" value="'+y.substring(6,10)+'">');
    document.write('<INPUT type="hidden" name="invoice" value="'+readCookie('po')+'">');
  }
  document.write('<INPUT type="hidden" name="return" value="'+urlAddress+'/main.html?page=shopBack">');
  document.write('<INPUT type="hidden" name="cbt" value="Finalize Your Order">');
  document.write('<INPUT type="hidden" name="cn" value="Message to '+coLogoText+':  ">');
  document.write('<INPUT type="hidden" name="shopping_url" value="'+urlAddress+'/main.html">');
  document.write('<INPUT type="hidden" name="cancel_return" value="'+urlAddress+'/main.html">');
  document.write('<INPUT type="hidden" name="no_shipping" value="2">');
}

function postClose() {
  document.write('</TD></TR></TABLE>');
}

function postMore() {
  if (xPrice != 0)
    document.write(' See additional information below.');
}

function postOpen() {
  document.write('<BR><TABLE bgcolor="white"><TR><TD class="descText">');
}

function showFinish(color,prefix) {
  document.write('<BR>');
  switch(prefix) {
    case 'FC': document.write('Chassis '); break;
    case 'FP': document.write('Faceplate '); break;
  }
  document.write('Finish: ');
  switch(color) {
    case 'BBA': document.write('<B>Brushed Black Anodized</B>'); break;
    case 'BL': document.write('<B>Black Laminate</B>'); break;
    case 'BSA': document.write('<FONT color="silver"><B>Brushed Silver Anodized</B></FONT>'); break;
    case 'OL': document.write('<FONT color="goldenrod"><B>Oak Laminate</B></FONT>'); break;
    case 'TBP': document.write('<FONT color="#444444"><B>Textured Black Powdercoat</B></FONT>'); break;
  }
}

function showImage(img,h,w,j) {
  if (((h > -1) || (w > -1)) && (h != -2) && (w != -2)) {
    document.write('<DIV id="layer'+j+'" class="popWindow">');
    document.write('<IMG src="/images/'+img+'" class="');
    if (w == -1) document.write('popHeight'); else document.write('popWidth');
    document.write('" onclick="popClose(\'layer'+j+'\'); return false;"><BR>');
    document.write('<FONT style="font-size:4pt"><BR></FONT>');
    document.write('&nbsp;&nbsp;<INPUT name="close" type="submit" value="Close" class="buttonOrange" onclick="popClose(\'layer'+j+'\'); return false;"><BR>');
    document.write('<FONT style="font-size:4pt"><BR></FONT>');
    document.write('</DIV>');
    document.write('<A href="javascript:popOpen(\'layer'+j+'\')" style="text-decoration:none">');
  }
  document.write('<IMG src="/images/'+img+'"');
  if (h > -1) document.write(' height="'+h+'"');
  if ((h > -1) && (h <= 50)) document.write(' width="'+h+'"'); else if (w > -1) document.write(' width="'+w+'"');
  if ((h == -1) || (h > 50) || (w > -1)) document.write(' border="0"');
  document.write('>');
  if ((h <= -1) || (j == 99)) document.write('<BR>'); else addSpace(4);
  if (((h > -1) || (w > -1)) && (h != -2) && (w != -2)) {
    if (j == 99)
      document.write('<IMG src="/images/enlarge.jpg" height="10" border="0"><FONT class="descTiny"> Click on image to zoom</FONT>');
    document.write('</A>');
  }
}

function showInfo(ia) {
  var h=0, i=0, j=0, s='', t=0.00, w=0;
  xLogo = coLogo;
  queryDatabase(0,xPart);
  document.write('<TABLE bgcolor="#ddeedd" cellspacing="0" callpadding="2" width="100%"><TR><TD>');
  xLink = '/find.html?sp=-1&fc=1';
  document.write('&nbsp;&nbsp;<A href="#" class="partLink" onclick="goHref(\'/find.html?sp=-1&fc=1\'); return false;">'+partName+'</A>');
  if (xPrice != 0) {
    getList(xPath0,1);
    xLink = '/find.html?sp='+offset+'&fc=1';
    document.write('&nbsp;'+linkArrow+'&nbsp;<A href="#" class="partLink" onclick="goHref(\'/find.html?sp='+offset+'&fc=1\'); return false;">'+result+'</A>');
    getList(xPath1,2);
    document.write('&nbsp;'+linkArrow+'&nbsp;<A href="#" class="partLink" onclick="goHref(\'/find.html?sp='+offset+'&fc=2\'); return false;">'+result+'</A>');
    document.write('<BR>');
    document.write('&nbsp;&nbsp;<A href="#" class="partLink" onclick="goHref(\'/find.html?sp=-1&fc=1\'); return false;">'+partName+'</A>');
    getList(xPath2,1);
    document.write('&nbsp;'+linkArrow+'&nbsp;<A href="#" class="partLink" onclick="goHref(\'/find.html?sp='+offset+'&fc=1\'); return false;">'+result+'</A>');
    getList(xPath3,2);
    document.write('&nbsp;'+linkArrow+'&nbsp;<A href="#" class="partLink" onclick="goHref(\'/find.html?sp='+offset+'&fc=2\'); return false;">'+result+'</A>');
  }
  document.write('</TD></TR></TABLE><BR>');
  document.write('<TABLE bgcolor="white" width="100%"><TR><TD align="left" valign="middle" colspan="99"><FONT class="descTitle">'+xDesc);
  if ((checkType(xUm) != -1) && (xUm.indexOf('model') == -1)) {
    document.write(' (');
    for (i = 0; i < xElement; i++) {
      document.write(xSizeList[i]);
      if (i < xElement - 1)
       document.write(',');
    }
    if (xUm.indexOf('feet') != -1)
      document.write(' ft.)');
    else if (xUm.indexOf('space') != -1)
      document.write('U)');
  }
  else if (xUm.indexOf('channel') != -1)
    document.write(' (Ch '+xUm.substring(xUm.indexOf('=')+1)+')');
  document.write('</FONT></TD></TR></TABLE><BR>');
  document.write('<TABLE bgcolor="white"><TR');
  if ((paypalCheckout != 'YES') || (cookiesEnabled == 'N'))
    document.write(' class="product" ');
  document.write('><TD align="left" valign="middle">');
  if (xPrice == 0) {
    xImage = 'discontinued.gif';
    xHeight = 120;
    xWidth = -2;
  }
  if ((ia == undefined) || (xPrice == 0))
    showImage(xImage,xHeight,xWidth,99);
  else if (ia.constructor.toString().indexOf('Array') == -1)
    showImage(xImage,xHeight,xWidth,99);
  else {
    showImage(xImage,xHeight,xWidth,0);
    for (i = 0; i < ia.length; i += 3) {
        if (i >= ia.length - 3) j = 99; else j = i + 1;
        if ((ia[i + 1] == undefined) || (ia[i + 2] == undefined)) { h = 100; w = -1; }
        else { h = ia[i + 1]; w = ia[i + 2]; }
        showImage(ia[i],h,w,j);
    }
  }
  document.write('</TD><TD>');
  addSpace(8);
  document.write('</TD>');
  if ((paypalCheckout != 'YES') || (cookiesEnabled == 'N'))
    googleForm('google','add',xPart,xDesc,xImage,xPrice,xWt,xShip);
  document.write('<TD align="left" valign="middle"');
  if (cookiesEnabled == 'N')
    document.write(' class="googlecart-add"');
  document.write('>');
  if (xPrice != 0) {
    getList(xPath4,0);
    document.write('<A href="#" onclick="goHref(\'/find.html?sp='+offset+'&fc=0\'); return false;">');
    document.write('<IMG src="/images/'+xLogo+'" class="showMfgr" title="see all products for this manufacturer" border="0">');
    document.write('</A>');
    document.write('<BR><FONT class="showModel">Model: '+xModel+'</FONT>');
  }
  document.write('<BR><FONT class="showSku">SKU: '+xPart+'</FONT>');
  if ((xPrice != 0) && ((checkType(xUm) == -1) || (xElement == 1))) {
    listPrice = Math.abs(xPrice) * 1.29;
    s = listPrice.toFixed(0) + '.99';
    document.write('<BR><FONT class="showList">Retail Price: $'+s+'</FONT>');
    t = Math.abs(xPrice);
    document.write('<BR><FONT class="showPrice">Online Price: $'+t.toFixed(2)+'</FONT><BR>');
  }
  if (xPrice == 0)
    document.write('<BR><FONT class="showOos">&nbsp;&nbsp;No Longer Available&nbsp;&nbsp;</FONT>');
  else if ((xPrice <= 0) && (checkType(xUm) == -1))
    document.write('<BR><FONT class="showOos">&nbsp;&nbsp;Sold Out&nbsp;&nbsp;</FONT>');
  else if ((checkType(xUm) != -1) || (xUm.indexOf(',') != -1))
    document.write('<BR><IMG src="/images/instock.gif">&nbsp;<FONT class="showMsg">See Below to Order</FONT>');
  else if ((paypalCheckout == 'YES') || ((googleCheckout == 'YES') && (xPrice < googleLimit))) {
    if ((paypalCheckout != 'YES') || (cookiesEnabled == 'N')) {
      document.write('<BR><INPUT class="googlecart-quantity" type="hidden" value="1">');
      document.write('<INPUT name="submit" type="submit" value="Add To Cart" class="buttonOrange" onclick="showLoadMsg();">');
    }
    else
      document.write('<BR><INPUT name="addToCart" type="button" value="Add To Cart" class="buttonOrange" onclick="goHref(\'shopCart.html?cmd=add&sku='+xPart+'&qty=1\');">');
  }
  document.write('</FONT></TD></TR></TABLE><HR>');
  document.write('<FONT class="descText">');
}

var xOptDefault='';
var xOptDesc='';
var xBuyNowItem='';
var xBuyNowDesc='';
var xBuyNowPrice='';
var xBuyNowWeight='';
var xBuyNowShip='';
var xDivider='/';
var xOr='&mdash; OR &mdash;';
function showPrice(pdf,sz,text,also,link) {
  var labels=new Array('PACKAGE','SKU','undefined','UNITS','EACH','TOTAL','QTY','SHIPPING','WEIGHT','BUY IT',xOr,'EXPRESS CHECKOUT','-1');
  var bc='', bypass=0, ch=0, cd='', cost=0, desc='', flag=0, hx=0, hs='', i=0, ix=0, iy=0;
  var iz=0, itemno='', mfgr='', n=0, optLabel='', perunit='', price=0.00, s=0, sizes='', spass='', str='', tpack='';
  var units=0, unitsz='', weight=0.00, wt=0.00, xfactor=0, xopts=1, xpass=0, xstart='', xstop='';
  xCount = 0;
  if ((xUm.indexOf('feet') != -1) && (xElement > 1))
    document.write(' Select cable length from chart below.');
  document.write('</FONT><FONT class="descText">');
  if ((xEach > 1) && (checkType(xUm) == -1)) {
    if (xUm.indexOf('box') != -1)
      document.write(' '+xEach+' per box');
    else
      document.write(' Sold in packages of '+xEach+'');
    if ((also != undefined) && (link != undefined)) {
      document.write(' (also available in packages of ');
      descLink(link,also);
      document.write('.)');
    }
    else
      document.write('.');
  }
  document.write('</FONT>');
  if (xWt != undefined)
    if ((xWt > 0) && ((checkType(xUm) == -1) || (xUm.indexOf('feet') != -1))) {
      document.write('<BR><FONT class="descWeight">Weight: '+xWt+' lb');
      if (xWt != 1)
        document.write('s');
      document.write('.');
      if (xUm.indexOf('feet') != -1)
        document.write(xDivider+'ft.');
      else if (xEach > 1) {
        if (xUm.indexOf('box') != -1)
          document.write(xDivider+'box');
        else
          document.write(xDivider+'pkg.');
      }
     document.write('</FONT>');
    }
  document.write('<DIV class="addthis_toolbox addthis_default_style ">');
  document.write('<TABLE bgcolor="white" cellpadding="4" cellspacing="4"><TR><TD>');
  if (xPrice != 0) {
    document.write('<A class="addthis_button_preferred_1"></A>');
    document.write('<A class="addthis_button_preferred_2"></A>');
    document.write('<A class="addthis_button_preferred_3"></A>');
    document.write('<A class="addthis_button_preferred_4"></A>');
    document.write('<A class="addthis_button_compact"></A>');
    document.write('<A class="addthis_counter addthis_bubble_style"></A>');
    document.write('&nbsp;&nbsp;&nbsp;&nbsp;');
    if (document.all) {
      document.write('<A href="javascript:window.external.AddFavorite(\''+urlAddress+'/'+xPart.substring(0,8)+'.html\',\''+xDesc+'\')" class="descDoc">');
      document.write('<IMG src="/images/bookmark.gif" border="0"></A>&nbsp;&nbsp;&nbsp;&nbsp;');
    }
    else if (window.sidebar) { 
      document.write('<A href="javascript:window.sidebar.addPanel(\''+xDesc+'\',\''+urlAddress+'/'+xPart.substring(0,8)+'.html\',\'\')" class="descDoc">');
      document.write('<IMG src="/images/bookmark.gif" border="0"></A>');
    }
    else if (window.opera && window.print)
      return true;
  } 
  if ((pdf != undefined) && (pdf != '') && (xPrice != 0)) {
    if (pdf.substring(0,4) != 'http') {
      if (pdf.indexOf('.pdf') != -1)
        pdf = '/support-files/'+pdf;
      else
        pdf = '/images/'+pdf;
    }
    if (!document.all)
      document.write('&nbsp;&nbsp;&nbsp;&nbsp;');
    document.write('<A href="'+pdf+'" class="descDoc"');
    if (!document.all)
      document.write(' target="_blank"');
    document.write('>');
    document.write('<IMG src="/images/datasheet.jpg" height="14" border="0">');
    document.write('</A>');
  }
  document.write('</TD></TR></TABLE>');
  document.write('</DIV>');
  document.write('<SCRIPT type="text/javascript" src="http://s7.addthis.com/js/250/addthis_widget.js#pubid=xa-4dcbf4d47ec6ed88"></SCRIPT>');
  if (xPrice == 0)
    return;
  xSizeList[xElement] = -1;
  xPriceList[xElement] = -1;
  if (xPrice < 0)
    labels[6] = '-1';
  if ((buyOneNow != 'YES') || (checkType(xUm) != -1))
    labels[10] = '-1';
  if (xUm == 'kit')
    labels[3] = 'KITS';
  else if (xUm == 'set')
    labels[3] = 'SETS';
  else if (checkType(xUm) != -1) {
    labels[3] = 'SIZE';
    labels[5] = 'PRICE';
    if (xUm.indexOf('feet') != -1) {
      labels[3] = 'LENGTH';
      labels[4] = 'COST'+xDivider+'FT';
    }
    if (xUm.indexOf('model') != -1)
      labels[3] = 'DESCRIPTION';
    if (xUm.indexOf('space') != -1) {
      labels[3] = 'INSIDE HEIGHT';
      labels[4] = 'COST'+xDivider+'U';
    }
  }
  if (xUm.indexOf(',') != -1) {
    if (xUm.indexOf('feet,bulk=') != -1) {
      labels[2] = 'CABLES';
      labels[4] = 'COST'+xDivider+'CABLE';
    }
    else {
      optLabel = xUm.substring(xUm.indexOf(',') + 1,xUm.indexOf('='));
      labels[2] = optLabel.toUpperCase();
    }
  }
  if (xOvsz <= 0) {
    if (xUm.indexOf('model') != -1) {
      labels[7] = labels[8];
      labels[8] = labels[9];
      labels[9] = labels[10];
      labels[10] = labels[11];
      labels[11] = '-1';
    }
    else {
      labels[7] = labels[9];
      labels[8] = labels[10];
      labels[9] = labels[11];
      labels[10] = '-1';
    }
  }
  document.write('<TABLE bgcolor="#ddddee" cellpadding="2" cellspacing="0"><TR>');
  document.write('<TD bgcolor="#ddddee"></TD>');
  i=0;
  while (labels[i] != '-1') {
    if (((i > 0) || (checkType(xUm) == -1)) && ((i != 2) || (xUm.indexOf(',') != -1)) && ((i != 4) || (xUm.indexOf('model') == -1)))
      document.write('<TD align="center" valign="bottom" class="shoppingCartHead">&nbsp;&nbsp;'+labels[i]+'&nbsp;&nbsp;</FONT></TD>');
    i++;
  }
  document.write('<TD bgcolor="#ddddee"></TD>');
  document.write('</TR>');
  if (xPrice == 0)
    return;
  if (checkType(xUm) != -1)
    sizes = xSizeList;
  else
    sizes = xCartQty;
  if (xPrice < 0) {
    xPrice = Math.abs(xPrice);
    flag = -1;
  }
  i = 0;
  while (bypass == 0) {
    bc = xCount / 2;
    document.write('<TR ');
    if ((paypalCheckout != 'YES') || (cookiesEnabled == 'N'))
      document.write('class="product" ');
    document.write('height="'+rowHeight+'" bgcolor="');
    itemno = xPartList[i];
    if (bc.toFixed(0) * 1 == bc.toFixed(1) * 1)
      document.write('#f0fff0');
    else
      document.write('#e8e8ff');
    document.write('"><TD bgcolor="#ddddee"></TD>');
    if (checkType(xUm) == -1) {
      document.write('<TD align="left" valign="middle" class="cartPkg">&nbsp;&nbsp;'+sizes[i]+' ');
      if ((xUm == 'shelf') && (sizes[i] > 1))
        document.write('shelves');
      else {
        if (xUm.indexOf(',') != -1)
          document.write(xUm.substring(0,xUm.indexOf(',')));
        else 
          document.write(xUm);
        if ((sizes[i] > 1) && (xUm.indexOf('box') != -1))
          document.write('es');
        else if (sizes[i] > 1)
          document.write('s');
      }
      document.write('&nbsp;&nbsp;</TD>');
    }
    if (checkType(xUm) == -1)
      itemno = getRoman(sizes[i],xPart.substring(0,8),xUm);
    document.write('<TD align="left" valign="middle" class="cartSku">&nbsp;&nbsp;'+itemno+'&nbsp;&nbsp;</FONT></TD>');
    if (checkType(xUm) != -1)
      units = sizes[i];
    else
      units = sizes[i] * xEach;
    if (checkType(xUm) == -1)
      unitsz = units.toFixed(0);
    else if (xUm.indexOf('model') != -1)
      unitsz = xDescList[i];
    else if ((xUm.indexOf('feet') != -1) && (sizes[i] == 1))
      unitsz = '1 foot';
    else if (xUm.indexOf('space') != -1) {
      hx = units * 1.75;
      hs = hx.toFixed(2);
      unitsz = units+'U&nbsp;&nbsp;('+hs.substring(0,hs.indexOf('.'));
      if (hs.substring(hs.indexOf('.')) == '.25')
        unitsz += '&frac14;';
      else if (hs.substring(hs.indexOf('.')) == '.50')
        unitsz += '&frac12;';
      else if (hs.substring(hs.indexOf('.')) == '.75')
        unitsz += '&frac34;';
      unitsz += '" H)';
    }
    else if (xUm.indexOf(',') != -1)
      unitsz = units+' '+xUm.substring(0,xUm.indexOf(','));
    else
      unitsz = units+' '+xUm;
    if (checkType(xUm) != -1)
      price = 1 * xPriceList[i];
    else
      price = getPriceEach(xCost,sizes[i]);
    if (price < 0)
      price = Math.abs(price);
    if (checkType(xUm) != -1) {
      if (price / sizes[i] < 1) {
        cost = Math.ceil(price / sizes[i] * 1000);
        cost /= 10;
        perunit =  cost.toFixed(1)+'&cent;';
      }
      else  {
        if (xUm.indexOf('feet,bulk=') != -1)
          cost = Math.ceil(price / (1 * xUm.substring(xUm.indexOf('=') + 1)) * 100) / 100;
        else
          cost = Math.ceil(price / sizes[i] * 100) / 100;
        perunit = '$'+cost.toFixed(2);
      }
    }
    else if (price / xEach < 0.1) {
      if (checkType(xUm) != -1)
        cost = Math.ceil(price / sizes[i] * 10000);
      else
        cost = Math.ceil(price / xEach * 10000);
      cost /= 100;
      perunit =  cost.toFixed(2)+'&cent;';
    }
    else if (price / xEach < 1) {
      if (checkType(xUm) != -1)
        cost = Math.ceil(price / sizes[i] * 1000);
      else
        cost = Math.ceil(price / xEach * 1000);
      cost /= 10;
      perunit =  cost.toFixed(1)+'&cent;';
    }
    else {
      cost = Math.ceil(price / xEach * 100) / 100;
      perunit = '$'+cost.toFixed(2);
    }
    if (checkType(xUm) != -1)
      xTotal = price;
    else
      xTotal = price * sizes[i];
    weight = xWt;
    if (checkType(xUm) == -1)
      weight = xWt * sizes[i];
    desc = xDesc;
    if (xUm.indexOf('model') != -1)
      desc = xDescList[i];
    else if (checkType(xUm) != -1) {
      if (xUm.indexOf('space') != -1)
        desc += ' ('+sizes[i]+'U)';
      else if (xUm.indexOf('feet') != -1) {
        if (sizes[i] == 1)
          desc += ' (1 foot)';
        else
          desc += ' ('+sizes[i]+' feet)';
      }
    }
    else if (sizes[i] > 1) {
      tpack = sizes[i] * xEach;
      if (desc.indexOf('(') != -1)
        desc = desc.substring(0,desc.indexOf('(') - 1);
      desc += ' ('+tpack+' pack)';
    }
    if (checkType(xUm) != -1) {
      queryDatabase(200,xPartList[i]);
      xfactor = 1;
    }
    else
      xfactor = sizes[i];
    xShip = getShipCost(xTotal,xOvsz,xfactor) * 1;
    if ((paypalCheckout == 'YES') && (cookiesEnabled != 'N'))
      cartForm('cart'+i,'add',itemno);
    else
      googleForm('google'+i,'add',itemno,desc,xImage,xTotal,weight,xShip);
    if (xUm.indexOf(',') != -1) {
      document.write('<TD align="center" valign="middle">&nbsp;&nbsp;');
      for (xpass = 0; xpass < xopts; xpass++) {
        if (checkType(xUm) != -1)
          queryDatabase(200,xPartList[i]);
        if ((xUm.indexOf(',') == -1) || ((xUm.indexOf('|') == -1) && (xUm.indexOf('~') == -1)) || (xUm.indexOf('model') != -1)) {
          str = xUm.substring(xUm.indexOf('=') + 1);
          str = str.substring(0,1);
          str = str.toUpperCase()+xUm.substring(xUm.indexOf('=') + 2);
          if (xUm.indexOf('feet') != -1)
            document.write('<FONT class="cartBulk">'+str+'</FONT>');
          else
            document.write('<FONT class="cartEach">'+str+'</FONT>');
        }
        else {
          if ((paypalCheckout == 'YES') && (cookiesEnabled != 'N'))
            document.write('<INPUT name="on'+spass+'" type="hidden" value="Option">');
          spass = xpass.toFixed(0);
          document.write('<SELECT class="');
          if ((paypalCheckout != 'YES') || (cookiesEnabled == 'N'))
            document.write('product-attr-option'+spass+'"');
          else if (bc.toFixed(0) * 1 == bc.toFixed(1) * 1)
            document.write('cartOption1');
          else
            document.write('cartOption2');
          document.write('" name="');
          if ((paypalCheckout != 'YES') || (cookiesEnabled == 'N'))
            document.write('os'+spass);
          else
            document.write('opt');
          document.write('" onChange="optChange(this.options[this.selectedIndex].value,itemno.substring(0,8),this.selectedIndex + 1);">');
          ix=xUm.indexOf('=') + 1;
          iy=ix;
          str='';
          while (ix < xUm.length) {
            while ((iy < xUm.length) && (xUm.substring(iy,iy+1) != '|'))
              iy++;
            str = xUm.substring(ix,ix + 1);
            str = str.toUpperCase()+xUm.substring(ix + 1,iy++);
            if (str.indexOf('~') != -1) {
              xstart = str.substring(0,str.indexOf('~'));
              xstop = str.substring(str.indexOf('~') + 1);
              for (ch = xstart * 1; ch <= xstop * 1; ch++) {
                cd = ch+'';
                if (xUm.indexOf('channel') != -1)
                  cd = 'Ch '+cd;
                 if (n++ == 0)
                  xOptDefault = cd;
                document.write('<OPTION value="'+cd+'"');
                if ((iz == 0) && (ch - (1 * xstart) == xpass))
                  document.write(' selected');
                document.write('>&nbsp;'+cd+'&nbsp;</OPTION>');
              }
            }
            else {
              if (n++ == 0)
                xOptDefault = str;
              document.write('<OPTION value="'+str+'">&nbsp;'+str+'&nbsp;</OPTION>');
            }
            ix = iy;
            iz++;
          }
          document.write('</SELECT>');
        }
      }
      document.write('&nbsp;&nbsp;</FONT></TD>');
    }
    document.write('<TD class="');
    if (xUm.indexOf('model') != -1)
      document.write('cartDesc');
    else
      document.write('cartEach');
    document.write('" align="');
    if ((xUm.indexOf('model') != -1) || (xUm.indexOf('space') != -1))
      document.write('left');
    else
      document.write('center');
    document.write('" valign="middle">&nbsp;&nbsp;'+unitsz+'&nbsp;&nbsp;</FONT></TD>');
    if (xUm.indexOf('model') == -1)
      document.write('<TD align="center" valign="middle" class="cartPrice">&nbsp;&nbsp;'+perunit+'&nbsp;&nbsp;</FONT></TD>');
    document.write('<TD align="right" valign="middle" class="cartTotal">&nbsp;&nbsp;$'+xTotal.toFixed(2)+'&nbsp;&nbsp;</FONT></TD>');
    if ((checkStock(itemno,xPath4) == -1) || (flag == -1)) {
      document.write('<TD colspan="2" align="left" valign="middle" class="cartOutOfStock">&nbsp;&nbsp;');
      if (checkType(xUm) != -1)
        document.write('<IMG src="/images/notinstock.gif">&nbsp;Sold Out');
      document.write('&nbsp;&nbsp;</TD>');
      if (xOvsz > 0)
        document.write('<TD>&nbsp;&nbsp;</TD>');
      if ((xOvsz > 0) || (xUm.indexOf('model') != -1))
        document.write('<TD>&nbsp;&nbsp;</TD>');
    }
    else {
      document.write('<TD align="center" valign="middle">&nbsp;&nbsp;');
      if ((paypalCheckout != 'YES') || (cookiesEnabled == 'N'))
        document.write('<INPUT class="googlecart-quantity" type="text" value="1" size="4" maxlength="4">');
      else {
        document.write('<INPUT type="text" name="qty" class="');
        if (bc.toFixed(0) * 1 == bc.toFixed(1) * 1)
          document.write('cartQty1');
        else
          document.write('cartQty2');
        document.write('" value="1" size="4" maxlength="4">');
      }
      document.write('&nbsp;&nbsp;</TD>');
      if (xOvsz > 0) {
        s = getShipCost(xTotal,xOvsz,xfactor) * 1;
        document.write('<TD align="right" valign="middle" class="cartShip">&nbsp;&nbsp;$'+s.toFixed(2)+'&nbsp;&nbsp;</TD>');
      }
      if ((xOvsz > 0) || (xUm.indexOf('model') != -1)) {
        wt = xWt;
        if (checkType(xUm) == -1)
          wt *= sizes[i];
        document.write('<TD align="right" valign="middle" class="cartWeight">&nbsp;&nbsp;');
        document.write(wt.toFixed(2));
        document.write(' lbs.&nbsp;&nbsp;</TD>');
      }
      document.write('<TD ');
      if ((paypalCheckout != 'YES') || (cookiesEnabled == 'N'))
        document.write('class="googlecart-add" ');
      document.write('align="center" valign="middle">&nbsp;&nbsp;');
      if ((paypalCheckout == 'YES') || ((googleCheckout == 'YES') && (xTotal <= googleLimit)))
        document.write('<INPUT name="submit_'+i+'" type="submit" value="Add To Cart" class="buttonOrange" onclick="showLoadMsg(); return true;">');
      document.write('&nbsp;&nbsp;</TD>');
    }
    document.write('</FORM>');
    document.write('<TD bgcolor="#ddddee"></TD>');
    if ((i > 0) || (checkStock(itemno,xPath4) == -1) || (flag == -1) || ((paypalCheckout != 'YES') && (googleCheckout != 'YES')) || (buyOneNow != 'YES') || (checkType(xUm) != -1))
        document.write('<TD bgcolor="#ddddee"></TD>');
    else {
      xOptDesc = desc;
      xBuyNowItem = itemno;
      xBuyNowDesc = desc;
      xBuyNowPrice = xTotal.toFixed(2);
      xBuyNowWeight = weight.toFixed(2);
      xBuyNowShip = getShipCost(xTotal,xOvsz,xfactor) * 1;
      if ((xUm.indexOf(',') != -1) && ((xUm.indexOf('|') != -1) || (xUm.indexOf('~') != -1)))
        xBuyNowDesc += ' [Option: '+xOptDefault+']';
      document.write('<TD rowspan="');
      if (googleCheckout == 'YES')
        document.write('3');
      else
        document.write('2');
      document.write('" class="buyOneNow">');
      if (googleCheckout == 'YES') {
        if (xPrice > googleLimit)
          document.write('<IMG src="'+buttonGoogleDisabled+'" height="20" width="120"><BR>');
        else {
          googleForm('googlez','click',xBuyNowItem,xBuyNowDesc,undefined,xBuyNowPrice,xBuyNowWeight,xBuyNowShip);
          document.write('<INPUT type="image" name="submit" src="'+buttonGoogleCheckout+'" height="20" width="120" title="buy one now with google checkout">');
          document.write('</FORM>');
        }
      }
      else if (paypalCheckout == 'YES') {
        paypalForm('paypalz',xBuyNowItem,xBuyNowDesc,xBuyNowPrice,xBuyNowWeight,xBuyNowShip);
        document.write('<BR><INPUT type="image" name="submit" src="'+buttonPayPalCheckout+'" height="20" width="120" title="buy one now with paypal checkout">');
        document.write('</FORM>');
      }
      document.write('<BR>');
      if ((googleCheckout == 'YES') && (paypalCheckout == 'YES')) {
        paypalForm('paypalz',xBuyNowItem,xBuyNowDesc,xBuyNowPrice,xBuyNowWeight,xBuyNowShip);
        document.write('<INPUT type="image" name="submit" src="'+buttonPayPalCheckout+'" height="20" width="120" title="buy one now with paypal checkout">');
        document.write('</FORM>');
      }
      document.write('</TD>');
    }
    document.write('<TD bgcolor="#ddddee"></TD></TR>');
    xCount++;
    i++;
    bypass = -1;
    if ((sizes[i] != '-1') && (sizes[i - 1] != '-1') && ((i == 0) || (checkType(xUm) != -1) || (xPrice * sizes[i] <= maxPrice)))
      bypass = 0;
  }
  document.write('<TR><TD colspan="99" bgcolor="#ddddee"></TD></TR></TABLE>');
}

function tableClose() {
  document.write('</TABLE>');
}

function tableItem(da) {
  var ix=0;
  var bc=xTable++ / 2;
  document.write('<TR height="26" bgcolor="');
  if (bc.toFixed(0) * 1 == bc.toFixed(1) * 1)
    document.write(tableColor1);
  else
    document.write(tableColor2);
  document.write('">');
  while (da[ix] != '-1')
    document.write('<TD class="specTable">'+da[ix++]+'</TD>');
  document.write('</TR>');
}

xTable=0;
function tableOpen() {
  document.write('<BR><BR><TABLE cellspacing="2" cellpadding="2">');
}

