// Edit these...

// This script removes the video, adds the pop-up and a prior alert message

var Page_Enter;
var TimeLimit=100000;
var Page_ShowPopOnExit=true;
var UseCookies=1;
var MySiteDomain='www.thewebreviewer.com';
var MyCartDomain='www.clickbank.com';

var chatMessage = "\nGet IMMEDIATE Access to TheWebReviewer EXTREME for FREE, which includes 10-weeks of in-depth videos on online money making, easy strategies to making money with little to no online experience, and helping you find the best path to success with our Home Business Test!\n\nPlus E.L.M.O. and No-Money-Marketing - at no cost.  PRESS the CANCEL Button Below...\n\n(In some browsers, You may need to scroll up to the top of the page to sign up!)";

// Don't edit these...

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 ) {
      window.onbeforeunload = SiteExit;
    }
  }
}

function InternalLink() {
	Page_ShowPopOnExit = false;
}

function PageEnter() {
   Page_Enter=new Date();
}



function SiteExit() {
	
   var curloc = window.location.hostname.toLowerCase()
   
   //if (MySiteDomain==curloc) {
	   //Page_ShowPopOnExit = false;
	 //  alert(curloc);
	  // alert(MySiteDomain);
   //}
	   
   if (Page_ShowPopOnExit==true) {

	    if (get_cookie("pucook1")) {
	    	var cooknum = get_cookie("pucook1")
		} else {
			var cooknum = 0
		}
		

		if (cooknum < UseCookies) {
      		window.onbeforeunload = null;

			var ie=document.all
			var dom1=document.getElementById
			var scroll_top=window.pageYOffset? window.pageYOffset : 0
			var calunits=document.layers? "" : "px"
			
			crossobj=(ie)? dropin.style : (dom1)?document.getElementById("dropin").style : document.dropin
			
			crossobj.top=scroll_top+50+calunits	
			crossobj.display='block'
			
			crossobj2=(ie)? videolayer.style : (dom1)?document.getElementById("videolayer").style : document.videolayer		
			crossobj2.display='none'
			
			crossobj3=(ie)? opaque.style : (dom1)?document.getElementById("opaque").style : document.opaque		
			crossobj3.display='block'
					
			// set a cookie if viewer has already seen it
			if (UseCookies > 0) {
				cooknum++
				var when = new Date()
				when.setMonth(when.getMonth()+1)
				var date = when.toGMTString()
				document.cookie = "pucook1="+cooknum+";expires="+date+";path=/"
			}
			
			// Create Today's Date
			var m_names = new Array("January", "February", "March", 
			"April", "May", "June", "July", "August", "September", 
			"October", "November", "December");
			
			var d = new Date();
			var curr_date = d.getDate();
			var curr_month = d.getMonth();
			var curr_year = d.getFullYear();
			var today_date = m_names[curr_month] + " " + curr_date + ", " + curr_year;
			
			var alert_msg = 'BEFORE YOU GO...I Have Something For You!\n\nSimply click CANCEL on the next window to receive immediate access to TheWebReviewer EXTREME, which includes 10-weeks of in-depth videos on online money making, easy strategies to making money with little to no online experience, and helping you find the best path to success with our Home Business Test!\n\nPlus E.L.M.O. and No-Money-Marketing...\n\nToday ('+today_date+') It\'s FREE!';

		alert(alert_msg);

   		return chatMessage; 
		}

	}
}

function dismissbox(){
if (window.bouncestart) clearInterval(bouncestart)
			var ie=document.all
			var dom1=document.getElementById
			
			crossobj=(ie)? dropin.style : (dom1)?document.getElementById("dropin").style : document.dropin
			crossobj.display='none'
			
			crossobj2=(ie)? videolayer.style : (dom1)?document.getElementById("videolayer").style : document.videolayer		
			crossobj2.display='block'
			
			crossobj3=(ie)? opaque.style : (dom1)?document.getElementById("opaque").style : document.opaque		
			crossobj3.display='none'
}

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

	for(var y=0; y<anchors.length; y++)
	{
		href = anchors[y].href.toLowerCase();
		if (!(href.indexOf("http://")!=-1 && href.indexOf(MySiteDomain)==-1))
			{
			anchors[y].clickhandler=InternalLink
			XBrowserAddHandlerPops(anchors[y],"click","clickhandler");
			}
	}
}

XBrowserAddHandlerPops(window,"load","PageEnter");
XBrowserAddHandlerPops(window,"load","LinkConvert");
//XBrowserAddHandlerPops(window,"beforeunload","SiteExit");
window.onbeforeunload = SiteExit;
//Page_ShowPopOnExit=true;

function get_cookie ( cookie_name )
{
  var results = document.cookie.match ( '(^|;) ?' + cookie_name + '=([^;]*)(;|$)' );
  if ( results )
    return ( unescape ( results[2] ) );
  else
    return null;
}
