// ==============================================================================================================
// BEGIN Layer object code --------------------------------------------------------------------------------------
// 
function movingObject(objectName,divString,xinit,yinit,speed) {
	this.IE5=this.NN4=this.NN6=false
	if(document.all)this.IE5=true
	else if(document.layers)this.NN4=true
	else if(document.getElementById)this.NN6=true
	
	var netscapestring=""
	var tmp
	var bgn, end
	var i
	var divstring=divString

	i=0
	bgn=0
	end=0
	do { 
		i++
		tmp = ""
		netscapestring += "document."
		end = divstring.indexOf(",")
		if( end > -1 ){
			tmp = divstring.substring(bgn,end)
			divstring = divstring.substring(end+1,divstring.length)
		} else {
			end = divstring.length
			tmp = divstring.substring(bgn,end)
			divstring = null
		}
		netscapestring += tmp
		if(divstring)netscapestring += "."
	} while( divstring )

	if(this.NN4)this.obj=eval(netscapestring)
	if(this.IE5)this.obj=eval("document.all."+tmp+".style")
	if(this.NN6)this.obj=eval("document.getElementById(\""+tmp+"\")"+".style")

	this.objname = objectName
	this.timer=null
	this.speed=speed
	this.active=false

	this.chase = Chase
	this.show = showDiv
	this.hide = hideDiv
	this.zindex = setZindex
	this.getx = getX
	this.gety = getY
	this.setx = setX
	this.sety = setY
	this.warp = warpTo
	
	this.warp(xinit,yinit)
}
function getX() {
	if(this.IE5)return parseInt(this.obj.pixelLeft)
	else if(this.NN4)return parseInt(this.obj.left)
	else if(this.NN6)return parseInt(this.obj.left)
}
function getY() {
	if(this.IE5)return parseInt(this.obj.pixelTop)
	else if(this.NN4)return parseInt(this.obj.top)
	else if(this.NN6)return parseInt(this.obj.top)
}
function setX(x) {
	if(this.IE5)this.obj.pixelLeft=x
	else if(this.NN4)this.obj.left=x
	else if(this.NN6)this.obj.left=x + "px"
}
function setY(y) {
	if(this.IE5)this.obj.pixelTop=y
	else if(this.NN4)this.obj.top=y
	else if(this.NN6)this.obj.top=y + "px"
}
function showDiv() {
	this.obj.visibility="visible"
}
function hideDiv() {
	this.obj.visibility="hidden"
}
function setZindex( z ) {
	this.obj.zIndex = z
}
function warpTo(x,y) {
	if(this.IE5) {
		this.obj.pixelLeft=x
		this.obj.pixelTop=y
	} else if(this.NN4) {
		this.obj.moveTo(x,y)
	} else if(this.NN6) {
		this.obj.left = x + "px"
		this.obj.top = y + "px"
	}
}
function Chase( x, y ) {
	decay=5
	dx=x-this.getx()
	dy=this.gety()-y
	distance=Math.round(Math.sqrt(dx*dx+dy*dy))
	if(dx==0) angle=Math.PI*((dy>0)?.5:1.5)
	else angle=Math.atan(dy/dx)+(Math.PI*((dx<0)?1:(dy<0)?2:0))
	xstep=(dx>1)?Math.ceil(distance*Math.cos(angle)/decay):Math.floor(distance*Math.cos(angle)/decay)
	ystep=(dy<1)?Math.ceil(-distance*Math.sin(angle)/decay):Math.floor(-distance*Math.sin(angle)/decay)
	this.setx(this.getx()+xstep)
	this.sety(this.gety()+ystep)
	if( distance>1 ) {
		this.active=true
		this.timer=setTimeout(this.objname+".chase("+x+","+y+")", this.speed)
	} else {
		clearTimeout(this.timer)
		this.hoverflag?this.hover(x,y):this.warp(x,y)
		this.active=false
	}
}
// END Layer object code ----------------------------------------------------------------------------------------

