/*
 * SimpleModal Contact Form
 * http://www.ericmmartin.com/projects/simplemodal/
 * http://code.google.com/p/simplemodal/
 *
 * Copyright (c) 2007 Eric Martin - http://ericmmartin.com
 *
 * Licensed under the MIT license:
 *   http://www.opensource.org/licenses/mit-license.php
 *
 * Revision: $Id: contact.js 39 2007-10-26 20:46:32Z emartin24 $
 *
 */

var panier = {

	updateAndShow: function (dialog) {
					   $('#modalBody').fadeOut(10);
						$('#modalBody').html('Mise à jour du panier ...');
						$('#modalBody').fadeIn(400, function () {
								$.ajax({
									url: '/panier.html',
									data: $('#fichecontenu .tarifs form').serialize(),
									dataType: 'html',
									complete: function (xhr) {
										$('#modalBody').fadeOut(10, function () {
											$('#modalBody').html(xhr.responseText).fadeIn(600);
											panier.show(dialog);
										});
										
									} //complete
								}); //Ajax
						});
	},
	
	show: function (dialog) {
					$('.closeBt').attr('class', 'panierCloseBt modalClose bouton');
					
					$('.qtPlus').click(function (e) {
						e.preventDefault();
						ref = $(this).attr("ref");
						$('#modalBody').fadeOut(10);
						$('#modalBody').html('Mise à jour du panier ...');
						$('#modalBody').fadeIn(400, function () {
								$.ajax({
									url: '/panier.html',
									data: 'action=qtup&ref='+ref,
									dataType: 'html',
									complete: function (xhr) {
										$('#modalBody').fadeOut(10, function () {
											$('#modalBody').html(xhr.responseText).fadeIn(600);
											panier.show(dialog);
										});
										
									} //complete
								}); //Ajax
						});
					}); //click qtPlus
					
					$('.qtMoins').click(function (e) {
						e.preventDefault();
						ref = $(this).attr("ref");
						$('#modalBody').fadeOut(10);
						$('#modalBody').html('Mise à jour du panier ...');
						$('#modalBody').fadeIn(400, function () {
								$.ajax({
									url: '/panier.html',
									data: 'action=qtdown&ref='+ref,
									dataType: 'html',
									complete: function (xhr) {
										$('#modalBody').fadeOut(10, function () {
											$('#modalBody').html(xhr.responseText).fadeIn(600);
											panier.show(dialog);
										});
										
									} //complete
								}); //Ajax
						});
					}); //click qtPlus
					
					$('.qtMaj').click(function (e) {
						e.preventDefault();
						$('#modalBody').fadeOut(10);
						$('#modalBody').html('Mise à jour du panier ...');
						$('#modalBody').fadeIn(400, function () {
								$.ajax({
									url: '/panier.html',
									data: $('.panierForm').serialize(),
									dataType: 'html',
									complete: function (xhr) {
										$('#modalBody').fadeOut(10, function () {
											$('#modalBody').html(xhr.responseText).fadeIn(600);
											panier.show(dialog);
										});
										
									} //complete
								}); //Ajax
						});
					}); //click qtMaj
					
					$('.supprProduit').click(function (e) {
						e.preventDefault();
						ref = $(this).attr("ref");
						$('#modalBody').fadeOut(10);
						$('#modalBody').html('Mise à jour du panier ...');
						$('#modalBody').fadeIn(400, function () {
								$.ajax({
									url: '/panier.html',
									data: 'action=qt&qte=0&ref='+ref,
									dataType: 'html',
									complete: function (xhr) {
										$('#modalBody').fadeOut(10, function () {
											$('#modalBody').html(xhr.responseText).fadeIn(600);
											panier.show(dialog);
										});
										
									} //complete
								}); //Ajax
						});
					});
					
					$('.modalClose').click(function (e) {
						e.preventDefault();
						contact.close(dialog);
					});
	} //show	
}; //panier