/*
 * 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 185 2009-02-09 21:51:12Z emartin24 $
 *
 */


$(document).ready(function () {
	$('#confirmDialog input.confirm, #confirmDialog select.confirm').change(function (e) {
		e.preventDefault();

		// example of calling the confirm function
		// you must use a callback function to perform the "yes" action
		var lan_var = form0.lan.options[form0.lan.options.selectedIndex].value;
		if(lan_var != 25){
		confirm("Var vill du handla från?", function () {
			window.location.href = '/?p=84&l=1&typ=1&lan='+ lan_var +'';
		}, function () {
			window.location.href = '/?p=84&l=1&lan='+ lan_var +'';
		});
		}
		

	});
});



function confirm(message, callback, nocallback) {
	$('#confirm').modal({
		close:false,
		position: ["20%",],
		overlayId:'confirmModalOverlay',
		containerId:'confirmModalContainer', 
		onShow: function (dialog) {
			dialog.data.find('.message').append(message);

			// if the user clicks "yes"
			dialog.data.find('.yes').click(function () {
				// call the callback
				if ($.isFunction(callback)) {
					callback.apply();
				}
				// close the dialog
				$.modal.close();
			});
			// if the user clicks "yes"
			dialog.data.find('.no').click(function () {
				// call the callback
				if ($.isFunction(nocallback)) {
					nocallback.apply();
				}
				// close the dialog
				$.modal.close();
			});
		}
	});
}
