/*
  dw_layer.js
  a few commonly-used functions for handling positioned divs
  used by Writing to Layers examples from www.dyn-web.com
  
  This code is from Dynamic Web Coding 
  at http://www.dyn-web.com/
  Copyright 2003 by Sharon Paine 
  See Terms of Use at http://www.dyn-web.com/bus/terms.html
  Permission granted to use this code 
  as long as this entire notice is included.
*/

layerHandler = {
  getRefs: function (id) {
    var el = (document.getElementById)? document.getElementById(id): (document.all)? document.all[id]: (document.layers)? document.layers[id]: null;
    if (el) el.css = el.style? el.style: el;
    return el;
  },
  
  writeLayer: function (el, cntnt) {
      if (typeof el.innerHTML!="undefined") {
          el.innerHTML = cntnt;
      } else if (document.layers) {
    			el.document.write(cntnt);
    			el.document.close();
      }
  },
  
  shiftTo: function (el,x,y) {
    var px = (document.layers || window.opera)? 0: "px";
    if (x != null) el.css.left = x + px;
    if (y != null) el.css.top = y + px;
  },

  show: function (el) { el.css.visibility = "visible"; },
  hide: function (el) { el.css.visibility = "hidden"; }
}

// adapted from act_api.js by Dan Pupius of www.13thparallel.org
var imageHandler = {
  imgs: new Array(),
  path: "",
  preload: function () {
    for (var i=0; i<arguments.length; i++) {
      var img = new Image();
      img.src = this.path + arguments[i];
      imageHandler.imgs.push(img);
    }
  }
}

// for browsers that don't support array push method
// from 13th parallel ( www.13thparallel.org )
if (Array.prototype && !Array.prototype.push) {
	Array.prototype.push = function() {
		for (var i=0; i<arguments.length; i++) this[this.length] = arguments[i];
		return this.length;
	};
}

// returns amount of vertical scroll
function getScrollY() {
	var sy = 0;
	if (document.documentElement && document.documentElement.scrollTop)
		sy = document.documentElement.scrollTop;
	else if (document.body && document.body.scrollTop) 
		sy = document.body.scrollTop; 
	else if (window.pageYOffset)
		sy = window.pageYOffset;
	else if (window.scrollY)
		sy = window.scrollY;
	return sy;
}

// returns amount of horizontal scroll
function getScrollX() {
	var sx = 0;
	if (document.documentElement && document.documentElement.scrollLeft)
		sx = document.documentElement.scrollLeft;
	else if (document.body && document.body.scrollLeft) 
		sx = document.body.scrollLeft; 
	else if (window.pageXOffset)
		sx = window.pageXOffset;
	else if (window.scrollX)
		sx = window.scrollX;
	return sx;
}