
/* JavaScript function to support Good/Bad/Ugly files.

   NOTE: This file is automatically generated from XML source files - do
   directly edit by hand.

   Copyright 2007 - Redali Consulting, Inc */

// Array of ALL published Good/Bad/Ugly pages
var GBU = new Array();

/* Adds a new entry to the array of GBU objects.
 *
 * name - Name of page. Like "rc18b" for "gbu/rc18b.html".
 * iconFile - Name of icon file. Like "rc18b-small.jpg".
 * iconWidth - Width of icon in pixels.
 * iconHeight - Height of icon in pixels.
 */

function addGbuEntry(name, title, iconFile, iconWidth, iconHeight) {

  var gbue = new Object();
  gbue._Name = name;
  gbue._IconFile = iconFile;
  gbue._IconWidth = iconWidth;
  gbue._IconHeight = iconHeight;
  gbue._Title = title;

  GBU.push(gbue);
}

/* Chooses a random good/bad/ugly page (from published collection) and
 * updates the necessary attributes of a <a> entity and
 *  <img> entity to allow end user to jump to page.
 *
 * rootDir - Relative path to root directory ("..").
 *
 * ida - ID of <a> entity to update "title" and "href" of (or null if you
 * don't want it updated.
 *
 * idimg - ID of <img> entity to update "src", "width",
 * "height", "title", and "alt" of (or null if you don't want it
 * updated.
 */

function rollGbu(rootDir, ida, idimg) {
  var idx = Math.floor(Math.random() * GBU.length);
  var gbue = GBU[idx];

  if (ida != null) {
    var e = document.getElementById(ida);
    if (e != null) {
      e.href = rootDir + "/gbu/" + gbue._Name + ".gbu.html";
      e.title = gbue._Title;
    }
  }

  if (idimg != null) {
    var e = document.getElementById(idimg);
    if (e != null) {
      e.src = rootDir + "/gbu/images/" + gbue._IconFile;
      e.width = gbue._IconWidth;
      e.height = gbue._IconHeight;
      e.title = gbue._Title;
      e.alt = gbue._Title;
    }
  }

}

/* Add list of plublished good/bad/ugly documents */

// A Poorly Labeled Boat Lift
addGbuEntry("boat-lift", "A Poorly Labeled Boat Lift", "boat-lift-small.jpg", 120, 120);

// The Logitech Harmony 659 Remote
addGbuEntry("harmony659", "The Logitech Harmony 659 Remote", "harmony659-small.jpg", 120, 120);

// A useful tool when doing web development
addGbuEntry("html-validator", "A useful tool when doing web development", "html-validator-small.gif", 120, 120);

// Model RC18B Remote Controlled Car
addGbuEntry("rc18b", "Model RC18B Remote Controlled Car", "rc18b-small.jpg", 120, 120);

// The trap (as in plumbing)
addGbuEntry("trap", "The trap (as in plumbing)", "trap-small.jpg", 120, 120);

// Including Unit Prices
addGbuEntry("unitprices", "Including Unit Prices", "unitprices-small.jpg", 120, 120);

// Well Designed Wrapping Paper
addGbuEntry("wrapping-paper", "Well Designed Wrapping Paper", "wrapping-paper-small.jpg", 120, 120);
