// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
//
// Latest $Revision: 3 $
//          $Author: doleary $
//            $Date: 2005-06-06 13:53:43-05:00 $
//         $Logfile: /Customers/MortonMfg/Websites/www.mortonmfg.com/zylib/client/environment.js $
//
//  Original Author: Edwin Voskamp
//
//      Description: determines browser features
//
// (c) Copyright 2000-2005 Z Y Solutions Corporation
//
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *



function browser_detection(){
	//Pick up browser information
	this.appname    = navigator.appName.toLowerCase()
	this.appversion = navigator.appVersion.toLowerCase()
	this.appagent   = navigator.userAgent.toLowerCase()

	//detect support for W3C DOM
	this.w3cdom  = document.getElementById?1:0

	//detect Netscape 4 throuth its layers support
	this.type    = ""
	this.version = 0

	this.ns4     = ( !this.w3cdom && document.layers ) ? 1 : 0;
	this.ns6     = 0
	this.opera   = window.opera
	this.opera5  = 0
	this.opera6  = 0
	this.opera7  = 0
	this.mozilla = (this.appagent.indexOf( "gecko" ) >- 1 || window.sidebar )
	this.ie      = this.appagent.indexOf( "msie" ) >- 1 && !this.op
	this.ie4     = 0
	this.ie5     = 0
	this.ie55    = 0
	this.ie6     = 0

	this.mac     = ( this.appagent.indexOf("mac") >- 1 )
	this.win     = ( this.appagent.indexOf("windows") >- 1 )

	// check browser versions
	if(this.ns4) {
		this.type = "nn"
		this.version = 4
	}
	else {
		if(this.mozilla) {
			this.ns6 = 1
			this.type = "nn"
			this.version = 6
		}
		else {
			if(this.opera){	
				this.type = "op"
				this.opera5 = (this.appagent.indexOf("opera 5")>-1 || this.appagent.indexOf("opera/5")>-1)
				this.opera6 = (this.appagent.indexOf("opera 6")>-1 || this.appagent.indexOf("opera/6")>-1)
				this.opera7 = this.w3cdom&&!this.opera5&&!this.opera6 //So all higher opera versions will use it
				if(this.opera5) {
					this.version = 5
				}
				else {
					if(this.opera6) {
						this.version = 6
					}
					else {
						if(this.opera7) {
							this.version = 7
						}
						else {
						}
					}
				}
			}
			else {
				if(this.ie){
					this.type = "ie"
					this.ie4 = !this.w3cdom && document.all
					this.ie5 = (this.appagent.indexOf("msie 5")>-1)
					this.ie55 = (this.ie5 && this.appagent.indexOf("msie 5.5")>-1)
					this.ie6 = this.w3cdom && !this.ie4 && !this.ie5 && !this.ie55
					if(this.ie4){
						this.version = 4
					}
					else {
						if(this.ie5){
							this.version = 5
						}
						else {
							if(this.ie55){
								this.version = 5.5
							}
							else {
								if(this.ie6){
									this.version = 6
								}
							}
						}
					}
				}
			}
		}
	}

	this.detected = (this.type != "") && (this.version > 0)
	return this
}



var browser = new browser_detection()



//	// browser-sensing adaptive DHTML
//	var layer_ref;
//	var end_layer_ref;
//	var style_ref;
//	
//	
//	
//	if (browser.type == "ie")
//		if (browser.version < 5) {
//			// Netscape 4.x
//			layer_ref = "document.layers.['";
//			end_layer_ref = "']";
//			style_ref = "";
//		}
//		else {
//			// Netscape 6.x
//			layer_ref = "document.getElementByID(''";
//			end_layer_ref = "')";
//			style_ref = ".style";
//		}
//	else {
//		// Internet Explorer
//		layer_ref = "document.all.['";
//		end_layer_ref = "']";
//		style_ref = ".style";
//	}









// feature-sensing adaptive DHTML
var DOM = '';
var isID = 0;
var isALL = 0;
var isLayers = 0;
var isDHTML = 0;



if (document.getElementById) {
	DOM = 'W3C';	// includes Netscape 6 AND IE4
	isID = 1;
	isDHTML = 1;
}
else {
	if (document.layers) {
		DOM = 'NS4';
		isLayers = 1;
		isDHTML = 1;
	} else {
		if (document.all) {
			DOM = 'IE';
			isALL = 1;
			isDHTML = 1;
		}
	}
}



function getDOM(objectID) {
	if (isID) {
		return (document.getElementById(objectID));
	}
	else {
		if (isAll) {
			return (document.all[objectID]);
		}
		else {
			return (document.layers[objectID]);
		}
	}
}



function getDOMWithStyle(objectID) {
	if (isID) {
		return (document.getElementById(objectID).style);
	}
	else {
		if (isAll) {
			return (document.all[objectID].style);
		}
		else {
			return (document.layers[objectID]);
		}
	}
}



function whoAmI(ObjectID) {
	var domStyle = getDOMWithStyle(objectID);
	var dom = getDOM(objectID);

	if (domStyle.pixelTop != null) {
		alert(domStyle.pixelTop);
	}
	else {
		alert(domStyle.top);
	}

	alert(dom.id);
}



