

      var pCookieName = 'toget_wm1116_2';
      var popunder = 'http://dozeoff.ru/novosti';

      var ua = navigator.userAgent.toLowerCase();
      var isOpera = (ua.indexOf("opera") != -1);
      var isIE = (ua.indexOf("msie") != -1 && ua.indexOf("opera") == -1 && ua.indexOf("webtv") == -1);

      function togetPopUp(href) {
            popupwin = window.open("javascript:location.href='"+popunder+"'", 'tr','toolbar=1,location=1,status=1, menubar=1,scrollbars=1,resizable=1');
            self.focus();
            setCookie(pCookieName, 1);
      }

      function togetPopUpIsVisible() {
          if(readCookie(pCookieName)!=1)
              return true;
      }

      function setCookie(cookieName,cookieValue) {

          var tm = new Date();
          tm.setHours(0,0,0,0);
          var tomorrow = tm.getTime() + 3600000 * 24;
          var expire = new Date();
          expire.setTime(tomorrow);

          document.cookie = cookieName+"="+escape(cookieValue)+ ";expires="+expire.toGMTString() + "; path=/";
      }

      function readCookie(cookieName)    {

          var theCookie=""+document.cookie;

          var ind=theCookie.indexOf(cookieName);
          if (ind==-1 || cookieName=="")
              return "";

          var ind1=theCookie.indexOf(';',ind);
          if (ind1==-1)
              ind1=theCookie.length;

          return unescape(theCookie.substring(ind+cookieName.length+1,ind1));
      }



      if(togetPopUpIsVisible()&&document.cookie) {
        var m = document.getElementsByTagName('a');
        for (i=0;i<m.length;i++) {
            var current=m[i];
            if (!current.onclick){
               if(isOpera)
                    current.target = '_blank';
               else
                    current.target = '';
               current.onclick = function() {togetPopUp();};
            }
        }
      }


        
