$(document).ready(function() {
	
	$("a[href*='http://']:not([href*='"+location.hostname+"'])").click(function(e) 
	{ 
		e.preventDefault();
		
		var thishref = $(this).attr('href');
		
		confirm("You are leaving the Ferdinand Farmers website.  Ferdinand Farmers is not responsible for the content on the site you are visiting.", 
				
				function () { window.open(thishref); }
				
			   );
	});

});

function confirm(message, callback) {
	$('#confirm').modal({
		closeHTML:"<a href='#' title='Close' class='modal-close'>x</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 () {
				// call the callback
				if ($.isFunction(callback)) {
					callback.apply();
				}
				// close the dialog
				$.modal.close();
			});
		}
	});
}