var home_timer;
function homeAnimReset() {
	var clViz = $("#home-texts>div:not(.blue):visible").attr("class");
	var animOk = 1;
	$("#home-texts").find("div").each(function() {
		if ($(this).is(":animated")) {
			animOk = 0;
		}
	});
	if (animOk == 1) {
		home_timer = clearTimeout(home_timer);
		$("#home-texts>div."+clViz).children(".inner").animate({opacity:0}, 500, "swing", function() {
			$(this).parent().animate({width:"hide"}, 1000, "swing", function() {
				$("#home-texts>div.blue").animate({width:"show"}, 1000, "swing", function() {
					$("#home-texts>div.blue").children(".inner").animate({opacity:100}, 500, "swing");
				});
			})
		});
	}
	else {
		if (typeof home_timer == "undefined") {
			home_timer = setTimeout(function(){homeAnimReset();}, 3000);
		}
	}
}

$(document).ready(function() {
	$("#home-texts>div.red").hide();
	$("#home-texts>div.green").hide();
	$("#home-texts>div.gold").hide();
	$("#page").mouseleave(
		function() {
			homeAnimReset();
		}
	);

	$("#home-message>li").mousemove(
		function(){
			var cl = $(this).attr("class");
			var clViz = $("#home-texts>div:visible").attr("class");
			var animOk = 1;
			$("#home-texts").find("div").each(function() {
				if ($(this).is(":animated")) {
					animOk = 0;
				}
			});
			if (animOk == 1) {
				if ($("#home-texts>div."+cl).is(":hidden")) {
					$("#home-texts>div."+clViz).children(".inner").animate({opacity:0}, 500, "swing", function() {
						$(this).parent().animate({width:"hide"}, 1000, "swing", function() {
							$("#home-texts>div."+cl+ " .inner").css("opacity", 0);
							$("#home-texts>div."+cl).animate({width:"show"}, 1000, "swing", function() {
								$("#home-texts>div."+cl+" .inner").animate({opacity:100}, 500, "swing");
							});
						});
					});
				}
			}
		}
	);
});

