var expDays = 2; // number of days the cookie should last
var page;

page = "http://exploretalent.com/exit_popup2.php";

var dName = self.location.href.toLowerCase().split('/')[2];
if(dName != null){
	//page = "http://"+dName+"/exit_popup2.php"
	page = "http://exploretalent.com/exit_popup2.php";
}


var windowprops = "width=420,height=250,location=no,toolbar=no,menubar=no,scrollbars=no,resizable=no";
var isNav4, isIE4;

var mys=self.location.href.toLowerCase().split('/')[2];
if (parseInt(navigator.appVersion.charAt(0)) >= 4) {
	isNav4 = (navigator.appName == "Netscape") ? true : false;
	isIE4 = (navigator.appName == "Microsoft Internet Explorer") ? true:false;
}

flag = "";
Yaxis = 0;
blurred = "no";

if (isIE4){
	document.onclick=sp;
	window.onclick=sp;
	document.onunload=usp;
	window.onunload=usp;
	window.onblur=blurme;
	window.onkeydown=usp;
}

function usp(ev) {	

		range = screen.height - document.body.offsetHeight;
				
		if (isIE4){
			ev=window.event;
		}

		if(range < 160) {
			upperY = -12;
		}
		if(range >= 160) {
			upperY = -35;
		}
		if(range >= 170) {
			upperY = -40;
		}

		if(Yaxis == 0) {
			Yaxis = ev.clientY;
		}

//		alert("X -> " + ev.clientX + " and " + "y -> " + ev.clientY);
		
		if (Yaxis > 0 || Yaxis < upperY || ev.keyCode == 116 || ev.keyCode == 17) 																											flag="no";

		if(Yaxis <= -9600) {
		   flag="yes";
		}

		if(blurred == "yes" && Yaxis < 0) {
		   flag = "yes";
		}

	    	var etpopup = GetCookie('etpopup');
		var banner = GetCookie('etBanner');
		var company_code = GetCookie('et');
				
		if(company_code == 1002) {
		   flag = "no";			
		}

	    	if(etpopup == "yes") {
		   flag = "no";
	    	}

	    	if(banner == "" || banner == null || banner.length < 2) { 	}
		else {
		   flag = "no";
		}

		if (isNav4){
                   flag = "no";
		}

		if ((flag=="" || flag=="yes") && ev.keyCode != 32 && ev.keyCode != 18) //spacebar & ctrl+tab	
		{
			pop();
		}
}

function sp(ev) {
	if (isIE4){
		ev=window.event;
	}
	Yaxis = ev.clientY;
}

function blurme(ev) {
	if (isIE4){
		ev=window.event;
	}
	Yaxis = ev.clientY;
	blurred = "yes";
}

function GetCookie (name) {
	var arg = name + "=";
	var alen = arg.length;
	var clen = document.cookie.length;
	var i = 0;
	while (i < clen) {
		var j = i + alen;
		if (document.cookie.substring(i, j) == arg)
			return getCookieVal (j);
		i = document.cookie.indexOf(" ", i) + 1;
		if (i == 0) break;
	}
	return null;
}
function getCookieVal(offset) {
   	var endstr = document.cookie.indexOf (";", offset);
   	if (endstr == -1)
   		endstr = document.cookie.length;
   	return unescape(document.cookie.substring(offset, endstr));
}

function pop() {
		/*var pageCheck =self.location.href.toLowerCase().split('/')[4];
		if (pageCheck != null){		
			if (pageCheck.substring(0,12) == "shipping.asp"){
			   	return;
			}
			if (pageCheck.substring(0,13) == "confirmed.asp"){
				return;
		}
		
		var shipCheck = self.location.href.toLowerCase().split('/')[4];
		if (shipCheck != null){
			if (shipCheck.substring(0,12) == "shipping.asp"){
			return;
		   }
		}
						
		var qString = pageCheck.split('?')[1]
		      if(qString != null){
			     if ((qString == "search_type=quickshop&search_value=103") ||(qString == "search_type=quickshop&search_value=104")||(qString == "search_type=quickshop&search_value=105")){
					return;
			      }
			}
		}
		
	       var pathCheck =self.location.href.toLowerCase().split('/')[5];
	       if(pathCheck != null){
		 if (pathCheck.substring(0,12) == "sympathy.asp"){		 	
			return;
		 }
		}
		
		var trCheck =self.location.href.toLowerCase().split('/')[5];
		    if(pathCheck != null){
			 if (pathCheck.substring(0,10) == "tr_exit.asp"){
			     return;
		     }
		}*/

		window.open(page, "POPUP1", windowprops);
				
}
