jQuery(document).ready(function($) {
	
	/* recadrage horizontal */
	function resizeImg() {	
		var ratio = $(window).width()/$("#fond-boutique").width();
		$("#fond-boutique, #store-container, img.affiche, #tir-aux-cochons")
			.width( function(index,width) { return width*ratio; })
			.height( function(index,height) { return height*ratio; });
		$("#store-container, img.affiche, #tir-aux-cochons").css({
			"top": function(index,top) {return parseFloat(top)*ratio;} ,
			"left": function(index,left) {return parseFloat(left)*ratio;} }
		);
	}

	resizeImg();

	$(window).resize( function() {resizeImg();} );
	
	/* ouverture du store */
	$("#store-tirette").click( function() {
		$("#fond-sonore").jPlayer("play");
		if ( parseFloat($("#store").css('top'))<0 ) {
			$('#store').animate({top: 0 }, 4320, function() {$(".store-cadre").toggle();});
			$(this).toggleClass('enbas').toggleClass('enhaut');
		}
		else {
			$(".store-cadre").toggle();
			var hauteurStore = $("#store").height() * (-0.9);
			$('#store').animate({top: hauteurStore }, 4320);
			$(this).toggleClass('enbas').toggleClass('enhaut');
		}
	});

	/* ouverture des liens dans colorbox */
	$(".popup2").colorbox({'iframe':true, 'width':'80%','height':'90%','href':this.href});
	$(".popup").colorbox({'iframe':true, 'width':'100%','height':'100%','href':this.href});
	
	/* musique de fond */
	$("#fond-sonore").jPlayer({
		ready: function() {this.element.jPlayer("setFile","http://d-zi-d.com/wp-content/themes/dzid/mp3/store.mp3")},
		preload: 'auto',
		swfPath: "http://d-zi-d.com/wp-content/themes/dzid/js/jPlayer",
		nativeSupport: true,
		oggSupport: false
	});
	
});
