$(function()
{
	$('#indexFeatures .cycle').cycle(
	{
		fx:      'scrollHorz',
		speed:   750, 
		timeout: 4500,
		pause:   1, 
		pager:   '#indexFeatures .pagination .numberSet', 
		next:    '#indexFeatures .pagination .next', 
		prev:    '#indexFeatures .pagination .prev', 
		sync: true, 
		
		pagerAnchorBuilder: function(idx, slide)
		{ 
    	return '\
			<a class="number" href="#">\
				<img class="image" src="images/blank.gif" alt="" />\
			</a>';
    } 
	});
	
	$('#indexFeaturedProducts .cycle').cycle(
	{
		fx:      'scrollHorz',
		speed:   500, 
		timeout: 0,
		pause:   1, 
		next:    '#indexFeaturedProducts .pagination .next', 
		prev:    '#indexFeaturedProducts .pagination .prev', 
		sync: true
	});
});

$(document).ready(function(){
	// HOME ---------------------------------
	$("div.homeNews ul").css({
		height :	"25px",
		overflow :	"hidden",
		position : "relative",
		top : " 0",
		left : "0px"
	});
	$("div.homeNews ul li").css({
		position	:	"absolute",
		top	:	"0px",
		display	:	"none"
	});
	$("div.homeNews ul li:first").addClass("first active").css({"display":"block"});
	$("div.homeNews ul li:last").addClass("last");
	
	var homeNewsPause = 3000;
	var homeNewsTimer;
	var homeNewsSpeed = 800;
	var homeNewsActive, homeNewsNext;
	
	homeNewsTimer = setInterval(function() {
		if ($("div.homeNews ul li:animated").length == 0) {
			
			homeNewsActive = $("div.homeNews ul li.active");
			if (homeNewsActive.hasClass("last")) {
				homeNewsNext = $("div.homeNews ul li:first");
			} else {
				homeNewsNext = homeNewsActive.next();
			}
			
			homeNewsActive.animate({
				top: "-25px",
				opacity : 0
			},homeNewsSpeed,function(){ homeNewsActive.removeClass("active")} );
			homeNewsNext.css({"display":"block","top":"25px",opacity:0}).animate({
				top: "0px",
				opacity : 1
			},homeNewsSpeed,function(){ homeNewsNext.addClass("active")} );
			
		}
	},homeNewsPause);
	
	$("div.homeNews ul li").hover(function(){
		clearInterval(homeNewsTimer);	
	},function(){
		homeNewsTimer = setInterval(function() {
			if ($("div.homeNews ul li:animated").length == 0) {
				
				homeNewsActive = $("div.homeNews ul li.active");
				if (homeNewsActive.hasClass("last")) {
					homeNewsNext = $("div.homeNews ul li:first");
				} else {
					homeNewsNext = homeNewsActive.next();
				}
				
				homeNewsActive.animate({
					top: "-25px",
					opacity : 0
				},homeNewsSpeed,function(){ homeNewsActive.removeClass("active")} );
				homeNewsNext.css({"display":"block","top":"25px",opacity:0}).animate({
					top: "0px",
					opacity : 1
				},homeNewsSpeed,function(){ homeNewsNext.addClass("active")} );
				
			}
		},homeNewsPause);
	});

});	
