var UserClicked=false;
document.onkeydown=spyclick;
document.onmousedown=spyclick;

function spyclick()
{
  UserClicked=true;
  setTimeout("UserClicked=false",2000);
}

window.onbeforeunload=popupBOU;

//	If there is not CATALOG_OK cookie, it will call the popup function.
function popupBOU() {
	if(!UserClicked) {
		if (getc("CATALOG_OK")!="1") {
			popup();
		}
	}
}

function prLinks()
{
	for(i=0; i<document.links.length; i++) {
		document.links[i].onclick = checklink;
	}
}

// If link is not within the site and the CATALOG_OK cookie is not set, popup
function checklink() {
	if(!this.toString().match(document.domain)) {
		if(getc("CATALOG_OK")!="1") {
			popup();
		}
	}
}

function popup() {
	window.open("/lead_form_short.php","ISILeadForm","scrollbars=yes,width=440,height=460");
}

/*
function popup()
{
	var win=window.open("","","width=300,height=300");
	win.document.write("kuku, come back! ;)");
	setc("adwas","true") 
}
*/

function getc(name){
	var rs=null;var mc=" " + document.cookie + ";";
	var sn=" " + name + "=";var sc=mc.indexOf(sn);var ec;
	if (sc!=-1) {
		sc+=sn.length;ec=mc.indexOf(";",sc);
		rs=unescape(mc.substring(sc,ec));}return rs;
	}

function setc(name,value) {
	document.cookie=name+"="+escape(value);
}