// Size of the array, ie. number of links to be randomly chosen.
var maxsize = 5;
var maxsizebig = 8;
// Image's width and height.
var iwidth = 160;


// Specify the links.
// Format: "URL,description,target,imageurl".
var link = new makeArray(maxsize);
var linkbig = new makeArray(maxsizebig);
linkbig[0] = new LinkObj("http://www.giltedgepublishing.co.nz/windows.php?Level=main", "Testing", "_top", "Sitepics/misc/Adverts/WOLbiscuit.jpg", "283");
linkbig[1] = new LinkObj("http://www.giltedgepublishing.co.nz/windows.php?Level=main", "Testing", "_top", "Sitepics/misc/Adverts/Jan05WOLBTeaser.jpg", "255");
linkbig[2] = new LinkObj("http://www.giltedgepublishing.co.nz/GFI.php", "Testing", "_top", "Sitepics/misc/Adverts/GFI1.jpg", "247");
linkbig[3] = new LinkObj("http://www.giltedgepublishing.co.nz/fastzone.php?lev=main", "Testing", "_top", "Sitepics/misc/Adverts/Jan05FZTeaser.jpg", "205");
linkbig[4] = new LinkObj("http://www.giltedgepublishing.co.nz/GFI.php", "Testing", "_top", "Sitepics/misc/Adverts/GFI3.jpg", "235");
linkbig[5] = new LinkObj("http://www.giltedgepublishing.co.nz/GFI.php", "Testing", "_top", "Sitepics/misc/Adverts/GFIBiscuit.jpg", "308");
linkbig[6] = new LinkObj("http://www.giltedgepublishing.co.nz/Themes.php?Subject=main", "Testing", "_top", "Sitepics/misc/Adverts/ThemeBiscuit.jpg", "312");
linkbig[7] = new LinkObj("http://www.giltedgepublishing.co.nz/gereaders.php?Grade=main", "Testing", "_top", "Sitepics/misc/Adverts/MMBiscuit.jpg", "240");

link[0] = new LinkObj("http://www.giltedgepublishing.co.nz/Faction.php", "Testing", "_top", "Sitepics/misc/Adverts/Jan05FactionTeaser.jpg", "160");
link[1] = new LinkObj("http://www.giltedgepublishing.co.nz/FamousNZ.php", "Testing", "_top", "Sitepics/misc/Adverts/Jan05NZrTeaser.jpg", "160");
link[2] = new LinkObj("http://www.giltedgepublishing.co.nz/Momentum.php", "Testing", "_top", "Sitepics/misc/Adverts/Momentumbiscuit06.jpg", "160");
link[3] = new LinkObj("http://www.giltedgepublishing.co.nz/WorkArt.php", "Testing", "_top", "Sitepics/misc/Adverts/WOA2.jpg", "160");

link[4] = new LinkObj("http://www.giltedgepublishing.co.nz/windowsBB.php", "Testing", "_top", "Sitepics/misc/Adverts/SUSBiscuit.jpg", "160");

var n = 0;

function LinkObj(url, description, target, img, height) {
  this.url = url;
  this.description = description;
  this.target = (target != null) ? target : "_top";
  this.image = img;
  this.height = height
  return this;
}

function gotoUrl(x) {
  if (link[x].target != null)
    window.open(link[x].url, link[x].target);
  else
    location.href = link[x].url;
  }
 
 function gotoUrlBig(x) {
  if (linkbig[x].target != null)
    window.open(linkbig[x].url, linkbig[x].target);
  else
    location.href = linkbig[x].url;
  }

function makeArray(size) {
  this.length = size;
  return this;
}

function showStatus(x) {
  window.status = link[x].description;
}

function getImageName(x) {
  return link[x].image;
}

function getHeight(x) {
  return link[x].height;
}

while (1) {
  n = Math.round(Math.random() * 10);
  if (n >= 0 && n < maxsize)
    break;
}

while (1) {
  b = Math.round(Math.random() * 10);
  if (b >= 0 && b < maxsizebig)
    break;
}


var htmltag = "<a href='javascript:gotoUrl(" + n + ")'>";
htmltag += "<img border=0 width=" + iwidth + " height=" + getHeight(n) + "name=\"bannerimg\" src=\"" + getImageName(n) + "\"></a>";


var htmltagbig = "<a href='javascript:gotoUrlBig(" + b + ")'>";
htmltagbig += "<img border=0 width=" + iwidth + " height=" + linkbig[b].height + "name=\"bannerimg\" src=\"" + linkbig[b].image + "\"></a>";


function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}