///////////////////////////
//                       //
// Configure:            //
//                       //
// Set "UseCookie"       //
// 0 - Randomize banners //
// 1 - Use cookie        //
//                       //
///////////////////////////

var useCookie = 1;

///////////////////////////

var rndnmb = -1;

expDays = 365;
exp = new Date ();
exp.setTime (exp.getTime () + (expDays * 24 * 60 * 60 * 1000));

var cocho = parseInt (GetCookie ("rotate"));

if (useCookie != 1)
  {
    while (rndnmb < 0 || rndnmb > 2)
      {
        rndnmb = Math.random ();
        rndnmb = Math.round (rndnmb *= 10) - 1;
      }
  }
else
  {
    if (cocho >= 0 && cocho <= 2)
      {
        cocho += 1;
        if (cocho > 2)
          cocho = 0;
      }
  else
    cocho = 0;

  SetCookie ("rotate", cocho);
  rndnmb = cocho;
}

document.write (rotation[rndnmb][0]);

///////////////////////////

function GetCookieVal (offset)
{
  var endstr = document.cookie.indexOf (";", offset);

  if (endstr == -1)
    endstr = document.cookie.length;

    return unescape (document.cookie.substring (offset, endstr));
}

function GetCookie (name)
{
  var arg = name + "=";
  var alen = arg.length;
  var clen = document.cookie.length;
  var i = 0;

  while (i < clen)
    {
      var j = i + alen;

      if (document.cookie.substring (i, j) == arg)
        return GetCookieVal (j);

      i = document.cookie.indexOf (" ", i) + 1;
      if (i == 0)
        break;
    }
  return "";
}

function SetCookie (name, value)
{
  document.cookie = name + "=" + escape (value) + "; expires=" + exp.toGMTString ();
}
