// configuration/constants
	var intRefreshrate = 15 // Hz
	var booEnableScrollLock = false // CPU hungry
	var booAutoAdjustAllObjectPositions = false // more CPU hungry


// primary functions - functionality
	function setColour(objId,objColour){
		if (ie){
			if(eval(objId+".style.color!='"+objColour+"'")) eval(objId+".style.color='"+objColour+"'")
		}
		if (mo){
			if(document.getElementById(objId).style.color!=objColour) document.getElementById(objId).style.color=objColour
		}
		if (ns){
			// I wish
		}	
	}
	
	function setBackgroundColour(objId,objColour){
		if (ie){
			if(eval(objId+".style.backgroundColor!='"+objColour+"'")) eval(objId+".style.backgroundColor='"+objColour+"'")
		}
		if (mo){
			if(document.getElementById(objId).style.backgroundColor!=objColour) document.getElementById(objId).style.backgroundColor=objColour
		}
		if (ns){
			// I wish
		}	
	}
	
	function setBackgroundImage(objId,objImageName){
		objImage = eval(objImageName)
		if (ie){
			if(eval(objId+".background!=objImage.src")) eval(objId+".background=objImage.src")
		}
		if (mo){
			if(document.getElementById(objId).style.backgroundImage!=objImage.src) document.getElementById(objId).style.backgroundImage=objImage.src
		}
		if (ns){
			// I wish
		}	
	}
	
	function setForegroundImage(imgDocId,objImageName,layerName) {
		objImage = eval(objImageName)
		if(ns && layerName!=-1){
			if(eval("document."+layerName+".document.images['"+imgDocId+"'].src!=objImage.src")) eval("document."+layerName+".document.images['"+imgDocId+"'].src = objImage.src")
		}else{
			if(document.images[imgDocId].src!=objImage.src) document.images[imgDocId].src = objImage.src
		}
	}
	
	function setContent(objId,objContent){
		if (ie){
			if(eval(objId+".innerHTML!=objContent")) eval(objId+".innerHTML=objContent")
		}
		if (mo){
			if(document.getElementById(objId).innerHTML!=objContent) document.getElementById(objId).innerHTML = objContent
		}
		if (ns){
			eval("document."+objId+".document.open()")
			eval("document."+objId+".document.write('"+objContent+"')")
			eval("document."+objId+".document.close()")
		}	
	}
	
	function setDimensions(objId,objWidth,objHeight,objDepth){
		if (ie&&v4){
			eval(objId+'.style.width = '+objWidth)
			eval(objId+'.style.height = '+objHeight)
		}
		if (mo||(ie&&!v4)){
			if(document.getElementById(objId).style.width!=objWidth)	document.getElementById(objId).style.width = objWidth
			if(document.getElementById(objId).style.height!=objHeight)	document.getElementById(objId).style.height = objHeight
		}
		if (ns){
			if(eval('document.'+objId+'.width!='+objWidth))		eval('document.'+objId+'.width = '+objWidth)
			if(eval('document.'+objId+'.height!='+objHeight))	eval('document.'+objId+'.height = '+objHeight)
		}	
	}	
	
	function setPosition(objId,objXpos,objYpos,objZpos,objWidth,objHeight,booScrollLock,booOffScreenGuard){
		// find page postition
		intXadjust = 0; intYadjust = 0
		if(booScrollLock){
			if (ie){
				intXadjust = document.body.scrollLeft
				intYadjust = document.body.scrollTop
			}
			if (mo){
				intXadjust = window.pageXOffset
				intYadjust = window.pageYOffset
			}
			if (ns){
				intXadjust = window.pageXOffset
				intYadjust = window.pageYOffset
			}
		}	
		// adjust positions for screen-fitting
		intScreenXAdjust=0; intScreenYAdjust=0
		if(booOffScreenGuard){
			// find page size
			if(ie){
				intPageWidth = document.body.offsetWidth
				intPageHeight = document.body.offsetHeight
			}
			if(ns||mo){
				intPageWidth = window.innerWidth
				intPageHeight = window.innerHeight
			}
			// find object size
			intObjId = objName2objID(objId)
			if(intObjId!=-1){
				intObjWidth = arrLayers[intObjId][6]
				intObjHeight = arrLayers[intObjId][7]
			}else{
				intObjWidth = 0
				intObjHeight = 0
			}
			// adjust object position
			if(intObjWidth+objXpos>intPageWidth)	intScreenXAdjust=intPageWidth-intObjWidth-objXpos
			if(intObjHeight+objYpos>intPageHeight)	intScreenYAdjust=intPageHeight-intObjHeight-objYpos
		}
		// set new positions
		if (ie){
			if(v4){
				eval(objId+'.style.left = '+(objXpos+intXadjust+intScreenXAdjust))
				eval(objId+'.style.top = '+(objYpos+intYadjust+intScreenYAdjust))
				eval(objId+'.style.zIndex = '+objZpos)
			}else{
				if(document.getElementById(objId).style.left!=objXpos+intXadjust+intScreenXAdjust)	document.getElementById(objId).style.left = objXpos+intXadjust+intScreenXAdjust
				if(document.getElementById(objId).style.top!=objYpos+intYadjust+intScreenYAdjust)	document.getElementById(objId).style.top = objYpos+intYadjust+intScreenYAdjust
				if(document.getElementById(objId).style.zIndex!=objZpos)							document.getElementById(objId).style.zIndex = objZpos
			}
		}
		if (mo){
			if(document.getElementById(objId).style.left!=objXpos+intXadjust+intScreenXAdjust)	document.getElementById(objId).style.left = objXpos+intXadjust+intScreenXAdjust
			if(document.getElementById(objId).style.top!=objYpos+intYadjust+intScreenYAdjust)	document.getElementById(objId).style.top = objYpos+intYadjust+intScreenYAdjust
			if(document.getElementById(objId).style.zIndex!=objZpos)							document.getElementById(objId).style.zIndex = objZpos
		}
		if (ns){
			if(eval('document.'+objId+'.left!='+objXpos+intXadjust+intScreenXAdjust))	eval('document.'+objId+'.left = '+(objXpos+intXadjust+intScreenXAdjust))
			if(eval('document.'+objId+'.top!='+objYpos+intYadjust+intScreenYAdjust))	eval('document.'+objId+'.top = '+(objYpos+intYadjust+intScreenYAdjust))
			if(eval('document.'+objId+'.zIndex!='+objZpos))								eval('document.'+objId+'.zIndex = '+objZpos)
		}
	}

	function setDisplay(objId,objState){
		if(objState){styleSetting=""}else{styleSetting="none"}
		
		if (ie){
			if(eval(objId+'.style.display!="'+styleSetting+'"')) eval(objId+'.style.display = "'+styleSetting+'"')
		}
		if (mo){
			if(document.getElementById(objId).style.display!=styleSetting) document.getElementById(objId).style.display = styleSetting
		}
		if (ns){
			// I wish //eval('document.'+objId+'.display = '+styleSetting)
		}	
	}

	function setVisibility(objId,objState){
		if (ie){
			if(objState){styleSetting="visible"}else{styleSetting="hidden"}
			if(eval(objId+'.style.visibility!="'+styleSetting+'"')) eval(objId+'.style.visibility = "'+styleSetting+'"')
		}
		if (mo){
			if(objState){styleSetting="visible"}else{styleSetting="hidden"}
			if(document.getElementById(objId).style.visibility!=styleSetting) document.getElementById(objId).style.visibility = styleSetting
		}
		if (ns){
			if(objState){styleSetting="show"}else{styleSetting="hide"}
			if(eval('document.'+objId+'.visibility!="'+styleSetting+'"')) eval('document.'+objId+'.visibility = "'+styleSetting+'"')
		}	
	}

	
// secondary functions - construction
	// preload possible background images
	function cacheBackgroundImage(objImageName,objImageSource){
		eval(objImageName + "= new Image(0,0);")
		eval(objImageName + ".src = '" + objImageSource + "';")
	}
	
	// store layer attributes centraly
	arrLayers =	new Array()
	function defineLayer(objName,booAbsolutePos,intXpos,intYpos,intZpos,intWidth,intHeight,intDepth,strContent,strUrl,booScrollable,booVisible,booScollLock,booOffscreenGuard){
		// store layer attributes in an array for reference
		//											0				1			2			3		4		5		6		7			8		9		10			11			12			13				14
		arrLayers[arrLayers.length] = new Array(arrLayers.length,objName,booAbsolutePos,intXpos,intYpos,intZpos,intWidth,intHeight,intDepth,strContent,strUrl,booScrollable,booVisible,booScollLock,booOffscreenGuard)
	}

	// look up a layer's name and return it's position in the list.
	function objName2objID(objName){
		objID = -1
		intA = 0
			// go through the entire list until you find the object's name
			while(intA<arrLayers.length && objID==-1){
				// if the name matches the list's element note it's ID
				if(arrLayers[intA][1]==objName){objID=arrLayers[intA][0]}
				intA = intA + 1
			}
		// give the ID back to the function's caller
		return objID
	}

	// write a layer-tag that works in all browsers
	function writeLayerTag(objName,OpenTag){
		objID = objName2objID(objName)
		// is it an open-tag?
		if(OpenTag){
			// url?
			if(arrLayers[objID][10]!=""){
				// netscape
				if(ns){
					// layer
						// absolute positioned
					if(arrLayers[objID][2]){strPosition='pagex="'+arrLayers[objID][3]+'" pagey="'+arrLayers[objID][4]+'" zindex="'+arrLayers[objID][5]+'"';strLayPrefix=''}else{strPosition='';strLayPrefix='i'}
						// visibility
					if(!arrLayers[objID][12]){strVisible='visibility="hide"'}else{strVisible=''}
						// tag construction
					strWrite = '<'+strLayPrefix+'layer name="'+arrLayers[objID][1]+'" src="'+arrLayers[objID][10]+'" '+strPosition+' width="'+arrLayers[objID][6]+'" height="'+arrLayers[objID][7]+'" '+strVisible+'>'
				// other
				}else{
					// iframe
						// absolute positioned
					if(arrLayers[objID][2]){strPosition='position:absolute; left: '+arrLayers[objID][3]+'px; top: '+arrLayers[objID][4]+'px; z-index: '+arrLayers[objID][5]+'; width: '+arrLayers[objID][6]+'px; height: '+arrLayers[objID][7]+'px;'}else{strPosition=''}
						// visibility
					if(!arrLayers[objID][12]){strVisible='visibility:hidden;'}else{strVisible=''}
						// tag construction
					if(booScrollable){strScroll='scrolling="auto"'}else{strScroll='scrolling="no"'}
					strWrite = '<iframe id="'+arrLayers[objID][1]+'" src="'+arrLayers[objID][10]+'" name="frm'+arrLayers[objID][1]+'" frameborder="0" width="'+arrLayers[objID][6]+'" height="'+arrLayers[objID][7]+'" '+strScroll+' style="'+strPosition+strVisible+'">'
				}
			// else
			}else{
				// netscape
				if(ns){
					// layer
						// absolute positioned
					if(arrLayers[objID][2]){strPosition='pagex="'+arrLayers[objID][3]+'" pagey="'+arrLayers[objID][4]+'"';strLayPrefix=''}else{strPosition='';strLayPrefix='i'}
						// visibility
					if(!arrLayers[objID][12]){strVisible='visibility="hide"'}else{strVisible=''}
						// tag construction
					strWrite = '<'+strLayPrefix+'layer name="'+arrLayers[objID][1]+'" '+strPosition+' width="'+arrLayers[objID][6]+'" height="'+arrLayers[objID][7]+'" '+strVisible+'>'
				// other
				}else{
					// div
						// absolute positioned
					if(arrLayers[objID][2]){strPosition='position:absolute;left:'+arrLayers[objID][3]+'px;top:'+arrLayers[objID][4]+'px;z-index:'+arrLayers[objID][5]+';'}else{strPosition=''}
						// visibility
					if(!arrLayers[objID][12]){strVisible='visibility:hidden;'}else{strVisible=''}
						// tag construction
					strWrite = '<div id="'+arrLayers[objID][1]+'" style="width:'+arrLayers[objID][6]+'px;height:'+arrLayers[objID][7]+'px;'+strPosition+strVisible+'">'
				}
			}
		// is it a close-tag
		}else{
			// url?
			if(arrLayers[objID][10]!=""){
				// netscape
				if(ns){
					// layer
					if(arrLayers[objID][2]){strLayPrefix=''}else{strLayPrefix='i'}
					strWrite = '</'+strLayPrefix+'layer>'
				// other
				}else{
					// iframe
					strWrite = '</iframe>'
				}
			// else
			}else{
				// netscape
				if(ns){
					// layer
					if(arrLayers[objID][2]){strLayPrefix=''}else{strLayPrefix='i'}
					strWrite = '</'+strLayPrefix+'layer>'
				// other
				}else{
					// div
					strWrite = '</div>'
				}
			}		
		}
		document.writeln(strWrite)
	}
	
	// write a predefined amount of layers with attributes
	function makeLayers(){
		// for all  layers in the central list
		for(var intA=0; intA<arrLayers.length; intA++){
			// writeLayerTag(true)
			writeLayerTag(arrLayers[intA][1],true)
			// write content
			document.writeln(arrLayers[intA][9])
			// writeLayerTag(false)
			writeLayerTag(arrLayers[intA][1],false)
		}
	}
	
	// lock specified layers to a scroll position
	function setScrollLock(){
		// delay before updating, every "intRefreshrate" above 5Hz is considered "as fast as possible"
		if(ie && intRefreshrate>5){
			onscroll = doScrollLock
		}else{
			setInterval('doScrollLock()',Math.round(1000/intRefreshrate))
		}
	}
	
	function doScrollLock(){
		for(var intA=0; intA<arrLayers.length; intA++){
			// only adjust the position of repositionable (booScrollLock) items
			if(arrLayers[intA][13] || booAutoAdjustAllObjectPositions){
				setPosition(arrLayers[intA][1],arrLayers[intA][3],arrLayers[intA][4],arrLayers[intA][5],arrLayers[intA][6],arrLayers[intA][7],arrLayers[intA][13],arrLayers[intA][14])
			}
		}
	return true
	}


//ternary function - operation
	var intJitterTimeout = 50

	var timeoutColour,cacheColourObjId
	function suggestColour(strId,strChange){
		if(cacheColourObjId==strId){clearTimeout(timeoutColour)}else{cacheColourObjId=strId}
		timeoutColour = setTimeout("setColour('"+strId+"','"+strChange+"')",intJitterTimeout)
	}
	
	var timeoutBackgroundColour,cacheBackgroundColourObjId
	function suggestBackgroundColour(strId,strChange){
		if(cacheBackgroundColourObjId==strId){clearTimeout(timeoutBackgroundColour)}else{cacheBackgroundColourObjId=strId}
		timeoutBackgroundColour = setTimeout("setBackgroundColour('"+strId+"','"+strChange+"')",intJitterTimeout)
	}		
	
	var timeoutBackgroundImage,cacheBackgroundImageObjId
	function suggestBackgroundImage(strId,strChange){
		if(cacheBackgroundImageObjId==strId){clearTimeout(timeoutBackgroundImage)}else{cacheBackgroundImageObjId=strId}
		timeoutBackgroundImage = setTimeout("setBackgroundImage('"+strId+"','"+strChange+"')",intJitterTimeout)
	}
	
	var timeoutForegroundImage,cacheForegroundImageObjId
	function suggestForegroundImage(strId,strChange){
		if(cacheForegroundImageObjId==strId){clearTimeout(timeoutForegroundImage)}else{cacheForegroundImageObjId=strId}
		timeoutForegroundImage = setTimeout("setForegroundImage('"+strId+"','"+strChange+"')",intJitterTimeout)
	}
	
	var timeoutVisibility,cacheVisibilityObjId
	function suggestVisibility(strId,strChange){
		if(cacheVisibilityObjId==strId){clearTimeout(timeoutVisibility)}else{cacheVisibilityObjId=strId}
		timeoutVisibility = setTimeout("setVisibility('"+strId+"','"+strChange+"')",intJitterTimeout)
	}
	
	var timeoutDisplay,cacheDisplayObjId
	function suggestDisplay(strId,strChange){
		if(cacheDisplayObjId==strId){clearTimeout(timeoutDisplay)}else{cacheDisplayObjId=strId}
		timeoutDisplay = setTimeout("setDisplay('"+strId+"','"+strChange+"')",intJitterTimeout)
	}
	
	
// executed inline
	// optionaly define scrolling (event) capture
	if(booEnableScrollLock || booAutoAdjustAllObjectPositions)setScrollLock()

