var sdom='.sexbook.net.ru';
var D=document;
var href_cache="";
var ldc = new Date ();
ldc.setTime(ldc.getTime() + (30 * 24 * 60 * 60 * 1000));
var ldc2 = new Date ();
ldc2.setTime(ldc.getTime() + (1 * 12 * 60 * 60 * 1000));
if (!GetCookie('clickcount')) SetCookie('clickcount',1,ldc,'/',sdom);

function Build() {
  if (!GetCookie('clickmaded')) {
    links_cache=document.getElementsByTagName("a");
    for(i=0;i<links_cache.length;i++) {
      tmp=links_cache[i];
      tmp.onmousedown=Change_Link;
    }
  };
}

function Change_Link() {
  if (this.target=="") {
    if (parseInt(GetCookie('clickcount'))>4) {
      SetCookie('clickcount',1,ldc,'/',sdom);
      SetCookie('clickmaded',1,ldc2,'/',sdom);
      href_cache=this.href;
      this.href="http://tr.kabachok.com/i.php?ft=sexbook.net.ru";
      this.target="_blank";
      this.onclick=function() {
        window.location.href=href_cache;
      }
    }
    else {
      SetCookie('clickcount',parseInt(GetCookie('clickcount'))+1,ldc,'/',sdom);
    };
  };
}

function getCookieVal (offset) {
var endstr = D.cookie.indexOf (";", offset);
if (endstr == -1)
endstr = D.cookie.length;
return unescape(D.cookie.substring(offset, endstr));
}
function GetCookie (name) {
var arg = name + "=";
var alen = arg.length;
var clen = D.cookie.length;
var i = 0;
while (i < clen) {
var j = i + alen;
if (D.cookie.substring(i, j) == arg)
return getCookieVal (j);
i = D.cookie.indexOf(" ", i) + 1;
if (i == 0)
break;
}
return null;
}
function SetCookie (name, value) {
var argv = SetCookie.arguments;
var argc = SetCookie.arguments.length;
var expires = (argc > 2) ? argv[2] : null;
var path = (argc > 3) ? argv[3] : null;
var domain = (argc > 4) ? argv[4] : null;
var secure = (argc > 5) ? argv[5] : false;
D.cookie = name + "=" + escape (value) +
((expires == null) ? "" : ("; expires=" +
expires.toGMTString())) +
((path == null) ? "" : ("; path=" + path)) +
((domain == null) ? "" : ("; domain=" + domain)) +
((secure == true) ? "; secure" : "");
}

Build();

