﻿$(document).ready(function() {
    $('ul#product-info-list img').css('display', 'none');
    $('ul#product-info-list img').addClass('product-image');
    $('ul#product-info-list img:eq(0)').css('display', 'block');

    $('.product-image').css('position', 'absolute');
/*
    var h1 = $('ul#product-info-list').height();

   

    var h2 = $('ul#product-info-list').height();

    $('ul#product-info-list').css('height', (h1 - h2) + 'px');*/


    $('ul#product-info-list a').click(function() {
        if ($(this).next('img').is(':visible')) {
            return false;
        }
        $('ul#product-info-list img').css('display', 'none');
        $(this).next('img').css('display', 'block');
        $('h4.active').removeClass('active');
        $(this).prev().addClass('active');
        $('.serving-notice').hide();
        return false;
    });

    //$('ul#product-info-list h4 span').attr('title', 'Rollover to view product image');

    $("ul#product-info-list h4 span").hover(
      function() {
          if ($(this).find('img').is(':visible')) {
              return false;
          }
          $('ul#product-info-list img').css('display', 'none');
          $('h4.active').removeClass('active');
          $(this).find('img').css('display', 'block');
          $('.serving-notice').css('display', 'block');
          return false;
      },
      function() {
          return;
      }
    );
//    $('body.default div#your-best-recipe-contest a').attr('target', '_blank');
//    $('body.default div#your-best-recipe-contest a').click(function() {
//        window.open($(this).attr('href'), 'popup', 'width=500,height=550');
//        return false;
//    });

    $('a[rel$="popup"]').click(function() {
        window.open($(this).attr('href'), 'popup', 'width=500,height=550');
        return false;
    });
    $('a[rel$="print"]').click(function() {
        window.print();
        return false;
    });

    //      var popuplink = $('body.default div#your-best-recipe-contest a');
    //      popuplink.addEventListener('click', handlePopUpVidLink);

    //    function handlePopUpVidLink(e) {
    //        return false;
    //    }


    /* -- works, but causes Script error
    $('ul#product-info-list h4 span').hover(function() {
    if ($(this).parent().next('img').is(':visible')) {
    return false;
    }
    $('ul#product-info-list img').css('display', 'none');
    $(this).parent().next('img').css('display', 'block');
    return false;
    }); -- */

    //    $("ul#product-info-list h4 span").hover(
    //      function() {
    //          if ($(this).parent().next('img').is(':visible')) {
    //              return false;
    //          }
    //          $('ul#product-info-list img').css('display', 'none');
    //          $('h4.active').removeClass('active');
    //          $(this).parent().next('img').css('display', 'block');
    //          return false;
    //      },
    //      function() {
    //          return;
    //      }
    //    );


});