var alertTimerId = 0;
var featureNum = 2;

$(document).ready(function(){
	$("#navigation a").hover(function(){
		$("ul.sub").hide();
		$("ul."+$(this).get(0).name).show();
	},function(){
		// go get some pizza ;)
	});

	$("table.select-feature a").hover(function(){
		$("div.feature").fadeOut();
		$("div."+$(this).get(0).name).fadeIn();

		$("table.select-feature td").removeClass("current");
		$(this).parents("td:first").addClass("current");
	},function(){
		// go get some pizza ;)
	});

	var needTimer = $("#features").size();
	
	if(needTimer > 0) {
		alertTimerId = setTimeout("nextFeature.show(featureNum)", 7000);

		$("#features").hover( function() {
			clearTimeout ( alertTimerId );
		},function(){
			alertTimerId = setTimeout("nextFeature.show(featureNum)", 7000);
		});

		$("table.select-feature").hover( function() {
			clearTimeout ( alertTimerId );
		},function(){
			alertTimerId = setTimeout("nextFeature.show(featureNum)", 7000);
		});
	}
	
});

nextFeature = {
	show : function(number) {
		$("div.feature").fadeOut();
		$("div.feature-"+number).fadeIn();

		$("table.select-feature td").removeClass("current");
		$("table.select-feature td:eq("+(number-1)+")").addClass("current");


		if(featureNum < 4)
			featureNum++;
		else
			featureNum = 1;

		alertTimerId = setTimeout("nextFeature.show(featureNum)", 7000);
	}
}