/*
 * 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(function ($) {
	$('#confirm-dialog input.confirm, #confirm-dialog a.confirm, a.confirm').click(function (e) {
		e.preventDefault();
		//alert('lien clique !');
		// example of calling the confirm function
		// you must use a callback function to perform the "yes" action
		confirm("#confirm"+$(this).attr("alt"), "", function () {
			window.location.href = 'http://www.ericmmartin.com/projects/simplemodal/';
		}, 'confirm-container', "10%");
	});
});

jQuery(function ($) {
	$('#confirm-dialog input.confirm-large, #confirm-dialog a.confirm-large').click(function (e) {
		e.preventDefault();
		//alert('lien clique !');
		// example of calling the confirm function
		// you must use a callback function to perform the "yes" action
		confirm("#confirm"+$(this).attr("alt"), "", function () {
			window.location.href = 'http://www.ericmmartin.com/projects/simplemodal/';
		}, 'confirm-container-large', "10%");
	});
});

jQuery(function ($) {
	$('#confirm-dialog input.confirm-medium, #confirm-dialog a.confirm-medium').click(function (e) {
		e.preventDefault();
		//alert('lien clique !');
		// example of calling the confirm function
		// you must use a callback function to perform the "yes" action
		confirm("#confirm"+$(this).attr("alt"), "", function () {
			window.location.href = 'http://www.ericmmartin.com/projects/simplemodal/';
		}, 'confirm-container-medium', "10%");
	});
});

function confirm(cible, message, callback, container, yTop) {
	$(cible).modal({
		closeHTML: "<a href='#' title='Fermer' class='modal-close'>Fermer</a>",
		position: [yTop,],
		overlayId: 'confirm-overlay',
		containerId: container, 
		onShow: function (dialog) {
			$('.message', dialog.data[0]).append(message);

			// if the user clicks "yes"
			$('.yes', dialog.data[0]).click(function () {
				// call the callback
				if ($.isFunction(callback)) {
					callback.apply();
				}
				// close the dialog
				$.modal.close();
			});
		}
	});
}
