This stuff is in the head
---------------------------
<script type="text/javascript">
var need_leave_popup=false;
var clicked_link=false;
var message = 'You may have unpaid items in your shopping cart. You must complete the checkout process for a seat to be reserved for you.';
window.onbeforeunload = function (evt) {
if(need_leave_popup==true || clicked_link==false){
/*if (typeof evt == 'undefined')
evt = window.event;
if (evt)
evt.returnValue = message; */
return message;
}
need_leave_popup=false;
clicked_link=false;
//return message;
}
</script>
This is at the bottom, right before the end of body
----------------------------------------------------
<script type="text/javascript">
var k;
if (Drupal.jsEnabled) {$(document).ready(function () {
<?php print $block['javascript'];?>
} ) };
</script>
<script type="text/javascript">
var anchors = document.getElementsByTagName("a");
for(var i = 0;i < anchors.length; i++){
var anchor = anchors[i];
if((anchor.href.indexOf("localhost")==-1) || (anchor.href.indexOf("/logout")>-1)){
anchor.onclick = function(){clicked_link=true;need_leave_popup=true;};
}
else
anchor.onclick = function(){clicked_link=true;};
}
</script>