//global_funcs.js

var error_shown = false;

//--------------------------------

function getPageX (ele) {
	var x = 0;
	var e = ele;
	while (e) {
		x += e.offsetLeft;
		e = e.offsetParent;
		}
	return x;
	}

//--------------------------------

function getPageY (ele) {
	var y = 0;
	var e = ele;
	while (e) {
		y += e.offsetTop;
		e = e.offsetParent;
		}
	return y;
	}

//--------------------------------

function errorbox (msg) {
	if (error_shown == true) return;
	alert ("ERROR: " + msg);
	error_shown = true;
	}

//--------------------------------

function apush (target, item) {
	target[target.length] = item;
	}

//--------------------------------

function do_nothing() {
	}

//--------------------------------

function imageRoll (img_out, img_over) {
	this.isImageRoll = true;
	this.iout = img_out;
	if (img_over) this.iover = img_over;
	else this.iover = this.iout;
	}

//--------------------------------

function divShow (s) {
  var e = document.getElementById(s);
  if (e) e.cbe.show();
  }

//--------------------------------

function divHide (s) {
  var e = document.getElementById(s);
  if (e) e.cbe.hide();
  }

//--------------------------------

function divMove (s, x, y) {
  var e = document.getElementById(s);
  if (e) e.cbe.moveTo (x, y);
  }

//--------------------------------

function glossaryDivShow (id, well) {
	var e = document.getElementById (well);
	if (e && e.cbe) {
		var e2 = document.getElementById (id);
		if (e2 && e2.cbe) {
			var x = getPageX(e.cbe.ele) + 30;
			var y = getPageY(e.cbe.ele) + (e.cbe.height()-e2.cbe.height()) - 15;
			e2.cbe.moveTo (x, y);
			}
		divShow (id);
		}
	}

//--------------------------------
// use these classes as prototype for buffering
// document writes (fixes ns4 bug)

function docBuffer_write (s) {
	this.docbuf += s;
	}

function docBuffer_writeln (s) {
	this.write (s + '\n');
	}

function docBuffer_writeBuffer (docptr) {
	var doc = docptr || document;
	doc.write (this.docbuf);
	}

function docBuffer() {
	this.docbuf = "";
	this.write = docBuffer_write;
	this.writeln = docBuffer_writeln;
	this.writeBuffer = docBuffer_writeBuffer;
	}

//--------------------------------
