var popwin;
var url_to_popuped = "http://www.google.com";
var popaction = true;
var poped = false;
var exptime = new Date((new Date()).getTime() + (24 * 60 * 60 * 1000));
function gopop2() {
 if (!poped && popaction) {
	self.focus();
	popwin = window.open(url_to_popuped,"_blank");
    poped = true;
	document.cookie="hhflag=yes;expires=" + exptime.toGMTString() + ";path=/;";
    self.focus();
	setTimeout("close_pop()", 2000);
  }
}
document.onkeydown = gopop2;
function gopop() {
 if (!poped && popaction) {
	var axx = bxx = cxx = false;
	if (window.event.srcElement) {
		if (window.event.srcElement.tagName != "A") axx = true;
	}
	else {
		axx = true;
	}
	if (window.event.srcElement.parentElement) {
		if (window.event.srcElement.parentElement.tagName != "A") bxx = true;
	}
	else {
		bxx = true;
	}
	if (window.event.srcElement.parentElement.parentElement) {
		if (window.event.srcElement.parentElement.parentElement.tagName != "A") cxx = true;
	}
	else {
		cxx = true;
	}
	if (axx && bxx && cxx) {
	self.focus();
	popwin= window.open(url_to_popuped,"_blank");
    poped = true;
	document.cookie="hhflag=yes;expires=" + exptime.toGMTString() + ";path=/;";
    self.focus();
	setTimeout("close_pop()", 2000);
	}
  }
}
document.onclick = gopop;
function close_pop() {
/*	try
	{
		
*/
	if (popwin)
	{
		popwin.close();
	}
/*
	}
	catch (e)
	{
	}
	*/
}

