// This script has been developed by ordecon.systems (http://www.ordecon.com/)
// All rights reserved. Please do not modify the source code and re-distribute
// only in the original package!

// Script configuration variables:
// Popup window options:

// The size of the popup window
// set this to 1 if you want the window maximized, 0 otherwise
var popupMaximized=0;

// if you don't want a maximized window, enter the size here, otherwise, just set it to any numerical value
var popupHeight=390;
var popupWidth=750;

// "yes" if you want the new window to have scrollbars, otherwise "no"
var popupScrollbars="no"; 

var popupMenubars="no";
var popupResizable="no";

var popupStatus="no";

// "yes" if you want the new window to have the address bar, otherwise "no"
var popupLocation="no";

// What is considered internal?
var internalBaseURLs = new Array(
"http://desertburn.com",
"http://www.desertburn.com"
);

// Extended Unload Event:
// Should I pop up a window when the user exits by manualy typing in an URL, choosing a bookmark, or hitting the back
// button?
// WARNING: browser security does not allow JavaScript to find out what the URL of the new page is. Therefore all such
// events (typing URL, opening a bookmark or hitting back) will cause a popup, regardless if they will keep the user
// on your page.
var catchExtendedUnloads=1;

//
//
// You can and should let the things below live their own life, without your meddling litle fingers! ;)
//
//
var browserIsNetscape=(navigator.appName.indexOf("Microsoft")!=-1) ? false : true;
var unloadNoticed=0;

function doPopup() {
	options = "scrollbars="+popupScrollbars+",location="+popupLocation+",menubar="+popupMenubars+",resizable="+popupResizable+",fullscreen="+popupMaximized+",status="+popupStatus+",titlebar=no,toolbar=no,width="+popupWidth+",height="+popupHeight;
	//alert(window.onclick);
	helpWindow = window.open(popupURL, '', options);
	//if (window.focus) {
	//	helpWindow.focus()
	//}
	//helpWindow.resizeTo(popupWidth, popupHeight);
	unloadNoticed=1;
}


function doInitPopupEvents() {
	// 2002-10-15, strange bugfix where IE6.0 doesn't reload/reexec the jscript global code
	// when we enter the page with back/forward. this means that our triggers (specially
	// unloadNoticed var) will be broken and won't popup further windows. oh, the pain...
	unloadNoticed = 0;
	
	if (browserIsNetscape) {
		window.captureEvents(Event.CLICK);
		window.onclick=checklink;
	} else {
		document.onclick=checklink;
	}
}


// Returns zero if the link is found among the internalBaseURLs, else it returns non-zero
function isLinkExternal(url) {
	var s = String(url);
	var foundInternals=0;

	for ( var i = 0; i < internalBaseURLs.length; i++ ) {
		if (s.search(internalBaseURLs[i]) == 0) {
			foundInternals++;
		}
	}

	return !foundInternals;
}


function checklink(e) {
	if (!browserIsNetscape) {
		targetURL = window.event.srcElement.href;
	} else {
		targetURL = e.target.href;
	}
	//alert(targetURL);

	// If the event carries a non-null targetURL with it, it means that the user is going away,
	// so let's check the click...
	if (targetURL && isLinkExternal(targetURL)) {
		unloadNoticed = 0;
		doPopup();
	} else {
		unloadNoticed=1;
	}
}


function doCheckUnloading() {
	//alert("Unload noticed:"+unloadNoticed+" extendedUnloads:"+catchExtendedUnloads);
	if (!unloadNoticed && catchExtendedUnloads) {
		doPopup();
	}

	// 2002-10-15, just playing it safe like in doInitPopupEvents. why does M$ have to
	// break bits and pieces of their stuff in every version?
	unloadNoticed=0;
}


