/*
	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"; }
}

// 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;
}
// resize fix for ns4
var origWidth, origHeight;
if (document.layers) {
	origWidth = window.innerWidth; origHeight = window.innerHeight;
	window.onresize = function() { if (window.innerWidth != origWidth || window.innerHeight != origHeight) history.go(0); }
}

// avoid error of passing event object in older browsers
if (!document.getElementById && !document.all && !document.layers)
	event = "";
	

var page_loaded; // set true onload
function doFlexTip(id,e,sHTML,offx,offy) {
	if (!page_loaded) return;
	var el = layerHandler.getRefs(id);
	if (!el) return;
	layerHandler.hide(el); // just in case ...
	var cntnt = '<div class="info">' + sHTML + '</div>';
	
	// get position of onmouseover event and use it to position layer  
	e = (window.event)? window.event: e;
	if (e) {
	 var x =  (e.pageX)? e.pageX: (e.clientX)? e.clientX + getScrollX(): 0;
		var y =  (e.pageY)? e.pageY: (e.clientY)? e.clientY + getScrollY(): 0;
	 layerHandler.shiftTo(el, x+offx, y+offy);
	}
	layerHandler.writeLayer(el, cntnt);
	layerHandler.show(el);
}

function hideFlexTip(id) {
	if (!page_loaded) return;
	var el = layerHandler.getRefs(id);
	if (!el) return;
	layerHandler.hide(el);
}