
function bindBehaviors()
{
  enableMenuImageRollovers();
  enableFullImageView();
}

// Bind click behavior to product images, preload images.
function enableMenuImageRollovers()
{
  var menu = document.getElementById('additional_product_images');
  if (!menu)
  {
    return;
  }
  var imgs = menu.getElementsByTagName('img');
  for(i=0; i < imgs.length; i++)
  {
    var img=imgs[i];
    var txt=img.src;

    var imgBig = new Image();
    imgBig.src=img.src.replace("_small","_large");
    
    img.imgBig = imgBig;
    
    img.onclick=function() {
      var mainImg = document.getElementById('main_product_image');
      mainImg.src=this.imgBig.src;
    };

  }

}

function enableFullImageView()
{
  var mainImg = document.getElementById('main_product_image');
  if (!mainImg)
  {
    return;
  }
  mainImg.onclick = function() {
    window.open(this.src.replace("_large.","."),'_blank');
  };
}

window.onload=bindBehaviors