// DynLayer Slide Methods

// straight line animation methods

// 19990531



// Copyright (C) 1999 Dan Steinman

// Distributed under the terms of the GNU Library General Public License

// Available at http://www.dansteinman.com/dynapi/



function DynLayerSlideTo(endx,endy,inc,speed,fn) {

	if (endx==null) endx = this.x

	if (endy==null) endy = this.y

	var distx = endx-this.x

	var disty = endy-this.y

	this.slideStart(endx,endy,distx,disty,inc,speed,fn)

}

function DynLayerSlideBy(distx,disty,inc,speed,fn) {

	var endx = this.x + distx

	var endy = this.y + disty

	this.slideStart(endx,endy,distx,disty,inc,speed,fn)

}

function DynLayerSlideStart(endx,endy,distx,disty,inc,speed,fn) {

	if (this.slideActive) return

	if (!inc) inc = 10

	if (!speed) speed = 20

	var num = Math.sqrt(Math.pow(distx,2) + Math.pow(disty,2))/inc

	if (num==0) return

	var dx = distx/num

	var dy = disty/num

	if (!fn) fn = null

	this.slideActive = true

	this.slide(dx,dy,endx,endy,num,1,speed,fn)

}

function DynLayerSlide(dx,dy,endx,endy,num,i,speed,fn) {

	if (!this.slideActive) return

	if (i++ < num) {

		this.moveBy(dx,dy)

		this.onSlide()

		if (this.slideActive) setTimeout(this.obj+".slide("+dx+","+dy+","+endx+","+endy+","+num+","+i+","+speed+",\""+fn+"\")",speed)

		else this.onSlideEnd()

	}

	else {

		this.slideActive = false

		this.moveTo(endx,endy)

		this.onSlide()

		this.onSlideEnd()

		eval(fn)

	}

}

DynLayer.prototype.slideInit = new Function("")

DynLayer.prototype.slideTo = DynLayerSlideTo

DynLayer.prototype.slideBy = DynLayerSlideBy

DynLayer.prototype.slideStart = DynLayerSlideStart

DynLayer.prototype.slide = DynLayerSlide

DynLayer.prototype.onSlide = new Function("")

DynLayer.prototype.onSlideEnd = new Function("")

