$(document).ready(function($){
	
	$('.underMenu').each(function(){
		var t = $(this);
		var t_w = t.width();
		var nav_height = $('#topNav').height();
		var p_width = t.closest('li').width();
		t.css({
			'top':nav_height,
			'left':-(t_w-p_width)/2
		});
	});
	
	$('#topNav li').hover(function(){
		$(this).find('.underMenu').fadeIn();
	},function(){
		$(this).find('.underMenu').fadeOut();
	});
	
	$('.rightArrow,.leftArrow').each(function(){
		parent_h = $(this).parent().height();
		$(this).css({'top':parent_h/2-18});
	});
	
	$('#productsList a.img,.cartProducts img').hover(function(){
	   t = $(this);
	   t_w = t.width();
	   t_l = t.offset().left;
	   t.parent().find('.productAbout').show();
	   
		 t.mousemove(function(e){
		 	body_w = $('body').width();
	   	about_w = t.parent().find('.productAbout').width();
	   	about_h = t.parent().find('.productAbout').height();	  
		 	curr_x = e.pageX-about_w-20;
	   	curr_y = e.pageY-about_h/2;

	   	if (t_l<about_w) {
			   	t.parent().find('.productAbout .rightArrow').empty().hide();
	   		  t.parent().find('.productAbout .leftArrow').show();
			   	t.parent().find('.productAbout').css({left:e.pageX+60,top:curr_y});	   		
		   } else if (body_w-(t_l+t_w)<about_w) {
	   		 t.parent().find('.productAbout .leftArrow').empty().hide();
	   		 t.parent().find('.productAbout .rightArrow').show();	   		 
	 			 t.parent().find('.productAbout').css({left:curr_x,top:curr_y}); 		   	
 			} else{ 
	   		 t.parent().find('.productAbout .leftArrow').empty().hide();
	   		 t.parent().find('.productAbout .rightArrow').show();	   		 
	 			 t.parent().find('.productAbout').css({left:curr_x,top:curr_y}); 		  	
 			}
		});
	},function(){
	   t.parent().find('.productAbout').hide('fast');
	});
	
 	body_w = $('body').width();	
	$('#basketBar').css({'width':body_w-59});
	

});