var z = "";
var i = 0;

z=readCookie("ad3");
if (z==null) {
  z = "";
  for (var n=1; n<=10; n++){
    i=Math.round(25*Math.random());
    //There is no chr() function, so you have to do this crazy shit:
    z=z+unescape("%"+d2h(i+97));
    }
  z=MakeDateString() + "-" + z;
  createCookie("ad3",z,365);
  }

document.write("<a href=../supernzb/index.html?Source=SuperNZB_Banner>" +
  "<img src=../images/supernzb_banner.gif width=728 height=90 border=0></a>");

document.write("<img src=http://www.techsono.com/images/1x1.gif?ad3=" + z + " width=0 height=0 border=0>");

function createCookie(name, value, days)
{
  if (days) {
    var date = new Date();
    date.setTime(date.getTime()+(days*24*60*60*1000));
    var expires = "; expires="+date.toGMTString();
    }
  else var expires = "";
  document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name)
{
  var ca = document.cookie.split(';');
  var nameEQ = name + "=";
  for(var i=0; i < ca.length; i++) {
    var c = ca[i];
    while (c.charAt(0)==' ') c = c.substring(1, c.length); //delete spaces
    if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length, c.length);
    }
  return null;
}

function d2h(d) {return d.toString(16);}

function MakeDateString() 
{
  var now = new Date();
  var y = "";
  var m = "";
  var d = "";
  var h = "";
  var n = "";
  var s = "";

  y=now.getFullYear();
  m=(now.getMonth()+1) + ''; //The month number is zero-relative. Adding the '' converts the number into as string.
  if (m.length == 1) {m="0" + m;}
  d=now.getDate() + '';
  if (d.length == 1) {d="0" + d;}
  h=now.getHours() + '';
  if (h.length == 1) {h="0" + h;}
  n=now.getMinutes() + '';
  if (n.length == 1) {n="0" + n;}
  s=now.getSeconds() + '';
  if (s.length == 1) {s="0" + s;}

  return y + "-" + m + "-" + d + "-" + h + ":" + n + ":" + s;
}

