$(document).ready(function() {
	$("a.design").live("click", function(){	return true; });
	$("a.content").live("click", function() {
		$("#content")
		.hide()
		.load(this.href+"&js=ok", function(){
			$(function() {
				   $('.miniatures img').animate({"opacity": .3 });
				   $('.miniatures img').hover(function() {
				   	$(this).stop().animate({ "opacity": 1 });
					}, function() {
						$(this).stop().animate({ "opacity": .3 });
				   });
			});
		})
		.slideDown(500);
		$('#nav > li > ul').hide();
		return false;
	});
	$(".flipBT").live("click", function(){
				$(".grande_image span").empty();
				var chemin = $(this).find(".chemin").attr("alt");
				var description = $(this).attr("title");

				$("#flipBox").flip({
					direction: 'bt',
					color: 'transparent',
					speed: 300,
					content: $('.grande_image img').attr({ src: chemin })
				});

				$('.grande_image span').html("" + description + "");
				return false;
			});
	$(".quantite").live("change", function()
	{
		$("#prix_total_"+this.name).html(Math.round((this.value * $("#prix_unite_"+this.name).html())*100) / 100);
		$("#tva_"+this.name).html(Math.round(((this.value * $("#prix_unite_"+this.name).html()) * (21/100))*100) / 100);
		$("#prix_tva_"+this.name).html(Math.round(( (this.value * $("#prix_unite_"+this.name).html()) * (121/100) )*100)/100);
		$("#st_htva").html('0');
		$("#st_tva").html('0');
		$("#st_ttc").html('0');
		$(".quantite").each(function() {
			$("#st_htva").html(Math.ceil((parseFloat($("#st_htva").html()) + parseFloat($("#prix_total_"+this.name).html()))*100) / 100);
			$("#st_tva").html(Math.ceil((parseFloat($("#st_tva").html()) + parseFloat($("#tva_"+this.name).html()))*100) / 100);
			$("#st_ttc").html(Math.ceil((parseFloat($("#st_ttc").html()) + parseFloat($("#prix_tva_"+this.name).html()))*100) / 100);
		});

	});
	$(".onchange").live("click", function()
	{
		if (this.value == "livraison")
		{
			$("#total_ttc").html(Math.round((parseFloat($("#st_ttc").html()) + parseFloat($("#frais_ttc").html()))*100) / 100);
		}
		else
		{
			$("#total_ttc").html(Math.round((parseFloat($("#st_ttc").html()) + parseFloat($("#distance_ttc").html()))*100) / 100);
		}
	});
	visites();
	setInterval('visites();', (30 * 1000));
	$("#top_menu").show();
	$("#bottom_menu").hide();
	$('#verif').live("submit", function() {
		alert("Merci pour votre achat !");
	});
});

function visites() {
	$("#visites")
	.hide()
	.load('visites.php')
	.show('fast');
}

function fortune() {
	$("#fortune").hide().load("index.php?aff=fortune&js=ok").fadeIn(1000);
	setTimeout('fortune()', 20000);
}

