// START UPSELL SUPPORT (amended 25-07-04)
var inupsell = false;
var inmain = false;
var inpopup = false;

function startupsellmain(){  // start of main product that contains upsell items
if ( inmain )
  {
  document.write('</td></tr></table></td></tr>');
  }
inmain = true;
inupsell = false;
}

function startnormal(){   // start of normal product
if ( inmain )
  {
  document.write('</td></tr></table></td></tr>');
  }
inmain = false;
inupsell = false;
}

function showimage(thisimage){  // display product image (scale down big upsell images
// parse e.g. <IMG SRC="image.jpg" ALT="Alt text" BORDER=0 HEIGHT=500 WIDTH=40 >
if ( inupsell )
  {
  var imgbits = thisimage.match(/(.*)HEIGHT=(\d*) WIDTH=(\d*)(.*)/);
  if ( imgbits != null )
    {
    if ( imgbits[3] > upsellimagewidth )
      {
      var sdown = upsellimagewidth / imgbits[3];
      imgbits[2] = Math.floor(imgbits[2] * sdown);
      imgbits[3] = upsellimagewidth;
      }
    if ( imgbits[2] > upsellimagemaxheight )
      {
      sdown = upsellimagemaxheight / imgbits[2];
      imgbits[2] = upsellimagemaxheight;
      imgbits[3] = Math.floor(upsellimagewidth * sdown);
      }
    document.write(imgbits[1] + 'HEIGHT=' + imgbits[2] + ' WIDTH=' + imgbits[3] + imgbits[4]);
    }
  }
else
  {
  if ( inpopup ) thisimage = '</a>' + thisimage + '<a name="xxx">'; // fix unnwanted link on popup pages
  document.write(thisimage);
  }
}
// END UPSELL SUPPORT