function GetRandom( min, max ) {
    if( min > max ) {
	return( -1 );
    }
    if( min == max ) {
	return( min );
    }
				 
    return( min + parseInt( Math.random() * ( max-min+1 ) ) );
}



var puShown = false;

        function doOpen(url)
        {
                if ( puShown == true )
                {
                        return true;
                }

		var winid = GetRandom(1, 100);
		
                win = window.open(url, winid, 'toolbar,status,resizable,scrollbars,menubar,location,fullscreen');
//              win = window.open(url, winid, 'height=680,width=790');
                if ( win )
                {
                        win.blur();
                        puShown = true;
                }
                return win;
                   
        }


        function setCookie(name, value, time)
        {
         var expires = new Date();

         expires.setTime( expires.getTime() + time );

         document.cookie = name + '=' + value + '; expires=' + expires.toGMTString();
        }


        function getCookie(name) {
         var cookies = document.cookie.toString().split('; ');
         var cookie, c_name, c_value;

         for (var n=0; n<cookies.length; n++) {
          cookie  = cookies[n].split('=');
          c_name  = cookie[0];
          c_value = cookie[1];

          if ( c_name == name ) {
           return c_value;
          }
         }

         return null;
        }


        function initPu()
        {
          if ( document.attachEvent )
          {
                  document.attachEvent( 'onclick', checkTarget );
          }
          else if ( document.addEventListener )
          {
                  document.addEventListener( 'click', checkTarget, false );
          }
        }


        function checkTarget(e)
        {
         if ( !getCookie('xrnbpop') ) {
                var e = e || window.event;
                var win = doOpen('http://xrnb.net/popdown.php');

          setCookie('xrnbpop', 1, 24*60*60*1000);
         }
        }



if (document.referrer.substring(0, 14) == location.href.substring(0, 14)) {

initPu();

}

else if (location.href.substring(0, 11) != 'http://xrnb') {
	if (document.referrer.substring(0, 11) == 'http://xrnb') {
	    setCookie('xrnbpop', 1, 24*60*60*1000);
	}      
}


