//domain=""
//domainsrc=""
//**************** Globals {{{1 ****************************
// Initializing {{{2
if (typeof(domain) != "undefined") document.domain = domain 
GlobalParms = new Object()
WinList = new Array()
ScheduleList = new Array()
MenuList = new Array()
GlobalParms.WindowLoaded = false
var SUBMITTED = -1
var RETURNED  = 0
var FINISHED  = 1
ie = (document.all)
if (ie) {
	GlobalParms.rightArrow =  "&nbsp;4"
	GlobalParms.downArrow = "&nbsp;6"
} else  {
	GlobalParms.rightArrow = "&nbsp;&#9656;&nbsp;" 
	GlobalParms.downArrow =  "&nbsp;&#9662;&nbsp;"
}
window.onload = function() { //{{{2
	if (ie) document.onselectstart = function(){return(false)}
	document.oncontextmenu = function(){return(false)}
	document.onmousedown = globalOnMouseDown
	document.onkeydown = globalOnKeyDown
	GlobalParms.WindowLoaded = true
	document.body.appendChild(zoombox.div)
}
function getScreenWidth() { //{{{2
	if (ie) return(document.body.clientWidth + document.body.scrollLeft)
	else return(window.innerWidth + window.scrollX)
}
function getScreenHeight() { //{{{2
	if (ie) return(document.body.clientHeight + document.body.scrollTop)
	else return(window.innerHeight + window.scrollY)
}
function getObjectName(obj) { //{{{2
	if (obj.constructor) var m = obj.constructor.toString().match(/function  *(.*).*\(.*\)/)
	if (m) {
		return(m[1])
	}
	else return(null)
}
function getLeftRelative(val,el) { //{{{2
	if (el) var div = (el.div) ? el.div : el
	var left = (div) ? div.offsetLeft : 0
	var width = (div) ? div.offsetWidth : getScreenWidth()
	if ( ! val.toString().match(/.*%$/)) return( Math.round(val + left) )
	return(Math.round (left + (parseFloat(val) / 100) * width) )
}
function getTopRelative(val,el) { //{{{2
	if (el) var div = (el.div) ? el.div : el
	var top = (div) ? div.offsetTop : 0
	var height = (div) ? div.offsetHeight : getScreenHeight()
	if ( ! val.toString().match(/.*%$/)) return( Math.round(val + top) )
	return(Math.round (top + (parseFloat(val) / 100) * height) )
}
function getWidthRelative(val,div) { //{{{2
	if ( ! val.toString().match(/.*%$/)) return(Math.round(val))
	var width = (div) ? div.offsetWidth : getScreenWidth()
	return(Math.round( (parseFloat(val) / 100) * width))
}
function getHeightRelative(val,div) { //{{{2
	if ( ! val.toString().match(/.*%$/)) return(Math.round(val))
	var height = (div) ? div.offsetHeight : getScreenHeight()
	return(Math.round ( (parseFloat(val) / 100) * height))
}
function getXCentered(el,refEl) { //{{{2
	if (el.div) el = el.div
	if (refEl.div) refEl = refEl.div
	var refCenter = refEl.offsetLeft + (refEl.offsetWidth / 2)
	return (Math.round (refCenter - (el.offsetWidth / 2)) )
}
	
function getYCentered(el,refEl) { //{{{2
	if (el.div) el = el.div
	if (refEl.div) refEl = refEl.div
	var refCenter = refEl.offsetTop + (refEl.offsetHeight / 2)
	return (Math.round (refCenter - (el.offsetHeight / 2)) )
}
	
function debug(txt) { //{{{2 
	if (typeof(debugCounter) == "undefined") {
		debugCounter = 0
		debugDiv = document.createElement("div")
		var f = document.body.firstChild
		if (f) document.body.insertBefore(debugDiv,f)
		else document.body.appendChild(debugDiv)
	}
	debugCounter++
	if (typeof(txt) == "undefined") txt = ""
	debugDiv.innerHTML = debugCounter + "->" + txt
}
//***************** Global event processing {{{1 ****************************
function getIframeEvent(ifr,e) { //{{{2
	if (ie) {
		var e = ifr.window.event
		GlobalParms.target = e.srcElement
		e.cancelBubble = true
	} else {
		GlobalParms.target = e.target
		e.stopPropagation()
	}
	if (ifr.win) with (ifr.win) {
		var dispX = left + borderWidth
		var dispY = top + borderWidth + titleHeight
	}
// Mozilla problem: iframe event returns parent coordinates
// 1) when resizing from border into iframe,
// 2) or when dragging a zoombox into an iframe different from started
// 3) NB Per aprol 2003 (Mozilla 1.3) 2) seems to be corrected
	if ( 
	        (GlobalParms.resizing && ifr.win == GlobalParms.fromWin) 
//	     || (     GlobalParms.zooming 
//		       && (GlobalParms.globally || ifr.win != GlobalParms.fromWin)
//		     )
	   ) {
		var dispX = 0
		var dispY = 0
	}
	parent.GlobalParms.X =  e.clientX + dispX
	parent.GlobalParms.Y =  e.clientY + dispY
	parent.GlobalParms.button =  e.button
	parent.GlobalParms.shiftKey = e.shiftKey
}
function getDocumentEvent(e) { //{{{2
	if (!e) e = event
	if (ie) {
		GlobalParms.X = e.clientX + document.body.scrollLeft
		GlobalParms.Y = e.clientY + document.body.scrollTop
		GlobalParms.target = e.srcElement
		e.cancelBubble = true
	} else {
		GlobalParms.X = e.clientX + window.scrollX
		GlobalParms.Y = e.clientY + window.scrollY
		GlobalParms.target = e.target
		e.stopPropagation
	}
	GlobalParms.button = e.button
	GlobalParms.shiftKey = e.shiftKey
}
function iframeOnMouseDown(e) { //{{{2
	getIframeEvent(this,e)
	GlobalParms.fromWin =  this.win
	this.win.raise()
	parent.globalOnMouseDown(0)
	return(false)
}
function iframeOnMouseMove(e) { //{{{2 
	getIframeEvent(this,e)
	parent.globalOnMouseMove(0)
	return(false)
}
function iframeOnMouseUp(e) { //{{{2 
	getIframeEvent(this,e)
	parent.globalOnMouseUp(0)
	return(false)
}
function iframeOnKeyDown(e) { //{{{2
	if (ie) e = this.window.event
	parent.globalOnKeyDown(e)
}
function initEvents(downFunc,moveFunc,upFunc,list,userFunc) { //{{{2
	GlobalParms.globally = (list == null)
	if (GlobalParms.globally) {
		eventWinList = WinList
		document.downFunc = downFunc
		document.moveFunc = moveFunc
		document.upFunc   = upFunc
		if (userFunc) GlobalParms.userFunc = userFunc
	}
	else {
		GlobalParms.userFunc = null
		if (getObjectName(list) == "Array") {
			eventWinList = list
		}
		else {
			eventWinList = new Array()
			eventWinList[0] = list
		}
	}
	for (var i = 0;i<eventWinList.length;i++) {
		var cnt = eventWinList[i].contentWindow
		if (! GlobalParms.globally) {
			cnt.downFuncSave = downFunc
			cnt.moveFuncSave = moveFunc
			cnt.upFuncSave = upFunc
			eventWinList[i].downFuncLoad = downFunc
			eventWinList[i].moveFuncLoad = moveFunc
			eventWinList[i].upFuncLoad = upFunc
			if (userFunc) {
				cnt.userFunc = userFunc
				eventWinList[i].userFuncLoad = userFunc
			}
		}
		cnt.downFunc = downFunc
		cnt.moveFunc = moveFunc
		cnt.upFunc = upFunc
	}
}
function exitEvents() { //{{{2
	with (GlobalParms) {
		if (GlobalParms.userFunc) {
			userFunc(startX,startY,stopX,stopY)
			userFunc = null
		} else if ( ! globally && fromWin && fromWin.contentWindow.userFunc) {
			fromWin.contentWindow.userFunc(startX,startY,stopX,stopY,fromWin)
		}
	}
	document.downFunc = null
	document.moveFunc = null
	document.upFunc = null
	for (var i = 0;i<eventWinList.length;i++) {
		var cnt = eventWinList[i].contentWindow
		cnt.downFunc = (cnt.downFuncSave) ? cnt.downFuncSave : null 
		if (eventWinList[i].upFuncLoad) {
			cnt.downFunc = eventWinList[i].downFuncLoad
			cnt.moveFunc = eventWinList[i].moveFuncLoad
			cnt.upFunc = eventWinList[i].upFuncLoad
		}
	}
	GlobalParms.globally = false
	GlobalParms.downFunc = null
	GlobalParms.moveFunc = null
	GlobalParms.upFunc = null
}
function globalOnMouseDown(e) { //{{{2
	if (GlobalParms.capture) return(false)
	if (e == 0) {  // called by iframeOnMouseDown
		var orWin = GlobalParms.fromWin.contentWindow
	} else {
		getDocumentEvent(e)
		GlobalParms.fromWin = WinList[0]
		var orWin = document
	}
	for (var i=0;i<MenuList.length;i++) { 
		if (GlobalParms.target != MenuList[i].div) MenuList[i].hide()
	}
	if (GlobalParms.button == 2 && typeof(DefaultPopup) != "undefined") {
		with (GlobalParms) {
			DefaultPopup.showAt(X,Y)
			return(false)
		}
	}
	if ( ! orWin.upFunc)  return(true)
	GlobalParms.downFunc = orWin.downFunc
	GlobalParms.moveFunc = orWin.moveFunc
	GlobalParms.upFunc = orWin.upFunc
	GlobalParms.capture = true
	GlobalParms.startX = GlobalParms.X
	GlobalParms.startY = GlobalParms.Y
	GlobalParms.startTarget = GlobalParms.target
	if (GlobalParms.fromWin) with (GlobalParms.fromWin) {
		GlobalParms.winLeft = left
		GlobalParms.winTop = top
		GlobalParms.winWidth =  width
		GlobalParms.winHeight = height
	}
	if (GlobalParms.downFunc) GlobalParms.downFunc(e)
	GlobalParms.onmousemovesave = document.onmousemove
	GlobalParms.onmouseupsave = document.onmouseup
	document.onmousemove = globalOnMouseMove
	document.onmouseup = globalOnMouseUp
	return(false)
}
function globalOnMouseMove(e) { //{{{2
	if (e != 0) getDocumentEvent(e)
	with (GlobalParms) {
		if (button == 2) return(false)
		if (X > 0 && Y > 0 && X < getScreenWidth() && Y < getScreenHeight()) {
			if (GlobalParms.moveFunc) GlobalParms.moveFunc(e)
		}
	}
	return(false)
}
function globalOnMouseUp(e) { //{{{2
	if (e != 0) getDocumentEvent(e)
	if (GlobalParms.button == 2) return(false)
	GlobalParms.stopX = GlobalParms.X
	GlobalParms.stopY = GlobalParms.Y
	if (GlobalParms.upFunc) GlobalParms.upFunc(e)
	GlobalParms.fromWin = null
	GlobalParms.capture = false
	if (GlobalParms.onmousemovesave) document.onmousemove = GlobalParms.onmousemovesave
	if (GlobalParms.onmouseup) document.onmouseup = GlobalParms.onmouseupsave
	return(false)
}
function globalOnKeyDown(e) { //{{{2
	if (!e) e = event
	if (e.keyCode == 27) {
		for (var i=0;i<MenuList.length;i++) {
			MenuList[i].hide()
		}
	}
	return(true)
}
function stopPropagation(e) { //{{{2
	if (ie) event.cancelBubble = true
	else e.stopPropagation()
	return(false)
}
//************** Global zoom, pan and click {{{1 ***************************
function zoomboxObj() { //{{{2
	var div = this.div = document.createElement("div")
	with (div.style) {
		position 	= "absolute"
		overflow 	= "hidden"
		border   	= "solid black 1px"
		zIndex 		= 100000
		visibility = "hidden"
	}
}
zoombox = new zoomboxObj()
zoomboxObj.prototype.showAt = function(x1,y1,x2,y2) { //{{{2
	var le = (x1 < x2 ) ? x1 : x2
	var tp = (y1 < y2 ) ? y1 : y2
	var wi = Math.abs(x2 - x1)
	var he = Math.abs(y2 - y1)
	with (this.div.style) {
		left   = le
		top    = tp
		width  = wi
		height = he
		visibility = "visible"
	}
}
zoomboxObj.prototype.hide = function() { //{{{2
	this.div.style.visibility = "hidden"
}
function globalZoom(func,winlist) { //{{{2
	initEvents(startZoom,moveZoom,stopZoomPan,winlist,func)
}
function globalPan(func,winlist) { //{{{2
	initEvents(startPan,movePan,stopZoomPan,winlist,func)
}
function startZoom(e) { //{{{2
	if (!ie) GlobalParms.zooming = true
	with (GlobalParms) zoombox.showAt(X,Y,X,Y)
}
function moveZoom(e) { //{{{2
	with (GlobalParms) zoombox.showAt(startX,startY,X,Y)
}
function startPan(e) { //{{{2
	if (!ie) GlobalParms.zooming = true
	with (GlobalParms.fromWin) zoombox.showAt(contentLeft,contentTop,contentLeft + contentWidth,contentTop + contentHeight)
}
function movePan(e) { //{{{2
	var dx = GlobalParms.X - GlobalParms.startX
	var dy = GlobalParms.Y - GlobalParms.startY
	with (GlobalParms.fromWin) {
		var x1 = contentLeft + dx
		var y1 = contentTop + dy
		var x2 = x1 + contentWidth
		var y2 = y1 + contentHeight
		zoombox.showAt(x1,y1,x2,y2)
	}
}
function stopZoomPan(e) { //{{{2
	if (!ie ) GlobalParms.zooming = false
	zoombox.hide()
	exitEvents()
	return(false)
}
function nullFunc(){return(null)}
function globalClick(func,winList) { //{{{2
	initEvents(nullFunc,null,exitEvents,winList,func)
}
function globalMove(func,winList) { //{{{2
	initEvents(nullFunc,func,exitEvents,winList,nullFunc)
}
//********************** ServerFrame {{{1 **********************************
function serverFrame(win) { //{{{2
	sfrCounter = (typeof(sfrCounter) == "undefined" ) ? 0 : ++sfrCounter
	var ifrname = "iframe" + sfrCounter
	if (ie) {
		var ifrHTML = 		'<iframe'
		ifrHTML = ifrHTML + ' id='   + ifrname
		ifrHTML = ifrHTML + ' name=' + ifrname
		if (typeof(domain) != "undefined") {
			ifrHTML = ifrHTML + ' src="' + domainsrc + '"'
		}
		ifrHTML = ifrHTML + '></iframe>'
		document.write(ifrHTML)
		var ifr = this.ifr = document.getElementById(ifrname)
	} else {
		var ifr = this.ifr = document.createElement("iframe")
		ifr.name = "iframe" + sfrCounter // do this before append!!
		document.body.appendChild(ifr)
	}
	ifr.serverFrame = this
	ifr.firsttime = true
	if (win) this.win = win
	with(ifr.style) {
		position 	="absolute"
		visibility 	= "hidden"
		top			= 50
		left 		= 100
		width 		= 500
		height 		= 300
		zIndex 		= 100000
	}
	this.scheduleList = new Array()
	this.status = FINISHED
	ScheduleList[ScheduleList.length] = this

	if(ie) ifr.onreadystatechange = onServerFrameLoad
	else ifr.onload = onServerFrameLoad
}
function onServerFrameLoad() { //{{{2
	if (ie && this.readyState != "complete") return
	try {
		this.body = this.contentWindow.document.body
	} catch(e) {
		this.style.visibility = "visible"
		var errmsg = "server error in window " 
		if (this.win) errmsg += this.win.title.text
		errmsg += ".\nPlease correct the error and reload the page \n(use "
		if (ie) errmsg += "<ctrl>Click for Internet Explorer"
		else errmsg += "<shift>Click for Mozilla/Netscape"
		errmsg += ")."
		alert(errmsg)
		this.style.visibility = "hidden"
		return
	}
	var doc = this.contentWindow.document
	var frm = doc.getElementsByTagName("form")[0]
	if (! frm) {
		frm = doc.createElement("form")
		doc.body.appendChild(frm)
		frm.method = "POST"
	}
	this.contentWindow.serverFrame = this.serverFrame
	this.serverFrame.contentWindow = this.contentWindow
	this.serverFrame.form = frm
	if (this.firsttime) {
		this.firsttime = false
		return
	}
	with (this.serverFrame) {
		if (scheduleList.length > 0) {
			status = RETURNED
		} else {
			if (this.serverFrame.execOnReturn) {
				execOnReturn(this.serverFrame)
			}
			status = FINISHED
		}
	}
	checkSchedule()
}


function getSlot(sf,name,value) { //{{{2
	if (typeof(sfs) == "undefined") {
		sfs = new Array()
		sfNames = new Array()
		sfValues = new Array()
		var i = 0
	} else {
		for (var i=0;i<sfs.length;i++) {
			if (!sfs[i]) break 
		}
	}
	sfs[i] = sf
	if (name) sfNames[i] = name
	if (value) sfValues[i] = value
	return(i)
}
serverFrame.prototype.setVar = function(name,value) { //{{{2
	var i = getSlot(this,name,value)
	if (GlobalParms.WindowLoaded) setTimeout("setVarThreaded(" + i + ")",0)
	else setTimeout("setVarThreaded(" + i + ")",500)
}
function setVarThreaded(slot) { 
	var sf = sfs[slot]
	var name = sfNames[slot]
	var value = sfValues[slot]
	for (var i=0;i<sf.form.length;i++) {
		var frmEl = sf.form[i]
		if (frmEl.name == name) {
			frmEl.value = value
			return
		}
	}
	var sb = sf.ifr.contentWindow.document
	var el = sb.createElement("input")
	el.type = "hidden"
	el.name = name
	el.value = value
	sf.form.appendChild(el)
	sfs[slot] = null
}
serverFrame.prototype.removeVar = function(name) { //{{{2
	var i = getSlot(this,name)
	setTimeout("removeVarThreaded(" + i + ")",0)
}
function removeVarThreaded(slot) { 
	var sf = sfs[slot]
	if (!sf) return
	var name = sfNames[slot]
	for (var i=0;i<sf.form.length;i++) {
		var frmEl = sf.form[i]
		if (frmEl.name == name) {
			sf.form.removeChild(frmEl)
			return
		}
	}
	sfs[i] = null
}
serverFrame.prototype.getVar = function(name) { //{{{2
	for (var i=0;i<this.form.length;i++) {
		var frmEl = this.form[i]
		if (frmEl.name == name) return (frmEl.value)
	}
	return(null)
}
serverFrame.prototype.flush = function() { //{{{2
	var i = getSlot(this)
	setTimeout("flushThreaded(" + i + ")",0)
}
function flushThreaded(i) {
	var sf = sfs[i]	
	sf.contentWindow.document.innerHTML = ""
	var frm = sf.contentWindow.document.createElement("form")
	sf.contentWindow.document.body.appendChild(frm)
	frm.method = "POST"
	sf.serverFrame.form = frm
	sfs[i] = null
}
serverFrame.prototype.setServerURL = function(url) { //{{{2
	var i = getSlot(this,url)
	if (GlobalParms.WindowLoaded) setTimeout("setServerURLThreaded(" + i + ")",0)
	else setTimeout("setServerURLThreaded(" + i + ")",500)
}
function setServerURLThreaded(i) {
	var sf = sfs[i]
	var url = sfNames[i]
	sf.form.action = url
	sfs[i] = null
}
serverFrame.prototype.setExecOnReturn = function(func) { //{{{2
	this.execOnReturn = func
}
serverFrame.prototype.setTarget = function (target) { //{{{2
	if (typeof(target) == "string") target = document.getElementById(target)
	this.target = target
	this.target.fromServerFrame = this
	if (target.tagName) with(target) if ((tagName == "IMG" || tagName == "IFRAME")) {
		if (ie) target.onreadystatechange = onTargetLoad
		else target.onload = onTargetLoad
	}
}
function onTargetLoad() { // {{{2
	if (ie && this.readyState != "complete") return
	this.fromServerFrame.status = FINISHED
	checkSchedule()
}
serverFrame.prototype.submit = function() { //{{{2
	var i = getSlot(this)
	if (GlobalParms.WindowLoaded) setTimeout("submitThreaded(" + i + ")",0)
	else setTimeout("submitThreaded(" + i + ")",500)
}
function submitThreaded(i) { 
	var sf = sfs[i]
	if (sf.form.action) {
		if (sf.target) {
			var tName = sf.target.tagName
			var tObj = getObjectName(sf.target)
			if (tObj == "win" || tName =="IMG") sf.status = SUBMITTED
			else {
				sf.target.status = SUBMITTED
				sf.status = FINISHED
			}
			if (tName == "IMG") {
				sf.target.src = sf.mkGetURL()
			}
			else if (tName == "IFRAME") {
				sf.form.target = sf.target.name
				sf.form.submit()
			}
			else {
				sf.form.target = sf.target.ifr.name
				sf.form.submit()
			}
		} else {
			sf.status = SUBMITTED
		}
	} else if (! sf.fromServerFrame && sf.execOnReturn) {
		if (sf.scheduleList.length == 0) {
			sf.execOnReturn(sf)
			sf.status = FINISHED
		} else {
			sf.status = RETURNED
		}
	}
	sfs[i] = null
}
serverFrame.prototype.mkGetURL = function() { //{{{2
	var url = this.form.action
	var separator = "?"
	for (var i=0;i<this.form.elements.length;i++) {
		var name = this.form.elements[i].name 
		var val = this.form.elements[i].value
		url = url + separator
		separator = "&"
		url = url + escape(name) + "=" + escape(val)
	}
	return (url)
}
serverFrame.prototype.schedule = function(sfr,after) { //{{{2
	if (!sfr) {
		this.scheduleList.length = 0
		return
	}
	var toFrame   = (after) ? this : sfr
	var fromFrame = (after) ? sfr  : this
	with (toFrame) {
		scheduleList[scheduleList.length] = fromFrame
		status = RETURNED
	}
	if (!toFrame.execOnAllReturn) fromFrame.status = SUBMITTED
}
serverFrame.prototype.scheduleWin = function (win,after) { //{{{2
	for (var i=0;i<win.serverFrames.length;i++) {
		this.schedule(win.serverFrames[i],after)
	}
}
serverFrame.prototype.scheduleElement = function (el,after) { //{{{2
	if (el.scheduleList) this.schedule(el,after)
	else if (el.serverFrames) this.scheduleWin(el,after) 
	else for (var i=0;i<el.length;i++) this.scheduleElement(el[i],after)
}
serverFrame.prototype.scheduleAfter = function() { //{{{2
	this.schedule()
	for (var i=0;i<arguments.length;i++) this.scheduleElement(arguments[i],true)
}
serverFrame.prototype.scheduleBefore = function() { //{{{2
	this.schedule()
	for (var i=0;i<arguments.length;i++) this.scheduleElement(arguments[i],false)
}
function checkSchedule() { //{{{2
	if (typeof(checking) != "undefined" && checking) {
		setTimeout("checkSchedule()",100)
		return
	}
	checking = true
	for (i=0;i<ScheduleList.length;i++) {
		var sfr = ScheduleList[i]
		if (sfr.status == RETURNED) {
			var allFinished = true
			for (var j=0;j<sfr.scheduleList.length;j++) {
				var sfrBefore = sfr.scheduleList[j]
				if (sfrBefore.status != FINISHED) allFinished = false
			}
			if (allFinished) {
				if (sfr.execOnReturn) {
					sfr.execOnReturn(sfr)
				} else if (sfr.execOnAllReturn) {
					sfr.execOnAllReturn(sfr.win)
				}
				sfr.status = FINISHED
				checkSchedule()
			}
		}
	}
	checking = false
}
//********************** Window {{{1 *************************************
function win(le,to,wi,he,title,src,refDiv) { //{{{2
	var div = this.div = document.createElement("div")
	document.body.appendChild(div)
	div.win = this
	this.winIndex 	 = WinList.length
	this.borderWidth = 5
	this.titleHeight = 16
	var topDisp		 = (ie) ? 1 : 0
	var borderDisp	 = (ie) ? 1 : this.borderWidth
	this.left        = getLeftRelative(le,refDiv) 
	this.top         = getTopRelative(to,refDiv) + topDisp 
	this.width       = getLeftRelative(wi,refDiv)  + 2*borderDisp - 2
	this.height      = getTopRelative(he,refDiv)  + 2*borderDisp - 2
	with (div.style) {
		border      = "lightgrey " + this.borderWidth
		borderStyle = "ridge"
		position    = "absolute"
	}
	this.ver = this.hor = -1
	this.resizeall(true,true)
	this.addTitle(title)
	this.addIcon()
	this.addDisplayFrame(src)
	this.serverFrames = new Array()
	this.addServerFrame().setTarget(this)
	WinList[WinList.length] = this
	
	div.onmouseover = setBorderCursor
	div.onmousemove = setBorderCursor
	div.onmousedown = initResize

	this.lastFrame = new serverFrame()
	this.lastFrame.win = this
	this.execBeforeSubmit = function(win){win.showLed()}
	this.lastFrame.execOnAllReturn = function(win){win.hideLed()}
	this.raise()
}
win.prototype.addTitle = function(titleText) { //{{{2
	var title = this.title = document.createElement("div")
	this.div.appendChild(title)
	title.win = this
	with (title.style) {
		position          = "absolute"
		left              = 0
		top               = 0
		width             = this.innerWidth
		border            = "none"
		borderBottomWidth = 3
		borderBottomColor = "gray"
		borderBottomStyle = "ridge"
		cursor            = "default"
		if (ie) height = this.titleHeight
		else height = this.titleHeight - parseInt(borderBottomWidth)
	}
	this.title.leftText 		= 0
	this.title.rightText 		= this.innerWidth
	this.title.leftButtons 		= 0
	this.title.rightButtons 	= 0
	var tl = this.textDiv = document.createElement("div")
	this.title.appendChild(tl)
	with (tl.style) {
		position		= "absolute"
		top 			= 0
		height			= this.titleHeight - 5
		color			= "black"
		font			= "caption"
		fontWeight 		= "bold"
		fontSize		= this.titleHeight - 5
		textAlign		= "center"
		overflow		= "hidden"
	}
	this.setTitle(titleText)
	if (typeof(winMenu) == "undefined" ) {
		winMenu = new menu()
		winButtonMenu = new menu
			("submit",submit0,
		  	 "windows",winMenu
			)
	}
	winMenu.addButton(this)
	this.addButton(1+WinList.length,winButtonMenu,true)
	this.addButton("X",iconify0)
	this.addButton("-",maxmin0)

	title.onmousedown = initWinMove
}
win.prototype.addButton = function(chr,func,atLeft) { //{{{2
	var btn = new button (chr,func)
	btn.div.innerHTML = chr
	this.title.appendChild(btn.div)
	btn.div.win = this
	btn.div.id = "button"
	btn.div.win = this
	with (btn.div.style) {
		font			= "caption"
		lineHeight		= (ie) ? 1.1 : 1.0
		fontWeight		= "bold"
		textAlign		= "center"
		position		= "absolute"
		top				= (ie) ? 0 : 0
		if (atLeft)  {	
			left		= 1
			this.title.leftText = this.title.leftButtons * 16
			this.title.leftButtons++
			this.led = btn
		} else {
			++this.title.rightButtons
			this.title.rightText = ((this.title.rightButtons) * -16) + this.innerWidth
			left 		= this.title.rightText
			btn.div.atRight = true
		}
	}
}
win.prototype.addIcon = function() { //{{{2
	var div = document.createElement("span")
	document.body.appendChild(div)
	with (div.style) {
		position		= "absolute"
		width			= 16
		height			= 16
		visibility 		= "hidden"
		cursor			= "default"
		color 		    = "#000000"
		backgroundColor = "#d0d0d0"
		border 		    = "1px solid black"
		borderColor	    = "#f0f0f0 #606060 #606060 #f0f0f0"
		fontFamily	    = "MS Arial  Sans Serif"
		fontSize	    = "14px"
		font			= "caption"
		fontWeight		= "bold"
		padding		    = "4px 4px 4px 4px"
		textAlign		= "center"
		whiteSpace	    = "pre"
	}
	this.icon 		= div
	this.iconified 	= false
	div.win 		= this
	div.positioned 	= -1
	div.onmouseup 	= function() {this.win.deIconify()}
	div.title 		= this.title.text
	div.innerHTML 	= this.winIndex + 1
}
win.prototype.addDisplayFrame = function(src) { //{{{2
	sfrCounter = (typeof(sfrCounter) == "undefined") ? 0 : ++sfrCounter
	var ifrname = "iframe" + sfrCounter
	if (ie) {
		var ifrHTML = 		'<iframe'
		ifrHTML = ifrHTML + ' id='   + ifrname
		ifrHTML = ifrHTML + ' name=' + ifrname
		if (typeof(domain) != "undefined") {
			ifrHTML = ifrHTML + ' src="' + domainsrc + '"'
		}
		ifrHTML = ifrHTML + '></iframe>'
		document.write(ifrHTML)
		var ifr = this.ifr = document.getElementById(ifrname)
	} else {
		var ifr = this.ifr = document.createElement("iframe")
		ifr.name = ifrname // do this before append!!
	}
	this.div.appendChild(ifr)
	ifr.win = this
	this.firsttime = true
	if (src) ifr.src = src
	else if (ie && typeof(domain) != "undefined") ifr.src = domainsrc
	with(ifr.style) {
		position = "absolute"
		left     = 0
		top      = this.titleHeight 
		width    = this.contentWidth
		height   = this.contentHeight
		border   = "none"
	}
	this.contentWindow = ifr.contentWindow
	
	if (ie) ifr.onreadystatechange = onWinLoad
	else ifr.onload = onWinLoad
}
function onWinLoad() { //{{{2
	if ( ie && this.readyState != "complete" ) return
	try {
		this.body = this.contentWindow.document.body
	} catch(e) {
		var errmsg = "server error in window " + this.win.title.text
		errmsg += ".\nPlease correct the error and reload the page \n(use "
		if (ie) errmsg += "<ctrl>Click for Internet Explorer"
		else errmsg += "<shift>Click for Mozilla/Netscape"
		errmsg += ")."
		alert(errmsg)
		if (typeof(domainsrc) != "undefined") this.src = domainsrc
		return
	}
	this.win.document = this.contentWindow.document
	with( this.contentWindow) {
		this.contentWindow.win = this.win
		document.win = this.win
		document.window = this.contentWindow
		document.oncontextmenu = function(){return(false)}
		if (ie) document.onselectstart = function(){return(false)}
		document.onmousedown = iframeOnMouseDown
		document.onmousemove = iframeOnMouseMove
		document.onmouseup = iframeOnMouseUp
		document.onkeydown = iframeOnKeyDown
	}
	with (this.contentWindow.document.body.style) {
		border = "none"
	    if (!backgroundColor) backgroundColor = "white"
	}
	if (this.win.fromServerFrame) {
		this.win.fromServerFrame.status = FINISHED
		checkSchedule()
	}
	if (this.win.firsttime) {
		this.win.firsttime=false
	} else {
		if (this.win.execOnReturn) this.win.execOnReturn(this.win)
		if (this.win.downFuncLoad) {
			this.contentWindow.downFunc = this.win.downFuncLoad
			this.contentWindow.moveFunc = this.win.moveFuncLoad
			this.contentWindow.upFunc = this.win.upFuncLoad
			if (this.win.userFuncLoad) this.contentWindow.userFunc = this.win.userFuncLoad
		}
	}
	
}
//****************** Window server access {{{1 ****************************   
win.prototype.addServerFrame = function(num) { //{{{2
	sbm = new serverFrame(this)
	this.serverFrames[this.serverFrames.length] = sbm
	if (typeof(num) == "undefined") return(sbm)
	for (var i=1;i<num;i++) { 
		sbm1 = new serverFrame(this)
		this.serverFrames[this.serverFrames.length] = sbm1
	}
	return(sbm)
}
win.prototype.setVar = function(name,value) { //{{{2
	this.serverFrames[0].setVar(name,value)
}
win.prototype.getVar = function(name) { //{{{2
	return(this.serverFrames[0].getVar(name))
}
win.prototype.getReturnedVar = function(name) {//{{{2
	var v = this.contentWindow.document.getElementsByTagName("form")[0]
	if (! v) return (null)
	if (! v[name]) return (null)
	return (v[name].value)
}
win.prototype.removeVar = function(name) { //{{{2
	this.serverFrames[0].removeVar(name)
}
win.prototype.flush = function() { //{{{2
	this.serverFrames[0].flush()
}
win.prototype.setServerURL = function(url) { //{{{2
	this.serverFrames[0].setServerURL(url)
}
win.prototype.submit = function() { //{{{2
//	if (this.lastFrame.status == RETURNED) {
//		var msg = "Sorry, this window already has a job running."
//		msg += "\nPlease wait until the red button has turned grey."
//		alert(msg)
//		return
//	}
	if (this.execBeforeSubmit) this.execBeforeSubmit(this)
	if (this.lastFrame.execOnAllReturn) {
		this.lastFrame.schedule()
		this.lastFrame.scheduleAfter(this)
		this.lastFrame.status = RETURNED
	}
	for (var i=0 ;i<this.serverFrames.length;i++) {
		this.serverFrames[i].submit()
	}
	setTimeout("checkSchedule()",50)
}
win.prototype.scheduleAfter = function(win) { //{{{2
	for (var i=0;i<this.serverFrames.length;i++) {
		this.serverFrames[i].scheduleWin(win,true)
	}
}
win.prototype.scheduleBefore = function(win) { //{{{2
	for (var i=0;i<this.serverFrames.length;i++) {
		this.serverFrames[i].scheduleWin(win,false)
	}
}
win.prototype.setExecBeforeSubmit = function(func) { //{{{2
	this.execBeforeSubmit = func
}
win.prototype.setExecOnReturn = function(func) { //{{{2
	this.execOnReturn = func
}
win.prototype.setExecAfterAllReturn = function(func) { //{{{2
	this.lastFrame.execOnAllReturn = func
}
win.prototype.setExecOnResize = function(func) { //{{{2
	this.execOnResize = func
}
//***************** Window move and resize {{{1 ****************************
function initWinMove(e) { //{{{2
	GlobalParms.fromWin = this.win
	this.win.raise()
	initEvents(null,doWinMove,stopWinMove)
	globalOnMouseDown(e)
}
function doWinMove(e) { //{{{2
	var dx = GlobalParms.X - GlobalParms.startX
	var dy = GlobalParms.Y - GlobalParms.startY
	WinList[0].move(dx,dy)
}
function stopWinMove(e) { //{{{2
	exitEvents()
}
function initResize(e) { //{{{2
	GlobalParms.fromWin = this.win
	this.win.raise()
	initEvents(startResize,moveResize,stopResize)
	globalOnMouseDown(e)
}
function startResize(e) { //{{{2
	if (!ie) GlobalParms.resizing = true
}
function moveResize(e) { //{{{2
	var dx = GlobalParms.X - GlobalParms.startX
	var dy = GlobalParms.Y - GlobalParms.startY
	if (GlobalParms.fromWin) GlobalParms.fromWin.resize(dx,dy)
}
function stopResize(e) { //{{{2
	if (!ie) GlobalParms.resizing = false
	exitEvents()
	if (GlobalParms.fromWin.execOnResize) GlobalParms.fromWin.execOnResize(GlobalParms.fromWin)
}
function setBorderCursor(e) { //{{{2
	if (GlobalParms.capture)  return(false)
	if (ie) var e = event
	var scrollX = (ie) ? document.body.scrollLeft : window.scrollX
	var scrollY = (ie) ? document.body.scrollTop  : window.scrollY
	var eX = e.clientX + scrollX 
	var eY = e.clientY + scrollY
	this.win.hor = this.win.ver = 0
	with (this.win) {
		if      (eX < left) return (false) 
		else if (eX > right) return (false)
		else if (eY < top) return (false)
		else if (eY > bottom) return (false)
		else if (eX <= innerLeft) hor = -1
		else if (eX >= innerRight) hor = 1
		else if (eY <= innerTop) ver = -1
		else if (eY >= innerBottom) ver = 1
		else return(false)
		if (hor) {
			if      (eY < top + 20) ver = -1 
			else if (eY > bottom - 20) ver = 1
		} else if (ver) {
			if      (eX < left + 20) hor = -1
			else if (eX > right - 20) hor = 1
		}
		var pos = ""
		if (ver == -1 ) pos = "n"
		else if (ver == 1) pos = "s"
		if (hor == -1) pos += "w"
		else if (hor == 1) pos += "e"
		pos += "-resize"
	}
	this.style.cursor = pos
	return(false)
}
win.prototype.resizeall = function(resize,firsttime) { //{{{2
	this.right       = this.left + this.width - 1
	this.bottom      = this.top + this.height - 1
	this.innerLeft   = this.left + this.borderWidth
	this.innerTop    = this.top + this.borderWidth
	this.innerWidth  = this.width - 2*this.borderWidth
	this.innerHeight = this.height - 2*this.borderWidth
	this.innerRight  = this.innerLeft + this.innerWidth - 1
	this.innerBottom = this.innerTop + this.innerHeight - 1
	this.contentLeft  = this.innerLeft
	this.contentWidth = this.innerWidth
	this.contentTop   = this.innerTop + this.titleHeight
	this.contentHeight= this.innerHeight - this.titleHeight
	with (this.div.style) {
		if ( ie) {
			if (this.hor == -1) left   = this.left - 1
			if (this.ver == -1) top    = this.top  - 1
			if (resize && this.hor !=  0) width  = this.width
			if (resize && this.ver !=  0) height = this.height
		} else {
			if (this.hor == -1) left   = this.left
			if (this.ver == -1) top    = this.top
			if (resize && this.hor !=  0) width  = this.innerWidth
			if (resize && this.ver !=  0) height = this.innerHeight
		}
	}
	if (firsttime || !resize) return
	with (this.title.style) {
		width = this.innerWidth
	}
	var btns = this.title.getElementsByTagName("span")
	var rightBtns = 0
	for (var i = 0;i<btns.length;i++) {
		var btn = btns[i]
		if (btn.atRight) {
			this.title.rightText = ((1+rightBtns) * -16) + this.innerWidth
			btn.style.left = this.title.rightText
			++rightBtns
		}
	}
	this.setTitle()
	with(this.ifr.style) {
		width = this.contentWidth
		height = this.contentHeight
	}
}	
win.prototype.move = function(dx,dy) { //{{{2
	mmoving = true
	with (this) {
		this.left = GlobalParms.winLeft + dx
		this.top = GlobalParms.winTop + dy
		if (dx != 0) this.hor = -1
		if (dy != 0) this.ver = -1
		this.resizeall(false)
	}
}
win.prototype.resize = function (dx,dy) { //{{{2
	var le = 0
	var wi = 0
	var to = 0
	var he = 0
	with (this) {
		if (hor == -1) {
			le = GlobalParms.winLeft + dx
			wi = GlobalParms.winWidth - dx 
		} else if (hor == 1) { 
			wi = GlobalParms.winWidth + dx
		}
		if (ver == -1) {
			to = GlobalParms.winTop + dy
			he = GlobalParms.winHeight - dy 
		} else if (ver == 1) {
			he = GlobalParms.winHeight + dy
		}
		if (this.hor != 0 && wi < 20 + this.title.leftText + this.innerWidth - this.title.rightText) return
		if (he > 0 && he < this.titleHeight + 20 ) return
		if (le - GlobalParms.winLeft > GlobalParms.winWidth - 50) return
		if (to - GlobalParms.winTop > GlobalParms.winHeight - (this.titleHeight + 20)) return
		if (le > 0) left = le
		if (wi > 0) width = wi
		if (to > 0) top = to
		if (he > 0 ) height = he
	}
	this.resizeall(true)
	return(false)
}
win.prototype.raise = function() { //{{{2
	if (WinList[0] == this && WinList.length > 1) return
	WinList[0].title.style.backgroundColor = "silver"
	WinList[0].textDiv.style.color = "black"
	this.title.style.backgroundColor = "teal"
	this.textDiv.style.color = "white"
	var i = 0
	while (WinList[i] != this) i++
	for (var j=i;j>0;j--) {
		WinList[j] = WinList[j-1]
		WinList[j].div.style.zIndex = 1000 - j
	}
	WinList[0] = this
	this.div.style.zIndex = 1000
	if (GlobalParms.currentHelpPage) {
		GlobalParms.currentHelpPage.raisedWindow = this
	}
}
win.prototype.setPosition = function(le,to,wi,he) { //{{{2
	this.left = le
	this.top = to
	this.width = wi
	this.height = he
	this.hor = -1
	this.ver = -1
	this.resizeall(true,false)
}
win.prototype.setTitle= function(txt) { //{{{2
	if (! txt) {
		if ( ! this.title.text) {
			return
		} else {
			txt = this.title.text
		}
	} else {
		this.title.text = txt
	}
	with (this.textDiv.style) {
		left = this.title.leftText
		width = this.title.rightText - this.title.leftText
	}
	this.textDiv.innerHTML = txt
}
win.prototype.maxmin = function() { //{{{2
	this.raise()
	if (this.oldLeft) with (this) {
		setPosition(oldLeft,oldTop,oldWidth,oldHeight)
		oldLeft = null
		if (this.execOnResize) this.execOnResize(this)
		return
	}
	this.oldLeft = this.left
	this.oldTop = this.top
	this.oldWidth = this.width
	this.oldHeight = this.height
	this.setPosition(0,0,getScreenWidth(),getScreenHeight())
	if (this.execOnResize) this.execOnResize(this)
}
win.prototype.deIconify = function() { //{{{2
	var ic = this.icon
	var w = parseInt(ic.style.width) + 5
	var h = parseInt(ic.style.height) + 5
	ic.style.visibility = "hidden"
	this.div.style.visibility = "visible"
	for (var i=0;i<WinList.length;i++) {
		var ic2 = WinList[i].icon
		if (ic2.positioned > ic.positioned) {
			ic2.positioned--
			var x = ic2.positioned * (w + 3)
			var y = getScreenHeight() - h
			ic2.style.left = x
			ic2.style.top = y
		}
	}
	ic.positioned = -1
	this.iconified = false
	this.raise()
}
win.prototype.iconify = function() { //{{{2
	var ic = this.icon
	var w = parseInt(ic.style.width) + 5
	var h = parseInt(ic.style.height) + 5
	ic.positioned = 0
	for (var i=0;i<WinList.length;i++) {
		var ic2 = WinList[i].icon
		if (ic2.style.visibility == "visible" && ! ic2.positioned != -1) {
			ic.positioned++
		}
	}
	var x = ic.positioned * (w + 3)
	var y = getScreenHeight() -h
	ic.style.left = x
	ic.style.top = y
	ic.style.visibility = "visible"
	this.div.style.visibility = "hidden"
	this.iconified = true
	var i = WinList.length - 1
	while (i > 0 && WinList[i].iconified) i--
	if (i > 0) WinList[i].raise()
}
win.prototype.showLed = function() { //{{{2
	this.led.div.style.backgroundColor = "red"
	this.icon.style.backgroundColor = "red"
}
win.prototype.hideLed = function() { //{{{2
	this.led.div.style.backgroundColor = "#d0d0d0"
	this.icon.style.backgroundColor = "#d0d0d0"
}
function submit0() { //{{{2
	WinList[0].submit()
}
function maxmin0() { //{{{2
	WinList[0].maxmin()
}
function iconify0() { //{{{2
	WinList[0].iconify()
}
//************************ Button {{{1 *************************************
function button(text,action,x,y,refDiv) { //{{{2
	if (text.div) {					// Object with internal DIV (eg slider)
		var div = text.div
	}
	else if (typeof(text) == "object") {	// DOM element
		var div = text
	} else { 							// Text or icon
		var div = this.div = document.createElement("span")
		document.body.appendChild(div)
		if (typeof(text) == "string") {
			if (text.match(/\.gif$/) || text.match(/\.png$/) || text.match(/\.jpg$/)) {
				if (typeof(iconDir) != "undefined") text = iconDir + text
				div.innerHTML = "<img src = " + text + ">"
				var icon = true
			} else {
//				text = text.replace(/ /g,"&nbsp;")
				div.innerHTML = text
				if (action && getObjectName(action) == "menu") this.mkArrow()
				var icon = false
			}
		}
	}
	div.button = this
	this.div = div
	this.action = action
	if (text.div) with (div.style) {
		position			= "relative"
		border 			    = "1px solid black"
		borderColor		    = "#f0f0f0 #606060 #606060 #606060"
		backgroundColor = "#d0d0d0"
		return
	}
	
	with (div.style) {
		position 		    = (x) ? "absolute" : "relative"
		if (x) {
			left = getLeftRelative(x,refDiv)
			top = getTopRelative(y,refDiv)
		}
		border 			    = "1px solid black"
		borderColor		    = "#f0f0f0 #606060 #606060 #f0f0f0"
		cursor 			    = "default"
		if (! icon) { 
			color 		    = "#000000"
			backgroundColor = "#d0d0d0"
			fontFamily	    = "Arial,  Sans Serif"
			fontSize	    = "12px"
			if (!text.div) padding		    = "0px 4px 0px 4px"
			whiteSpace	    = "pre"
		}
	}
	this.div.onmousedown = function(e) { //{{{3 
		if (GlobalParms.capture) return(false)
		if (ie) {
			var e = event
			e.cancelBubble = true
		} else e.stopPropagation()
		if (! this.pushed) {
			var b = this.style.borderColor
			if (this.menu && this.menu.toggleButtons())  this.button.toggle()
			else this.style.borderColor = "#606060 #f0f0f0 #f0f0f0 #606060"
			
			if (this.menu && this.menu.stickyButtons() && ! this.menu.toggleButtons()) {
				var btns = this.menu.btns
				for (var i=0;i<btns.length;i++) {
					var btn = btns[i]
					if (btn != this.button) btn.div.style.borderColor = "#f0f0f0 #606060 #606060 #f0f0f0"
				}
			}
		}
		this.pushed = true
		if (this.win) this.win.raise()
		if (this.menu) {
			if (this.menu.sticky()) this.button.schedule(0)
			else  this.button.schedule(350)
		} else this.button.schedule(1)
		
		return(false)
	}
	this.div.onmouseup = function(e) { //{{{3 
		if (GlobalParms.capture) return(false)
		if (ie) {
			var e = event 
			e.cancelBubble = true
		} else e.stopPropagation()
		if (! this.menu || !this.menu.stickyButtons()) this.style.borderColor 	= "#f0f0f0 #606060 #606060 #f0f0f0"
		if (this.pushed && action) {
			if (getObjectName(action) == "Function") {
				action(this.button)
				for (var i=0;i<MenuList.length;i++) MenuList[i].hide()
			}
			else if (getObjectName(action) == "win") {
				action.raise()
				for (var i=0;i<MenuList.length;i++) MenuList[i].hide()
			}
		}
		this.pushed = false
		return(false)
	}
	this.div.onmousemove = function(e) { //{{{3 
		if (GlobalParms.capture) return(false)
		if (ie) event.cancelBubble = true
		else e.stopPropagation()
		return(false)
	}
	this.div.onmouseout = function(e) { //{{{3 
		if (GlobalParms.capture) return(false)
		if (ie) event.cancelBubble = true
		else e.stopPropagation()
		if (! this.menu ||  ! this.menu.stickyButtons()) this.style.borderColor 	= "#f0f0f0 #606060 #606060 #f0f0f0"
		this.pushed = false
		return(false)
	}	
	this.div.onmouseover = function(e) { //{{{3 
		if (GlobalParms.capture) return(false)
		if (ie) event.cancelBubble = true
		else e.stopPropagation()
		if (this.menu && !this.menu.sticky() && !this.menu.stickyButtons()) {
			this.onmousedown(e)
		} 
		return(false)
	}
}
button.prototype.mkArrow = function() { //{{{2
	var subdiv  = this.subdiv = document.createElement("span")
	this.div.appendChild(subdiv)
	with (subdiv.style) {
		position = "relative"
		whiteSpace = "pre"
		if (ie) {
			top = -2
			fontFamily = "Webdings"
			fontSize = "7px"
		}
	}
}
button.prototype.schedule = function (time) { //{{{2
	if (!this.action) return
	if (GlobalParms.scheduleId) clearTimeout(GlobalParms.scheduleId)
	GlobalParms.scheduledButton = this
	var newMenu = this.action
	GlobalParms.scheduleId = setTimeout("activateScheduledButton()",time)
}
function activateScheduledButton() { //{{{2
	var btn = GlobalParms.scheduledButton
	var btnMenu = btn.div.menu
	var newMenu = btn.action
	if (newMenu && getObjectName(newMenu) == "menu") {
		newMenu.calledFrom = btnMenu
		btn.showSubMenu(newMenu)
	} 
	for (var i=0;i<MenuList.length;i++) {
		var m = MenuList[i]
		if (m == btnMenu || m == newMenu) continue
		var aktCalledFrom = m.calledFrom
		while (aktCalledFrom && aktCalledFrom != btnMenu) {
			aktCalledFrom = aktCalledFrom.calledFrom
		}
		if (aktCalledFrom) {
			m.hide() 
		}
	}
}
button.prototype.showSubMenu = function(menu) { //{{{2
	if (menu.sticky()) return
	if (this.div.menu) {	// when called from another menu
		var menuX = parseInt(this.div.menu.div.style.left)
		var menuY = parseInt(this.div.menu.div.style.top)
		var menuWidth = this.div.menu.div.offsetWidth
		var menuHeight = this.div.menu.div.offsetHeight
	} else { 	// when called from leftmost button in window title bar
		var menuX = this.div.win.left - 2
		var menuY = this.div.win.top + this.div.win.borderWidth 
		this.menuX = this.div.win.borderWidth
		var menuHeight = this.div.offsetHeight
	}
	if (this.div.menu && this.div.menu.vertical()) {
		var x1 = menuX + menuWidth 
		if (x1 + menu.div.offsetWidth > getScreenWidth()) {
			x1 = menuX - menu.div.offsetWidth
		}
		var y1 = menuY + this.menuY + parseInt(menu.div.style.borderTopWidth)
	} else {
		var x1 = menuX + this.menuX
		var y1 = menuY + menuHeight 
		if (y1 + menu.div.offsetHeight > getScreenHeight()) {
			y1 = menuY - menu.div.offsetHeight 
		}
	}
	GlobalParms.menuFrom = this.div.menu
	menu.showAt(x1,y1)
}
button.prototype.toggle = function() {  //{{{2
	if (this.toggled) { 
		b ="#f0f0f0 #606060 #606060 #f0f0f0"
		this.toggled = false
	} else {
		b = "#606060 #f0f0f0 #f0f0f0 #606060"
		this.toggled = true
	}
	this.div.style.borderColor 	= b
}
	
function setIconDir(dir) { //{{{2	
	if (! dir.match(/.*\/$/)) dir += "/"
	iconDir = dir 
}
//************************** Menu {{{1 ***************************************
function menu() { //{{{2
	var div = this.div = document.createElement("div")
	document.body.appendChild(div)
	MenuList[MenuList.length] = this
	this.calledFrom = null
	with (div.style) {
		position 		= "absolute"
		backgroundColor = "#d0d0d0"
		borderTop 		= "5px"
		borderTopColor 	= "silver"
		borderTopStyle 	= "ridge"
		visibility 		= "hidden"
		zIndex 			= 10000
	}
	div.menu = this
	this.btns = new Array()
	i = 0
	while (i<arguments.length) {
		var item = arguments[i++]
		if (getObjectName(item) != "button") { 
			var btnFunc = arguments[i++]
			var btn = new button(item,btnFunc)
		} else {
			var btn = item
		}
		this.btns[this.btns.length] = btn
		div.appendChild(btn.div)
		btn.div.menu = this
	}
	this.vertical(true)
	this.realSticky(false)
	div.onmousedown = initMoveMenu
}
menu.prototype.addButton = function(item,func) { //{{{2
	if (getObjectName(item) == "win") {
		var btn = new button(item.title.text,item)
	} else if (getObjectName(item) == "button") {
		var btn = item
	} else {						// text string or DOM element
		var btn = new button(item,func)
	}
	this.btns[this.btns.length] = btn
	this.div.appendChild(btn.div)
	btn.div.menu = this
	this.vertical(this.vertical())
}
menu.prototype.showAt = function(x,y) { //{{{2
	var w = this.div.offsetWidth
	var h = this.div.offsetHeight
	var scrw = x+w - getScreenWidth()
	var scrh = y+h - getScreenHeight()
	if (scrw > 0) x -= scrw
	if (scrh > 0) y -= scrh
	if (y < 0) y = 0
	this.div.style.left = x 
	this.div.style.top = y
	if (! this.waiting) {
		this.div.style.visibility = 'visible'
	}
	for (var i = 0;i<MenuList.length;i++) if (MenuList[i].sticky()) MenuList[i].div.style.zIndex = 10000
	this.div.style.zIndex = 10001
}
menu.prototype.hide = function(e) { //{{{2
	if ( ! this.isSticky) this.div.style.visibility = "hidden"
}
menu.prototype.vertical = function(bool) { //{{{2
	if (typeof(bool) == "undefined") return(this.isVertical)
	var styleParm = (bool) ? "block" : "inline"
	for (i=0;i<this.btns.length;i++) with (this.btns[i].div.style) {
		display = styleParm
	}
	this.isVertical = bool
	var menuX = 0;
	var menuY = 0;
	for (i=0;i<this.btns.length;i++) {
		var btn = this.btns[i]
		btn.menuX = menuX
		btn.menuY = menuY
		if (this.isVertical) {
			menuY = menuY + btn.div.offsetHeight
			if (btn.subdiv) with (btn.subdiv.style) {
				btn.subdiv.innerHTML = GlobalParms.rightArrow
				left = btn.div.offsetWidth - (btn.subdiv.offsetLeft + parseInt(btn.subdiv.offsetWidth)) 
			}
		}
		else {
			menuX = menuX + btn.div.offsetWidth
			btn.div.style.width = "auto"
			if (btn.subdiv) with (btn.subdiv.style) {
				left = 0
				btn.subdiv.innerHTML = GlobalParms.downArrow
			}
		}
	}
}
menu.prototype.sticky = function(bool) { //{{{2
	if (typeof(bool) == "undefined") return(this.isSticky)
	this.isSticky = bool
	this.div.style.borderTopColor = (this.isRealSticky) ? "blue" : (this.isSticky) ? "red" : "silver"
	if (!  this.isSticky) this.hide()
}
menu.prototype.realSticky = function(bool) { //{{{2
	if (typeof(bool) == "undefined") return(this.isRealSticky)
	this.isRealSticky = bool
	this.sticky(this.isRealSticky)
}
menu.prototype.stickyButtons = function(bool) { //{{{2
	if (typeof(bool) == "undefined") return(this.isStickyButton)
	this.isStickyButton = bool
}
menu.prototype.toggleButtons = function(bool) { //{{{2
	if (typeof(bool) == "undefined") return(this.isToggleButton)
	this.isToggleButton = bool
	this.stickyButtons(bool)
}
menu.prototype.setAsDefault = function() { //{{{2
	DefaultPopup = this
}
function initMoveMenu(e) { //{{{2
	var target = (ie) ? event.srcElement : e.target
	if ( target.onmousedown != initMoveMenu) return
	initEvents(startMoveMenu,moveMenu,stopMoveMenu)
	globalOnMouseDown(e)
	return(false)
}
function startMoveMenu(e) { //{{{2
	menuMoved = false
	GlobalParms.menuStartX = parseInt(GlobalParms.target.style.left)
	GlobalParms.menuStartY = parseInt(GlobalParms.target.style.top) 
	for (var i = 0;i<MenuList.length;i++) MenuList[i].div.style.zIndex = 10000
	GlobalParms.target.style.zIndex = 10001
}
function moveMenu(e) { //{{{2
	menuMoved = true
	var dx = GlobalParms.X - GlobalParms.startX 
	var dy = GlobalParms.Y - GlobalParms.startY
	var lf = GlobalParms.menuStartX + dx
	var tp =  GlobalParms.menuStartY + dy
	var scrw = getScreenWidth()
	var scrh = getScreenHeight()
	with (GlobalParms.startTarget) {
		if (Math.abs(lf) < 15) style.left = 0 
		else if (Math.abs(lf + offsetWidth - scrw) < 15) style.left = scrw - offsetWidth 
		else style.left = lf
		if (Math.abs(tp) < 15) style.top =  0 
		else if (Math.abs(tp + offsetHeight - scrh) < 15) style.top = scrh - offsetHeight 
		else style.top = tp
	}
}
function stopMoveMenu(e) { //{{{2
	if (!menuMoved) with (GlobalParms.target) {
		if (GlobalParms.shiftKey) {
			var sl1 = menu.btns[0].div.firstChild.slider
			if (sl1) sl1.vertical(! sl1.vertical())
			else menu.vertical(!menu.vertical())
		} else with (GlobalParms.target) {
			if (!menu.realSticky()) menu.sticky(! menu.sticky())
		}
	}
	menuMoved = false
	exitEvents()
}
// ************************* HelpFrame //{{{1 ****************************
function helpFrame(le,to,wi,he,refDiv) { //{{{2
	var div = this.div = document.createElement("div")
	document.body.appendChild(div)
	div.helpFrame = this
	with (div.style) {
		position = "absolute"
		left = getLeftRelative(le,refDiv)
		top = getTopRelative(to,refDiv)
		width = getLeftRelative(wi,refDiv)
		height = getTopRelative(he,refDiv) 
		border = "ridge lightgrey"
		borderWidth = "2px 4px 4px 2px"
		zIndex = 2000
		background = "white"
		overflow = "hidden"
	}

	var titleBar = this.titleBar = document.createElement("div")
	div.appendChild(titleBar)
	titleBar.helpFrame = this
	with (titleBar.style) {
		position = "relative"
		borderBottom = "3px ridge black "
		color = "white"
		backgroundColor = "rgb(11,8,128)"
	}
	titleBar.onmousedown = initMoveHelp

	var titleText = this.titleText = document.createElement("span")
	titleBar.appendChild(titleText)
	titleText.helpFrame = this
	with (titleText.style) {
		position = "relative"
		cursor = "default"
		fontSize = (ie) ? "0.8em" : "0.8em"
		font = "caption"
		fontWeight = "bold"
	}
	
	var buttons = this.buttons = document.createElement("span")
	titleBar.appendChild(buttons)
	buttons.helpFrame = this
	with (buttons.style) {
		position = "absolute"
		top = (ie) ? 0 : 1
		fontSize = (ie) ? "60%" :"0.55em"
		cursor = "default"
		if (ie) {
			fontFamily = "Webdings" 
			var leftAr	= "&#51;" // 3"
			var rightAr	= "&#52;" // 4"
			var downAr	= "&#54;" // 6"
			lineHeight = "80%"
		}
		else {
			fontFamily = "sans-serif"
			fontWeight = "bold"
			var leftAr	= "&#9668;&nbsp;" 
			var rightAr	= "&#9658;&nbsp;" 
			var downAr	= "&#9660;&nbsp;"
		}
	}
	this.downButton = this.addButton(downAr,showPageMenu)
	this.leftButton = this.addButton(leftAr,prevPage)
	this.rightButton = this.addButton(rightAr,nextPage)
	buttons.style.left = (titleBar.offsetWidth - buttons.offsetWidth) - 1 
	
	var textArea = this.textArea = document.createElement("div")
	div.appendChild(textArea)
	with (textArea.style) {
		position = "relative"
		fontFamily = "sans serif"
	}

	this.addPageMenu()

	this.pages = new Array()
	this.titles = new Array()
	this.elements = new Array()
}
helpFrame.prototype.addButton = function(chr,func) { //{{{2
	var div = document.createElement("span")
	this.buttons.appendChild(div)
	div.helpFrame = this
	div.innerHTML = chr
	div.func = func
	div.helpFrame = this
	with (div.style) { 
		position = "relative"
		border = "1px solid"
		color = "black"
		backgroundColor = "silver"
		borderColor = "#f0f0f0 #606060 606060 f0f0f0"
	}
	div.onmousedown = defaultMouseDown = function (e) { // {{{2
		if (ie) e = event
		this.style.borderColor = "#606060 f0f0f0 f0f0f0 606060"
		if (this.func) this.func(e)
		if (ie ) event.cancelBubble = true
		else e.stopPropagation()
		for (var i=0;i<MenuList.length;i++) MenuList[i].hide()
		return(false)
	}
	div.onmouseup = div.onmouseout = defaultMouseUp = function (e) { //{{{3
		this.style.borderColor = "#f0f0f0 #606060 606060 f0f0f0"
		if (ie ) event.cancelBubble = true
		else e.stopPropagation()
		return(false)
	}
	div.onmousemove = function(e) { //{{{3
		if (ie ) event.cancelBubble = true
		else e.stopPropagation()
		return(false)
	}
	return(div)
}
function mkHelpFrame(name,le,to,wi,he) { // {{{2
	var p = new helpFrame(le,to,wi,he)
	var pages = document.getElementsByName(name)
	for (var i = 0;i<pages.length;i++) p.addPage(pages[i])
	for (var i=pages.length-1;i>=0;i--) document.body.removeChild(pages[i])
	return(p)
}
helpFrame.prototype.addPage = function(span,elements) { //{{{2
	var div  = document.createElement("span")
	this.textArea.appendChild(div)
	div.helpFrame = this
	div.elements = new Array()
	with (div.style) {
		position = "absolute"
		left = 0
		top = 0
		width = this.div.offsetWidth
		height = this.div.offsetHeight
		visibility = "hidden"
		backgroundColor = "rgb(244,244,200)"
		overflow = "auto"
	}
	if (!span) span = document.createElement("span")
	else if (typeof(span == "string")) span = document.getElementById(span)
	div.innerHTML = span.innerHTML
	div.id = span.id
	this.currentPage = this.pages.length
	this.pages[this.currentPage] = div
	if (span.id) var title = span.id
	else var title = currentPage
	this.titles[this.currentPage] = title
	this.addPageButton(title)
	for (var i = 1;i<arguments.length;i++) {
		this.addSingleElement(div,arguments[i])
	}
	document.body.removeChild(span)
	span = null
	this.showPage(0)
}
helpFrame.prototype.addSingleElement = function (page,el) { //{{{2
	if (getObjectName(el) == "Array") {
		for (var i=0;i<el.length;i++) this.addSingleElement(page,el[i])
		return
	}
	if (typeof(el) == "string") el = document.getElementById(el)
	else if (el.menu) el = el.menu
	page.elements[page.elements.length] = el
	if (el.style) el.style.visibility = "hidden"
	else if (el.div) {
		el.div.style.visibility = "hidden"
		if (el.ifr) {
			if (! page.winMenu) page.winMenu = new menu()
			page.winMenu.addButton(el)
		}
	}
}
helpFrame.prototype.removeElements = function(pageId,elements) { //{{{2
	var page = document.getElementById(pageId)
	if (typeof(elements) =="undefined") {
		page.elements = new Array()
		return
	}
	if (getObjectName(elements) == "Array") {
		var ar = elements
	} else {
		var ar = new Array()
		for (i=0;i<elements.length;i++) {
			var el1 = elements[i]
			for (var j=0;j<page.elements.length;j++) {
				var el2 = page.elements[i]
				el1.toRemove = (el1 == el2) 
			}
		}
	}
	var i = 0
	var last = page.elements.length
	while (i<page.elements.length) {
		var el = page.elements[i]
		if (el.toRemove) {
			page.elements[i] = page.elements[last]
			page.elements.length = last
			last--
		}
		i++
	}
}
helpFrame.prototype.showPage = function (pagenr) { //{{{2
	if (pagenr < 0 || pagenr >= this.pages.length) return
	if (pagenr == 0) {
		disableButton(this.leftButton)
		enableButton(this.rightButton)
	} else if (pagenr == this.pages.length-1) {
		disableButton(this.rightButton)
		enableButton(this.leftButton)
	} else {
		enableButton(this.leftButton)
		enableButton(this.rightButton)
	}
	if (typeof(this.currentPage) != "undefined" && pagenr != this.currentPage ) {
		var p = this.pages[this.currentPage]
		if (!this.oldHeight) p.style.visibility = "hidden"
		for (var i=0;i<p.elements.length;i++) {
			var el = p.elements[i] 
			if (el.style) var div = el
			else if (el.div) {
				if (el.iconified) var div = el.icon
				else var div = el.div
			}
			else var div = null
			div.style.visibility = "hidden"
		}
	}
	this.currentPage = pagenr
	if (this.oldHeight) {
		this.oldPage = this.pages[this.currentPage]
	} 
	
	var p = this.pages[this.currentPage]
	if (!this.oldHeight) p.style.visibility = "visible"
	for (var i=0;i<p.elements.length;i++) {
		var el = p.elements[i] 
		if (el.style) var div = el
		else if (el.div) {
			if (el.sticky && ! el.sticky()) var div = null
			else if (el.iconified) var div = el.icon
			else {
				var div = el.div
				if (! p.raisedWindow) {
					p.raisedWindow = div.win
				}
			}
		}
		else var div = null
		if (div) div.style.visibility = "visible"
	}
	this.titleText.innerHTML = this.titles[this.currentPage]
	if (p.winMenu) {
		winMenu.div = p.winMenu.div
	}
	GlobalParms.currentHelpPage = p
	if (p.raisedWindow) p.raisedWindow.raise()
}
helpFrame.prototype.addPageMenu = function() { //{{{2
	var div = this.pageMenu = document.createElement("div")
	document.body.appendChild(div)
	with (div.style) {
		position = "absolute"
		visibility = "hidden"
		backgroundColor = "silver"
		cursor = "default"
		border = "2px solid" 
		borderColor = "#f0f0f0 #606060 606060 f0f0f0"
		font = "menu"
		fontSize=12
		zIndex = this.div.style.zIndex + 500
	}

	div.helpFrame = this
}
helpFrame.prototype.addPageButton = function(text) { //{{{2
	var div = document.createElement("div") 
	this.pageMenu.appendChild(div)
	div.helpFrame = this
	div.pageNr = this.currentPage
	with (div.style) {
		position = "relative"
		color = "white"
		backgroundColor = "rgb(11,8,128)"
		padding = "0 2 0 4"
		whiteSpace = "pre"
		fontSize = (ie) ? "0.8em" : "0.8em"
		font = "caption"
	}
	if (ie) text = text.replace(/ /g,"&nbsp;")
	div.innerHTML = text
		
	div.onmouseover = function(e) {
		this.style.color = "white"
		this.style.backgroundColor = "teal"
		return(false)
	}
	div.onmouseout = function(e) {
		this.style.color = "white"
		this.style.backgroundColor = "rgb(11,8,128)"
	}
	div.onmouseup = function (e) {
		this.helpFrame.showPage(this.pageNr)
		this.helpFrame.pageMenu.style.visibility = "hidden"
	}
}
helpFrame.prototype.toggle = function() { //{{{2
	if (typeof(this.oldHeight) == "undefined" || ! this.oldHeight) { 
		this.oldHeight = this.div.offsetHeight
		if (ie) {
			this.div.style.overflow = "hidden"
			this.div.style.height = this.titleBar.offsetHeight + parseInt(this.titleBar.style.borderBottomWidth)
		}
		else this.div.style.height = this.titleBar.offsetHeight
		for (var i = 0;i<this.pages.length;i++) {
			var page = this.pages[i]
			if (page.style.visibility == "visible") {
				this.oldPage = page
				page.style.visibility = "hidden"
			}
		}
	} else {
		this.oldPage.style.visibility = "visible"
		if (ie) { 
			this.div.style.overflow = "auto"
		}
		this.div.style.height = this.oldHeight
		this.oldHeight = null
	}
}
function enableButton(b) { //{{{2 
	if (b.style.color == "000000") return
	b.style.color = "000000"
	b.onmousedown = defaultMouseDown
	b.onmouseup = defaultMouseUp
}
function disableButton(b) { //{{{2
	if (b.style.color == "707070") return
	b.style.color = "707070"
	b.style.borderColor = "#f0f0f0 #606060 606060 f0f0f0"
	b.onmousedown = b.onmouseup = function(e){
		if (ie ) event.cancelBubble = true
		else e.stopPropagation()
		return(false)}
}
function nextPage(e) { //{{{2
	var p = (ie) ? event.srcElement.helpFrame : e.target.parentNode.helpFrame
	p.showPage(p.currentPage+1)
	return(false)
}
function prevPage(e) { //{{{2
	var p = (ie) ? event.srcElement.helpFrame : e.target.parentNode.helpFrame
	p.showPage(p.currentPage-1)
	return(false)
}
function showPageMenu(e) { //{{{2
	with (this) {
		var x = offsetLeft + 2
		var y = offsetTop + offsetHeight + 3
		var parent = offsetParent
		while (parent) {
			x += parent.offsetLeft
			y += parent.offsetTop
			parent = parent.offsetParent
		}
	}
	var pm = this.helpFrame.pageMenu
	var wx = x + pm.offsetWidth
	var wy = y + pm.offsetHeight
	var sx = getScreenWidth()
	var sy = getScreenHeight()
	if (wx > sx) x = sx - pm.offsetWidth
	if (wy > sy) y = sy - pm.offsetHeight
	with (pm.style) {
		left = x
		top = y
		visibility = "visible"
	}
}
function initMoveHelp(e) { //{{{2
	initEvents(startMoveHelp,moveHelp,stopMoveHelp)
	helpMoved = false
	globalOnMouseDown(e)
	return(false)
}
function startMoveHelp(e) { //{{{2
	var t = GlobalParms.target
	if (t.helpFrame) var target = t.helpFrame.div
	else var target = t.parentNode.helpFrame.div
	GlobalParms.startTarget = target
	GlobalParms.helpStartX = parseInt(target.style.left)
	GlobalParms.helpStartY = parseInt(target.style.top)
}
function moveHelp(e) { //{{{2
	helpMoved = true
	var dx = GlobalParms.X - GlobalParms.startX 
	var dy = GlobalParms.Y - GlobalParms.startY
	var lf = GlobalParms.helpStartX + dx
	var tp =  GlobalParms.helpStartY + dy
	with (GlobalParms.startTarget) {
		style.left = lf
		style.top = tp
	}
}
function stopMoveHelp(e) { //{{{2
	if (!helpMoved && GlobalParms.startTarget.helpFrame) {
		GlobalParms.startTarget.helpFrame.toggle()
	}
	helpMoved = false
	exitEvents()
}
// ************************* Slider //{{{1 ********************************
function slider(le,from,to,interval,title) { //{{{2
	this.from = from
	this.to = to
	if (interval) this.interval = interval
	this.sliderLength = le
	this.sliderWidth = (ie) ? 12 : 8
	this.isVertical = true
	this.isVisible = true
	
	var div = this.div = document.createElement("span")
	document.body.appendChild(div)
	div.slider = this
	with (div.style) {
		position = "absolute"
		width = this.sliderLength
		height = this.sliderWidth
		backgroundColor = "white"
		border = "2px solid black"
		var innerWi = (ie) ? this.sliderWidth - parseInt(borderWidth) : this.sliderWidth
	}
	div.onmouseup = function(e) {
		if (ie) var e = event
		var target = (ie) ? event.srcElement : e.target
		if (!target.slider || target.pos) return
		if (target.slider.vertical()) { 
			var click = e.clientY - target.parentNode.offsetTop
			var width = this.offsetHeight
		} else {
			var click = e.clientX - target.parentNode.offsetLeft
			var width = this.offsetWidth
		}
		with (target.slider) {
			var val = click/width * (to - from) + from
			if (vertical()) click = click - sliderWidth  
			newPos = click - sliderWidth / 2
			if (newPos < inner.startPos) newPos = inner.startPos
			else if (newPos > inner.lastPos) newPos = inner.lastPos
			if (vertical()) inner.pos = inner.style.top = newPos
			else inner.pos = inner.style.left = newPos
			newVal = getValue()
			setValue(newVal)
		}
		if (target.slider.stopFunc) target.slider.stopFunc(target.slider)
	}
	
	
	var inner = this.inner = document.createElement("span")
	div.appendChild(inner)
	inner.slider = this
	with (inner.style) {
		position = "absolute"
		left = (this.div.offsetWidth / 2) - (this.inner.offsetWidth / 2)
		width = innerWi
		height = innerWi - 1
		backgroundColor = "black"
		overflow = "hidden"
	}
	inner.pos = parseInt(inner.style.left)
	inner.startPos = 0
	inner.lastPos = 1 + this.sliderLength - inner.offsetWidth
	if (ie) {
		inner.startPos -= parseInt(div.style.borderWidth)
		inner.lastPos -= parseInt(div.style.borderWidth)
	}
	inner.onmousedown = initMoveSlider

	var valueDiv = this.valueDiv = document.createElement("span")
	div.appendChild(valueDiv)
	valueDiv.slider = this
	with (valueDiv.style) {
		position = "absolute"
		whiteSpace = "nowrap"
		cursor = "default"
	}	

	if (title) {
		var titleDiv = this.titleDiv = document.createElement("span")
		titleDiv.innerHTML = title
		div.appendChild(titleDiv)
		titleDiv.slider = this
		with (titleDiv.style) {
			position = "absolute"
			whiteSpace = "nowrap"
			cursor = "default"
		}	
	}

	this.setValue(this.getValue())
	this.vertical(false)
	this.menu = new menu(this)
	this.menu.realSticky(true)
//	this.menu.div.appendChild(div)
	return(this)
}
slider.prototype.setTitle = function (text) { //{{{2
	this.titleDiv.innerHTML = text
}
slider.prototype.visible = function(bool) { //{{{2
	if (typeof(bool) == "undefined") return(this.isVisible)
	this.isVisible = bool
	if (this.isVisible) this.menu.div.style.visibility = "visible"
	else this.menu.div.style.visibility = "hidden"
}
	
slider.prototype.vertical = function (bool) { //{{{2
	if (typeof(bool) == "undefined") return(this.isVertical)
	this.isVertical = bool
	if (this.isVertical) {
		this.div.style.width = this.sliderWidth
		this.div.style.height = this.sliderLength
		this.inner.style.left = 0
		this.inner.style.top = this.inner.pos
		this.valueDiv.style.left = (this.sliderWidth/2) - (this.valueDiv.offsetWidth/2) 
		this.valueDiv.style.top = this.sliderLength
		if (this.titleDiv) {
			this.titleDiv.style.left = (this.sliderWidth/2) - (this.titleDiv.offsetWidth/2) 
			this.titleDiv.style.top = -(this.titleDiv.offsetHeight + 5)
		}
	} else {
		this.div.style.width = this.sliderLength
		this.div.style.height = this.sliderWidth
		this.inner.style.left = this.inner.pos
		this.inner.style.top = 0
		this.valueDiv.style.left = (this.sliderLength/2) - (this.valueDiv.offsetWidth/2)
		this.valueDiv.style.top = this.sliderWidth
		if (this.titleDiv) {
			this.titleDiv.style.left = (this.sliderLength/2)- (this.titleDiv.offsetWidth/2)
			this.titleDiv.style.top = - (this.titleDiv.offsetHeight + 5)
		}
	}
}
slider.prototype.getValue = function() { //{{{2
	var range = this.to - this.from
	with (this.inner) var ratio =  (pos-startPos) / (lastPos - startPos)
	var floatVal = this.from + (ratio * range) 
	if (! this.interval) return(floatVal)
	if (this.from < this.to) {
		var v = this.from
		while (v <= floatVal) v += this.interval
	} else {
		var v = this.to
		while (v <= floatVal) v += this.interval
	}
	return(v - this.interval)
}
slider.prototype.setValue = function(val) { //{{{2
	var perc = (val - this.from) / (this.to - this.from)
	with (this.inner) {
		pos = perc * (startPos + (lastPos-startPos))
		if (this.isVertical) style.top = pos
		else style.left = pos
	}
	this.valueDiv.innerHTML = val
	this.vertical(this.vertical())
}
slider.prototype.setMoveFunc = function(func) { //{{{2
	this.moveFunc = func
}
slider.prototype.setStopFunc = function (func) { //{{{2
	this.stopFunc = func
}
slider.prototype.showAt = function(x,y) { //{{{2
	this.menu.showAt(x,y)
}
function initMoveSlider(e) { //{{{2
	initEvents(startMoveSlider,moveSlider,stopMoveSlider)	
	globalOnMouseDown(e)
}
function startMoveSlider(e) { //{{{2
	GlobalParms.slider = GlobalParms.target.slider
	GlobalParms.sliderStartX = parseInt(GlobalParms.target.style.left)
	GlobalParms.sliderStartY = parseInt(GlobalParms.target.style.top)
}
function moveSlider(e) { //{{{2
	with (GlobalParms) {
		if (startTarget.slider.isVertical) {
			var diffY = Y - startY
			var newPos = sliderStartY + diffY
		} else  {
			var diffX = X - startX
			var newPos = sliderStartX + diffX
		}
		if (newPos < startTarget.startPos) newPos = startTarget.startPos
		else if (newPos > startTarget.lastPos) newPos = startTarget.lastPos
		startTarget.pos = newPos
		if (startTarget.slider.isVertical) startTarget.style.top = newPos
		else startTarget.style.left = newPos
		var val = startTarget.slider.getValue()
		startTarget.slider.valueDiv.innerHTML = val
		startTarget.slider.vertical(startTarget.slider.vertical())
		if (startTarget.slider.moveFunc) startTarget.slider.moveFunc(startTarget.slider)
	}
}
function stopMoveSlider(e) { //{{{2
	with (GlobalParms)
	if (startTarget.slider.stopFunc) startTarget.slider.stopFunc(startTarget.slider)
	exitEvents()
}
//{{{2
