/*
	BrowserClass
	Last updated 2007-05-01
*/

function BrowserClass() {
	var ua = navigator.userAgent.toLowerCase(), p;
	this.isWin=(ua.indexOf("win")>=0);
	this.isMac=(ua.indexOf("mac")>=0);
	if (this.isIE=((p=ua.indexOf("msie"))>=0)) this.version = parseFloat(ua.substring(p+5,ua.length));
	if (this.isNetscape=((p=ua.indexOf("netscape"))>=0)) {
		p = ua.indexOf("/",p);
		if (p>0) this.version = parseFloat(ua.substring(p+1,ua.length));
		else this.version = 0;
	}
	if (this.isOpera=(p=ua.indexOf("opera")>=0)) {
		p = ua.indexOf("/",p);
		if (p>0) this.version = parseFloat(ua.substring(p+1,ua.length));
		else this.version = 0;
	}
	if (this.isNav4=(!this.isIE && !this.isNetscape && !this.isOpera)) {
		this.version = parseFloat(ua);
	}

	this.getObject = function(objectOrID, inDocument) {
		if (typeof(objectOrID)=="object") return(objectOrID);
		if (!inDocument) inDocument=document;
		if (inDocument.getElementById) return(inDocument.getElementById(objectOrID));
		else {
			var p,i,o;
			if (!(o=inDocument[objectOrID]) && inDocument.all)
				return(inDocument.all[objectOrID]);	// IE 4 & 5
			for (i=0;!o && i<inDocument.forms.length;i++)
				o=inDocument.forms[i][objectOrID]; // Nav: search forms
			for (i=0;!o && inDocument.layers && i<inDocument.layers.length;i++)
				o=getObject(objectOrID,inDocument.layers[i].document);	// Nav: search layers
			return(o);
		}
	}
	this.displayElement = function(objectOrID,displayStyle,toggle) {
		if (!displayStyle) displayStyle = "block";
		var o = this.getObject(objectOrID);
		if (o) {
			if (toggle) {
				if (o.style.display=="none" || o.style.display=="") o.style.display = displayStyle;
				else o.style.display = "none";
			} else o.style.display = displayStyle;
		}
	}
	this.applyRollover = function(buttonLinkObjectOrID,stateNames,rolloverSuffix,actionFunction,deactivatedSuffix,beginDeactivated) {
		if (this.isIE) {
			var buttonLinkElement = this.getObject(buttonLinkObjectOrID);
			if (buttonLinkElement) return(new MultipleStateButton(buttonLinkElement,stateNames,rolloverSuffix
																  ,actionFunction,deactivatedSuffix,beginDeactivated));
			else return(null);
		} else return(null);
	}
	this.changeRolloverState = function(buttonLinkObjectOrID, stateName) {
		var buttonLinkElement = this.getObject(buttonLinkObjectOrID);
		if (buttonLinkElement && buttonLinkElement.multipleStateButton) buttonLinkElement.multipleStateButton.setState(stateName);
	}
	this.setStyleProperty = function(objectOrID,styleProperty,styleValue) {
		var o = this.getObject(objectOrID);
		if (o && o.style) o.style[styleProperty] = styleValue;
	}
	this.getStyleProperty = function(objectOrID,styleProperty) {
		var o = this.getObject(objectOrID);
		if (o && o.style) return(o.style[styleProperty]);
		else return(null);
	}
	this.setElementText = function(objectOrID,newText) {
		var o = this.getObject(objectOrID);
		if (o && o.innerText) o.innerText = newText;
		else if (o && o.childNodes && o.childNodes.length>0) o.childNodes[0].nodeValue = newText;
	}
	this.getElementText = function(objectOrID) {
		var o = this.getObject(objectOrID);
		if (o && o.innerText) return(o.innerText);
		else if (o && o.childNodes && o.childNodes.length>0) return(o.childNodes[0].nodeValue);
		else return(null);
	}
	this.getEvent = function(eventArgument) {
		return(eventArgument ? eventArgument : (window.event ? window.event : null));
	}
	this.getEventTarget = function(eventObject) {
		return(eventObject && eventObject.target ? eventObject.target : (eventObject && eventObject.srcElement ? eventObject.srcElement : null));
	}
	this.getMouseX = function(eventObject) {
		return(eventObject.pageX ? eventObject.pageX : eventObject.clientX);
	}
	this.getMouseY = function(eventObject) {
		return(eventObject.pageY ? eventObject.pageY : eventObject.clientY);
	}

	return(this);
}

var Browser = new BrowserClass();

