//Javascript Document

$("document").ready(function(){
	
	$(".featured_prev").click(function(event){
		event.preventDefault();
		
		if (cs == 0) { cs = csmax;	}
			else { cs--; }
		var myimg = new Image();
		myimg.src = products[cs][2];
		setTimeout("loadslide()", 800);
	});
	
	$(".featured_next").click(function(event){
		event.preventDefault();		
		if (cs == csmax) { cs = 0;	}
			else { cs++; }
		var myimg = new Image();
		myimg.src = products[cs][2];
		setTimeout("loadslide()", 800);
	});
	
	$(".feature_box").hover(function(){
		clearInterval(auto);								 
	},function(){
		auto = setInterval("autoslide()", 5500);								 
	});
	
	loadslide();
	var auto = setInterval("autoslide()", 5500);
});

function autoslide() {
	if (cs == csmax) { cs = 0;	}
	else { cs++; }
	var myimg = new Image();
	myimg.src = products[cs][2];
	setTimeout("loadslide()", 800);
}

function loadslide() {
		$(".product_image img").fadeOut(500);
		$(".feature_box h3").fadeOut(500);
		$(".feature_box p").fadeOut(500,function(){
			$(".feature_box h3").attr("innerHTML", products[cs][0]);
			$(".feature_box p").attr("innerHTML", products[cs][1]);
			$(".product_image img").attr("src", products[cs][2]);
		});
		$(".product_image img").fadeIn(500);
		$(".feature_box h3").fadeIn(500);
		$(".feature_box p").fadeIn(500);	
}

