/**
 * main.js
 *
 * @author Paul Horton <phorton@doc-net.com>
 * @copyright Doctor Net Limited &copy; 2008
 * @package WebSite.WebSite
 */

/**
 * Document onready
 *
 */
$(document).ready(function() {
   if($('#TB_window').size() == 0) {
      if ($('#productMenuLoadingContainer').size() > 0) {
         $('#mainLayoutLeftColumn').append($('#productMenuLoadingContainer').html());
      }

      $('#productMenuContainer A').click(function() {
         var int_id = parseInt($(this).attr('id').slice(20));
         if (int_id > 0) {
            if ($('DL.productCategoryVisible:visible').length > 0) {
               // Hide any others open first
               $('DL.productCategoryVisible:visible').slideUp("normal", show_product_menu(int_id));
            } else {
               show_product_menu(int_id)
            }
         }
      });

      $('A.moneyBackGuarantee').hover(function(e) {
         // Over
         $("body").append('<div id="moneyBackGuaranteeTT" style="width: 375px"><div id="moneyBackGuaranteeTTArrowRight" style="left: 376px"></div><div id="moneyBackGuaranteeTTCloseRight">14 Day Money back guarantee</div><div id="moneyBackGuaranteeTTContent"></div></div>');
         $('#moneyBackGuaranteeTTContent').html($('#moneyBackGuaranteeContent').html());
         var offset = $(this).offset();
         var intXPos = offset.left - 375 - 11;
         var intYPos = offset.top;
         $('#moneyBackGuaranteeTT').css({left: intXPos + "px", top: intYPos + "px"});
         $(this).css('cursor','pointer');
         //$('#moneyBackGuaranteeContent').show();
      }, function() {
         // Out
         $('#moneyBackGuaranteeTT').remove();
      });
      
      $('DIV.freeDeliveryProduct').hover(function(e) {         
         // Over
         $("body").append('<div id="freeDeliveryProductTT" style="width: 375px"><div id="freeDeliveryProductTTArrowRight" style="left: 376px"></div><div id="freeDeliveryProductTTCloseRight">Free Delivery on this item</div><div id="freeDeliveryProductTTContent"></div></div>');
         $('#freeDeliveryProductTTContent').html($('#freeDeliveryProductContent').html());
         var offset = $(this).offset();
         var intXPos = offset.left - 375 - 11;
         var intYPos = offset.top;
         $('#freeDeliveryProductTT').css({left: intXPos + "px", top: intYPos + "px"});
         $(this).css('cursor','pointer');
         //$('#freeDeliveryProductContent').show();
      }, function() {
         // Out
         $('#freeDeliveryProductTT').remove();
      });
      
      $('DIV.freeDeliveryBasket').hover(function(e) {         
         // Over
         $("body").append('<div id="freeDeliveryBasketTT" style="width: 375px"><div id="freeDeliveryBasketTTArrowRight" style="left: 376px"></div><div id="freeDeliveryBasketTTCloseRight">Delivery Charges</div><div id="freeDeliveryBasketTTContent"></div></div>');
         $('#freeDeliveryBasketTTContent').html($('#freeDeliveryBasketContent').html());
         var offset = $(this).offset();
         var intXPos = offset.left - 375 - 11;
         var intYPos = offset.top;
         $('#freeDeliveryBasketTT').css({left: intXPos + "px", top: intYPos + "px"});
         $(this).css('cursor','pointer');
         //$('#freeDeliveryBasketContent').show();
      }, function() {
         // Out
         $('#freeDeliveryBasketTT').remove();
      });      
      
      
   }
});

/**
 * Show a product menu (animated)
 *
 */
function show_product_menu(int_menu_id) {
   $('#productCategory_' + int_menu_id + ':hidden').slideDown("normal");
   $('#productCategory_' + int_menu_id).addClass('productCategoryVisible');
}
