function addEvent(elm, evType, fn, useCapture) {
	if (elm.addEventListener) {
		elm.addEventListener(evType, fn, useCapture);
		return true;
	}
	else if (elm.attachEvent) {
		var r = elm.attachEvent('on' + evType, fn);
		return r;
	}
	else {
		elm['on' + evType] = fn;
	}
}

function removeEvent(obj,type,fn){
  if(obj.removeEventListener) 
  {
    obj.removeEventListener(type,fn,false);
  }  
  else if(obj.detachEvent)
  {
    obj.detachEvent("on"+type, fn);
  }
}

var poped = false;
var url = window.location.href;
var urlToPop = 'http://www.hcjsg.com/DotaAllstars.aspx'
var newWin;
if( url == urlToPop )
{
	newWin = this.window;
	setTimeout("bybyeNW();",35000)
}
else
{
	addEvent(window.document,'click', smartOpen,false);
}
var poped = false;
var my_pop_URL = new Array();
my_pop_URL[0] = "http://www.hcjsg.com/DotaAllstars.aspx";
my_pop_URL[1] = "http://www.hcjsg.com/DotaAllstars/tabid/84/articleType/CategoryView/categoryId/3/Dota-Maps.aspx";
my_pop_URL[2] = "http://www.hcjsg.com/DotaAllstars/tabid/84/articleType/CategoryView/categoryId/5/Dota-Strategies.aspx";
my_pop_URL[3] = "http://www.hcjsg.com/DotaAllstars/tabid/84/articleType/CategoryView/categoryId/7/Dota-Basic.aspx";
my_pop_URL[4] = "http://www.hcjsg.com/DotaAllstars/tabid/84/articleType/CategoryView/categoryId/14/Dota-Videos.aspx";
my_pop_URL[5] = "http://www.hcjsg.com/DotaAllstars/tabid/84/articleType/AuthorView/authorID/15/DotaFuns.aspx";
function smartOpen()
{
	if( !poped )
	{
	    var rn=Math.floor(Math.random()*(my_pop_URL.length))
		OpenUrl('sp1', my_pop_URL[rn]);
	}
}
function OpenUrl(ckName, surl)
{
	var Then = new Date() 
    Then.setTime(Then.getTime() + 5*60000)
    var cookieHeader = ckName+"=" 
	var cookieString = new String(document.cookie)
    var beginPosition = cookieString.indexOf(cookieHeader)
    if (beginPosition == -1 && !poped)
    {
		//newWin = window.open (surl, 'newwindow', 'height=1, width=1, top=2000,left=2000, toolbar=no, menubar=no, scrollbars=no, resizable=yes,location=no, status=no') 
		//newWin = window.open (surl, 'newwindow', 'toolbar=no, menubar=no, scrollbars=yes, resizable=yes,location=yes, status=no') 
		newWin = window.open(surl);
		poped = true;
		document.cookie = cookieHeader + "pzhjhasdh;expires="+ Then.toGMTString()
		this.focus(); 
	}
}
function bybyeNW()
{
	newWin.opener = null;
	newWin.close();
}

