/*
 * SimpleModal Confirm Modal Dialog
 * http://www.ericmmartin.com/projects/simplemodal/
 * http://code.google.com/p/simplemodal/
 *
 * Copyright (c) 2009 Eric Martin - http://ericmmartin.com
 *
 * Licensed under the MIT license:
 *   http://www.opensource.org/licenses/mit-license.php
 *
 * Revision: $Id: confirm.js 212 2009-09-03 05:33:44Z emartin24 $
 *
 */

jQuery(document).ready(function () {
	jQuery('#confirm-dialog input.confirm, #confirm-dialog a.confirm').click(function (e) {
		e.preventDefault();
		var id = this.id.replace('deleteId_', "");
		var id_orderNumber = id.split("_");
		confirm("Vil du slette den gemte ordre "+id_orderNumber[1]+"?", function () {
			window.location.href = './?action=deleteOrder&orderId='+id_orderNumber[0];
		});
	});
});

function confirm(message, callback) {
	jQuery('#confirm').modal({
		closeHTML:"<a href='#' title='Luk' 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();
			});
		}
	});
}