var exec = new Array();
var dir = new Array();
function startExpand(target, expandTo, speed){
//alert(target +":"+ exec[target] +":"+ dir[target]);
if(!exec[target])
exec[target] = 0;
if(!dir[target])
dir[target] = 'open';
if(dir[target] == 'open') {
exec[target] = exec[target] + speed;
if(exec[target] < expandTo) {
document.getElementById(target).style.height = (exec[target]) + "px";
setTimeout("startExpand('" + target + "'," + expandTo + "," + speed + ")",1);
} else {
document.getElementById(target).style.height = (expandTo) + "px";
dir[target] = 'close';
}
} else {
exec[target] = exec[target] - (speed*2);
if(exec[target] > 0) {
document.getElementById(target).style.height = (exec[target]) + "px";
setTimeout("startExpand('" + target + "'," + expandTo + "," + speed + ")",1);
} else {
document.getElementById(target).style.height = "0px";
dir[target] = 'open';
}
}
}
//var so_target;
var so_interval;
function slide(target, expandTo, speed) {
var intv_call = 'slideIt(\'' + target + '\',' + expandTo + ')';
clearInterval(so_interval);
so_interval = setInterval(intv_call,speed);
}
function slideIt(target, expandTo) {
var current = document.getElementById(target).offsetHeight;
distTo = Math.abs(current - expandTo);
var goSize = distTo/6;
if( goSize < 1 ) goSize = 1;
if( current > expandTo ) {
//make shorter
document.getElementById(target).style.height = (current-goSize) + "px";
} else {
// make taller
document.getElementById(target).style.height = (current+goSize) + "px";
}
if( distTo < 2 ) {
// very close, kill the timer, set it to the right height
document.getElementById(target).style.height = expandTo + "px";
clearInterval(so_interval);
}
//alert(distTo +":"+ goSize);
}