// sidebarupsellsupport.js v1.00

var hiddencode = '';
var inupsell = false;

// set the window name to unique value
Now = new Date();
var WindowName = "W" + Now.getTime();
window.name = WindowName;

function extinfobuttonimage(imagecode){ 
  if (! inupsell)
    {
    document.write(imagecode);
    }
}

function upsellimage(thisimage, sizes, name){   // display product image (scale down big upsell images)
  if (thisimage != 'NETQUOTEVAR:IMAGEFILE')	// that's what we see if there's no image
    {
    var imgbits = sizes.match(/(\d+)\D+(\d+)/);
    if ( imgbits != null )
      {
      if ( imgbits[2] > upsellimagewidth )
        {
        var sdown = upsellimagewidth / imgbits[2];
        imgbits[1] = Math.floor(imgbits[1] * sdown);
        imgbits[2] = upsellimagewidth;
        }
      if ( imgbits[1] > upsellimagemaxheight )
        {
        sdown = upsellimagemaxheight / imgbits[1];
        imgbits[1] = upsellimagemaxheight;
        imgbits[2] = Math.floor(upsellimagewidth * sdown);
        }
      document.write('<img border=0 src="' + thisimage + '" HEIGHT=' + imgbits[1] + ' WIDTH=' + imgbits[2] 
                   + ' alt=" ' + name + '">');
      }
    else
      {
      document.write('Bad sizes: ' + sizes);
      }
    }
}

function appendupsellitem(anchor){	// append the Upsell product HTML to our pending string
 hiddencode += document.getElementById('product-' + anchor).innerHTML;
 inupsell = false;
}

function showupsellitems(){		// output the accumulated Upsell product HTML.
 var caption = 1 ? upsellcaption + '<br><br>' : '';
 document.getElementById('upsellarea').innerHTML = caption + hiddencode;
}
