var reviews = new Array(19999)  // Make it global array
	function place_window()
	{
		if (is.ie)
		{
			mywindow.lyr.moveTo(200 + document.body.scrollLeft,50 + document.body.scrollTop)
		}
		else
		{
			mywindow.lyr.moveTo(200 + window.pageXOffset,50 + window.pageYOffset)
		}
	}

	function Show_text_in_Layer(item,site_name)  // Script that shows the data in the layer
	{
		var one, two
		place_window()
		mywindow.lyr.show()
		//mywindow.lyr.moveBy(0,100)

		if (is.ie)
		{
			document.all['Scroll0TextT'].innerHTML ='<font face="Verdana, Arial, Helvetica, sans-serif">'+ reviews[item]+'</font>'
			//window.alert('New text = ['+document.all['Scroll0TextT'].innerHTML+']')
			mywindow.scroll.url = null
			if (!mywindow.scroll.setH) mywindow.scroll.textHeight = (is.ns)? mywindow.scroll.textlyr.doc.height : mywindow.scroll.textlyr.elm.scrollHeight
			one = mywindow.scroll.textHeight+mywindow.scroll.marginT+mywindow.scroll.marginB-mywindow.scroll.h+2*mywindow.scroll.border.v
			two = mywindow.scroll.bar.h-mywindow.scroll.box.h
			mywindow.scroll.ratio = mywindow.scroll.textHeight/two
			//window.alert('Text: '+mywindow.scroll.textHeight+' / Window: '+two+', Ratio: '+mywindow.scroll.ratio)
			mywindow.scroll.jumpTo('top')
			mywindow.scroll.boxlyr.css.visibility = 'inherit'
			//mywindow.scroll.ratio > 1 ? mywindow.scroll.boxlyr.css.visibility = 'inherit' : mywindow.scroll.boxlyr.hide()
			document.all['DynWindow0TitlebarE'].innerHTML = '<font face="Verdana, Arial, Helvetica, sans-serif" size="2" color=white><b>&nbsp;&nbsp;Site Guide&trade;&nbsp;-&nbsp;&nbsp;' + site_name +' </b></font>'
			//window.alert(document.all['Scroll0TextT'].css)
		}
		else
		{
			this.textlyr = new DynLayer('Scroll0TextT')
			this.textlyr.elm.document.open()
			this.textlyr.elm.document.write("<font size='2pt' face='Verdana, Arial, Helvetica, sans-serif'>"+reviews[item]+"</font>")
			this.textlyr.elm.document.close()
			this.textlyr = new DynLayer('DynWindow0TitlebarE')
			this.textlyr.elm.document.open()
			this.textlyr.elm.document.write("<font size='2pt' face='Verdana, Arial, Helvetica, sans-serif' color=white><b>&nbsp;&nbsp;Site Guide<sup>TM</sup>&nbsp;-&nbsp;" + site_name + " </b></font>")
			this.textlyr.elm.document.close()
		}
	//	mywindow.lyr.reload()
	}
// Drag Object
// an object that makes an unlimited number DynLayers draggable
// 19990326

// Copyright (C) 1999 Dan Steinman
// Distributed under the terms of the GNU Library General Public License
// Available at http://www.dansteinman.com/dynduo/

function Drag(dynlayer) {
	this.element = dynlayer
	this.obj = null
	this.array = new Array()
	this.active = false
	this.offsetX = 0
	this.offsetY = 0
	this.zIndex = 9
	this.resort = true
	this.add = DragAdd
	this.remove = DragRemove
	this.setGrab = DragSetGrab
	this.mouseDown = DragMouseDown
	this.mouseMove = DragMouseMove
	this.mouseUp = DragMouseUp
}
function DragAdd() {
	for (var i=0; i<arguments.length; i++) {
		var l = this.array.length
		this.array[l] = arguments[i]
		this.array[l].dragGrab = new Array(0,this.array[l].w,this.array[l].h,0)
		this.zIndex += 1
	}
}
function DragSetGrab(dynlayer,top,right,bottom,left) { 
	dynlayer.dragGrab = new Array(top,right,bottom,left)
}
function DragRemove() {
	for (var i=0; i<arguments.length; i++) {
		for (var j=0; j<this.array.length; j++) {
			if (this.array[j]==arguments[i]) {
				for (var k=j;k<=this.array.length-2;k++) this.array[k] = this.array[k+1]
				this.array[this.array.length-1] = null
				this.array.length -= 1
				break
			}
		}
	}
}
function DragMouseDown(x,y) {
	for (var i=this.array.length-1;i>=0;i--) {
		var lyr = this.array[i]
		if (this.element) {x+=this.element.x; y+=this.element.y}
		if (checkWithin(x,y,lyr.x+lyr.dragGrab[3],lyr.x+lyr.dragGrab[1],lyr.y+lyr.dragGrab[0],lyr.y+lyr.dragGrab[2])) {
			this.obj = this.array[i]
			this.offsetX = x-this.obj.x
			this.offsetY = y-this.obj.y
			this.active = true
			break
		}
	}
	if (this.active && this.resort) {
		this.obj.css.zIndex = this.zIndex++
		for (var j=i;j<=this.array.length-2;j++) this.array[j] = this.array[j+1]
		this.array[this.array.length-1] = this.obj
	}
	if (!this.active) return false
	else return true
}
function DragMouseMove(x,y) {
	if (!this.active) return false
	else {
		if (this.element) {x+=this.element.x; y+=this.element.y}
		this.obj.moveTo(x-this.offsetX,y-this.offsetY)
		return true
	}
}
function DragMouseUp() {
	if (!this.active) return false
	else {
		this.active = false
		return true
	}
}

// automatically define the "drag" object
drag = new Drag()

// checkWithin() function is required
function checkWithin(x,y,left,right,top,bottom) {
	if (x>=left && x<right && y>=top && y<bottom) return true
	else return false
}
// Scroll Object
// a widget that draws a JavaScript scrollbar to scroll a layer
// 19990410

// Copyright (C) 1999 Dan Steinman
// Distributed under the terms of the GNU Library General Public License
// Available at http://www.dansteinman.com/dynduo/

function Scroll(x,y,width,height) {
	this.name = "Scroll"+(Scroll.count++)
	this.x = x
	this.y = y
	this.w = width
	this.h = height
	this.url = null
	this.active = false
	this.bar = new Function()
	this.arrow = new Function()
	this.arrow.active = false
	this.box = new Function()
	this.border = new Function()
	this.setH = false
	this.history = new Array()
	this.historyLoc = -1
	this.historyLen = -1
	this.visibility = null
	this.zIndex = null
	this.contentRef = null
	this.slideInc = 7
	this.slideSpeed = 20
	this.clipImages = true
	this.usebuffer = true
	this.obj = this.name+"ScrollObject"
	eval(this.obj+"=this")
	this.setMargins = ScrollSetMargins
	this.setMargins(10,10,10,10)
	this.setDimensions = ScrollSetDimensions
	this.setDimensions(0,0,15,this.h,15,15,30,1)
	this.setColors = ScrollSetColors
	this.setColors(null,"#000000","#C5C5C5","#555555","#898989")
	this.preload = ScrollPreload
	this.setImages = ScrollSetImages
	this.setImages()
	this.setHeight = ScrollSetHeight
	this.build = ScrollBuild
	this.load = ScrollLoad
	this.writeContent = ScrollWriteContent
	this.back = ScrollBack
	this.forward = ScrollForward
	this.reload = ScrollReload
	this.activate = ScrollActivate
	this.jumpTo = ScrollJumpTo
	this.barDown = ScrollBarDown
	this.barMove = ScrollBarMove
	this.barUp = ScrollBarUp
	this.arrowDown = ScrollArrowDown
	this.arrowUp = ScrollArrowUp
	this.arrowSlide = ScrollArrowSlide
}
function ScrollSetDimensions(barX,barY,barW,barH,arrowuH,arrowdH,boxH,border) {
	this.arrow.uy = barY
	this.arrow.dy = barY+barH-arrowdH
	this.arrow.uh = arrowuH
	this.arrow.dh = arrowdH
	this.bar.x = barX+this.w
	this.bar.y = barY+this.arrow.uh
	this.bar.w = barW
	this.bar.h = barH-this.arrow.uh-this.arrow.dh
	this.box.h = boxH
	this.border.v = border
}
function ScrollSetColors(bg,border,bar,arrow,box) {
	this.bgcolor = bg
	this.border.color = border
	this.bar.color = bar
	this.arrow.color = arrow
	this.box.color = box
}
function ScrollSetMargins(l,r,t,b) {
	this.marginL = l
	this.marginR = r
	this.marginT = t
	this.marginB = b
}
function ScrollPreload(imgObj,imgSrc) {
	if (imgSrc) {
		eval(imgObj+' = new Image()')
		eval(imgObj+'.src = "'+imgSrc+'"')
		eval(imgObj+'s = true')
	}
	else eval(imgObj+'s = false')
}
function ScrollSetImages(box0,box1,up0,up1,dn0,dn1,bar,directory) {
	if (arguments.length<8) directory = ''
	for (var i=0;i<arguments.length-1;i++) arguments[i] = arguments[i]? directory+arguments[i] : ''
	this.preload(this.obj+'.box.image0',box0)
	this.preload(this.obj+'.box.image1',box1)
	this.preload(this.obj+'.arrow.upimage0',up0)
	this.preload(this.obj+'.arrow.upimage1',up1)
	this.preload(this.obj+'.arrow.dnimage0',dn0)
	this.preload(this.obj+'.arrow.dnimage1',dn1)
	this.preload(this.obj+'.bar.image',bar)
	this.bar.imageW = this.bar.w
	this.bar.imageH = this.bar.h
	this.bar.tile = ''
}
function ScrollBuild() {
	var nm = this.name
	var b = this.border.v
	var bw = this.bar.w
	var ml = this.marginL
	var mr = this.marginR
	var mt = this.marginT
	var bc = this.border.color
	
	this.css = css(nm,this.x,this.y,null,null,null,this.visibility,this.zIndex)+
	css(nm+'BG',0,0,this.w,this.h,this.bgcolor)+
	css(nm+'BorderT',0,0,this.w,b,bc)+
	css(nm+'BorderB',0,this.h-b,this.w,b,bc)+
	css(nm+'BorderL',0,0,b,this.h,bc)+
	css(nm+'BorderR',this.w-b,0,b,this.h,bc)+
	css(nm+'ArrowU',this.bar.x,this.arrow.uy,bw,((this.clipImages)?this.arrow.uh:null),this.arrow.color)+
	css(nm+'ArrowD',this.bar.x,this.arrow.dy,bw,((this.clipImages)?this.arrow.dh:null),this.arrow.color)+
	css(nm+'ArrowUC',this.bar.x,this.arrow.uy,bw,this.arrow.uh)+
	css(nm+'ArrowDC',this.bar.x,this.arrow.dy,bw,this.arrow.dh)+
	css(nm+'Bar',this.bar.x,this.bar.y,bw,((this.clipImages)?this.bar.h:null),this.bar.color,null,null,this.bar.tile)+
	css(nm+'BarC',this.bar.x,this.bar.y,bw,this.bar.h)+
	css(nm+'Box',0,0,bw,((this.clipImages)?this.box.h:null),this.box.color,'hidden')+
	css(nm+'TextC',b+ml,b,this.w-2*b-ml-mr,this.h-2*b)+
	css(nm+'TextT',0,mt,this.w-2*b-ml-mr)
	
	this.divStart = ''
	if (is.ie && this.usebuffer) this.divStart += '<IFRAME NAME="'+nm+'Frame" WIDTH=0 HEIGHT=0 STYLE="display:none"></IFRAME>\n'
	this.divStart += '<DIV ID="'+nm+'">\n'+
	'<DIV ID="'+nm+'BG"></DIV>\n'+
	'<DIV ID="'+nm+'BorderT"></DIV>\n'+
	'<DIV ID="'+nm+'BorderB"></DIV>\n'+
	'<DIV ID="'+nm+'BorderL"></DIV>\n'+
	'<DIV ID="'+nm+'BorderR"></DIV>\n'+
	'<DIV ID="'+nm+'TextC">\n'
	if (is.ie && !this.usebuffer) this.divStart += '<IFRAME NAME="'+nm+'Frame" WIDTH='+(this.w-2*b-ml-mr)+' HEIGHT='+(this.h-2*b)+' MARGINWIDTH=0 MARGINHEIGHT=0 SCROLLING="NO" FRAMEBORDER="NO"></IFRAME>\n'
	else this.divStart += '<DIV ID="'+nm+'TextT">\n'
	this.divEnd = '</DIV>\n'
	if (is.ns || this.usebuffer) this.divEnd += '</DIV>\n'
	this.divEnd += '<DIV ID="'+nm+'Bar">\n'
	if (this.bar.images) this.divEnd += '<IMG SRC="'+this.bar.image.src+'" WIDTH="'+this.bar.imageW+'" HEIGHT="'+this.bar.imageH+'">\n'
	this.divEnd += '<DIV ID="'+nm+'Box">'
	if (this.box.image0s) this.divEnd += '<IMG NAME="'+nm+'BoxImg" SRC="'+this.box.image0.src+'">'
	this.divEnd += '</DIV>\n</DIV>\n<DIV ID="'+nm+'ArrowU">'
	if (this.arrow.upimage0s) this.divEnd += '<IMG NAME="'+nm+'UpImg" SRC="'+this.arrow.upimage0.src+'">'
	this.divEnd += '</DIV>\n<DIV ID="'+nm+'ArrowD">'
	if (this.arrow.dnimage0s) this.divEnd += '<IMG NAME="'+nm+'DnImg" SRC="'+this.arrow.dnimage0.src+'">'
	this.divEnd += '</DIV>\n'+
	'<DIV ID="'+nm+'BarC"></DIV>\n'+
	'<DIV ID="'+nm+'ArrowUC"></DIV>\n'+
	'<DIV ID="'+nm+'ArrowDC"></DIV>\n'+
	'</DIV>\n'
	this.div = this.divStart+this.divEnd
}
function ScrollActivate(w,h) {	if (h) {
		this.textHeight = h
		this.setH = true
	}	// Puts data inside the Window in IE	// alert(this.name+'TextT')  // To see the variable name in IE
	//if (is.ie && this.usebuffer && parent.frames[this.name+'Frame'].document.body.innerHTML) document.all[this.name+'TextT'].innerHTML = parent.frames[this.name+'Frame'].document.body.innerHTML
	this.lyr = new DynLayer(this.name)	if (is.ie && !this.usebuffer) {
		this.textlyr = new DynLayer('content',null,this.name+'Frame')
		this.contentRef = this.name+'content'
	}
	else {	
		this.textlyr = new DynLayer(this.name+'TextT')
		this.contentRef = this.name+'.document.'+this.name+'TextC.document.'+this.name+'TextT'
		if (this.lyr.nestref) this.contentRef = this.lyr.nestref+'.document.'+this.contentRef//		alert(this.textlyr.id)
	}
	this.boxlyr = new DynLayer(this.name+'Box',DynLayer.nestRefArray[this.name+"Box"])
	this.arrowur = new DynLayer(this.name+'ArrowU')
	this.arrowu = new DynLayer(this.name+'ArrowUC')
	this.arrowu.elm.onmousedown = new Function(this.obj+'.arrowDown(1); return false;')
	this.arrowu.elm.onmouseup = new Function(this.obj+'.arrowUp(); return false;')
	this.arrowu.elm.onmouseout = new Function(this.obj+'.arrowUp(); return false;')
	if (is.ns) this.arrowu.elm.captureEvents(Event.MOUSEDOWN | Event.MOUSEUP)
	this.arrowdr = new DynLayer(this.name+'ArrowD')
	this.arrowd = new DynLayer(this.name+'ArrowDC')
	this.arrowd.elm.onmousedown = new Function(this.obj+'.arrowDown(-1); return false;')
	this.arrowd.elm.onmouseup = new Function(this.obj+'.arrowUp(); return false;')
	this.arrowd.elm.onmouseout = new Function(this.obj+'.arrowUp(); return false;')
	if (is.ns) this.arrowd.elm.captureEvents(Event.MOUSEDOWN | Event.MOUSEUP)
	this.barlyr = new DynLayer(this.name+'BarC')
	this.barlyr.elm.scroll = this.obj
	this.barlyr.elm.onmousedown = ScrollBarDownStart
	this.barlyr.elm.onmousemove = ScrollBarMoveStart
	this.barlyr.elm.onmouseup = new Function(this.obj+'.barUp(); return false;')
	this.barlyr.elm.onmouseout = new Function(this.obj+'.arrowUp(); return false;')
	if (is.ns) this.barlyr.elm.captureEvents(Event.MOUSEDOWN | Event.MOUSEUP | Event.MOUSEMOVE)
	if (!this.setH) this.textHeight = (is.ns)? this.textlyr.doc.height : this.textlyr.elm.scrollHeight
	this.setH = false 
	if (is.ns) {
		this.textlyr.css.clip.bottom = Math.max(this.textHeight,this.h-2*this.border.v-this.marginT)
		this.textlyr.css.clip.right = this.w - this.border.v*2
	}
	this.ratio = (this.textHeight+this.marginT+this.marginB-this.h+2*this.border.v)/(this.bar.h-this.box.h)
	this.jumpTo('top')
	if (this.ratio>0) this.boxlyr.css.visibility = 'inherit'
	else this.boxlyr.hide() 
}
function ScrollLoad(url) {
	if (url != this.url) {
		this.historyLoc += 1
		this.historyLen = this.historyLoc
		this.history[this.historyLen] = url
		this.reload()
	}
}
function ScrollBack() {
	if (this.historyLoc > 0) {
		this.historyLoc -= 1
		this.reload()
	}
}
function ScrollForward() {
	if (this.historyLoc < this.historyLen) {
		this.historyLoc += 1
		this.reload()
	}
}
function ScrollReload() {
	this.url = this.history[this.historyLoc]
	this.refresh = true
	if (is.ns) {
		this.textlyr = new DynLayer(this.name+'TextT')
		this.textlyr.elm.src = this.url		//		this.textlyr.elm.document.open()
//		this.textlyr.elm.document.write(TEXT_TO_WRITE)
//		this.textlyr.elm.document.close()
	}
	else if (is.ie) parent.frames[this.name+'Frame'].document.location = this.url
}
function ScrollJumpTo(y) {
	var by,ty
	if (y == "top") {
		by = 0
		ty = this.marginT
	}
	else if (y=="bottom" && this.ratio>0) {
		by = this.bar.h-this.box.h
		ty = -this.ratio*by+this.marginT
	}
	else if (y<this.textHeight) {
		ty = -y
		by = (ty-this.marginT)/-this.ratio
	}
	this.textlyr.moveTo(0,ty)
	this.boxlyr.moveTo(0,by)
}
function ScrollSetHeight(h) {
	this.activate(w,h)
}
function ScrollBarDownStart(e) {
	if (is.ie && event.button==2) return false
	var y = (is.ns)? e.layerY : event.offsetY
	eval(this.scroll+'.barDown('+y+')')
	return false
}
function ScrollBarDown(y) {
	if (this.ratio<=0) return
	var boxh = this.box.h
	var boxy = this.boxlyr.y
	if (y>=boxy && y<boxy+boxh) {
		if (this.box.image1s) this.boxlyr.doc.images[this.name+"BoxImg"].src = this.box.image1.src
		this.clickYnew = y-boxy
		this.clickYold = y
		this.active = true
	}			
	else {
		if (y<=boxh/2) this.boxlyr.moveTo(0,0)
		else if (y>=this.bar.h-boxh/2) this.boxlyr.moveTo(0,this.bar.h-boxh)
		else this.boxlyr.moveTo(0,y-boxh/2)
		if (this.box.image1s) this.boxlyr.doc.images[this.name+"BoxImg"].src = this.box.image1.src
		this.textlyr.moveTo(0,-this.ratio*(this.boxlyr.y)+this.marginT)
		this.clickYnew = y-this.boxlyr.y
		this.clickYold = y
		this.active = true
	}
}
function ScrollBarUp() {
	this.active = false
	if (this.box.image1s) this.boxlyr.doc.images[this.name+"BoxImg"].src = this.box.image0.src
}
function ScrollBarMoveStart(e) {
	var y = (is.ns)? e.layerY : event.offsetY
	eval(this.scroll+'.barMove('+y+')')
	return false
}
function ScrollBarMove(y) {
	if (!this.active) return false
	var diff = y-this.clickYold
	var boxy = this.boxlyr.y
	var barh = this.bar.h-this.box.h
	if (boxy+diff<0 || boxy+diff>barh) {
		if (boxy+diff<0) this.boxlyr.moveTo(0,0)
		else this.boxlyr.moveTo(0,barh)
		this.clickYold = boxy+this.clickYnew
	}
	else {
		this.boxlyr.moveTo(0,y-this.clickYnew)
		this.clickYold = y
	}
	this.textlyr.moveTo(0,-this.ratio*(this.boxlyr.y)+this.marginT)
	return false
}
function ScrollArrowDown(dir) {
	if (this.ratio>0) {
		this.arrow.active = true
		if (dir==1 && this.arrow.upimage1s) this.arrowur.doc.images[this.name+"UpImg"].src = this.arrow.upimage1.src
		if (dir==-1 && this.arrow.dnimage1s) this.arrowdr.doc.images[this.name+"DnImg"].src = this.arrow.dnimage1.src
		this.arrowSlide(dir)
	}
}
function ScrollArrowUp() {
	if (this.ratio>0) {
		this.arrow.active = false
		this.active = false
		if (this.arrow.upimage1s) this.arrowur.doc.images[this.name+"UpImg"].src = this.arrow.upimage0.src
		if (this.arrow.dnimage1s) this.arrowdr.doc.images[this.name+"DnImg"].src = this.arrow.dnimage0.src
		if (this.box.image1s) this.boxlyr.doc.images[this.name+"BoxImg"].src = this.box.image0.src
	}
}
function ScrollArrowSlide(dir) {
	if (this.arrow.active) {
		if ((dir==1 && this.textlyr.y<this.marginT-this.slideInc) || (dir==-1 && this.textlyr.y>-(this.textHeight+2*this.border.v+this.marginB-this.h-this.slideInc))) {
			this.textlyr.moveBy(0,dir*this.slideInc)
			this.boxlyr.moveTo(0,(this.textlyr.y-this.marginT)/-this.ratio)
			setTimeout(this.obj+'.arrowSlide('+dir+')',this.slideSpeed)
		}
		else {
			if (dir==1) this.textlyr.moveTo(0,this.marginT)
			else if (dir==-1) this.textlyr.moveTo(0,-(this.textHeight+2*this.border.v+this.marginB-this.h))
			this.boxlyr.moveTo(0,(this.textlyr.y-this.marginT)/-this.ratio)
		}
	}
}
function ScrollWriteContent(doc) {
	if (!this.usebuffer && is.ie) {
		var str = '<STYLE TYPE="text/css">'+
		css('content',0,this.marginT,this.w-2*this.border.v-this.marginL-this.marginR)
		str += '</STYLE>'
		doc.write(str)
	}
}
Scroll.count = 0

ns4 = (document.layers)? true:false
ie4 = (document.all)? true:false

function init() {
	mywindow.activate()
	// initialize mouse events
	document.onmousedown = mouseDown
	document.onmousemove = mouseMove
	document.onmouseup = mouseUp
	if (ns4) document.captureEvents(Event.MOUSEDOWN | Event.MOUSEMOVE | Event.MOUSEUP)
}

function mouseDown(e) {
	if ((ns4 && e.which == 1) || ie4) {
		var x = (ns4)? e.pageX : event.x
		var y = (ns4)? e.pageY : event.y+document.body.scrollTop
		drag.mouseDown(x,y)
		if (drag.active) {
			// put more code here to do something else when starting a drag
			return false
		}
		else {
			if(ns4 && e.target!=document) routeEvent(e)
			return true
		}
	}
}
function mouseMove(e) {
	var x = (ns4)? e.pageX : event.x
	var y = (ns4)? e.pageY : event.y+document.body.scrollTop
	if (drag.active) {
		drag.mouseMove(x,y)
		// put more code here to do something else while dragging
		return false
	}
	else {
		if(ns4 && e.target!=document) routeEvent(e)
		return true
	}
}
function mouseUp(e) {
	var x = (ns4)? e.pageX : event.x
	var y = (ns4)? e.pageY : event.y+document.body.scrollTop
	if (drag.active) {
		drag.mouseUp()
		// put more code here to do something else when finished a drag
		return false
	}
	else {
		if(ns4 && e.target!=document) routeEvent(e)
		return true
	}
}

//mywindow = new DynWindow("mywindow",170,40,300,250)	
//mywindow.visibility = 'hidden'
//mywindow.visibility = 'visible'
//mywindow.build()

// Dynamic Layer Object
// sophisticated layer/element targeting and animation object which provides the core functionality needed in most DHTML applications
// 19990604

// Copyright (C) 1999 Dan Steinman
// Distributed under the terms of the GNU Library General Public License
// Available at http://www.dansteinman.com/dynduo/

function DynLayer(id,nestref,frame) {
	if (!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
		}
		if (is.ns5) {
			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 = 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-30 : this.elm.offsetHeight-30
	}
	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() {
	this.css.visibility = (is.ns)? "show" : "visible"
}
function DynLayerHide() {
	this.css.visibility = (is.ns)? "hide" : "hidden"
}
DynLayer.prototype.moveTo = DynLayerMoveTo
DynLayer.prototype.moveBy = DynLayerMoveBy
DynLayer.prototype.show = DynLayerShow
DynLayer.prototype.hide = DynLayerHide
DynLayerTest = new Function('return true')

// DynLayerInit Function
function DynLayerInit(nestref) {
	if (!DynLayer.set) DynLayer.set = true
	if (is.ns) {
		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
			var index = divname.indexOf("Div")
			if (index > 0) {
				eval(divname.substr(0,index)+' = new DynLayer("'+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++])
		}
	}
	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")
			if (index > 0) {
				eval(divname.substr(0,index)+' = new DynLayer("'+divname+'")')
			}
		}
	}
	return true
}
DynLayer.nestRefArray = new Array()
DynLayer.refArray = new Array()
DynLayer.refArray.i = 0
DynLayer.set = false

// Slide Methods
function DynLayerSlideTo(endx,endy,inc,speed,fn) {
	if (endx==null) endx = this.x
	if (endy==null) endy = this.y
	var distx = endx-this.x
	var disty = endy-this.y
	this.slideStart(endx,endy,distx,disty,inc,speed,fn)
}
function DynLayerSlideBy(distx,disty,inc,speed,fn) {
	var endx = this.x + distx
	var endy = this.y + disty
	this.slideStart(endx,endy,distx,disty,inc,speed,fn)
}
function DynLayerSlideStart(endx,endy,distx,disty,inc,speed,fn) {
	if (this.slideActive) return
	if (!inc) inc = 10
	if (!speed) speed = 20
	var num = Math.sqrt(Math.pow(distx,2) + Math.pow(disty,2))/inc
	if (num==0) return
	var dx = distx/num
	var dy = disty/num
	if (!fn) fn = null
	this.slideActive = true
	this.slide(dx,dy,endx,endy,num,1,speed,fn)
}
function DynLayerSlide(dx,dy,endx,endy,num,i,speed,fn) {
	if (!this.slideActive) return
	if (i++ < num) {
		this.moveBy(dx,dy)
		this.onSlide()
		if (this.slideActive) setTimeout(this.obj+".slide("+dx+","+dy+","+endx+","+endy+","+num+","+i+","+speed+",\""+fn+"\")",speed)
		else this.onSlideEnd()
	}
	else {
		this.slideActive = false
		this.moveTo(endx,endy)
		this.onSlide()
		this.onSlideEnd()
		eval(fn)
	}
}
DynLayerSlideInit = new Function()
DynLayer.prototype.slideInit = new Function()
DynLayer.prototype.slideTo = DynLayerSlideTo
DynLayer.prototype.slideBy = DynLayerSlideBy
DynLayer.prototype.slideStart = DynLayerSlideStart
DynLayer.prototype.slide = DynLayerSlide
DynLayer.prototype.onSlide = new Function()
DynLayer.prototype.onSlideEnd = new Function()

// Clip Methods
function DynLayerClipInit(clipTop,clipRight,clipBottom,clipLeft) {
	if (is.ie) {
		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) {
		this.css.clip.top = t
		this.css.clip.right = r
		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 DynLayerClipBy(t,r,b,l) {
	this.clipTo(this.clipValues('t')+t,this.clipValues('r')+r,this.clipValues('b')+b,this.clipValues('l')+l)
}
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])
}
DynLayer.prototype.clipInit = DynLayerClipInit
DynLayer.prototype.clipTo = DynLayerClipTo
DynLayer.prototype.clipBy = DynLayerClipBy
DynLayer.prototype.clipValues = DynLayerClipValues

// Write Method
function DynLayerWrite(html) {
	if (is.ns) {
		this.doc.open()
		this.doc.write(html)
		this.doc.close()
	}
	else if (is.ie) {
		this.event.innerHTML = html
	}
}
DynLayer.prototype.write = DynLayerWrite

// 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)
}
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)
}
// DynWindow Object
// a widget-object that creates a draggable window with a Scroll to mimic an OS window
// 19990528

// Copyright (C) 1999 Dan Steinman
// Distributed under the terms of the GNU Library General Public License
// Available at http://www.dansteinman.com/dynduo/

//Image_URL = "http://195.40.194.39/Work/dhtml/dyn%20window%20test/images"

// ********************************************  Stuff done by me (Dinis Cruz - DDplus)
DynWindow_Title = "Empty QAZ"
//********************************************


function DynWindow(name,x,y,width,height) {
	this.name = "DynWindow"+(DynWindow.count++)
	this.x = x
	this.y = y
	this.w = width
	this.h = height
	this.title = ''
	this.visibility = 'inherit'
	this.zIndex = 10
	this.obj = this.name + "DynWindowObject"
	eval(this.obj + "=this")
	this.built = false
	
	this.scroll = new Scroll(0,0,this.w-15,this.h-20)
	this.scroll.setDimensions(0,0,15,this.scroll.h,14,15,29,1)
	this.scroll.clipImages = false
	this.scroll.setImages('scroll-img-box0.gif','scroll-img-box1.gif','scroll-img-up0.gif','scroll-img-up1.gif','scroll-img-dn0.gif','scroll-img-dn1.gif','scroll-img-bar.gif','/qazgraphics/layers/')
	this.scroll.build(false)
	
	this.closeImg0 = new Image()
	this.closeImg0.src = "/qazgraphics/layers/window-close0.gif"
	this.closeImg1 = new Image()
	this.closeImg1.src = "/qazgraphics/layers/window-close1.gif"
	this.minImg0 = new Image()
	this.minImg0.src = "/qazgraphics/CLOSEbutton1.gif"
	this.minImg1 = new Image()
	this.minImg1.src = "/qazgraphics/CLOSEbutton1.gif"
	
	this.setTitle = DynWindowSetTitle
	this.activate = DynWindowActivate
	this.build = DynWindowBuild

	this.minimizeDown = DynWindowMinimizeDown
	this.minimize = DynWindowMinimize
	this.closeDown = DynWindowCloseDown
	this.close = DynWindowClose
}
	/*css(this.name+'Min',(this.w/2)-27,this.h-30,54,13,null,null,this.zIndex+1)+
	css(this.name+'MinE',(this.w/2)-27,this.h-30,54,13,null,null,this.zIndex+1)+*/

function DynWindowBuild(write) {
	this.css = (write!=false)? css('START'):''
	this.css += css(this.name+'DynWindow',this.x,this.y,this.w,this.h,null,this.visibility,this.zIndex)+
	css(this.name+'Titlebar1',0,0,this.w,18,'#000000')+
	css(this.name+'Titlebar2',1,1,this.w-2,17,'#2A5E89')+
	css(this.name+'TitlebarE',0,0,this.w,18)+
	css(this.name+'Title',18,2,this.w-36,null,'transparent')+
	css(this.name+'Min',5,this.h-23,30,16,null,null,this.zIndex+1)+
	css(this.name+'MinE',5,this.h-23,30,16,null,null,this.zIndex+1)+
	css(this.name+'Close',this.w-18,0,18,18)+
	css(this.name+'CloseE',this.w-18,0,18,18)+
	css(this.name+'Content',0,18,this.w,this.h-20,'#DDDDFF',null,this.zIndex,'font-size:9pt;font-family:Verdana,Arial,Helvetica,sans-serif;')+
	this.scroll.css
	if (write!=false) {
		this.css += css('END')
		//window.alert(this.css)
		document.write(this.css)
	}
	
	//Title = "Emply QAZ"
	//Title = '<font color=white><b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; NEW QAZ' + DynWindow_Title + '</b></font>
	
	this.divStart = '<DIV ID="'+this.name+'DynWindow">\n'+
	'<DIV ID="'+this.name+'Titlebar1">\n'+
	'<DIV ID="'+this.name+'Titlebar2"></DIV>\n'+
	'</DIV>\n'+
	'<DIV ID="'+this.name+'Title"></DIV>\n'+
	'<DIV ID="'+this.name+'TitlebarE"><font color=white><b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;' + DynWindow_Title + '</b></font></DIV>\n'+
	'<DIV ID="'+this.name+'Min"><IMG NAME="'+this.name+'MinImg" SRC= "/qazgraphics/CLOSEbutton1.gif" WIDTH=30 HEIGHT=16></DIV>\n'+
	'<DIV ID="'+this.name+'Close"><IMG NAME="'+this.name+'CloseImg" SRC="/qazgraphics/layers/window-close0.gif" WIDTH=18 HEIGHT=18></DIV>\n'+
	'<DIV ID="'+this.name+'MinE"></DIV>\n'+
	'<DIV ID="'+this.name+'CloseE"></DIV>\n'+
	'<DIV ID="'+this.name+'Content">\n'+
	this.scroll.divStart	
	this.divEnd = this.scroll.divEnd+
	'</DIV>\n'+
	'</DIV>\n'
	this.div = this.divStart+this.divEnd
	this.built = true
	//window.alert(this.divStart)
}
function DynWindowActivate() {
	this.lyr = new DynLayer(this.name+'DynWindow')
	this.titlelyr = new DynLayer(this.name+'Title')
	this.titlelyr.write = DynLayerWrite
	this.minl = new DynLayer(this.name+'Min')
	this.minlyr = new DynLayer(this.name+'MinE')
	if (is.ns) this.minlyr.event.captureEvents(Event.MOUSEDOWN | Event.MOUSEUP | Event.CLICK)
	this.minlyr.event.onmousedown = new Function(this.obj+'.minimizeDown(); return false;')
	this.minlyr.event.onmouseup = new Function(this.obj+'.minimize(); return false;')
	this.closel = new DynLayer(this.name+'Close')
	this.closelyr = new DynLayer(this.name+'CloseE')
	if (is.ns) this.closelyr.event.captureEvents(Event.MOUSEDOWN | Event.MOUSEUP | Event.CLICK)
	this.closelyr.event.onmousedown = new Function(this.obj+'.closeDown(); return false;')
	this.closelyr.event.onmouseup = new Function(this.obj+'.close(); return false;')
	eval('drag.add('+this.obj+'.lyr)')
	eval('drag.setGrab('+this.obj+'.lyr,0,382,18,0)')
}
function DynWindowMinimizeDown() {
	this.minl.doc.images[this.name+"MinImg"].src = this.minImg1.src
}
function DynWindowMinimize() {
	this.minl.doc.images[this.name+"MinImg"].src = this.minImg0.src
	this.lyr.hide()
}
function DynWindowCloseDown() {
	this.closel.doc.images[this.name+"CloseImg"].src = this.closeImg1.src
}
function DynWindowClose() {
	this.closel.doc.images[this.name+"CloseImg"].src = this.closeImg0.src
	this.lyr.hide()
}
function DynWindowSetTitle(title) {
	this.title = title
	if (this.built) this.titlelyr.write('<DIV ALIGN="CENTER" CLASS="windowTitleStyle">'+this.title+'</DIV>')
}
DynWindow.count = 0
