var browser = new dudiBrowser();
	
function dudiBrowser() {
	var agt=navigator.userAgent.toLowerCase();

	// is DOM
	this.DOM = document.getElementById?1:0;

	// is IE
	this.IE = document.all?1:0;

	// is IE
	this.IE5 = this.IE?(document.hasFocus?0:1):0;

	// is NS
	this.NS = (!this.DOM && !this.IE)?1:0

	// is on mac
	this.MAC = (agt.indexOf("mac")!=-1);
	
	// is on mac safari
	this.SAFARI = (agt.indexOf("safari")!=-1);
	
	// is on win 98
    this.WIN9X = (agt.indexOf("windows 9")!=-1);

}
	
function element(id) {
	this.id = id;
	this.obj = browser.NS?document.layers[id]:browser.DOM?document.getElementById(id):document.all[id];
	if(this.obj) {
		this.elm = browser.NS?eval("document."+id):document;
		this.css = browser.NS?eval("document."+id):(browser.DOM || browser.IE)?this.obj.style:"NaN";
		this.w = browser.NS?this.css.clip.width:browser.DOM?this.obj.offsetWidth:browser.IE?this.css.pixelWidth:"NaN";
		this.h = browser.NS?this.css.clip.height:browser.DOM?this.obj.offsetHeight:browser.IE?this.css.pixelHeight:"NaN";
		this.setH = function (height) {this.css.height = height}
		this.setW = function (width) {this.css.width = width}
		this.getH = function () {return browser.NS?this.css.clip.height:browser.DOM?this.obj.offsetHeight:browser.IE?this.css.pixelHeight:"NaN";}
		this.getW = function () {return browser.NS?this.css.clip.width:browser.DOM?this.obj.offsetWidth:browser.IE?this.css.pixelWidth:"NaN";}
		this.show = function () {this.css.display = "block";}
		this.hide = function () {this.css.display = "none";}
		this.setPT = function (height) {this.css.paddingTop = height;}
		this.setMT = function (height) {this.css.marginTop = height;}
		this.setPB = function (height) {this.css.paddingBottom = height;}
		this.setMB = function (height) {this.css.marginBottom = height;}
		this.getMT = function () { 
			tempMT = parseInt(this.css.marginTop);
			return (isNaN(tempMT))?0:tempMT;
		}
		this.getPT = function () { 
			tempPT = parseInt(this.css.paddingTop);
			return (isNaN(tempPT))?0:tempPT;
		}
		this.getMB = function () { 
			tempMB = parseInt(this.css.marginBottom);
			return (isNaN(tempMB))?0:tempMB;
		}
		this.getPB = function () { 
			tempPB = parseInt(this.css.paddingBottom);
			return (isNaN(tempPB))?0:tempPB;
		}
		
		if(this.obj.tagName == "IFRAME") {
			this.setOnload = function (func) {
				if(this.obj.addEventListener) {
				
					this.obj.addEventListener("load", func, false);
				} else if(this.obj.attachEvent) {
				
					this.obj.detachEvent("onload", func); // Bug fix line
					this.obj.attachEvent("onload", func);
				}
			}	
		}
	}
	
	return this;
}

function showHideSelect(show) {	
	if(browser.IE) {
		var aSel = document.getElementsByTagName("SELECT");
		
		for(var x=0;x<aSel.length; x++) {
		
			if(show) {
				aSel[x].style.display = "inline";
			} else {
				aSel[x].style.display = "none";
			}
		} 
	}
}


var BrowserDetect = {
	init: function () {
		this.browser = this.searchString(this.dataBrowser) || "An unknown browser";
		this.version = this.searchVersion(navigator.userAgent)
			|| this.searchVersion(navigator.appVersion)
			|| "an unknown version";
		this.OS = this.searchString(this.dataOS) || "an unknown OS";
	},
	searchString: function (data) {
		for (var i=0;i<data.length;i++)	{
			var dataString = data[i].string;
			var dataProp = data[i].prop;
			this.versionSearchString = data[i].versionSearch || data[i].identity;
			if (dataString) {
				if (dataString.indexOf(data[i].subString) != -1)
					return data[i].identity;
			}
			else if (dataProp)
				return data[i].identity;
		}
	},
	searchVersion: function (dataString) {
		var index = dataString.indexOf(this.versionSearchString);
		if (index == -1) return;
		return parseFloat(dataString.substring(index+this.versionSearchString.length+1));
	},
	dataBrowser: [
		{ 	string: navigator.userAgent,
			subString: "OmniWeb",
			versionSearch: "OmniWeb/",
			identity: "OmniWeb"
		},
		{
			string: navigator.vendor,
			subString: "Apple",
			identity: "Safari"
		},
		{
			prop: window.opera,
			identity: "Opera"
		},
		{
			string: navigator.vendor,
			subString: "iCab",
			identity: "iCab"
		},
		{
			string: navigator.vendor,
			subString: "KDE",
			identity: "Konqueror"
		},
		{
			string: navigator.userAgent,
			subString: "Firefox",
			identity: "Firefox"
		},
		{
			string: navigator.vendor,
			subString: "Camino",
			identity: "Camino"
		},
		{		// for newer Netscapes (6+)
			string: navigator.userAgent,
			subString: "Netscape",
			identity: "Netscape"
		},
		{
			string: navigator.userAgent,
			subString: "MSIE",
			identity: "Explorer",
			versionSearch: "MSIE"
		},
		{
			string: navigator.userAgent,
			subString: "Gecko",
			identity: "Mozilla",
			versionSearch: "rv"
		},
		{ 		// for older Netscapes (4-)
			string: navigator.userAgent,
			subString: "Mozilla",
			identity: "Netscape",
			versionSearch: "Mozilla"
		}
	],
	dataOS : [
		{
			string: navigator.platform,
			subString: "Win",
			identity: "Windows"
		},
		{
			string: navigator.platform,
			subString: "Mac",
			identity: "Mac"
		},
		{
			string: navigator.platform,
			subString: "Linux",
			identity: "Linux"
		}
	]

};
BrowserDetect.init();
