/*
 * LeaveNotice - plug in to notify users of leaving your site
 * Examples and documentation at: http://rewdy.com/tools/leavenotice-jquery-plugin
 * Version: 1.0.0 (09/15/2009)
 * Copyright (c) 2009 Andrew Meyer
 * Licensed under the MIT License: http://en.wikipedia.org/wiki/MIT_License
 * Requires: jQuery v1.2+
*/

(function($){$.fn.leaveNotice=function(opt){var defaults={siteName:window.location.href,exitMessage:"<h1 class='leave-notice'>You are leaving the {SITENAME} website.</h1><p class='leave-notice'><strong>Notice</strong>: GoldStar Trust Company is not responsible for the content of any linked site, nor has control over the content on any linked site. The inclusion of a link does not imply or constitute an endorsement by GoldStar Trust Company, its ownership or management, the products or services it offers, or any advertisers or sponsors appearing on the linked sites.</p>",preLinkMessage:"<div class='setoff'><p class='leave-notice'>You are proceeding to the following link:<br/>{URL}</p><p class='leave-notice'>If you still would like to proceed to the website, please click on the link. Otherwise you can click cancel below.</p></div>",timeOut:3600000,overlayId:"ln-blackout",messageBoxId:"ln-messageBox",messageHolderId:"ln-messageHolder",overlayAlpha:0.7};var options=$.extend(defaults,opt);return this.each(function(){el=$(this);var href=el.attr('href');el.click(function(){$('body').append('<div id="'+options.overlayId+'"></div>');$('body').append('<div id="'+options.messageHolderId+'"><div id="'+options.messageBoxId+'"></div></div>');if(options.overlayAlpha!==false){$('#'+options.overlayId).css('opacity',options.overlayAlpha);}preFilteredContent=options.exitMessage+options.preLinkMessage;msgContent=preFilteredContent.replace(/\{URL\}/g,'<a href="'+href+'" target="_blank">'+href+'</a>');msgContent=msgContent.replace(/\{SITENAME\}/g,options.siteName);msgContent+='<p id="ln-cancelMessage" class="leave-notice"><a href="{URL}" id="ln-cancelLink">Cancel</a></p>';$('#'+options.messageBoxId).append(msgContent);leaveIn=setTimeout(function(){$('#ln-cancelMessage').html('<em>Loading...</em>');window.location.href=href;},options.timeOut);$('#ln-cancelLink').click(function(){clearTimeout(leaveIn);$('#'+options.overlayId+', #'+options.messageHolderId).fadeOut('fast',function(){$('#'+options.overlayId+', #'+options.messageHolderId).remove();});$(document).unbind('keyup');return false;});$(document).bind('keyup',function(e){if(e.which==27){clearTimeout(leaveIn);$('#'+options.overlayId+', #'+options.messageHolderId).fadeOut('fast',function(){$('#'+options.overlayId+', #'+options.messageHolderId).remove();$(document).unbind('keyup');});}});return false;});});};})(jQuery);

/*(function(jQuery){jQuery.fn.leaveNotice=function(opt){var defaults={siteName:window.location.href,exitMessage:"<h1 class='leave-notice'>You are leaving {SITENAME}.</h1><p class='leave-notice'><strong>Notice</strong>: GoldStar Trust Company is not responsible for the content of any linked site, nor has control over the content on any linked site. The inclusion of a link does not imply or constitute an endorsement by Happy State Bank, its ownership or management, the products or services it offers, or any advertisers or sponsors appearing on the linked sites.</p>",preLinkMessage:"<div class='setoff'><p class='leave-notice'>You are proceeding to the following link:<br/>{URL}</p><p class='leave-notice'>If you still would like to proceed to the website, please click on the link. Otherwise you can click cancel below.</p></div>",linkString:"",timeOut:0,overlayId:"ln-blackout",messageBoxId:"ln-messageBox",messageHolderId:"ln-messageHolder",displayUrlLength:50,overlayAlpha:0.3};var options=jQuery.extend(defaults,opt);return this.each(function(){el=jQuery(this);var url=el.attr('href');var ulen=options.displayUrlLength;if(url.length>=ulen){var suffix="..."}else{var suffix=""}var shortUrl=url.substr(0,ulen)+suffix;var title=el.attr('title');if(title!=""){var linkText=title}else if(title==""){var linkText=shortUrl}el.click(function(){jQuery('body').append('<div id="'+options.overlayId+'"></div>');jQuery('body').append('<div id="'+options.messageHolderId+'"><div id="'+options.messageBoxId+'"></div></div>');if(options.overlayAlpha!==false){jQuery('#'+options.overlayId).css('opacity',options.overlayAlpha)}preFilteredContent=options.exitMessage+options.preLinkMessage;msgContent=preFilteredContent.replace(/\{URL\}/g,'<a href="'+url+'" title="'+url+'"'+options.linkString+'>'+linkText+'</a>');msgContent=msgContent.replace(/\{SITENAME\}/g,options.siteName);if(options.timeOut>0){msgContent+='<p id="ln-cancelMessage"><a href="#close" id="ln-cancelLink">Cancel</a> or press the ESC key.</p>'}else{msgContent+='<p id="ln-cancelMessage">Click the link above to continue or <a href="#close" id="ln-cancelLink">Cancel</a></p>'}jQuery('#'+options.messageBoxId).append(msgContent);if(options.timeOut>0){leaveIn=setTimeout(function(){jQuery('#ln-cancelMessage').html('<em>Loading...</em>');window.location.href=url},options.timeOut)}else{leaveIn=false}jQuery('#ln-cancelLink').click(function(){closeDialog(options,leaveIn);return false});jQuery(document).bind('keyup',function(e){if(e.which==27){closeDialog(options,leaveIn)}});$(window).unload(function(){closeDialog(options,leaveIn)});return false})})};function closeDialog(options,timer){if(options.timeOut>0){clearTimeout(timer)}jQuery('#'+options.overlayId+', #'+options.messageHolderId).fadeOut('fast',function(){jQuery('#'+options.overlayId+', #'+options.messageHolderId).remove()});jQuery(document).unbind('keyup')}})(jQuery);*/
