/*
 * 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 ($) {
	$('#menu 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("You are now leaving the Swedish Fish website and moving to " + unescape($(this).attr('href')) + ", an external website independently operated and not managed by Cadbury Adams USA LLC. You will be subject to the destination site's privacy policy and terms of use when you leave this site. If you do not wish to leave the site, click Cancel. Or, click OK to continue.", $(this).attr('href'));
	});
});

function confirm(message, link) {
	$('#confirm').modal({
		closeHTML: "<a href='#' title='Close' class='modal-close'><img src='images/confirm/close.jpg' alt='Close button' /></a>",
		position: ["20%",],
		overlayId: 'confirm-overlay',
		containerId: 'confirm-container', 
		onShow: function (dialog) {
			$('.message', dialog.data[0]).append(message);

			// if the user clicks "yes"
			$('.yes', dialog.data[0]).click(function () {
				window.open(link);

				// close the dialog
				$.modal.close();
			});
		}
	});
}
