// BEGIN definition for ToggleImage object

function ToggleImage (imageName, urlOn, urlOff, relBase) {
  relBase = relBase ? relBase : '';
  this.name = imageName;
  this.onImage = new Image();
  this.onImage.src = relBase + urlOn;
  this.offImage = new Image();
  this.offImage.src = relBase + urlOff;
}

new ToggleImage('', '', '', '');

function ToggleImage_on (msg) {
  if (document.images) {
    document[this.name].src = this.onImage.src;
  }
  window.status = msg;
  return true;
}
ToggleImage.prototype.on = ToggleImage_on;

function ToggleImage_off () {
  if (document.images) {
    document[this.name].src = this.offImage.src;
  }
  window.status = '';
  return true;
}
ToggleImage.prototype.off = ToggleImage_off;

// END definition for ToggleImage object

function changeImages(imgSet, action) {
  if (document.images) {
    //document[imgSet.name].src = eval("imgSet." + action + ".src");
  }
}

// Popup window function

function openAnyWindow(url, name) {
  var l = openAnyWindow.arguments.length;
  var w = "";
  var h = "";
  var features = "";
  for (i=2; i<l; i++) {
    var param = openAnyWindow.arguments[i];
    if ( (parseInt(param) == 0) || (isNaN(parseInt(param))) ) {
      features += param + ',';
    }
    else {
      (w == "") ? w = "width=" + param + "," : h = "height=" + param;
    }
  }
  features += w + h;
  var code = "popupWin = window.open(url, name";
  if (l > 2) code += ", '" + features + "'";
  code += ")";
  eval(code);
}

// function to request a URL in another window
// grabbed from http://developer.irt.org/script/40.htm
// and hacked by Dave Cash (2002/05/28)

function load(url,target,options) {
  if (target != '') {
    target.window.location.href = url;
    target.window.focus();
    if (options.indexOf('close') != -1) {
      top.close();
    }
  }
  else {
    window.location.href = url;
    window.focus();
  }
}


/* JavaScript redirect for variable targets                  *
 *  by Dave Cash <dave@gnofn.org> 2000/06/20, copyleft 2000  *
 *  distributed under terms of the GNU Public License        *
 *  compatible with Netscape 3.04+ and MSIE 3.02+            *
 *  please use and redistribute with these comments          *
 *                                                           *
 * Values in the form's option elements should consist of    *
 * a target frame name followed by a colon and then a        *
 * fully-quallified URL.  For example, to redirect the       *
 * contents of the frame (or window) named 'main' to the     *
 * the www.inequality.org web site, form an option element   *
 * as follows:                                               *
 *                                                           *
 *   <option value="main:http://www.inequality.org">         *
 *                                                           *
 * To redirect out of a framed context, simply put nothing   *
 * before the first colon, thusly:                           *
 *                                                           *
 *   <option value=":http://www.inequality.org">             *
 *                                                           *
 * Dig?                                                      */

function selectLaunch (formName) {
  choice = document.forms[formName].choice.options[document.forms[formName].choice.selectedIndex].value;
  target = choice.substring(0, choice.indexOf('	'));
  url = choice.substring(choice.indexOf('	') + 1, choice.length);
  if (target=='new') {
    code='top.open(url, target)';
  } 
  else if (target) {
    code = 'top.' + target + '.window.location = "' + url + '";';
  }
  else {
    code = 'top.window.location = "' + url + '";';
  }
  eval(code);
}
