Cufon.replace('h3, .category-head h2, .page-head h3, .page-head-alt h3, .postTitle h2, .base-mini .head h4, .title',
			  {  hover: true});



var $j = jQuery.noConflict();
// execute your scripts when the DOM is ready. this is a good habit 
$j(function() { 

	
	$j(".catalog-menu .content li").click(function(){
		 window.location=$j(this).find("a").attr("href");
		 return false;
	});
	
	// LOGIN
	$j(".miniloginbox").hide(); 
	$j(".btn_login").click(function(){
	  $j(".miniloginbox").slideToggle("slow");
	  $j(this).toggleClass("active");
	});

	$j("#checkout-overlay").hide(); 
	$j(".checkout-btn").click(function(){
	  $j("#checkout-overlay").fadeIn("slow");	  
	});
	$j("#checkout-popup").append("<span class='checkoutClose'></span>");
	$j(".checkoutClose").click(function(){
	  $j("#checkout-overlay").fadeOut("fast");	  
	});
	// enable tooltip for "download" element. use the "slide" effect 
    // $j(".rating-box").tooltip('#demotip';{ effect: 'slide'}); 
	
	// $j("#social-box img[title]").tooltip('#demotip'); 
		
	// initialize tooltip 
	
   

	$j(".slider-product").hover(function(){
		$j(".slider-product .zoom").fadeTo("fast", 1.0); // This should set the opacity to 100% on hover
			},function(){
		$j(".slider-product .zoom").fadeTo("fast", 0); // This should set the opacity back to 30% on mouseout
	});

		$j(".cms-home .middle").hide(); 
		$j(".cms-home .middle").fadeIn(4000);
	
	/* carrello dropdown */
	$j(".carrello_dropdown").hide(); 

	//Switch the "Open" and "Close" state per click
	$j(".btn_apricarrello").toggle(function(){
		$j(this).addClass("active");
		}, function () {
		$j(this).removeClass("active");
	});

	//Slide up and down on click
	$j(".btn_apricarrello").click(function(){
		$j(".carrello_dropdown").slideToggle("slow");
	});
	
	
	
	
	$j("li.control label:last").click(function(e){
					$j('.onestepcheckout-column-left').scrollTo("#shipp_div" || 0, 1500);
					e.preventDefault();
					});
	
	/* $j(".box_home .boxx").click(function() {
	  window.location = $j(this).find("a").attr("href");
}); */
// sliders
$j("#slider-home").easySlider({
		auto: true,
		continuous: true,
		numeric: true, 
		speed: 800,
		pause: 4000
							  });

$j(".slider-product").easySlider({
		auto: false,
		continuous: false,
		numeric: false
	});



$j(".product-img-box .more-views li a").fadeTo("fast", 0.4); // This sets the opacity of the thumbs to fade down to 30% when the page loads
$j(".product-img-box .more-views li a").hover(function(){
$j(this).fadeTo("fast", 1.0); // This should set the opacity to 100% on hover
},function(){
$j(this).fadeTo("fast", 0.4); // This should set the opacity back to 30% on mouseout
});



  // $j(".listing-type-grid .product-image, .btn_login").fadeTo("slow", 0.6); // This sets the opacity of the thumbs to fade down to 30% when the page loads
 
 $j(".btn_login").hover(function(){
 $j(this).fadeTo("fast", 1.0); // This should set the opacity to 100% on hover
 },function(){
 $j(this).fadeTo("fast", 0.6); // This should set the opacity back to 30% on mouseout
 }); 


$j.fn.center = function () {
    this.css("position","fixes");
    this.css("top", ( $j(window).height() - this.height() ) / 3+$j(window).scrollTop() + "px");
    this.css("left", ( $j(window).width() - this.width() ) / 2+$j(window).scrollLeft() + "px");
    return this;
}
$j("#overlay-loading").center();

$j("#overlay-loading").fadeOut(1500); 
$j(".next-arrow, li.item a, .prev-arrow").click(function() {
   $j("#overlay-loading").fadeIn(1000);
   return true;
});
});

$j(document).ready(function(){
	/* This code is executed after the DOM has been completely loaded */
	
	var totWidth=0;
	var positions = new Array();
	
	$j('#slides .slide').each(function(i){
		
		/* Traverse through all the slides and store their accumulative widths in totWidth */
		
		positions[i]= totWidth;
		totWidth += $j(this).width();
		
		/* The positions array contains each slide's commulutative offset from the left part of the container */
		
		if(!$j(this).width())
		{
			alert("Please, fill in width & height for all your images!");
			return false;
		}
		
	});
	
	$j('#slides').width(totWidth);

	/* Change the cotnainer div's width to the exact width of all the slides combined */

	$j('#menu ul li a').click(function(e,keepScroll){

			/* On a thumbnail click */

			$j('li.menuItem').removeClass('act').addClass('inact');
			$j(this).parent().addClass('act');
			
			var pos = $j(this).parent().prevAll('.menuItem').length;
			
			$j('#slides').stop().animate({marginLeft:-positions[pos]+'px'},450);
			/* Start the sliding animation */
			
			e.preventDefault();
			/* Prevent the default action of the link */
			
			
			// Stopping the auto-advance if an icon has been clicked:
			if(!keepScroll) clearInterval(itvl);
	});
	
	$j('#menu ul li.menuItem:first').addClass('act').siblings().addClass('inact');
	/* On page load, mark the first thumbnail as active */
	
	
	
	/*****
	 *
	 *	Enabling auto-advance.
	 *
	 ****/
	 
	var current=1;
	function autoAdvance()
	{
		if(current==-1) return false;
		
		$j('#menu ul li a').eq(current%$j('#menu ul li a').length).trigger('click',[true]);	// [true] will be passed as the keepScroll parameter of the click function on line 28
		current++;
	}

	// The number of seconds that the slider will auto-advance in:
	
	var changeEvery = 10;

	var itvl = setInterval(function(){autoAdvance()},changeEvery*1000);

	/* End of customizations */
});



