// Jquery slider-gallery code.
$(window).ready(function () {
  $('.jt').cluetip({
      width : 200,
      cluetipClass: 'jtip',
      arrows: true,
      dropShadow: false,
      hoverIntent: false,
      sticky: true,
      mouseOutClose: true,
      closePosition: 'title',
      closeText: '<img src="' + baseUrl + 'img/cross.png" alt="close" />',
      onShow: handleThickbox
    });

    // Show manufacturer logo on mouseover event
    $(".productPreviewImg").mouseover(function() {
        setProductLogo(this);
    });

    // Show previous product image on mouseout event
    $(".productPreviewImg").mouseout(function() {
        setProductLogo(this);
    });
});


//Function to set the spotlight product logo
function setProductLogo(element) {
    // Set the link id
    var linkId = element.id.replace("productLink_", "");

    // Set bg image object
    var bgImage = $("#productImage_"+linkId);

    // Store the previous link url
    var prevLink = $(bgImage).css('background-image');

    // Set the key
    var key = $(element).attr('key');

    // Replace the previous link url with the new
    if (productImagePreview[key]) {
        $(bgImage).css('background-image', productImagePreview[key])
        // Save the previous link url
        productImagePreview[key] = prevLink;
    }
}

function handleThickbox()
{
    tb_init('a.thickbox');
}