var onLoadScript="";

function Browser() {

	var b=navigator.appName;
	if (b=="Netscape") this.b="ns";
	else if ((b=="Opera") || (navigator.userAgent.indexOf("Opera")>0)) this.b = "opera";
	else if (b=="Microsoft Internet Explorer") this.b="ie";
// I have disabled the following line, but something similar might be useful later, 
// but launching a popup window is more polite than this alert. 	
//if (!b) alert('Unidentified browser./nThis browser is not supported,');
	this.version=navigator.appVersion;
	this.v=parseInt(this.version);
	this.ns=(this.b=="ns" && this.v>=4);
	this.ns4=(this.b=="ns" && this.v==4);
	this.ns6=(this.b=="ns" && this.v==5);
	this.ie=(this.b=="ie" && this.v>=4);
	this.ie4=(this.version.indexOf('MSIE 4')>0);
	this.ie4up = (this.ie && this.v >= 4); 
	this.ns5up = (this.ns && this.v >= 5); 	
	this.ie5=(this.version.indexOf('MSIE 5')>0);
	this.ie5up = (this.ie5); 
	this.ie55=(this.version.indexOf('MSIE 5.5')>0);
	this.opera=(this.b=="opera");
	this.def=(this.ie||this.dom); // most used browsers, for faster if loops

	var ua=navigator.userAgent.toLowerCase();
	this.mac = (ua.indexOf("mac")!=-1);

	if (ua.indexOf("win")>-1) this.platform="win32";
	else if (ua.indexOf("mac")>-1) this.platform="mac";
	else this.platform="other";
}
var is = new Browser();
//  tiny extra css. these are ONLY used by old browsers. 
//  VAST majority of users will NEVER request these files. 
//  Even NS4 is around 7% of market and falling 
if (is.ns4 && is.mac==false) {
  var css = "<LINK rel='stylesheet' type='text/css' href='/css/browser/ns4.css'>\n";
	document.write(css);
} 
if (((is.ns4)||(is.ie4))&&( is.mac)) {
	var css = "<LINK rel='stylesheet' type='text/css' href='/css/browser/ns4mac.css'>\n";
	document.write(css);
}
if (is.ie4 && is.mac==false) {
	var css = "<LINK rel='stylesheet' type='text/css' href='/css/browser/ie4.css'>\n";
	document.write(css);
}

function LayerObject(divId) {
	this.name = divId;
	if (is.ns4) this.ob = eval("document." +divId);
	else if (is.ie4) this.ob = document.all(divId);
	else this.ob = document.getElementById(divId);
	this.x = 0;
	this.y = 0;
	this.width	=	this.getWidth();
	this.height	=	this.getHeight();
}
LayerObject.prototype.px = (is.version>=5)?"px":"";
LayerObject.prototype.hideSyntax = (is.ns4)? "hide":"hidden";
LayerObject.prototype.showSyntax = "visible";
 
 //  NS4::   Unbelievable, but document.layername.document.imgname works for img-in-layer-in document
 //  and it works for img in layer in table  in document. 
 //  but it doesnt work for img in layer in table in table in document.  
 //  Maybe a workaround exists, but it seems unlikely at this point. 
 //  The images MUST therefore be nested only one deep....   =|

LayerObject.prototype.getInlineLeft = function() {
	if (is.ns4) return this.ob.pageX;
	else if ((is.ie) || (is.opera)) {
		var elem = this.ob;
		var xPos = 0;
		var yPos = 0;
		while (elem.offsetParent != null) {
			xPos += elem.offsetLeft;
			yPos += elem.offsetTop;
			elem = elem.offsetParent;
		}
		if (is.mac) xPos += 2;
		return xPos;
	}	
	else return (this.ob.offsetLeft + document.body.offsetLeft);
}

LayerObject.prototype.getInlineTop = function() {
	if (is.ns4) return this.ob.pageY;
	else if ((is.ie) || (is.opera)) {
		var elem = this.ob;
		var yPos=0;
		while (elem.offsetParent != null) {
			yPos += elem.offsetTop;
			elem = elem.offsetParent;
		}
		if (is.mac) yPos += 2;
		return yPos;
	}
	else return (this.ob.offsetTop+ document.body.offsetTop);
}

//getWidth and getHeight works for both inline and positioned divs.
LayerObject.prototype.getWidth = function () {	
	if (is.ns4) return this.ob.clip.width;
	else if (is.opera) return this.ob.style.pixelWidth;
	else return this.ob.offsetWidth;
}
LayerObject.prototype.getHeight = function () {
	if (is.ns4) return this.ob.clip.height;
	else if (is.opera) return this.ob.style.pixelHeight;
	else return this.ob.offsetHeight;
}
LayerObject.prototype.hide = function() {
	if (is.ns4) this.ob.visibility = this.hideSyntax;
	else this.ob.style.visibility = this.hideSyntax;
}
LayerObject.prototype.show = function() {	
	if (is.ns4) this.ob.visibility = this.showSyntax;
	else this.ob.style.visibility = this.showSyntax;
}
LayerObject.prototype.moveLayerTo = function(toX, toY) {
	this.x = toX;
	this.y = toY;
}
LayerObject.prototype.updateLayer =  function() {
	if (is.ns4) {
		this.ob.left = Math.round(this.x) + this.px;
		this.ob.top = Math.round(this.y)+ this.px ;
	}
	else {
		this.ob.style.left = Math.round(this.x) + this.px;
		this.ob.style.top = Math.round(this.y)  + this.px;
	}
} 
//-----------------
function roll(divName, imgName, which) {
	var suffix = (which==1)?"on":"off"
	if ((is.ns4)&&(divName!=0)) {
		var imgObject = eval("document." + divName +".document.images['"+imgName +"']");
		imgObject.src = eval(imgName + "_" + suffix + ".src");
	}	
	else {
		document.images[imgName].src = eval(imgName + "_" + suffix + ".src");
	} 
}

function init() {
	if (onLoadScript) eval(onLoadScript);
}

// Workaround for the netscape resize problem --
// namely, on resize ns looses div positioning and 
// styles from css files.
// This checks to see if the window's dimensions have
// actually changed (because Netscape often fires a
// false onResize event when it forms scrollbars);
// if the dimensions have changed, page is reloaded
function resizefix(){
if((document.resizeFix.initWidth  != window.innerWidth) || 
	   (document.resizeFix.initHeight != window.innerHeight))
	{
		document.location = document.location;
	}
}

// This code creates a new object with properties
// to hold the current window width & height to be
// used in the event of a netscape resize
document.resizeFix = new Object();
if(is.ns4){
	document.resizeFix.initWidth  = window.innerWidth;
	document.resizeFix.initHeight = window.innerHeight;
window.onresize=resizefix;
}

//---------------- END GLOBAL.JS