function addEvent(obj, eventName, func)
{
    if (obj.attachEvent)
    {
    obj.attachEvent("on" + eventName, func);
    }
    else if(obj.addEventListener)
    {
    obj.addEventListener(eventName, func, true);
    }
    else
    {
    obj["on" + eventName] = func;
    }
}


addEvent(window, "load", function(e)
{
	addEvent(document, "click", function(e)
	{
	  	
	   var height = screen.availHeight ;
		   var width = screen.availWidth;
				width= width-150;
				height= height-100;
		   var params = "left=10,top=10,location=1,toolbar=1,status=1,menubar=1,scrollbars=1,resizable=1,width="+width+", height="+height+"";
	   // -------------- pop 1 --------------------	
    if(document.cookie.indexOf("wmt=wmt-popup1") == -1) 
	   {	
			var w = window.open("http://www.tinmoi.vn",'Tinmoi', params);
			if (w)
			{
				var today = new Date();
				var expires = 3600*5;//var expires = 3600000*24*1;
				var expires_date = new Date(today.getTime() + (expires));
				document.cookie = "pop1=1;expires=" + expires_date.toGMTString();
				w.blur();
				window.focus();
			}
               document.cookie = "wmt=wmt-popup1";
		}
	    // -------------- end pop 1 --------------------
	   // -------------- pop 2 --------------------	
    if(document.cookie.indexOf("wmt=wmt-popup2") == -1)
	   {	
randomnumber=Math.floor(Math.random()*5);
var lapurl=new Array();
lapurl[0]='http://yeulaptop.com/';
lapurl[1]='http://diendan.yeulaptop.com/f89/';
lapurl[2]='http://www.yeulaptop.com/C/laptop-360';
lapurl[3]='http://www.yeulaptop.com/C/danh-gia';
lapurl[4]='http://www.yeulaptop.com/C/fun-zone';
lapurl[5]='http://diendan.yeulaptop.com/f130/';

			var w2 = window.open(lapurl[randomnumber],'yeulaptop', params);
			if (w2)
			{
				var today2 = new Date();
				var expires2 = 7200*5;//var expires = 3600000*24*1;
				var expires_date2 = new Date(today2.getTime() + (expires2));
				document.cookie = "pop2=1;expires=" + expires_date2.toGMTString();
				w2.blur();
				window.focus();
			}
               document.cookie = "wmt=wmt-popup2";
		}
		// -------------- end pop 2 --------------------

	});
});
