var eventid;
var layerno;
var sortload=0;

// List of Methods
//Constructor

function DynLayer(id,nestref,frame) {
    if (!is.ns5 && !DynLayer.set && !frame) DynLayerInit()
    this.frame = frame || self
    if (is.ns) {
        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
        }
        else if (is.ns5) {
         //   this.elm = document.getElementById(id)
            this.elm = this.event = document.getElementById(id)
            this.css = this.elm.style
            //alert("css:" + this.css.position + this.css.height + this.css.width + this.css.visibility );
            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 = this.frame.document.all[id]
        this.css = this.frame.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 DynLayerMoveTo(x,y) {
    if (x!=null) {
        this.x = x
        if (is.ns) this.css.left = this.x
        else this.css.pixelLeft = this.x
    }
    if (y!=null) {
        this.y = y
        if (is.ns) this.css.top = this.y
        else this.css.pixelTop = this.y
    }
}

function DynLayerMoveBy(x,y) {
    this.moveTo(this.x+x,this.y+y)
}

function DynLayerShow() {
if(is.ns5)
	this.css.visibility = "visible"
else
    this.css.visibility = (is.ns)? "show" : "visible"
}

function updatelayer()
{
	collapse.showlayer(1)
}

function DynLayerLoad(url) {
//Added by Amit SR 5197021
eventid = this.event;
if(is.ns5)
{
	window.frames["dummyframe"].location = url ;
}	
///////
    else if (is.ns) 
    {
      this.css.onload = updatelayer;
      this.css.src=url;
    }
    else if (is.ie) 
    {
     dummyframe.document.location =url;
    }
    eventid = this.event;
}

function DynLayerHide() {
if(is.ns5)
	this.css.visibility = "hidden"
else
    this.css.visibility = (is.ns)? "hide" : "hidden"
}

// DynLayerInit Function
function DynLayerInit(nestref) {
    if (!DynLayer.set) DynLayer.set = true
    if (is.ns && (!is.ns5)) {
        if (nestref) ref = eval('document.'+nestref+'.document')
        else {nestref = ''; ref = document;}
        for (var i=0; i<ref.layers.length; i++) {
            var divname = ref.layers[i].name
            DynLayer.nestRefArray[divname] = nestref
            
            if (ref.layers[i].document.layers.length > 0) {
                DynLayer.refArray[DynLayer.refArray.length] = (nestref=='')? ref.layers[i].name : nestref+'.document.'+ref.layers[i].name
            }
        }
        if (DynLayer.refArray.i < DynLayer.refArray.length) {
            DynLayerInit(DynLayer.refArray[DynLayer.refArray.i++])
        }
    }
}


// Clip Methods

function DynLayerClipInit(clipTop,clipRight,clipBottom,clipLeft) {
    if (is.ie || is.ns5) {
        if (arguments.length==4) this.clipTo(clipTop,clipRight,clipBottom,clipLeft)
        else if (is.ie4) this.clipTo(0,this.css.pixelWidth,this.css.pixelHeight,0)
    }
}

function DynLayerClipTo(t,r,b,l) {
    if (t==null) t = this.clipValues('t')
    if (r==null) r = this.clipValues('r')
    if (b==null) b = this.clipValues('b')
    if (l==null) l = this.clipValues('l')
    if (is.ns) {
    	//alert(this.css.visibility)
       //alert("clip:"+this.css.clip);
        this.css.clip.top = t
        this.css.clip.right = r
        //alert(b);
        this.css.clip.bottom = b
        this.css.clip.left = l
    }
    else if (is.ie) this.css.clip = "rect("+t+"px "+r+"px "+b+"px "+l+"px)"
}

function DynLayerClipValues(which) {
    if (is.ie) var clipv = this.css.clip.split("rect(")[1].split(")")[0].split("px")
    if (which=="t") return (is.ns)? this.css.clip.top : Number(clipv[0])
    if (which=="r") return (is.ns)? this.css.clip.right : Number(clipv[1])
    if (which=="b") return (is.ns)? this.css.clip.bottom : Number(clipv[2])
    if (which=="l") return (is.ns)? this.css.clip.left : Number(clipv[3])
}
 
// 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.ns5 = (this.b=="ns" && this.v==5)
    this.ie = (this.b=="ie" && this.v>=4)
    this.ie4 = (this.version.indexOf('MSIE 4')>0)
    this.ie5 = (this.version.indexOf('MSIE 5')>0)
    this.min = (this.ns||this.ie)
    
}

// 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)
}

//------------------------------------- From Common File ----------------------


// DynLayer ChangeImage Method
// swaps an image in the layer
function DynLayerImg(imgName,imgObj,theMessage) {
	//changeTab(imgName,theMessage);
            if (is.ns) {
            	//alert(imgName);
            	//alert(this.doc);
            	//this.doc.images['I11L'].src = imgObj
                //this.doc.images[imgName].src = imgObj            
                //***this.doc.images[imgName].lowsrc = theMessage            
            }    
            //else {
            //    document.images[imgName].src = imgObj
            //    document.images[imgName].alt = theMessage
            //    }
            
}

// DynLayer GetRelative Methods
// retrieves the real location of a relatively positioned layer
function DynLayerGetRelativeX() {
    return (is.ns && (!is.ns5))? this.css.pageX : this.elm.offsetLeft
}

function DynLayerGetRelativeY() {
    return (is.ns && (!is.ns5))? this.css.pageY : this.elm.offsetTop
}


// DynLayer GetContent Width/Height Methods
// retrieves the total width/height of the contents of the layer when they are not known
function DynLayerGetContentWidth() {
    return (is.ns && (!is.ns5))? this.doc.width : this.elm.scrollWidth
}

function DynLayerGetContentHeight() {
    return (is.ns && (!is.ns5))? this.doc.height : this.elm.scrollHeight
}

//--------------------------------------------

// List of event assignments
DynLayer.prototype.moveTo = DynLayerMoveTo
DynLayer.prototype.moveBy = DynLayerMoveBy
DynLayer.prototype.showIt = DynLayerShow
DynLayer.prototype.loadIt = DynLayerLoad
DynLayer.prototype.hideIt = DynLayerHide
DynLayerTest = new Function('return true')

DynLayer.nestRefArray = new Array()
DynLayer.refArray = new Array()
DynLayer.refArray.i = 0
DynLayer.set = false

DynLayer.prototype.clipInit = DynLayerClipInit
DynLayer.prototype.clipTo = DynLayerClipTo
DynLayer.prototype.clipValues = DynLayerClipValues

is = new BrowserCheck()

DynLayer.prototype.getRelativeX = DynLayerGetRelativeX
DynLayer.prototype.getRelativeY = DynLayerGetRelativeY
DynLayer.prototype.img = DynLayerImg

DynLayer.prototype.getContentWidth = DynLayerGetContentWidth
DynLayer.prototype.getContentHeight = DynLayerGetContentHeight

//---------------------------------------

