function addEvent(elm, evType, fn, useCapture)
{
	if (elm.addEventListener)
	{
		elm.addEventListener(evType, fn, useCapture);
		return true;
	}
	else if (elm.attachEvent)
	{
		var r = elm.attachEvent('on' + evType, fn);
		return r;
	}
	else
	{
		elm['on' + evType] = fn;
	}
}

function addListeners(e)
{
	addEvent(window, 'beforeunload', exitAlert, false);
	//add listeners to all the links on the site to remove the beforeunload event onclick
	var links = document.getElementsByTagName('a');
	for(var i=0; i<links.length; i++)
	{
		addEvent(links[i], 'click', nopop);
	}
	
}

function nopop()
{
removeEvent(window, 'beforeunload', exitAlert, false)
}


function exitAlert(e)
{
	document.location.href="http://www.www-xbox360repair.com/discountcb.html";
	var msg = "\n>>>>>> Wait! I'll Give You My Guide For A Crazy Discount Price of Just $19.<<<<<<\n\nI Want You To Have This Discount!\nJust click (CANCEL) button below!\n\n";
	if (!e) { e = window.event; } 
	if (e) { e.returnValue = msg; }
	return msg;
}

function removeEvent(elm, evType, fn, useCapture){
    if (elm.removeEventListener) {
        elm.removeEventListener(evType, fn, useCapture);
        return true;
    }
    else 
        if (elm.attachEvent) {
            var r = elm.detachEvent('on' + evType, fn);
            return r;
        }
        else {
            elm['on' + evType] = '';
        }
}

addEvent(window, 'load', addListeners, false);
