﻿// Gourmet Outfitters
// @2007
//
// Main Javascript Functions file
//

function RO_GetObjectByID(id,o) {
  var c, el, els, f, m, n;
  if (!o) o = document;
  if (o.getElementById) el = o.getElementById(id);
  else if (o.layers) c = o.layers;  
  else if (o.all) el = o.all[id];
  if (el) return el;
  if (o.id==id || o.name==id) return o;
  if (o.childNodes) c = o.childNodes;
  if (c) for(n=0; n<c.length; n++) {
    el=RO_GetObjectByID(id,c[n]);
    if (el) return el;
  }
  f = o.forms;
  if (f) for(n=0; n<f.length; n++) {
    els = f[n].elements;
    for(m=0; m<els.length; m++) {
      el=RO_GetObjectByID(id,els[n]);
      if (el) return el;
    }
  }
  return null;
}

function PreLoadImages() {
  var doc = document;
  if (doc.images) {
    if (!doc.preloadimages) doc.preloadimages = new Array();
    for (var xcntr=0; xcntr<arguments.length; xcntr++) {
      doc.preloadimages[xcntr] = new Image();
      doc.preloadimages[xcntr].src = arguments[xcntr];
    }
  }
}

function SwapImage() {
  var args = arguments, elm;
  elm = RO_GetObjectByID(args[0]);
  if (elm) {
    elm.src = args[1];
  }
}

function showDiv() {
  var elm = RO_GetObjectByID(arguments[0]);
  if (elm.style.visibility == 'hidden') {
    elm.style.visibility = 'visible';
    elm.style.display = 'inline';
  } else {
    elm.style.visibility = 'hidden';
    elm.style.display = 'none';
  }
  return true;
}

