
var mouseover = "00";
var overlay=false;
var zindex = 100;
var mousestop = false;
$().ready(function() {
	$("#overlay").css("opacity", "0");
	$(".product-info").css("opacity", "0");
	$(".product").css("opacity", "0");
	$(".product").css("display", "block");
});

function fadeInProduct(id) {
	mouseover = id;
	overlay = true;
	$("#overlay").stop();
	$("#product" + id).stop();
	$("#product-info-" + id).stop();
	setTimeout("fadeInProductNow('" + id + "')", 700);
}

function fadeInProductNow(id) {
	if (mouseover == id) {
		$("#content").css("z-index", "11");
		$("#product-info-" + id).css("display", "block");
		$("#product-info-" + id).css("z-index", zindex++);
		$("#product" + id)
			.stop()
			.animate({
					opacity: 1.0
				},
				1200
			);
		$("#product-info-" + id)
			.stop()
			.animate({
					opacity: 1.0
				},
				1200
			);
		fadeInBackground();
	}
}

function fadeOutProduct(id)
{
	mouseover="00";
	overlay=false;
	setTimeout('fadeOutProductNow("' + id + '")', 50);
}

function fadeOutProductNow(id) {

	if( mouseover != id ){
		$("#product-info-"+id)
		.stop()
		.animate({
			opacity: 0.0
		},
		800
	);
	$("#product"+id)
	.stop()
	.animate(
		{
			opacity: 0.0
		},
		800,
		function()
		{
			$("#product-info-"+id).css("display", "none");
		}
	);
	if (!overlay) {
		fadeOutBackground();
	}
	}
}

function fadeInBackground() {
	overlay=true;
	$("#overlay")
	.stop()
	.animate({
		opacity: 0.5
	},
	500
);
$("#overlay")
.css("display","block");

}

function fadeOutBackground() {
	$("#overlay")
	.stop()
	.animate({ opacity: 0 }, 500, function() {
		$("#overlay")
		.css("display", "none");
		zindex = 11;
		$("#footer").css("z-index", "11");
		$("#content").css("z-index", "1");
	}
);
}

function toProduct(id)
{
	window.location = $("#product-link-"+id).attr("href");
}

