function JumpTo(jumpURL)
 {
 top.location = jumpURL;
 }
 
function FlipTo(flipURL)
 {
  self.location = flipURL;
 }
 
function GoBack( aForm )
 {
  if (aForm.name == 'canceled')
    return false;
  else 
    return true;
 }
 
function OpenHelpWin( where )
{
 if (typeof(where)=="undefined") {
  alert("There is no context help available for this topic.");
 } else {
  win=window.open(where, 'help',
      'width=800,height=1080,scrollbars=yes,resizable=yes,location=yes');
  doc=win.document.open();
  doc.write('Document Loading... Please Wait');
  doc.close();
  win.location = where;
  win.status   = where;
 };
 return true;
}
 
/*
 * get_obj -	obtain obj in DoM independent manner
 */
function GetObj(name) {
  if (document.getElementById) {
    return document.getElementById(name);
  } else if (document.all) {
    return document.all[name];
  } else if (document.layers) {
    return document.layers[name];
  } else {
    alert('**gok');
    return null;
  }
}

/*
 * compile a list of nodes with the specified class.
 *
 * Input:
 *	a	- array to use for results (null initially)
 *	d	- node (document initially)
 *	c	- class name
 *
 * Returns an array with all the nodes with that class.
 */

function ListElementsByClass(a, d, c, m) {
  var i, j;
  var n;

  if (a == null) {
     a = new Array;
     j = 0;
  } else {
     j = a.length;
  }

  n = d.childNodes;

  if (d.nodeType == 1) {
      if (d.className) {
          if (m(c, d.className)) {
              a[j++] = d;
	      }
	  }
  }

  for (i = 0; i < n.length; ++i) {
    ListElementsByClass(a, n[i], c, m);
  }

  return a;
}

/*
 * CoyoteInit - initialisation
 */

function CoyoteInit(c, m, name) {

/*
 * window.coyote is our namespace.
 */

  if (window.coyote == null) {
    window.coyote = new Object;
  }

  var ns = window.coyote;

/*
 * w.c.equal is an associative array indexed by class name
 * of arrays of document elements having that class name.
 */

  if (ns.classes == null) {
    ns.classes = new Object;
  }

  if (ns.classes[name] == null) {
    ns.classes[name] = new Object;
  }

  if (ns.classes[name][c] == null) {

/*
 * compile a list of the nodes with the indicated class.
 * (Hopefully the c,m pairs will remain distinct)
 */

    ns.classes[name][c] = ListElementsByClass(null,document,c,m);
  }
  return ns.classes[name][c];
}

/*
 * Equal_p -	predicate
 */

function Equal_p(a, b) {
  return (a == b);
}

/*
 * ClassMatch_p -	predicate
 */

function ClassMatch_p(a, b) {
  var c = b.split(' ');
  var i;

  for (i=0; i < c.length; ++i) {
    if (c[i] == a) {
      return true;
    }
  }

  return false;
}

/*
 * SetVisibility - set the visibility of all elements in the document
 *		       matching the class to the specified value.
 *
 * First time called, it will compile a list of all the elements,
 * but it retains this so will be faster subsequently.
 *
 * We keep stuff in the window.coyote object to avoid namespace issues.
 */

function SetVis(c, how) {
  var n;
  var i;

  n = CoyoteInit(c, ClassMatch_p, 'classmatch');

  for (i = 0; i < n.length; ++i) {
    n[i].style.visibility = how;
  }
}

function SetDisplay(c, how) {
  var n;
  var i;

  n = CoyoteInit(c, ClassMatch_p, 'classmatch');

  for (i = 0; i < n.length; ++i) {
    n[i].style.display = how;
  }
}

/*
 * ShowClass -	show elements having specified class
 */

function ShowClass(c) {
  SetDisplay(c, '');
}

/*
 * HideClass -	Hide(collpase) elements having specified class
 */

function HideClass(c) {
  SetDisplay(c, 'none');
}

/*
 * HideClassBits -	hide all elements whose class hex ID matches
 */

function Prefix_p(a, b) {
  return b.indexOf(a) == 0;
}

function HideClassBits(mask) {
  var n;
  var i;
 
  n = CoyoteInit('0x', Prefix_p, 'prefix');

  for (i = 0; i < n.length; ++i) {
    var cbits;

    cbits = parseInt(n[i].className.slice(2), 16);

    if (mask & cbits) {
      n[i].style.display = 'none';
    }
  }
}

function ShowClassBits(mask) {
  var n;
  var i;
 
  n = CoyoteInit('0x', Prefix_p, 'prefix');

  for (i = 0; i < n.length; ++i) {
    var cbits;

    cbits = parseInt(n[i].className.slice(2), 16);

    if (mask & cbits) {
      n[i].style.display = '';
    }
  }
}


/*
 * Inherit - fuction for the inheritance buttons.
 *
 * Input:
 *	o	- button object
 *	setting	- what the inherited setting was
 *	input	- the name on the checkbox input we are managing
 */

function Inherit(o, setting, input) {
  var cb = o.form[input];

  if (o.value == 'explicit') {
    o.value = 'inherited';

    if (setting) {
      cb.checked = true;
    } else {
      cb.checked = false;
    }
    cb.disabled = true;
    cb.value = 'inherited';
  } else if (o.value == 'inherited') {
    o.value = 'explicit';
    cb.disabled = false;
    cb.value = 'explicit';
  }
}

/*
 * InheritCB - fuction for the inheritance check box.
 *
 * Input:
 *	o	- button object
 *	setting	- what the inherited setting was
 *	input	- the name on the checkbox input we are managing
 */

function InheritCB(o, setting, input) {
  var cb = o.form[input];

  if (o.checked) {
    if (setting) {
      cb.checked = true;
    } else {
      cb.checked = false;
    }
    cb.disabled = true;
  } else {
    cb.disabled = false;
  }
  UpdateDisplay();
}
