n = (document.layers) ? 1:0
        ie = (document.all) ? 1:0



        function init() {
                // initialize objects
		if (ie) bufferDIV = new dynLayer("page",null,1)
		if (n) nDiv = new dynLayer("buffer2",null,1)                           
                // initialize events
                document.onmousedown = mouseDown
                document.onmousemove = mouseMove
                document.onmouseup = mouseUp
                if (n) document.captureEvents(Event.MOUSEDOWN | Event.MOUSEMOVE | Event.MOUSEUP)
        }

        // drag variables
        dragActive = 0
        dragObject = null
        dragArray = new Array()
        dragLayerX = 0
        dragLayerY = 0
        dragLayerZ = 0

        function mouseDown(e) {
                if ((n && e.which == 1) || ie) {
                        if (n) {var x=e.pageX; var y=e.pageY}
                        if (ie) {var x=event.x; var y=event.y}
                        for (var i=dragArray.length-1;i>=0;i--) {
                                if (x>=dragArray[i].x && x<=dragArray[i].x+dragArray[i].w && y>=dragArray[i].y && y<=dragArray[i].y+dragArray[i].h) {
                                        dragObject = dragArray[i]
                                        dragLayerX = x-dragObject.x
                                        dragLayerY = y-dragObject.y
                                        dragActive = 1
                                        break
                                }
                        }
                        if (dragActive) {
                                // following code is optional - it brings the layer on top of all other
                                // draggable layers and re-arranges dragArray accordingly
                                dragObject.css.zIndex = dragLayerZ++
                                for (var j=i;j<=dragArray.length-2;j++) dragArray[j] = dragArray[j+1]
                                dragArray[dragArray.length-1] = dragObject
                                // put more code here to do something else when starting a drag
                        }
                }
        }
        function mouseMove(e) {
                if (n) {var x=e.pageX; var y=e.pageY}
                if (ie) {var x=event.x; var y=event.y}
                if (dragActive) {
                        dragObject.moveTo(x-dragLayerX,y-dragLayerY)
                        return false
                }
        }
        function mouseUp(e) {
                if (n) {var x=e.pageX; var y=e.pageY}
                if (ie) {var x=event.x; var y=event.y}
                dragActive = 0
                // put more code here to do something else when finished a drag
        }

        function dynLayer(id,nestref,drag) {
                if (n) {
                        if (nestref) {
                                this.css = eval("document." + nestref + ".document." + id)
                                this.ref = eval("document." + nestref + ".document." + id + ".document")
                        }
                        else {
                                this.css = document.layers[id]
                                this.ref = document.layers[id].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 (ie) {
                        this.css = document.all[id].style
                        this.ref = document
                        this.x = this.css.pixelLeft
                        this.y = this.css.pixelTop
                        this.w = this.css.pixelWidth
                        this.h = this.css.pixelHeight
                }
                this.obj = id + "Object"
                eval(this.obj + "=this")
                this.moveBy = dynLayerMoveBy
                this.moveTo = dynLayerMoveTo
                this.show = dynLayerShow
                this.hide = dynLayerHide
                if (drag) {
                        dragArray[dragArray.length] = this
                        dragLayerZ++
                }
        }
        function dynLayerMoveBy(x,y) {
                this.x += x
                this.css.left = this.x
                this.y += y
                this.css.top = this.y
        }
        function dynLayerMoveTo(x,y) {
                this.x = x
                this.css.left = this.x
                this.y = y
                this.css.top = this.y
        }
        function dynLayerShow() {
                if (n) this.css.visibility = "show"
                else if (ie) this.css.visibility = "visible"
        }
        function dynLayerHide() {
                if (n) this.css.visibility = "hide"
                else if (ie) this.css.visibility = "hidden"
        }

		

	function change_content(new_content) { if (ie)buffer1.document.location=new_content
	if (ie){reloaddiv()}
	if (n) document.buffer2.src=new_content
	}

	function reloaddiv(){setInterval("loaddiv()",100)}	

	 function loaddiv(){if (ie) 
	var content=buffer1.document.body.innerHTML
	 if (ie) document.all.page.innerHTML=content	
		}
