jQuery.noConflict();

jQuery(document).ready(function(){
  if(jQuery("#slider-dis").length) {
    jQuery("#slider-dis").easySlider({
  		auto: true,
  		continuous: true,
  		pause:6000,
  		numeric: true
  	});
  }
  if(jQuery("#product-image-lightbox").length) {
     jQuery('#product-image-lightbox a[rel=lightbox]').lightBox();
     jQuery('#product-image-lightbox a[rel=lightbox_plus]').lightBox();
  }
  
  if(jQuery("#block-related-slider").length) {
    jQuery("#block-related-slider").easySlider({
  		auto: false,
  		continuous: true,
  		pause:5000
  	});
  }
  /* jQuery(".block-categories li.level0 > a").click(function() {
    obj = jQuery(this);
    active_menu = obj.parent().parent().children(".active");
    
    if (!obj.parent().hasClass("active")) {
      prev_menu = active_menu.children("ul.level0");
      active_menu.removeClass("active");
      jQuery(this).next().slideDown("slow").parent().addClass("active");
      prev_menu.slideUp("slow");
    }
    
    return false;
  }); */
  if(jQuery(".product-tabs").length) {
      //Default Action
      jQuery(".product-tabs-content").hide(); //Hide all content
      jQuery("ul.product-tabs li:first").addClass("active").show(); //Activate first tab
      jQuery(".product-tabs-content:first").show(); //Show first tab content
    
      //On Click Event
      jQuery("ul.product-tabs li").click(function() {
      jQuery("ul.product-tabs li").removeClass("active"); //Remove any "active" class
      jQuery(this).addClass("active"); //Add "active" class to selected tab
      jQuery(".product-tabs-content").hide(); //Hide all tab content
      var activeTab = jQuery(this).find("a").attr("href"); //Find the rel attribute value to identify the active tab + content
     
      jQuery(activeTab).fadeIn(); //Fade in the active content
      return false;
     }); 
  }
  
  if(jQuery("#slider-views-vert").length) {
    jQuery("#slider-views-vert").easySlider({
  		auto: false,
  		continuous: true,
  		pause:5000,
  		vertical:true,
      nextId: "slider1next",
		  prevId: "slider1prev"

  	});
  }
  
  if(jQuery("#slider-views-horiz").length) {
    jQuery("#slider-views-horiz").easySlider({
  		auto: false,
  		continuous: true,
  		pause:5000,
      nextId: "slider1next",
		  prevId: "slider1prev"

  	});
  }
  if(jQuery('#nav').length) {
   ulWidth = parseInt(jQuery('#nav').css('width'));
   availableTab = new Array();
   /* Parse each LI element from the menu */
   for(i = 1; i < 100; ++i) {
      if(!jQuery('#nav .nav-'+i).length) break;
      ulWidth = ulWidth-parseInt(jQuery('#nav .nav-'+i).css('width'))
      availableTab['nav0-'+i] = ulWidth;
   }
   /* availableTab is an array containing the width left to the right of the page for each element */
   jQuery('#nav li.level0').each(function() {
    jQuery(this).mouseover(function() {
      /* IE CSS Fix */
      jQuery(this).css({'background':"#000081", 'z-index':"999" });
      jQuery(this).find('a.level-top').css({'color':"#578ABD"});
      /* IE CSS Fix */
      idB = jQuery(this).attr('id');
      available = availableTab[idB];
      obk = jQuery(this).find('ul.level0');
      if(parseInt(obk.css('width'))) {
       /* if the width of the block is bigger than the width left, we display the block on the left */
       if(parseInt(obk.css('width')) > available) {
         obk.addClass('right-s0');
         fsize = -parseInt(obk.css('width'))+parseInt(jQuery(this).css('width'))-12;
        }
        else {
         fsize = 0; 
        }
        obk.css({left:fsize});
      }
    }).mouseleave(function() { 
      /* IE CSS Fix */
      jQuery(this).find('a.level-top').css({'color':"#3D3D3D"}); 
      jQuery(this).css({ 'background':"none", 'z-index':"0" }); 
      /* IE CSS Fix */
      jQuery(this).find('ul.level0').css({left:"-10000px"}); }); 
      
  }); 
    
  }


  /*jQuery.fn.reviewSave = function() {
    var error = 0;
    jQuery(".feedback-checkout input:checked").each(function() { 
      if(jQuery(this).val() == 'undefined') error = 1;
    });
    if(error)
      alert('Please answer the feedback questions before placing your order');
    else
      review.save();
  }
  */
});
