$(function() {
	Cufon.replace('h1, h2, h3, .button, button, #cart-info2, #nav, #categories, .box h3, #footer-menu, .copyright, #cart p, #login label, .login-links, .sort, #paginator', {hover: true});

	// reverse items order because of the float-right property
	$.fn.reverseOrder = function() {
		return this.each(function() {
			$(this).prependTo( $(this).parent() );
		});
	};

	$('#paginator *').reverseOrder();

	// fade toggle
	jQuery.fn.fadeToggle = function(speed, easing, callback) {
	   return this.animate({opacity: 'toggle'}, speed, easing, callback);
	};
	// height toggle
	jQuery.fn.heightToggle = function(speed, easing, callback) {
	   return this.animate({height: 'toggle'}, "slow", easing, callback);
	};

	// cart box
	$("#cart").hide();
	$("#cart-button").click(function() {
		$("#login").fadeOut();
		$("#cart").heightToggle();
	});

	// login box
	$("#login").hide();
	$("#login-button").click(function() {
		$("#cart").fadeOut();
		$("#login").heightToggle();
	});

	$("#footer-menu a:last-child").css("background", "none");

	// header slideshow
	$('#slideshow').cycle({
		fx:     'fade',
		speed:  2000,
		timeout: 5000,
		random: 1,
	});

	// featured  products
	$('#rotator').cycle({
		fx:     'fade',
		timeout: 0,
		pause: 1,
		prev: '#prev',
		next: '#next',
	});
	
	$(".content:empty").remove();
});

sfHover = function() {
	var sfEls = document.getElementById("categories").getElementsByTagName("LI");
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			this.className+=" sfhover";
		}
		sfEls[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
		}
	}
}
if (window.attachEvent) window.attachEvent("onload", sfHover);
