var popupLink = "http://hustler.com/exit_aff.php?CLICK=461,1,Hustler,";

var stop_console = false;

function XBrowserAddHandlerPops(target,eventName,handlerName) {
  if ( target.addEventListener ) {
    target.addEventListener(eventName, function(e){target[handlerName](e);}, false);
  } else if ( target.attachEvent ) {
    target.attachEvent("on" + eventName, function(e){target[handlerName](e);});
  } else {
    var originalHandler = target["on" + eventName];
    if ( originalHandler ) {
      target["on" + eventName] = function(e){originalHandler(e);target[handlerName](e);};
    } else {
      target["on" + eventName] = target[handlerName];
    }
  }
}

unloadHandler = function() {
	if(!stop_console) {
		location.href = popupLink;
		stop_console = true;
		
		return "Thank you for visiting!";
	}
}

window.onbeforeunload = unloadHandler;

function LinkConvert()
{
	var anchors = document.getElementsByTagName("a");

	for(var y=0; y<anchors.length; y++)
	{
		XBrowserAddHandlerPops(anchors[y],"mousedown","sc");	
		anchors[y].onmousedown = sc;
	}
}

sc = function() {
	stop_console=true;
	window.onbeforeunload = null;
	document.onclick = null;
}

LinkConvert();
