/* ***************************************************************
	CROSS BROWSER FUNCTIONS

	Copyright (c) 2002 - 2003 Nequalsone, LLC.  All rights reserved.

    Author: Hollie Buffington
    Version: $Id: cross.js,v 2.0 2003/07/24 19:53:38 hollie Exp $
****************************************************************** */

// Determine Browser Type (stored in B_Type obj.)
var B_Type = new crossBrowserType();
function crossBrowserType() {
	this.IE = false;
	this.NS4 = false;
	this.NS6 = false;
	this.id = "";

	if (document.all) {this.IE = true; this.id = "IE";}
	else if (document.getElementById) {this.NS6 = true; this.id = "NS6";}
	else if (document.layers) {this.NS4 = true; this.id = "NS4";}
}

// Return Mouse Position
var crossMouseX, crossMouseY;
if (B_Type.NS4) document.captureEvents(Event.MOUSEMOVE);

function crossMousePosition(e) {
	if (B_Type.IE) {
		crossMouseX=crossGetScroll("x") + event.clientX //event.x + document.body.scrollLeft;
		crossMouseY=crossGetScroll("y") + event.clientY - 12 //event.y + document.body.scrollTop;
	}
	else {crossMouseX=e.pageX; crossMouseY=e.pageY;}
}

// Return Reference to DHTML object basied on ID
function crossGetObject(id) {
	var obj = null;
	if (B_Type.IE) obj=document.all[id];
	else if (B_Type.NS6) obj=document.getElementById(id);
	else if (B_Type.NS4) obj=document.layers[id];
	return obj;
}

// Write text/html in DHTML object
function crossWrite(obj, text) {
	if (B_Type.IE) obj.innerHTML = text;
	else if (B_Type.NS6) obj.innerHTML = text;
	else if (B_Type.NS4) {
		obj.document.open();
		obj.document.write(text);
		obj.document.close();
	}
}

// Determine available window width
function crossInnerWindowWidth() {
	var val;
	if (B_Type.IE) val=document.body.clientWidth;
	else if (B_Type.NS6) val=window.innerWidth;
	else if (B_Type.NS4) val=window.innerWidth;
	return val;
}

// Determine actual window width
function crossOuterWindowWidth() {
	var val;
	if (B_Type.IE) val=document.body.offsetWidth;
	else if (B_Type.NS6) val=window.outerWidth;
	else if (B_Type.NS4) val=window.outerWidth;
	return val;
}

// Determine available window height
function crossInnerWindowHeight() {
	var val;
	if (B_Type.IE) val=document.body.clientHeight;
	else if (B_Type.NS6) val=window.innerHeight;
	else if (B_Type.NS4) val=window.innerHeight;
	return val;
}

// Determine Scroll-position, "y" = vertical, "x" = horizontal
function crossGetScroll(axis) {
	var val;
	if (!axis || axis == "y") {  // vertical axis
		if (B_Type.IE){
			if (document.documentElement && document.documentElement.scrollTop) val = document.documentElement.scrollTop;
			else if (document.body)val = document.body.scrollTop
		}else if (B_Type.NS6) val=window.pageYOffset;
		else if (B_Type.NS4) val=window.pageYOffset;
	}
	else {  // horizontal axis
		if (B_Type.IE){
			if (document.documentElement && document.documentElement.scrollTop) val = document.documentElement.scrollLeft;
			else if (document.body) val = document.body.scrollLeft;
		}else if (B_Type.NS6) val=window.pageXOffset;
		else if (B_Type.NS4) val=window.pageXOffset;
	}
	return val;
}

// Set Scroll-position
function crossSetScroll(x, y) {
	window.scrollTo(x, y);
}


// Object Positioning x/y
function crossMoveTo(obj, x, y) {
	if (B_Type.IE) {obj.style.pixelLeft=x; obj.style.pixelTop=y;}
	else if (B_Type.NS4) {obj.left=x; obj.top=y;}
	else if (B_Type.NS6) {obj.style.left=x+"px"; obj.style.top=y+"px";}
}

// ODetermine object-position
function crossGetPositionX(obj) {
	if (B_Type.IE) return obj.style.pixelLeft;
	else if (B_Type.NS4) return obj.left;
	else if (B_Type.NS6) return parseInt(obj.style.left);
}
function crossGetPositionY(obj) {
	if (B_Type.IE) return obj.style.pixelTop;
	else if (B_Type.NS4) return obj.top;
	else if (B_Type.NS6) return parseInt(obj.style.top);
}

// Show object (set visible)
function crossShowObject(obj) {
	if (B_Type.IE || B_Type.NS6) {obj.style.visibility="visible";}
	else if (B_Type.NS4) {obj.visibility="show";}
}
// Hide Object (set hidden)
function crossHideObject(obj) {
	if (B_Type.IE || B_Type.NS6) {obj.style.visibility="hidden";}
	else if (B_Type.NS4) {obj.visibility="hide";}
}


// Set background-color
function crossBackgroundColor(color, obj) {
	if (typeof obj == "undefined") {document.bgColor=color; return;}
	if (B_Type.IE || B_Type.NS6) {obj.style.backgroundColor=color;}
	else if (B_Type.NS4) {obj.document.bgColor=color;}
}


// Set background-picture
function crossBackgroundImage(obj, img) {
	if (B_Type.IE || B_Type.NS6) {obj.style.backgroundImage="url(" + img + ")";}
	else if (B_Type.NS4) {obj.background.src = img;}
}
