
// Slide Methods
function DynLayerClipSlideTo(endx,endy,inc,speed,fn) {
	if (endx==null) endx = this.clipValues('r')
	if (endy==null) endy = this.clipValues('b')
	
	var distx = endx-this.clipValues('r')
	var disty = endy-this.clipValues('b')
	this.clipSlideStart(endx,endy,distx,disty,inc,speed,fn)
}

function DynLayerClipSlideBy(distx,disty,inc,speed,fn) {
	var endx = this.clipValues('r') + distx
	var endy = this.clipValues('b') + disty
	this.clipSlideStart(endx,endy,distx,disty,inc,speed,fn)
}

function DynLayerClipSlideStart(endx,endy,distx,disty,inc,speed,fn) {
	if (this.clipSlideActive) 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.clipSlideActive = true
	this.clipSlide(dx,dy,endx,endy,num,1,speed,fn)
}

function DynLayerClipSlide(dx,dy,endx,endy,num,i,speed,fn) {
	if (!this.clipSlideActive) return
	if (i++ < num) {
		this.clipBy(0,dx,dy,0)
		this.onClipSlide()
		if (this.clipSlideActive) setTimeout(this.obj+".clipSlide("+dx+","+dy+","+endx+","+endy+","+num+","+i+","+speed+",\""+fn+"\")",speed)
		else this.onClipSlideEnd()
	}
	else {
		isOpen = true;
		this.clipSlideActive = false
		this.clipTo(0,endx,endy,0)
		this.onClipSlide()
		this.onClipSlideEnd()
		eval(fn)
	}
}

function DynLayerOpenMenu() {
	if (!this.isOpen) {
		this.clipSlideTo(168,160);
	}
}

function DynLayerCloseMenu() {
	if (this.isOpen) {
		this.clipSlideTo(0,0);
	}
}

function DynLayerClipSlideInit() {}
DynLayer.prototype.clipSlideInit = DynLayerClipSlideInit
DynLayer.prototype.clipSlideTo = DynLayerClipSlideTo
DynLayer.prototype.clipSlideBy = DynLayerClipSlideBy
DynLayer.prototype.clipSlideStart = DynLayerClipSlideStart
DynLayer.prototype.clipSlide = DynLayerClipSlide
DynLayer.prototype.onClipSlide = new Function()
DynLayer.prototype.onClipSlideEnd = new Function()
DynLayer.prototype.openMenu = DynLayerOpenMenu
DynLayer.prototype.closeMenu = DynLayerCloseMenu
