/* Version 1.00 - 06/01/99 */
/* Version 1.01 - 09/27/99 */
/*    GetTop - uses offsetLeft instead of style.pixelLeft (IE only)            */
/*    GetLeft - uses offsetTop instead of style.pixelTop (IE only)             */
/*    getTopLeftOnPage - returns a Point to a topleft position (by CP)         */
/*    setTopLeftOnPage - takes a point and object and sets its position (by CP)*/
/*    definition of Point - creates a Point object (by CP)                     */

function Point(x, y) {
	this.x = x
	this.y = y
}

function browser_SetVisibility(aObject, bShow){
	if(this.IE || this.NS6){
		aObject.style.visibility = (bShow ? "visible" : "hidden");
	} else {
		aObject.visibility = (bShow ? "show" : "hide");
	}
}

function browser_GetVisibility(aObject){
	if(this.IE){
		return( (aObject.style.visibility == "visible"?true:false) );
	} else {
		return( (aObject.visibility == "show"?true:false) );
	}
}

function browser_SetPosition(aObject, aTop, aLeft){
	if(this.IE){
		aObject.style.pixelTop = aTop;
		aObject.style.pixelLeft = aLeft;
	} else {
		aObject.top = aTop;
		aObject.left = aLeft;
	}
}

function browser_GetLeft(aObject){
	return( (this.IE ? aObject.offsetLeft : aObject.x) );
}

function browser_GetTop(aObject){
	return( (this.IE ? aObject.offsetTop : aObject.y) );
	}
	
function browser_getTopLeftOnPage(aObject){
	if (this.IE) {
		var t = aObject;
		if (t == null) 
			return null;
		var x = 0;
		var y = 0;
		while (t.tagName != 'BODY') {
			x += t.offsetLeft;
			y += t.offsetTop;
			t = t.offsetParent;
		}
		return new Point(x, y);
	}	else {
		return new Point(aObject.pageX, aObject.pageY);
	}
}

function browser_setTopLeftOnPage(aObject, pt) {
	if (this.IE) {
		var pPt = B.getTopLeftOnPage(aObject.offsetParent);
		aObject.style.left = pt.x - pPt.x;
		aObject.style.top  = pt.y - pPt.y;
	}	else {
		aObject.pageX = pt.x;
		aObject.pageY = pt.y;
	}
}
		
/* A browser specific object... */
function browserObject(){

	// Initialize Variables
	this.type = "Unknown";
	this.IE = false;
	this.IE4 = false;
	this.IE5 = false;
	this.NS = false;
	this.NS4 = false;
	this.NS6 = false;
	this.range = "";
	this.style = "";
	this.canCache = true;
	this.buzy = false;
	
	// Methods
	this.getLeft = browser_GetLeft;
	this.getTop = browser_GetTop;
	this.getVisibility = browser_GetVisibility;
	this.setPosition = browser_SetPosition;
	this.setVisibility = browser_SetVisibility;
	this.getTopLeftOnPage = browser_getTopLeftOnPage;
	this.setTopLeftOnPage = browser_setTopLeftOnPage;

	// some actual logic
	this.version = parseFloat(navigator.appVersion);
	ua = navigator.userAgent;
	iLoc = ua.indexOf('MSIE');
	if(iLoc >= 0){
		this.version = parseFloat(navigator.userAgent.substring(iLoc+4, iLoc+4+5));
		this.IE = true;
		this.IE4 = this.version >= 4;
		this.IE5 = this.version >= 5;
		this.range = ".all";
		this.style = ".style";
		this.type = "Internet Explorer";
	} else {
		iLoc = ua.indexOf('Mozilla/');
		if(iLoc >= 0){
			iLoc2 = ua.indexOf('Netscape6/');
			if(iLoc2 >= 0){
				this.version = parseFloat(navigator.userAgent.substring(iLoc+10, iLoc+10+3));
				this.NS = true;
				this.NS6 = true;
				this.type = "Netscape Navigator";
            } else {
                iLoc = ua.indexOf('Firefox/');
                if (iLoc >= 0) {
                    this.version = parseFloat(navigator.userAgent.substring(iLoc + 8, iLoc + 8 + 5));
                    this.NS = true;
                    this.NS4 = false;
                    this.NS6 = true;
                    this.type = "Firefox";
                } else {
                    this.version = parseFloat(navigator.userAgent.substring(iLoc + 8, iLoc + 8 + 5));
                    this.NS = true;
                    this.NS4 = this.version >= 4;
                    this.type = "Netscape Navigator";
                }                
			}
		}
	}
}

var B = new browserObject();
