/*
 * SimpleModal Confirm Modal Dialog
 * http://www.ericmmartin.com/projects/simplemodal/
 * http://code.google.com/p/simplemodal/
 *
 * Copyright (c) 2010 Eric Martin - http://ericmmartin.com
 *
 * Licensed under the MIT license:
 *   http://www.opensource.org/licenses/mit-license.php
 *
 * Revision: $Id: confirm.js 238 2010-03-11 05:56:57Z emartin24 $
 *
 */
jQuery.noConflict();
jQuery(function (jQuery) {
	jQuery('#confirm-dialog input.confirm, #confirm-dialog a.confirm').click(function (e) {
		e.preventDefault();

		// example of calling the confirm function
		// you must use a callback function to perform the "yes" action
		confirm("Vous devez vous identifier pour accèder à cette fonction. Utilisez le lien \"Se connecter\" en haut du site ou inscrivez-vous gratuitement en <a href=\"inscription.php\">cliquant ici</a>.", function () {
			window.location.href = 'inscription.php';
		});
	});
	
	jQuery('#confirm-dialog2 input.confirm2, #confirm-dialog2 a.confirm2').click(function (e) {
		e.preventDefault();

		// example of calling the confirm function
		// you must use a callback function to perform the "yes" action
		confirm("Vous ne pouvez aller qu'à 5 soirées maximum pour une même date.", function () {
			window.location.href = '';
		});
	});
	
	jQuery('#confirm-dialog3 input.confirm3, #confirm-dialog3 a.confirm3').click(function (e) {
		e.preventDefault();

		// example of calling the confirm function
		// you must use a callback function to perform the "yes" action
		confirm("Attention, voulez-vous vraiment vous désinscrire du site?", function () {
			document.form_monpassword.submit();
		});
	});
	
	jQuery('#confirm-dialog4 input.confirm4, #confirm-dialog4 a.confirm4').click(function (e) {
		e.preventDefault();

		// example of calling the confirm function
		// you must use a callback function to perform the "yes" action
		confirm("Vous ne pouvez plus voter. Vous avez le droit à 5 votes par semaine.", function () {
			window.location.href = '';
		});
	});
	
	jQuery('#confirm-dialog5 input.confirm5, #confirm-dialog5 a.confirm5').click(function (e) {
		e.preventDefault();

		// example of calling the confirm function
		// you must use a callback function to perform the "yes" action
		confirm("Vous ne pouvez plus ajouter de lieu de sortie à vos favoris. Vous avez le droit à 5 lieus de sorties favoris maximum. Vous pouvez les gérer dans la partie Mon compte > Mes lieus de sorties favoris .", function () {
			window.location.href = '';
		});
	});
});

function confirm(message, callback) {
	jQuery('#confirm').modal({
		closeHTML: "<a href='#' title='Close' class='modal-close'>x</a>",
		position: ["20%",],
		overlayId: 'confirm-overlay',
		containerId: 'confirm-container', 
		onShow: function (dialog) {
			jQuery('.message', dialog.data[0]).append(message);

			// if the user clicks "yes"
			jQuery('.yes', dialog.data[0]).click(function () {
				// call the callback
				if (jQuery.isFunction(callback)) {
					callback.apply();
				}
				// close the dialog
				jQuery.modal.close();
			});
		}
	});
}
