jQuery(document).ready(function($){
		
    $("#tooltip").hide(); 
    
    $(".product_grid_item").mousemove(function(e){
    	
    	// hide any other
        //$(this).parents(".product_grid_display").children(".product_hover_popup").hide();        
        
       windowHeight = $(window).height();
       popupHeight = $(this).children(".product_hover_popup").height();
        
       //alert(windowHeight); 
       
       // jQuery.support.cssFloat == false in IE
       
       if( jQuery.support.cssFloat ){
       
       		// non IE website
       
	       if( (e.clientY + popupHeight) < windowHeight ){
		       
		       
		      // $(this).children(".product_hover_popup").show();
		       
		       $(this).children(".product_hover_popup").css({
		            top: (e.clientY + 5) + "px",
		            bottom: "",
		            left: (e.clientX + 10) + "px"
		       });
		   }
		   else{
		   
		   	   $(this).children(".product_hover_popup").css({
		   	   		top: "",
		            bottom: 0,
		            left: (e.clientX + 10) + "px"
		       });
		   
		   }       
       
       
       }
       else{
       
       	   // IE website
       	
	       if( (e.clientY + popupHeight) < windowHeight ){
		       
		       
		      // $(this).children(".product_hover_popup").show();
		       
		       $(this).children(".product_hover_popup").css({
		            top: (e.pageY + 5) + "px",
		            bottom: "",
		            left: (e.pageX + 10) + "px"
		       });
		   }
		   else{
		   
		   	   $(this).children(".product_hover_popup").css({
		   	   		top: "",
		            bottom: 0,
		            left: (e.pageX + 10) + "px"
		       });
		   
		   }      
       
       }
        

        
    });
    
    $(".product_grid_item").mouseover(function(e){
   	 $(".product_hover_popup").hide();
    	$(this).children(".product_hover_popup").show();
    });
    
    
    $(".product_grid_item").mouseout(function(e){
        $(".product_hover_popup").hide();
    });

	
	
	// add superfish to side menus
    $('ul.PeCategories').superfish({
    	delay: 700,
    	speed: 800,
    	animation: {opacity: 'show'},
    	autoArrows: false,
    	dropShadows: false
    	
    }); 
     
	// mark menu items with a submenu - superfish is not working...
	$('ul.PeCategories li').each(function(){
		if( $(this).children('ul.SubCategories').length > 0 ){
			
			$(this).addClass('has-sub');
		}
	});
	

    $('ul.side-links').superfish({
    	delay: 300,
    	speed: 300,
    	animation: {opacity: 'show'},
    	autoArrows: false,
    	dropShadows: false
    	
    }); 
     
	// mark menu items with a submenu - superfish is not working...
	$('ul.side-links li').each(function(){
		if( $(this).children('ul').length > 0 ){
			
			$(this).addClass('has-sub');
		}
	});






	// handle calendar menu

	$(".cal-holder").removeClass("visible");
	$("#all-cals").addClass("visible");
	$("#all-cals-tab").addClass("selected");
	
	// remove no js anchor tags
	$(".no-js-anchor").removeAttr("name");
	$(".cal-nav-tab").attr("onclick", "return false;");


	$(".cal-nav-tab").click(function(){
		
		// hide all visible cals, unmark all tabs
		$(".cal-holder").removeClass("visible");
		$(".cal-nav-tab").removeClass("selected");
		
		// get clicked tab id
		var calToShow = $(this).attr("rel");
		
		$(this).addClass("selected");
		
		$(calToShow).addClass("visible");
		
	});
	
	/*
	
		Was used to keep cart at top of screen, switched to fixed css
		
	jQuery(window).scroll(function()
	{
 		 jQuery('#top-bar').animate({top:jQuery(window).scrollTop()+"px" },{queue: false, duration: 200});
 		 
	});	
	*/
});


