var start_top;
var start_left;
var start_width;
var start_height;
var end_top;
var end_left;
var end_width;
var end_height;
var nbr_steps;
var speed;

var curr_top;
var curr_left;
var curr_width;
var curr_height;

var curr_step;

var anim_holder_obj;
var anim_image_obj;

function init_animate(anim_holder_id,anim_image_id) {
	this.anim_holder_obj=document.getElementById(anim_holder_id);
	this.anim_image_obj=document.getElementById(anim_image_id);
}

function animate(start_top,start_left,start_width,start_height,end_top,end_left,end_width,end_height,nbr_steps,speed,init_delay) {
	setTimeout("start("+start_top+","+start_left+","+start_width+","+start_height+","+end_top+","+end_left+","+end_width+","+end_height+","+nbr_steps+","+speed+")",init_delay);
}

function start(start_top,start_left,start_width,start_height,end_top,end_left,end_width,end_height,nbr_steps,speed) {
//	alert("s_t="+start_top+" s_l="+start_left+" s_w="+start_width+" s_h="+start_height+" e_t="+end_top+" e_l="+end_left+" e_w="+end_width+" e_h="+end_height+" n_s="+nbr_steps);
	this.start_top=start_top;
	this.start_left=start_left;
	this.start_width=start_width;
	this.start_height=start_height;
	this.end_top=end_top;
	this.end_left=end_left;
	this.end_width=end_width;
	this.end_height=end_height;
	this.nbr_steps=nbr_steps;
	this.speed=speed;

	curr_top=start_top;
	curr_left=start_left;
	curr_width=start_width;
	curr_height=start_height;

	anim_holder_obj.style.top=''+curr_top+'px';
	anim_holder_obj.style.left=''+curr_left+'px';
	anim_holder_obj.style.width=''+curr_width+"px";
	anim_holder_obj.style.height=''+curr_height+"px";
	
	anim_image_obj.width=curr_width;
	anim_image_obj.height=curr_height;

	curr_step=0;

	anim_holder_obj.style.display="block";

	setTimeout("move()",speed)
}

function move() {
	curr_step++;

	curr_top=parseInt(start_top+(curr_step*((end_top-start_top)/nbr_steps)));
	curr_left=parseInt(start_left+(curr_step*((end_left-start_left)/nbr_steps)));
	curr_width=parseInt(start_width+(curr_step*((end_width-start_width)/nbr_steps)));
	curr_height=parseInt(start_height+(curr_step*((end_height-start_height)/nbr_steps)));


	anim_holder_obj.style.top=''+curr_top+'px';
	anim_holder_obj.style.left=''+curr_left+'px';
	anim_holder_obj.style.width=''+curr_width+'px';
	anim_holder_obj.style.height=''+curr_height+'px';
	anim_image_obj.width=curr_width;
	anim_image_obj.height=curr_height;
	if (curr_step<nbr_steps)
	{
		setTimeout("move()",speed);
	}
	else {
		anim_holder_obj.style.top=''+end_top+'px';
		anim_holder_obj.style.left=''+end_left+'px';
		anim_holder_obj.style.width=''+end_width+'px';
		anim_holder_obj.style.height=''+end_height+'px';
		anim_image_obj.width=end_width;
		anim_image_obj.height=end_height;
	}

}
