
	$(function() {
			   
		// * Facebox
		$('a[rel*=modal]').facebox();
		
		// * Menu
        function megaHoverOver(){
            $(this).find(".sub").stop().fadeTo('fast', 1).show();
        }
        function megaHoverOut(){ 
          $(this).find(".sub").stop().fadeTo('fast', 0, function() {
              $(this).hide(); 
          });
        }
        var config = {    
             sensitivity: 2, // number = sensitivity threshold (must be 1 or higher)    
             interval: 100, // number = milliseconds for onMouseOver polling interval    
             timeout: 500, // number = milliseconds delay before onMouseOut 
             over: megaHoverOver, // function = onMouseOver callback (REQUIRED)    
             out: megaHoverOut // function = onMouseOut callback (REQUIRED)    
        };
    
        $("ul#nav li .sub").css({'opacity':'0'});
		$("ul#nav li .sub ul:last-child").css("margin-right","0");
        $("ul#nav li").hoverIntent(config);
		
		// * Banner
		$('#slider').nivoSlider({
			directionNav: false
		});
		
		// * Preview de produto
		imagePreview = function(){	
			xOffset = 80;
			yOffset = 80;
		
			$("a.preview").hover(function(e){
				this.t = this.title;
				this.title = "";	
				var c = (this.t != "") ? "<br/>" + this.t : "";
				$("body").append("<p id='preview'><img src='"+ this.rel +"' alt='Image preview' />"+ c +"</p>");								 
				$("#preview")
					.css("top","-" + (e.pageY - xOffset) + "px")
					.css("left",(e.pageX + yOffset) + "px")
					.fadeIn("fast");						
				},
				function(){
					this.title = this.t;	
					$("#preview").remove();
				});	
				$("a.preview").mousemove(function(e){
					$("#preview")
						.css("top",(e.pageY - xOffset) + "px")
						.css("left",(e.pageX + yOffset) + "px");
				});			
		};
		imagePreview();
		
	});
