//this file extends the functionality of layerapi.js by offering layer dropdown animation

addWindowObj("dropdown")

function setdrop(n) {
	temp=n.split("_");
	for (k=1;k<4;k++) {
		if (temp[k].indexOf("m")!=-1) {
			temp[k]=Math.floor(temp[k].substring(1,10));
			temp[k]=temp[k]*-1;
		}
	}
	eval(temp[0]+"obj.endpoint="+temp[1]+";")
	eval(temp[0]+"obj.moveTo("+temp[2]+","+temp[3]+")")
	eval(temp[0]+"obj.show()")
	eval(temp[0]+"obj.dropstate='start';")
	eval(temp[0]+"obj.dropstart="+temp[3]+";")
	return
}

function obj_dropdown() {//animate a layer to a specified height
	this.doanimate()
}

function obj_doanimate() {
	if (this.dropstate=="start") {
		dest=this.endpoint;
	} else {
		dest=this.dropstart;
	}
	if (this.y>dest) {
		amt=Math.floor(((this.y-dest)/10)*-1)
		if (amt>-1) {amt=-1}
		
	} else if (this.y<dest) {
		amt=Math.floor(((this.y-this.endpoint)/10)*-1)
		if (amt<1) {amt=1}
		
	} else {
		amt=0
		if (this.dropstate=="start") {
			this.dropstate="end"
		} else {
			this.dropstate="start"
		}
	}
	this.moveBy(0,amt)
	if (amt!=0) {
		this.timerid=setTimeout(this.objname+".doanimate()",10)
	}
}

objLayer.prototype.dropdown=obj_dropdown
objLayer.prototype.doanimate=obj_doanimate
