/* DHTML API BY JONAS BOHLIN
GENERIC, DO NOT EDIT THIS FILE FOR SPACE. SHOULD CONTAIN ALL OBJECTS USED IN ANY FILE!!!
ver: 3.0 BETA 0.5
VARIANT A: Bug fix for ie styles set on layers as class
Modification history
	991022
		added slide object, incorporated mousemove (should be removed.)
	000120
		added browserobject.
		
	000127
		revised browserobject.
		revised initLayers
		revised swapButtonImage
		replaced objects makeLayer and makeNestedLayer with one generic function. nestref is now supplied last!!!
		added forceActive to swapButtonImage()
		rewrote load_open for ie to work on automated transfer on loaded.
		added default extra (15) value to compareObjPositions()
		edited contentDim to return offset value
		incorporated oClient into all dapi functions and objects.
	000225
		knapp method made obsolete by wrapImage (and was removed)
		createPosObj made obsolete by wrapImage (and was removed)
		added wrapImage object
		started incorporating "lazie" functions
		removed generateMovePath and moveByPath. (obsolete through animations.js)
	000315
		Created events.js, for handling generic, page level events.
	000725
		Do not use the "lazie"-functions, they will be revised or discontinued.
	001106
		added ie5_5pc property to oClient for specific use with scroll (now)
	010118
		Added clearEvent() method. setEvent() method was added a while ago, though not really in DAPI yet.
	010129 [2.2.2]
		Edited the makeLayer object to use createElement and appendChild if IE5+. Boosted dynamic layer generation by approx. 34%!!!
	020122 [3.0b]
		Started integrating NS 6.0 functionality. Dapi 3.0 is not backwards compatible!
		Modified browser-object to be more accurate w/ ie versions...
	020216
		Added pop() method for ie4&5		
		Modified getUniqueId to work with IE4 (stupid glitch.)
	020217
		Changed makeLayer for ie4 so that last item is added as lastchild, hence first item added remains first item...
	020218
		IE 5 mac can't use attachEvent, fixed that.
		IE 5.1 can use BeforeEnd in insertAdjacentHTML, but 5.0 is seriously erratic and can only use afterbegin at its best of times..
	020219
		Added contanins method for object in ns6. might need more work, to make it more like ie contains()
	020227
		Edited load_open and transfer for better compability.
		
	020318 (3.0 beta 0.5)
		Removed isObject, inverse and isFloat to dapi_lib.js
		
		
TO DO:
look in to z functions (raiseLayerToTop)

*/
/*
updated 3.0 
not tested 3.0
*/
function browser(){
	var sUA=navigator.userAgent.toLowerCase();
	this.compatible = (sUA.indexOf('compatible')!=-1);	
	this.ns  = (!this.compatible && sUA.indexOf('mozilla')!=-1); 	
	this.ge = (this.ns && sUA.indexOf('gecko')!=-1);
	this.geNs = (sUA.indexOf('gecko')!=-1 && sUA.indexOf('netscape')!=-1);	//eg netscape
	this.ie = (sUA.indexOf("msie") != -1);			
	this.opera = (sUA.indexOf("opera") != -1);
	
	//use to read netscape 6 true subversion
	//alert(sUA)
	iAdd = 0
	if (this.compatible || this.geNs || this.ge || this.opera){		
			if (this.opera){
				reApp = /opera.([0-9\.]+)/
				this.ie = false
			} else if (this.ie) {
				reApp = /msie.([0-9\.]+)/
			} else if (this.geNs){
				reApp = /gecko\/.+\/([0-9\.]+)/
			} else if (this.ge) {
				reApp = /rv\:([0-9\.]+)/
				iAdd = 6 //add to make it look like netscape 6, 7 etc
				
			}
			//alert(reApp)
		aRes = reApp.exec(sUA)
		//alert(aRes+"\n"+sUA)
		this.appVersion = aRes[1] //RegExp.$1   
	} 
	
	else {
		this.appVersion = navigator.appVersion
	}
	//alert("appVersion " + this.appVersion)
	//if (!this.appVersion) alert("appversion problem: "+this.appVersion)
	this.major = parseInt(this.appVersion)+iAdd; 
    this.minor = parseFloat(this.appVersion)+iAdd;

//    this.ns5 = this.ns6 = (this.ns && (this.major == 5)); //gecko browsers should go for this one
//    this.ns5up = this.ns6up = (this.ns && (this.major >= 5)); //
    this.ns5 = this.ns6 = (this.ge && this.major==6); ////(this.ns && (this.major == 5 || this.major==6) || (this.ge && this.major==1)); //gecko browsers should go for this one
    this.ns5up = this.ns6up = (this.ge && this.major>=6); //(this.ns && (this.major >= 5)); //
	this.ns7 = (this.ge && this.major==7);//((this.ns && this.major == 7) || (this.ge && this.major==1)); //netscape gecko can continue here...
	this.ns7up = (this.ge && this.major>=7); //((this.ns && this.major >= 7) || (this.ge && this.major==1)); //netscape gecko can continue here...	
//check these last...
    this.ns4 = (this.ns && (this.major == 4)); 
    this.ns4up = (this.ns && (this.ns4 || this.ns6 || this.ns6up)); 
    this.nsOnly  = (this.ns && ((sUA.indexOf(";nav") != -1) || (sUA.indexOf("; nav") != -1)));
	
	this.ie3down = (this.ie && (this.major < 4)); 
    this.ie4  = (this.ie && (this.major == 4)); 
    this.ie4up  = (this.ie && (this.major >= 4)); 
    this.ie5  = (this.ie && (this.major == 5)); 
    this.ie5up  = (this.ie && (this.major >= 5));
	this.ie5_5 = (this.ie && (this.minor == 5.5));	
	this.ie5_5up = (this.ie && this.minor >= 5.5);
    this.ie6  = (this.ie && (this.major == 6));
    this.ie6up  = (this.ie && (this.major >= 6));

	//alert(this.opMajor+"\n"+this.opMinor+"\n"+sUA+"\n"+this.opAppVersion)
	this.op5 = (this.opera && this.major==5) 
	this.op5up = (this.opera && this.major>=5) 	
	this.op6 = (this.opera && this.major==6) 	
	this.op6up = (this.opera && this.major>=6)
	
	this.dom = (this.ie5up || this.ns5up || this.op5up)
	
	this.win   = ((sUA.indexOf("win")!=-1) || (sUA.indexOf("16bit")!=-1));
	this.mac    = (sUA.indexOf("mac")!=-1);
	window.oClient = this
		//alert(this.minor+"\n"+this.major+" ns6: "+oClient.ns6)
}
/*
object initLayers
origin: objects/initLayers.js
*/

function addPop(){
	if (oClient.ie4up && typeof(Array.prototype.pop)=="undefined"){
		Array.prototype.pop = dapi_Pop
	}
}

/*
	Fake pop emulates the pop method available in ns3+ & ie5.5+. pop removes the last item in an array
*/
function dapi_Pop(){
	var oRemoved = this[this.length-1]
	this.length = this.length-1
	return oRemoved
}

function addContains(){
	if ((oClient.ns5up || oClient.ns4) && typeof(Object.prototype.contains)=="undefined"){
		Object.prototype.contains = dapi_Contains
	}
}

function dapi_Contains(oElement,oObj){
		if (oClient.ns5up){
			if (!oElement) return false
			if (this==oElement) return true
			//debug("locate "+oElement.id+" in "+this.id,5)
			oNodeAt = oElement 
			 do {
				oNodeAt = oNodeAt.parentNode
			} while (this!=oNodeAt && oNodeAt.parentNode)
			retVal = (this==oNodeAt)
			//debug("returning "+retVal,5)
			return retVal
		} else if (oClient.ns4){
			//alert(sObj+"\n"+oElement.id+"\n"+eval(sObj))
			//if ()
			
			if (!oElement) return false
			if (oObj==oElement) return true
			//debug("locate "+oElement.id+" in "+this.id,5)
			oNodeAt = oElement 
			 do {
				oNodeAt = oNodeAt.oParent
			} while (oObj!=oNodeAt && oNodeAt.oParent)
			retVal = (oObj==oNodeAt)
			//alert(retVal)
			//debug("returning "+retVal,5)
			return retVal
			
			/*if (!oElement) return false
			else if (!sObj) return false
			oObj = eval(sObj)
			alert(oObj)
			if (!oObj.ids) oObj.ids = new Array()

			//alert(sObj.ids[oElement.id])
			if (typeof(oObj.ids[oElement.id])=="undefined"){
				oObj.ids[oElement.id] = (oObj.toString().indexOf(oElement.id)>-1)
				alert("add item as "+oObj.ids[oElement.id])
			} */
			
//			sObj.ids[oElement.id] = eval(sObj).toString().indexOf(oElement.id)
//			retVal = (retVal>-1)
			//if (!retVal) alert("Does not contain"+retVal)
			//else  alert("contains"+retVal)
			//return oObj.ids[oElement.id]
			
		}
}

/*
updated 3.0 
not tested 3.0
*/
function wrapLayer(sDiv,sDivObj,sNest){
	//Testa om sDiv eller sDivObj är objekt...

	bODiv =  (typeof(sDiv)=="object")
	bObjNest =  (typeof(sNest)=="object")
	
	if (bODiv) {
		this.layer = sDiv
	} else if (oClient.dom){
		this.layer = document.getElementById(sDiv)		
	} else if (oClient.ie4) {
		this.layer = document.all[sDiv];
		
	} else if (oClient.ns4) {
		if (sNest){
			this.layer = (bObjNest)?sNest.layer.document.layers[sDiv]:eval(sNest).document[sDiv];
		} else {
			this.layer = document[sDiv];
		}
	}

	//lägg till "style" till netscape.
	if (!this.layer){
		alert("Layer "+sDiv+"\nDoes not exist")
	}
	if (oClient.ns4){
		this.layer.style = this.layer
	}
	
	this.obj = sDivObj

	var bReadProps = true
	if (oClient.ie4){
		if (!this.layer.tagName){
			alert("can't read those props")
			bReadProps = false
		}
		
	}

	if (oClient.dom && bReadProps){
		this.id = this.layer.id;
		this.w = (!oClient.opera)?this.layer.offsetWidth:this.layer.style.pixelWidth;
		this.h = (!oClient.opera)?this.layer.offsetHeight:this.layer.style.pixelHeight;
	    this.xpos = (!oClient.opera)?this.layer.offsetLeft:this.layer.style.pixelLeft;
		this.ypos =  (!oClient.opera)?this.layer.offsetTop:this.layer.style.pixelTop;
		this.z = this.layer.style.zIndex;
	} else if (bReadProps) {
		this.id = (oClient.ns4)?this.layer.id:this.layer.id;
		this.w = (oClient.ns4)?this.layer.clip.width:this.layer.style.pixelWidth; // use offset with IFRAME
		this.h = (oClient.ns4)?this.layer.clip.height:this.layer.style.pixelHeight;
	    this.xpos = (oClient.ns4)?this.layer.left:this.layer.style.pixelLeft;
		this.ypos = (oClient.ns4)?this.layer.top:this.layer.style.pixelTop;
		
		this.z = this.layer.style.zIndex;
	}
}
{
p 					= wrapLayer.prototype
p.writeIntoLayer 	= writeIntoLayer
p.layerVis 			= layerVis
p.setLayerPixel		= wrapLayer_setPixel // remove
p.setPixel			= wrapLayer_setPixel
p.nudge				= setRelativePixel
p.setZ				= setLayerZindex
p.setClip 			= setLayerClip
p.getClip			= wrapLayer_getClip
p.raiseTop			= raiseLayerToTop
p.comparePos 		= compareObjPositions
p.load_open			= load_open
p.addCover			= addCover
p.addEvent			= wrapLayer_addEvent
p.clearEvent		= wrapLayer_clearEvent
p.getOffsetWidth	= wrapLayer_getOffsetWidth
p.getOffsetHeight	= wrapLayer_getOffsetHeight
p.getDim			= wrapLayer_getDim
p.getOffsetLeft		= wrapLayer_getOffsetLeft
p.getOffsetTop		= wrapLayer_getOffsetTop		
//p.getContentHeight	= wrapLayer_getContentHeight
//p.getClipHeight		= wrapLayer_getClipHeight
p.setWidth			= wrapLayer_setWidth
p.setHeight			= wrapLayer_setHeight
}

/* 
object makeLayer
original: objects/makeLayer.js

updated 3.0 
not tested 3.0

*/
function makeLayer(zindex,left,top,width,height,bgcolor,show,content,nestref,sId,bForceClip){
	//if (oClient.opera){ return false }
	//ID is optional, but preferred.
	sId = sId || getUniqueID("MakeLayer")

	if (oClient.ie5up) {
		a = document.getElementById(sId)
		if (a) alert("suggested id already exists!\n"+sId+"\n"+a.id)
	}
	if (!content) content = ""
	if (show && show==true) sVis = "visible";
	else if (show) sVis = show;
	else sVis = "hidden"
	
			
	if (oClient.ns4){
		//alert("begin-create")
		if (nestref) oDiv = new Layer(zindex, nestref.layer);
		else oDiv = new Layer(zindex);
		//alert("end create")		
		oDiv.left = left;
		if (isNaN(top)) alert(top+","+left+","+width+"\n"+makeLayer.caller+"\n"+oClient.ns4up)
		oDiv.top = top;
		oDiv.clip.width = width;
		oDiv.clip.height = height;
		oDiv.zIndex = zindex;
		if (bgcolor  && bgcolor!="transparent") oDiv.bgColor = bgcolor
		if (content){
			oDiv.document.open("text/html");
			oDiv.document.write(content);
			oDiv.document.close();
		}
		oDiv.visibility = sVis
		return oDiv
	} else {

			if (!content) content = ""
			if (show && show==true) vis = "visible";
			else if (show) vis = show;
			else vis = "hidden"
		if (oClient.ie4 || (oClient.mac && oClient.ie5up)){
			var createStr = '<DIV ID="'+sId+'" STYLE="position: absolute;">'+content+'</DIV>'
			
			if (nestref) nestref.layer.insertAdjacentHTML("BeforeEnd", createStr) //Changed so that every item is added as lastchild, hence first item added remains first item...
			else document.body.insertAdjacentHTML("BeforeEnd", createStr)
			oDiv = document.all[sId]
		} else { 
		    var mainDiv = document.getElementById('gSnakeInner');
			var oDiv=document.createElement("DIV");
			if (nestref) nestref.layer.appendChild(oDiv);			
			else mainDiv.appendChild(oDiv)
			
			oDiv.id = sId
			oDiv.style.position = "absolute"			
			oDiv.innerHTML = content			
		}	
		if (!oDiv.style) alert("Unique ID problem! DAPI CALLING\n"+oDiv.id+"\n"+createStr+"\n"+sId)
		oDiv.style.visibility = sVis;
		oDiv.style.zIndex = zindex;
		if (bgcolor) oDiv.style.backgroundColor = bgcolor
		oDiv.style.left = left+"px";
		oDiv.style.top = top+"px";
	
		oDiv.style.width = width+"px";
		oDiv.style.height = height+"px";
		if (!bForceClip) oDiv.style.clip =  "rect(auto auto auto auto)"	
		else oDiv.style.clip =  "rect("+0+"px "+width+"px "+height+"px "+0+"px)"	
		//oDiv.style.clip =  "rect(0px "+width+"px "+height+"px 0px)"	
		return oDiv
	}
}

/*
created 3.0 
not tested 3.0
*/
function getUniqueID(sPrefix){
	sId = sPrefix || ""
	if (oClient.ie4 || (oClient.mac && oClient.ie5up)){
		do { a = (sId + Math.round(Math.random()*99999))} while (document.all[a])
		sId = a
	} else if (oClient.ie5up && !oClient.opera){
		sId += document.uniqueID
	} else if (oClient.ns5up || oClient.opera){
		do { a = (sId + Math.round(Math.random()*99999))} while (document.getElementById(a))
		sId = a
	} 
	return sId
}


//example: obj.addEvent("onmouseover",function)
/*
updated 3.0 
not tested 3.0
*/
function wrapLayer_addEvent(sEvent,oFunction,bUseCapture,bIgnoreCoverNS){

	if (oClient.ns5up){
		this.layer.addEventListener(sEvent.substring(2),oFunction,bUseCapture)
	} else if (oClient.pc && oClient.ie5up){	
		this.layer.attachEvent(sEvent,oFunction)
	} else {
		var addCover = (oClient.ns4 && !bIgnoreCoverNS && this.cover)?".cover":"";
		oSetEventTo = (oClient.ns4)?this.obj+addCover+".layer":this.obj+".layer";
		eval(oSetEventTo+"."+ sEvent +"="+ oFunction)
		if (oClient.ns4){
			sCapture = sEvent.substring(2).toUpperCase()
	 		eval(oSetEventTo+".captureEvents(Event."+sCapture+")")
		}
	}
}


//example: obj.clearEvent("onmouseover")
/*
updated 3.0 
not tested 3.0
*/
function wrapLayer_clearEvent(nEvent){
	argLen = wrapLayer_clearEvent.arguments.length
	args = wrapLayer_clearEvent.arguments
	igCoverPassed = (typeof(args[argLen-1])=="boolean")?true:false;
	ignoreCover = (igCoverPassed)?args[argLen-1]:false;
	var addCover = (oClient.ns4up && !ignoreCover && this.cover)?".cover":"";
	iRunTo = (igCoverPassed)?argLen-1:argLen;
	for (e = 0;e<iRunTo;e++){
		oSetEventTo = (oClient.ns4)?this.obj+addCover+".layer":this.obj+".layer.access";
		sEvent = args[e]
		eval(oSetEventTo+"."+ sEvent +"= null")
		if (oClient.ns4){
			sCapture = sEvent.substring(2).toUpperCase()
 			eval(oSetEventTo+".releaseEvents(Event."+sCapture+")")
		}
	 }
}

/*
object openWindow
original: objects/openWindow.js
*/
function openWindow(id,url,w,h,x,y,bNormalWindow,nManual,bNoFocus) {
		if (!window.OfficialMap){
			window.OfficialMap = (!window.oWindow)?new mapWindow():window.oWindow;
		}
		var sArgs = "toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0"
		if ((typeof(w)=="boolean" && w==true)){ //create a replica of the current window
				sArgs = "toolbar=1,location=1,directories=1,status=1,menubar=1,scrollbars=1,resizable=1"
				var	winW = OfficialMap.w
				var	winH = OfficialMap.h
				var	Xwin = OfficialMap.xpos
				var	Ywin = OfficialMap.ypos	
		} else {
			/*create a new window but use default arg-string,
			with possibility for manual additions (can't disable)*/
			if (bNormalWindow) sArgs = "toolbar=1,location=1,directories=1,status=1,menubar=1,scrollbars=1,resizable=1"
			
			var winW = w || 0.5;
			var	winH = h || 0.5;

			var Xwin = x || 0.5;
			var Ywin = y || 0.5;

			if (isFloat(winW))	winW = parseInt(OfficialMap.screenW*winW)
			if (isFloat(winH))	winH = parseInt(OfficialMap.screenH*winH)
			if (isFloat(Xwin)) Xwin = parseInt((OfficialMap.screenW - winW)*Xwin);
			if (isFloat(Ywin)) Ywin = parseInt((OfficialMap.screenH - winH)*Ywin);
			//alert(winW)
		}
		
		if (nManual){
			aProps = nManual.split(",")
			for (i=0;i<aProps.length;i++){
				aRe = eval("/("+aProps[i]+")=./i")
				if (aRe.test(sArgs)){
					sArgs = sArgs.replace(aRe,"$1=1")
				} else {
					sArgs += ","+aProps[i]+"=1"
				}
			}
		}
		
    if (winW || winH || Xwin || Ywin) sArgs += ',width='+winW+',height='+winH+',left='+Xwin+',top='+Ywin
		//alert(sArgs)
		this.win = window.open(url,id,sArgs)
		if (!bNoFocus) this.win.focus()
		return this.win
}

/*
object makeImage
original: objects/makeImage.js
*/
function makeImage(src,width,height){	
		if (oClient.ie4up && !oClient.opera){
			this.img = document.createElement("IMG")
			if (width && height){
				this.img.width = width
				this.img.height = height
			}
			this.img.src = src
			this.img.border = 0
			return this.img
		} else {
			if (width && height) this.img = new Image(width, height)
			else this.img = new Image()
			this.img.src = src
			return this.img
		}
}

/* 
object makeImage

function wrapImage(sImageName,sDefaultSwap,oNest){
		ns4 = oClient.ns4up
		var modX = (oNest)?oNest.xpos:0;
		var modY = (oNest)?oNest.ypos:0;

		if (oNest && ns4) this.image = (isObject(oNest))?oNest.layer.document.images[sImageName]:eval(oNest).document.images[sImageName];
		else this.image = document.images[sImageName]
		//alert(sImageName)
		this.parentLayer = oNest
		this.imagename 	= sImageName
		this.dSrc		= this.image.src
		this.dActive 	= (sDefaultSwap)?new makeImage(sDefaultSwap):null;
		this.w 			= (ns4)?this.image.width:this.image.offsetWidth;
		this.h 			= (ns4)?this.image.height:this.image.offsetHeight;
		this.isActive 	= 0
}
*/
function wrapImage(sImageName,vDefaultSwap,oNest){
		ns4 = oClient.ns4
		var modX = (oNest)?oNest.xpos:0;
		var modY = (oNest)?oNest.ypos:0;
//alert(sImageName)
		if (oNest && ns4) this.image = (isObject(oNest))?oNest.layer.document.images[sImageName]:eval(oNest).document.images[sImageName];
		else this.image = document.images[sImageName]

		//alert(sImageName)
		this.parentLayer = oNest
		this.imagename 	= sImageName
		this.dSrc		= this.image.src
		this.dActive 	= (vDefaultSwap)?(!isObject(vDefaultSwap))?new makeImage(vDefaultSwap):vDefaultSwap:null;
		this.w 			= (ns4)?this.image.width:this.image.offsetWidth;
		this.h 			= (ns4)?this.image.height:this.image.offsetHeight;
		this.isActive 	= 0
}
{
 p 				= wrapImage.prototype
 p.swap 		= wrapImage_swap
}

/*
method swapImage
original: functions/swapButtonImage.js (not updated)
method of: wrapImage()
*/
function wrapImage_swap(oImg,forceActive){
	oUseImage = oImg || this.dActive
	if (this.isActive || oUseImage){
		if (forceActive || forceActive==0) this.isActive = (forceActive==1)?0:1;
//		alert(this.image.src+"\n"+this.isActive)
//		this.image.src		= (this.isActive)?this.dSrc:oUseImage.src;	
		this.image.src		= (this.isActive)?this.dSrc:oUseImage.src;	
		this.isActive 		= (this.isActive)?0:1;
	}
}

/*
	method addCover()
	method of: wrapLayer
	updated 3.0 
	not tested 3.0
*/
function addCover(noWrap){
	var oCoverTemp = new makeLayer(this.z+1,0,0,this.w,this.h,null,"inherit",null,this,this.obj+"cover")
	this.cover	= new wrapLayer(oCoverTemp,this.obj+".cover");
}

/*
	method load_open()
	original: functions/load_open.js
	method of: wrapLayer
*/
function load_open(url,bMultiple) {
	if (this.hasScroll){
		this.reset()	
		//pauseMouseMoveEvents() //DONT FORGET ABOUT THIS BABY!!
	}
	if (oClient.ns4){
			this.layer.load(url,this.layer.clip.width)
	} else {
		window.recipLayer = this
		if (bMultiple){
			sId = getUniqueID("ieBufferFrame")
			document.body.insertAdjacentHTML("BeforeEnd","<iframe id=\""+sId+"\" style=\"position: absolute; display: none; visibility: hidden;\" onload=\"transfer('"+sId+"',true)\"></iframe>")
			//alert(document.getElementById(sId)
		} else if (!document.all["ieBufferFrame"]){
			sId = "ieBufferFrame"
			document.body.insertAdjacentHTML("BeforeEnd","<iframe id=\"ieBufferFrame\" style=\"position: absolute; display: none; visibility: hidden;\" onload=\"transfer()\"></iframe>")
		}
		document.all[sId].src = url
	}
}

function transfer(sObjBuffer,bAdd) {
	if (recipLayer) {
		if (oClient.ie4up){
			oBuffer = (sObjBuffer)?eval(sObjBuffer):ieBufferFrame;
			if (!bAdd) recipLayer.writeIntoLayer(oBuffer.document.body.innerHTML)
			else {
				recipLayer.layer.insertAdjacentHTML("BeforeEnd",oBuffer.document.body.innerHTML)
			}
		}
		if (typeof(recipLayer.calibrate)!="undefined") recipLayer.calibrate()
		if (typeof(recipLayer.onLoadAction)!="undefined") eval(recipLayer.onLoadAction)
		//if (typeOf(resumeMouseMoveEvents)!="undefined") resumeMouseMoveEvents() //DONT FORGET ABOUT THIS BABY!!
	}
}

/*
	method comareObjPositions
	original: functions/compateObjPositions.js
	method of wrapLayer
*/
function compareObjPositions(request,xpos,ypos,extra){
	if (request == "inside"){
		//if (!extra) alert(this.action+"\n"+xpos+">="+this.xpos+" && "+xpos+"<="+(this.xpos+this.w) +"&&"+ ypos+">="+this.ypos +"&&"+ ypos +"<="+(this.ypos+this.h)+"")
		if (xpos>=this.xpos && xpos<=(this.xpos+this.w) && ypos>=this.ypos && ypos<=(this.ypos+this.h)) return true
		else return false
	}
	if (request == "closeTo"){
		var extra = extra || 15
		if (xpos+extra>=this.xpos && xpos-extra<=(this.xpos+this.w) && ypos+extra>=this.ypos && ypos-extra<=(this.ypos+this.h)) return true
		else return false
	}
	return false
}

/*
	method getContentDim
	original: functions/getContentDim.js
	method of wrapLayer
*/
/*function getContentDim(type) {
	var ns4 = oClient.ns4up
    var windowHeight 	= this.getClip("b")
	var windowWidth 	= this.getClip("r")
    var contentHeight 	= (ns4)? this.layer.document.height : this.layer.access.scrollHeight;
	var contentWidth 	= (ns4)? this.layer.document.width : this.layer.access.scrollWidth;
	var offsetHeight 	= contentHeight - windowHeight
	var offsetWidth 	= contentWidth - windowWidth
	var retVal 			= (type=="h")?offsetHeight:offsetWidth;

    return retVal
}*/


function wrapLayer_setWidth(iWidth) {
        if (oClient.ns4) this.layer.clip.right = iWidth
        else this.layer.style.width = iWidth
}

function wrapLayer_setHeight(iHeight) {
        if (oClient.ns4) this.layer.clip.bottom = iHeight
        else this.layer.style.height = iHeight
}

/*
	method setLayerClip
	origin: functions/setLayerClip.js
	method of wrapLayer
*/
function setLayerClip(clipTop,clipRight,clipBottom,clipLeft){
		clipTop 	= (clipTop!=null)?clipTop:this.getClip('t');
		clipRight 	= (clipRight!=null)?clipRight:this.getClip('r');
		clipBottom 	= (clipBottom!=null)?clipBottom:this.getClip('b');
		clipLeft	= (clipLeft!=null)?clipLeft:this.getClip('l');
	if (oClient.ns4){
		this.layer.clip.top		= clipTop 	
		this.layer.clip.right 	= clipRight	
		this.layer.clip.bottom 	= clipBottom
		this.layer.clip.left 	= clipLeft
	 } else {
		this.layer.style.clip = "rect("+clipTop+"px "+clipRight+"px "+clipBottom+"px "+clipLeft+"px)"
	 }
}

/*
	method getLayerClip
	origin: functions/getLayerClip.js
	method of wrapLayer
*/
/*function getLayerClip(which) {
        if (oClient.ns4) {
                if (which=="t") return this.layer.clip.top
                if (which=="r") return this.layer.clip.right
                if (which=="b") return this.layer.clip.bottom
                if (which=="l") return this.layer.clip.left
        } else {
                var clipv = this.layer.style.clip.split("rect(")[1].split(")")[0].split("px")
                if (which=="t") return Number(clipv[0])
                if (which=="r") return Number(clipv[1])
                if (which=="b") return Number(clipv[2])
                if (which=="l") return Number(clipv[3])
        }
}*/

function wrapLayer_getOffsetTop() {
        if (oClient.ns4) rVal = this.layer.top
        else rVal = this.layer.offsetTop
		return rVal
}

function wrapLayer_getOffsetLeft() {
        if (oClient.ns4) rVal = this.layer.left
        else rVal = this.layer.offsetLeft
		return rVal
}

function wrapLayer_getOffsetHeight(bContentHeight) {
        if (oClient.ns4) rVal = (bContentHeight)?this.layer.document.height:this.layer.clip.height;
        else if (oClient.opera) rVal = this.layer.style.pixelHeight
		else rVal = this.layer.offsetHeight
		//alert("body: "+this.layer.style.clip+"\noffset: "+this.layer.offsetHeight)
		return rVal
}

/*function wrapLayer_getContentHeight() {
        if (oClient.ns4) rVal = this.layer.document.height
        else if (oClient.opera) rVal = this.layer.style.pixelHeight
		else rVal = this.layer.offsetHeight
//		alert("contentHeight: "+rVal)
		rVal = parseInt(rVal)
		return rVal
}*/

/*
method getDim
returns the height/width of the content of a layer.
*/

function wrapLayer_getDim(vWhich){ //0 || width, 1 || height
	bH = (vWhich == 1 || vWhich == "height")
	if (oClient.ns4) rVal = (bH)?this.layer.document.height:this.layer.document.width;
    else if (oClient.opera) rVal = (bH)?this.layer.style.pixelHeight:this.layer.style.pixelWidth;
	else rVal = (bH)?this.layer.offsetHeight:this.layer.offsetWidth;
	rVal = parseInt(rVal)
	return rVal
}
/*
method getClip
return content-width & -height if no clip...
*/

function wrapLayer_getClip(vWhich,bForceRead) { //nothing = all as array, top || 0 , 1 || right, 2 || bottom, 3 || left, 4 || width, 5 || height
		if (!oClient.ns4 && (!this.clip || bForceRead)){
			//var aClip = new Array()
			sClip = this.layer.style.clip
			aClip = sClip.match(/-?[0-9]+/g) //+[a-zA-Z]+
//			alert("clip match: "+aClip+"\nclip is "+this.layer.style.clip)
			
//			aRe = /[0-9]+/
//			bHasClip = aRe.test(this.layer.style.clip)
//			if (bHasClip) aClip = this.layer.style.clip.split("rect(")[1].split(")")[0].split("px")
			if (!aClip){ 
				 //alert("no clip "+aClip+"\n"+this.layer.style.clip)
				 aClip = [0,this.getDim("width"),this.getDim("height"),0] 
			}
			//if (document.defaultView) alert(document.defaultView.getComputedStyle(this.layer,'').getPropertyValue("clip"))
			this.clip = new Object()
			this.clip.top = parseInt(aClip[0])
			this.clip.right = parseInt(aClip[1])
			this.clip.bottom = parseInt(aClip[2])
			this.clip.left = parseInt(aClip[3])
			this.clip.width =this.clip.right - this.clip.left
			this.clip.height =  this.clip.bottom - this.clip.top
		} else if (oClient.ns4 && !this.clip){
			this.clip = this.layer.clip
//			alert(this.clip)
		}
// just for debug
		oClip = this.clip
	//	alert(oClip.top+","+oClip.right+","+oClip.bottom+","+oClip.left+","+oClip.width+","+oClip.height)
// done with debug
		vType = typeof(vWhich)
		if (vType=="string"){
			iRet = this.clip[vWhich]		
		} else {
			aClip = [this.clip.top,this.clip.right,this.clip.bottom,this.clip.left,this.clip.width,this.clip.height]
			if (vType == "undefined") iRet = aClip
			else iRet = aClip[vWhich]
		}
		//alert("1 "+iRet)
		//if (isNaN(iRet)) iRet = this.getDim(vWhich)
		//alert("2 "+iRet)
		return iRet
		/*switch (vWhich){
			case 0,"t":
				iVal = 
			case 1,"r":

			case 2,"b":			
			
			case 3,"l":
			
			case 4,"w":			
			
			case 5,"h":			
			
			case else:
				iVal = [oClip.top,oClip.right,oClip.bottom,oClip.left,oClip.width,oClip.height]
		}*/
        if (oClient.ns4) aClip = this.layer.clip.height
		else {
			aRe = /([0-9]+)/
			hasClip = aRe.test(this.layer.style.clip)
			if (hasClip){
				aClip = this.layer.style.clip.split("rect(")[1].split(")")[0].split("px")//aRe.exec(this.layer.style.clip)//this.layer.style.clip.replace(aRe,"$1")
				rVal = aClip[2]
			} else {
//				alert(this.layer.style.clip.right)
				rVal = this.getDim(0)
			}

		}
        //else if (oClient.opera) rVal = this.layer.style.pixelHeight
		//else rVal = this.layer.offsetHeight
//		alert("clipHeight: "+rVal)
		rVal = parseInt(rVal)
		return rVal
}

//bContentWidth retrieves the width of the content rather than the set width of the layer since ns4 can't have relative widths of layers.
function wrapLayer_getOffsetWidth(bContentWidth) {
		//if (sChildId) alert(this.layer.document.layers[sChildId].clip)
        if (oClient.ns4) rVal = (bContentWidth)?this.layer.document.width:this.layer.clip.width;
        else rVal = this.layer.offsetWidth
		return rVal
}


/*
	method raiseLayerToTop
	origin: functions/raiseLayerToTop.js
	method of wrapLayer
*/
function raiseLayerToTop(){
	var atZ = this.z
	if (oClient.ns4up) for (i=0;i<document.layers.length;i++){
		if (document.layers[i].zIndex>atZ) atZ=document.layers[i].zIndex
	} else {
		eZ=document.all.tags("DIV")
		for (i=0;i<eZ.length;i++) if (eZ[i].style.zIndex>atZ) atZ = eZ[i].style.zIndex
	}
	this.setZ(atZ+1)
}

/*
	method setLayerZindex
	origin: functions/setLayerZindex.js
	method of wrapLayer
*/
function setLayerZindex(z){
	this.layer.zIndex = this.z = z
}

/*
	method setRelativePixel
	origin: functions/setRelativePixel.js
	method of wrapLayer
*/
function setRelativePixel(pLeft,pTop){
	if (oClient.ie4 || oClient.ns4){
		if (pLeft!=null) this.layer.left = this.xpos += pLeft
		if (pTop!=null) this.layer.top = this.ypos += pTop
	}
}

/*
	method setPixel
	origin: functions/setLayerPixel.js
	method of wrapLayer
*/
function wrapLayer_setPixel(pLeft,pTop){
//IEMAC CAN't SET this.layer.style.left!
//why? edited in the mac thing on 02-04-18
	//if (oClient.ns4){
	//alert(this.layer.top)
//		if (pLeft!=null) this.layer.left = this.xpos = pLeft
//		if (pTop!=null) this.layer.top = this.ypos = pTop
//	} else if (oClient.ns5up || oClient.ie4up || oClient.opera){
		if (pLeft!=null) this.layer.style.left = this.xpos = pLeft
		if (pTop!=null) this.layer.style.top = this.ypos = pTop
//	}
}

/*
	method layerVis()
	origin: functions/layerVis.js
	method of wrapLayer
*/
function layerVis(visible){
	if (visible && visible==true) vis = "visible";
	else if (visible) vis = visible;
	else vis = "hidden";
	this.layer.style.visibility = vis
}

/*
	method writeIntoLayer
	origin: functions/writeIntoLayer.js
	method of wrapLayer
*/
function writeIntoLayer(htmlContent){
	if (oClient.ns4) {
		this.layer.document.open("text/html")
		this.layer.document.write(htmlContent)
		this.layer.document.close()
	} else {
		this.layer.innerHTML = htmlContent
		
	}
}



/* Not updated to work with ns6 and other browsers. */
function mapWindow(autoResize) {
		this.w = (oClient.ns || oClient.opera)?window.innerWidth:document.body.clientWidth;
		this.h = (oClient.ns || oClient.opera)?window.innerHeight:document.body.clientHeight;
		this.outerW = (oClient.ns || oClient.opera)?window.outerWidth:document.body.offsetWidth;
		this.outerH = (oClient.ns || oClient.opera)?window.outerHeight:document.body.offsetHeight;
		this.xpos = (oClient.ns || oClient.opera)?window.screenX:window.screenLeft;
		this.ypos =  (oClient.ns || oClient.opera)?window.screenY:window.screenTop;

		this.screenW = screen.availWidth
		this.screenH = screen.availHeight
		//alert(this.outerW+" : "+this.outerH)
		this.center_x = this.w*.5
		this.center_y = this.h*.5
		
		this.px_right = this.w - this.center_x
		this.px_left = this.w - this.center_x
		this.px_top = -this.h - this.center_y
		this.px_bottom = this.h - this.center_y
		window.oWindow = this
		if (autoResize && oClient.ns4up) {
			//var fn = new Function("if (oWindow.w!=window.innnerWidth || oWindow.h!=window.innerHeight){ location.reload() }")
			var fn = new Function("if (oWindow.w!=window.innnerWidth || oWindow.h!=window.innerHeight){ history.go(0) }")
			window.onresize = fn
		}
}

