
function unloadWin(evt){
	// We disable all popups unless the browser is IE
	var disablePopup = true;
	if(!evt) {
		// Yuck - check to see if the mouse cursor is in the general vicinity of where 
		// the back button generally resides... only on IE, of course, because moz/FF/NS
		// can't track the cursor outside of the client area.  In IE6, this check will kill
		// popups for back, forward, and refresh.  In IE7, it won't kill for refresh, because refresh
		// is way over on the right side of the toolbar.
		evt = window.event;
		disablePopup = (evt.clientX > 0 && evt.clientX < 120) && evt.clientY < 0;
	}
	
	// Determine mouse position
	var h = aopinfo.height; // pop height
	var w = aopinfo.width; // pop width
	var url = aopinfo.popUrl; // pop url
	/* -- */
	var l = (screen.width - w) / 2;
	var t = (screen.height - h) / 2;

	if( !disablePopup ) {
		var p = 'width=' +w+ ',height=' +h+ ',left=' +l+ ',top=' +t+ ',scrollbars=yes'
		var w = window.open(url,'popup',p);
		if (window.focus) w.focus();
	}
}

function setUnload(on){
	var show = false;
	if(window.aopinfo && window.location.pathname!="/policy/servicesagreement.rcmx") {
			show = aopinfo.showOnAbandon && on;
	}
	window.onunload = (show) ? unloadWin : null;
}

setUnload(true);

$(document).ready(function(){
	$("a,input[type='image'],button").click( function() {
		setUnload(false);
	} );
	$("select").change( function() {
		setUnload(false);
	} );
	$("form").submit( function() {
		setUnload(false);
	} );
	$("area").click(function() { 
		setUnload(false);
	} );
});