///////////////////////////////////
//                               //
//   "Simple banner rotation"    //
//                               //
// Written by Chris Hansen, 2000 //
//         Public Domain         //
//                               //
//           Contact:            //
//    info@nextgeneration.dk     //
// http://www.nextgeneration.dk  //
//                               //
///////////////////////////////////

///////////////////////////////////
//                               //
// 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("Banner"));

if (useCookie != 1)
{
     while (rndnmb < 0 || rndnmb > 12)
     {
          rndnmb = Math.random();
          rndnmb = Math.round(rndnmb *= 10) - 1;
     }
}
else
{
     if (cocho >= 0 && cocho <= 12)
     {
          cocho += 1;

          if (cocho > 12)
               cocho = 0;
     }
     else
          cocho = 0;

     SetCookie ("Banner", cocho);
     rndnmb = cocho;
}

document.write ("<A href=" + banner[rndnmb][1] + " target=_blank><IMG src=" + banner[rndnmb][0] + " border=1></A>");

///////////////////////////////////

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();
}
