/*******************************************************************
	Browser-Independent Layer Handler Version 2.01
	
	©2004 A+R Media Studio
	http://www.AandRmediastudio.com
	
	written by Rudy Dominguez (rudy@AandRmediastudio.com)
	
	These scripts are free software; you can redistribute it and/or
	modify it under the terms of the GNU General Public License
	as published by the Free Software Foundation; either version 2
	of the License, or (at your option) any later version.

	This program is distributed in the hope that it will be useful,
	but WITHOUT ANY WARRANTY; without even the implied warranty of
	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
	GNU General Public License for more details.
	
*******************************************************************/

var bilh = new BILH();

function BILH(){
	this.ver = navigator.appVersion
	this.dom = (document.getElementById)? 1 : 0
	
	this.ie5 = ((this.ver.indexOf("MSIE 5") >= 0) && this.dom)? 1 : 0;
	this.ie4 = (document.all && !this.dom)? 1 : 0;
    this.ns6 = (this.dom && parseInt(this.ver) >= 6)? 1 : 0;
	this.ns5 = (this.dom && parseInt(this.ver) >= 5)? 1 : 0;
	this.ns4 = (document.layers && !this.dom)? 1 : 0;
		
	this.refs = new Object();
	
	this.useMenu = true;
	this.current = "";
	this.timerID = null;
	this.navImgID = "";
	this.defaultMenu = "";
}

BILH.prototype.register = function() {
	var layerID, i;
	
	if (arguments.length > 0) 
		for (i=0; i < arguments.length; i++) {
			if (typeof (arguments[i]) == "string") {
				layerID = arguments[i];
				this.refs[layerID] = new Object();
				
				this.refs[layerID].name = layerID;
				this.refs[layerID].layer = (this.dom)? document.getElementById(layerID) : (this.ie4)? document.all[layerID] : (this.ns4)?  document[layerID] : 0;
				this.refs[layerID].style = (this.dom)? document.getElementById(layerID).style : (this.ie4)? document.all[layerID].style : (this.ns4)?  document[layerID] : 0;
			}
		}
		
	return;
}

BILH.prototype.isVisible = function(layerID) {	
	return (this.refs[layerID].style.visibility == "visible" || this.refs[layerID].style.visibility == "show");
}

BILH.prototype.show = function(layerID) {
	if (typeof(this.refs[layerID]) != "undefined") {
		this.refs[layerID].style.visibility = (this.ns4)? "show" : "visible";
		if (this.useMenu) this.current = layerID;
	}
	
	return;
}

BILH.prototype.hide = function(layerID) {
	if (typeof(this.refs[layerID]) != "undefined") {
		this.refs[layerID].style.visibility = (this.ns4)? "hide" : "hidden";
		
	}
	
	return;
}

BILH.prototype.hideMenu = function(layerID) {
	if (this.useMenu) {
		this.timerID = setTimeout("bilh.hideMenuAll();", 250);
	}
	
	return;
}

BILH.prototype.hideMenuAll = function(hideDefault) {
	var item;
	
	if (re && (this.navImgID != "")) re.setOff(this.navImgID);
	
	if (this.useMenu) {
		stuntSwap("fLayer1",true);
		stuntSwap("fLayer2",true);
		for (item in this.refs) {
			this.hide(this.refs[item].name);
		}

		if ((this.defaultMenu != "") && !hideDefault) this.show(this.defaultMenu);
	}
	
	return;
}

BILH.prototype.showMenu = function(layerID, navImgID) {
	if (this.useMenu) {
		clearTimeout(this.timerID);
		
		this.hideMenuAll(true);
		stuntSwap( ((navImgID == "navcontact") || (navImgID == "navpartners") || (navImgID == "navnews"))? "fLayer2" : "fLayer1" );
		if (navImgID == "navnews") stuntSwap("fLayer1");
		
		if (layerID != "") this.show(layerID);
		
		if (re && re.useOnState && (typeof(navImgID) != "undefined")) {
			re.setOn(navImgID);
			this.navImgID = navImgID;
		}

		if (re && re.useOverState && (typeof(navImgID) != "undefined")) {
			re.setOver(navImgID);
			this.navImgID = navImgID;
		}
	}
	
	return;
}

BILH.prototype.getLeft = function(layerID){
	return (document.getElementById)? 
				 (document.all || !this.refs[layerID].layer.parentNode)?
					this.refs[layerID].layer.offsetLeft : 
					(this.refs[layerID].layer.offsetLeft - this.refs[layerID].layer.parentNode.offsetLeft) 
				:(document.all)?
					this.style.pixelLeft : 
					this.style.left;
}

BILH.prototype.setLeft = function(layerID, x){
	if(!isNaN(x)) this.refs[layerID].style.left = (document.getElementById)? new String(x + "px") : x;
}

BILH.prototype.getHeight = function(layerID)
{	return (document.getElementById) ? this.refs[layerID].layer.offsetHeight
		: (document.all) ? (this.refs[layerID].style.pixelHeight)
			? this.refs[layerID].style.pixelHeight
				: this.refs[layerID].layer["clientHeight"] : this.refs[layerID].style.clip 
					? (this.refs[layerID].style.clip.bottom - this.refs[layerID].style.clip.top)
						: (this.refs[layerID].layer.height) ? this.refs[layerID].layer.height : -1;
}

BILH.prototype.setHeight = function(layerID, newHeight){
	if(!isNaN(newHeight))
		(document.getElementById)?
			this.refs[layerID].style.height = (newHeight + "px") :
			(document.all)?
				this.refs[layerID].style.pixelHeight = newHeight :
				this.refs[layerID].style.clip.bottom += (newHeight - this.refs[layerID].layergetHeight());
}

BILH.prototype.getTop = function(layerID)
{	return (document.getElementById) ? 
				 (document.all || !this.refs[layerID].layer.parentNode)?
					this.refs[layerID].layer.offsetTop : 
					(this.refs[layerID].layer.offsetTop - this.refs[layerID].layer.parentNode.offsetTop) 
				:(document.all)?
					this.refs[layerID].style.pixelTop : 
					this.refs[layerID].style.top;
}

BILH.prototype.setTop = function(layerID, y){	
	if(!isNaN(y)) this.refs[layerID].top = (document.getElementById)?  (y + "px") : y;
}