var x = 100; //Starting Location - left
var y = 400; //Starting Location - top
var dest_x = 400;  //Ending Location - left
var dest_y = 300;  //Ending Location - top
var interval = 2; //Move 10px every initialization

function animate(fieldname)
{

	x=findPosX(document.getElementById(fieldname));
		
	y=findPosY(document.getElementById(fieldname));
	dest_y=y;
	div_id =fieldname+'_x';
		
	document.getElementById(div_id).style.display="block";	
	
	document.getElementById(div_id).style.left=x;
	document.getElementById(div_id).style.top=y;	
	
	moveImage(div_id);
	return false;
}

function moveImage(div_id) {
	//Keep on moving the image till the target is achieved
	if(x<dest_x) x = x + interval; 
	if(y<dest_y) y = y + interval;

	//Move the image to the new location
	document.getElementById(div_id).style.top  = y+'px';
	document.getElementById(div_id).style.left = x+'px';

	if (x+interval < dest_x)  {
		//Keep on calling this function every 100 microsecond 
		//	till the target location is reached
		window.setTimeout("moveImage('"+div_id+"')",30);
	}
}

function findPosX(obj)
  {
    var curleft = 0;
    if(obj.offsetParent)
        while(1) 
        {
          curleft += obj.offsetLeft;
          if(!obj.offsetParent)
            break;
          obj = obj.offsetParent;
        }
    else if(obj.x)
        curleft += obj.x;
    return curleft;
  }

  function findPosY(obj)
  {
    var curtop = 0;
    if(obj.offsetParent)
        while(1)
        {
          curtop += obj.offsetTop;
          if(!obj.offsetParent)
            break;
          obj = obj.offsetParent;
        }
    else if(obj.y)
        curtop += obj.y;
    return curtop;
  }

