// Dynamic Layer Object - Modified 05.30.01
// Copyright (C) 1999 Dan Steinman
// Distributed under the terms of the GNU Library General Public License
// Available at http://www.dansteinman.com/dynapi/

function DynLayer(id,nestref) {
        if (is.ns) {
                if (is.ns4) {
                        if (!nestref) var nestref = DynLayer.nestRefArray[id]
                        if (!DynLayerTest(id,nestref)) return
                        this.css = (nestref)? eval("document."+nestref+".document."+id) : document.layers[id]
                        this.elm = this.event = this.css
                        this.doc = this.css.document
                } else if (is.ns6) {
                        this.elm = document.getElementById(id)
                        this.css = this.elm.style
                        this.doc = document
                }
                this.x = this.css.left
                this.y = this.css.top
                this.w = this.css.clip.width
                this.h = this.css.clip.height
        }
        else if (is.ie) {
                this.elm = this.event = document.all[id]
                this.css = document.all[id].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")
}
function DynLayerShow() {
        this.css.visibility = (is.ns4)? "show" : "visible"
}
function DynLayerHide() {
        this.css.visibility = (is.ns4)? "hide" : "hidden"
}
DynLayer.prototype.show = DynLayerShow
DynLayer.prototype.hide = DynLayerHide
DynLayer.prototype.setbg = DynLayerSetbg
DynLayerTest = new Function('return true')
DynLayer.nestRefArray = new Array()
DynLayer.refArray = new Array()
DynLayer.refArray.i = 0
DynLayer.set = false

// BrowserCheck Object
function BrowserCheck() {
        var b = navigator.appName
        if (b=="Netscape") this.b = "ns"
        else if (b=="Microsoft Internet Explorer") this.b = "ie"
        else this.b = b
        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.b=="ie" && this.v==4)
        this.ie5 = (this.b=="ie" && this.v==5)
    this.ie6 = (this.b=="ie" && this.v==6)
        this.min = (this.ns||this.ie)
}
is = new BrowserCheck()

// CSS Function
function css(id,left,top,width,height,color,vis,z,other) {
        if (id=="START") return '<STYLE TYPE="text/css">\n'
        else if (id=="END") return '</STYLE>'
        var str = (left!=null && top!=null)? '#'+id+' {position:absolute; left:'+left+'px; top:'+top+'px;' : '#'+id+' {position:relative;'
        if (arguments.length>=4 && width!=null) str += ' width:'+width+'px;'
        if (arguments.length>=5 && height!=null) {
                str += ' height:'+height+'px;'
                if (arguments.length<9 || other.indexOf('clip')==-1) str += ' clip:rect(0px '+width+'px '+height+'px 0px);'
        }
        if (arguments.length>=6 && color!=null) str += (is.ns)? ' layer-background-color:'+color+';' : ' background-color:'+color+';'
        if (arguments.length>=7 && vis!=null) str += ' visibility:'+vis+';'
        if (arguments.length>=8 && z!=null) str += ' z-index:'+z+';'
        if (arguments.length==9 && other!=null) str += ' '+other
        str += '}\n'
        return str;
}
function writeCSS(str,showAlert) {
        str = css('START')+str+css('END')
        document.write(str)
        if (showAlert) alert(str)
}

// Set the background color of a DIV
function DynLayerSetbg(color) {
        if (is.ns) this.doc.bgColor = color
        else if (is.ie) this.css.backgroundColor = color
}
