// browser sniffing
function browserCheck() {
    var agent = navigator.userAgent.toLowerCase();
    this.major = parseInt(navigator.appVersion);
    this.minor = parseFloat(navigator.appVersion);
    this.ns  = ((agent.indexOf('mozilla')!=-1) && ((agent.indexOf('spoofer')==-1) && (agent.indexOf('compatible') == -1)));
    this.ns4b = (this.ns && ((this.minor < 4.04) || (this.minor == 4.7)));
    this.ns4 = (this.ns && (this.major == 4));
		this.ns6 = (this.ns && (this.major == 5));
    this.ie   = (agent.indexOf("msie") != -1);
    this.ie4  = (this.ie && (this.major == 4));
    this.ie5 =  (this.ie && agent.indexOf("msie 5.0")!=-1);
    this.ie55 = (this.ie && agent.indexOf("msie 5.5")!=-1);
		this.ie6 = (this.ie && agent.indexOf("msie 6.0")!=-1);
    this.win   = (agent.indexOf("win")!=-1);
    this.mac   = (agent.indexOf("mac")!=-1);
}

var is = new browserCheck();

// Steinman's DynLayer
function DynLayer(id,nestref,frame) {
	//bc:maybe? if (!is.ns6 && !DynLayer.set && !frame) DynLayerInit()
	if (!DynLayer.set && !frame) DynLayerInit()
	this.frame = frame || self
	//bc:if (is.ns) {
	if (is.ns4) {
		if (is.ns4) {
			if (!frame) {
				if (!nestref) var nestref = DynLayer.nestRefArray[id]
				//if (!DynLayerTest(id,nestref)) return
				this.css = (nestref)? eval("document."+nestref+".document."+id) : document.layers[id]
			}
			else this.css = (nestref)? eval("frame.document."+nestref+".document."+id) : frame.document.layers[id]
			this.elm = this.event = this.css
			this.doc = this.css.document
		}
		//bc:else if (is.ns6) {
		//bc:	this.elm = document.getElementById(id)
		//bc:	this.css = this.elm.style
		//bc:	this.doc = document
		//bc: }
		this.x = this.css.left
		this.y = this.css.top
		this.w = this.css.clip.width
		this.h = this.css.clip.height
	}
	//bc:else if (is.ie) {
	else if (is.ie || is.ns6) {
    //bc:
    if (is.ie)
		this.elm = this.event = this.frame.document.all[id]
    //bc:
    else 
		this.elm = this.event = this.frame.document.getElementById(id)

		//bc:this.css = this.frame.document.all[id].style
		this.css = this.elm.style
		this.doc = document
		this.x = this.elm.offsetLeft
		this.y = this.elm.offsetTop
		this.w = (is.ie4)? this.css.pixelWidth : this.elm.offsetWidth
		this.h = (is.ie4)? this.css.pixelHeight : this.elm.offsetHeight
	}
	this.id = id
	this.nestref = nestref
	this.obj = id + "DynLayer"
	eval(this.obj + "=this")
	this.isShowing = false;
}

var nestLoopRun = false;
function DynLayerInit(nestref) {
	if (!DynLayer.set) DynLayer.set = true
	if (is.ns4) {
		if (nestref) ref = eval('document.'+nestref+'.document')
		else {nestref = ''; ref = eval('document');}
		for (var i=0; i<ref.layers.length; i++) {
			var divname = ref.layers[i].name
			var index = divname.indexOf("Div")

			var divRef = divname.substring(0,index)
			if (index > 0) {
				eval(divRef+' = new DynLayer("'+divname+'","'+nestref+'")')				
			}
		}//end loop
	}
	else if (is.ns6) {
   		var nodeList = document.getElementsByTagName('div');
		for (var i=0; i<nodeList.length; i++) {
			var divname = nodeList[i].id
			var index = divname.indexOf("Div")
			if (index > 0) {
				eval(divname.substr(0,index)+' = new DynLayer("'+divname+'")')
			}
		}
	}
	else if (is.ie) {
		for (var i=0; i<document.all.tags("DIV").length; i++) {
			var divname = document.all.tags("DIV")[i].id
			var index = divname.indexOf("Div")
			var divRef = divname.substring(0,index)
			if (index > 0) {
				eval(divRef+' = new DynLayer("'+divname+'")')
			}
		}
	}
	return true	
}

DynLayer.nestRefArray = new Array()
DynLayer.refArray = new Array()
DynLayer.refArray.i = 0
DynLayer.set = false