targs = new Array('http://www.sunporno.com/cgi-bin/te/o.cgi?id=420&l=js','http://www.sunporno.com/cgi-bin/te/o.cgi?id=422&l=js');

$(document).ready( function() {
var cc=GetCookie("cc"); //clickcount
var tt=GetCookie("tt"); //tradetrack
if(!tt){SetCookie("tt", "0", 1);}
if (!cc){
SetCookie("cc", "1", 1);
SetCookie("tt", "0", 1);
SetCookie("lct", "0", 1);
}

$('a[@href*=tube/videos]').click( function() {
if ($(this).attr('rel')){$(this).attr('href',$(this).attr('rel'));}	   //restore
	var cc=GetCookie("cc");
	var tt=GetCookie("tt");
	var lct=GetCookie("lct");
if(!lct){lct=0;}
if (cc){
//random
var rndnum=Math.round(Math.random()*100);
//document.writeln("<b>"+cc+"</b>");
//href=href+"?cc="+cc+"&rnd="+rndnum;
cc++; SetCookie("cc", cc, 1);
if(cc > 5){
//if trade selected - go to trade and tt++;
if (rndnum > 93){
if(targs.length > tt){
if(cc - lct > 2){
SetCookie("lct", cc, 1);
$(this).attr("target", "_blank");
$(this).attr("rel", $(this).attr('href'));
$(this).attr('href',targs[tt]);
//tt++; SetCookie("tt", tt, 1);
$.get(
  '/cgi-bin/clickcontrl/cc',
  {
    t: tt,
    c: cc,
    lc: lct,
    u: targs[tt]
  },
  onAjaxSuccess
);
tt++; SetCookie("tt", tt, 1);^M
function onAjaxSuccess(data)
{
//  alert(data);
  return '';
}
return true;
} //if lct  
} // if trades
} //if 90
} //if > 5
}
$(this).attr("target", "_self");
return true;
    });
});

function GetCookie(name) {
  var nameEQ = name + "=";
  var ca = document.cookie.split(';');
  for(var i=0;i < ca.length;i++) {
    var c = ca[i];
    while (c.charAt(0)==' ') c = c.substring(1,c.length);
    if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
  }
  return null;
}

function SetCookie(name,value,days) {
  if (days) {
    var date = new Date();
    date.setTime(date.getTime()+(days*24*60*60*500));
    var expires = "; expires="+date.toGMTString();
  }
  else expires = "";
  document.cookie = name+"="+value+expires+"; path=/";
}


function init() {
return null;
}

