// JavaScript Document
var the_timeout;

function moveDiv(numX, numY, stepCount, stepX, stepY)
{
  // get the stylesheet
  //
  var the_style = getStyleObject("myDiv");
  if (the_style)
  {
    // get the current coordinate and add 5
    var current_left = parseInt(the_style.left);
	var current_top = parseInt(the_style.top);
	
	if(stepX == 0){
		var xDif = Math.abs(Math.abs(current_left) - numX)/50;
		//alert ("the current left is: "+current_left);
		//alert ("the setp will be: "+xDif);
	}else{
		var xDif = stepX;
	}
	if(stepY == 0){
		var yDif = Math.abs(Math.abs(current_top) - numY)/50;
		//alert ("the current top is: "+current_top);
		//alert ("the setp will be: "+yDif);
	}else{
		var yDif = stepY;
	}
	//alert ("the x dif is: "+xDif+ " the y dif is: "+yDif); 
	
	if(Math.abs(current_left) > numX){
		var new_left = current_left + xDif;
	}else if(Math.abs(current_left) < numX){
		var new_left = current_left - xDif;
	}
	
	if(Math.abs(current_top) > numY){
		var new_top = current_top + yDif;
	}else if(Math.abs(current_top) < numY){
		var new_top = current_top - yDif;
	}
	
    // set the left property of the DIV, add px at the
    // end unless this is NN4
    if (document.layers){
      the_style.left = new_left;
	  the_style.top = new_top;
    }
    else{  
      the_style.left = new_left + "px";
	  the_style.top = new_top + "px";
    }
    
    // if we haven't gone to far, call moveDiv() again in a bit
    if (stepCount < 50){
		stepCount = stepCount + 1;
		//num = num - 10;
      the_timeout = setTimeout('moveDiv('+numX+','+numY+','+stepCount+','+xDif+','+yDif+');',50);
    }
	
	
  }
}




function getStyleObject(objectId) {
    // cross-browser function to get an object's style object given its
    if(document.getElementById && document.getElementById(objectId)) {
	// W3C DOM
	return document.getElementById(objectId).style;
    } else if (document.all && document.all(objectId)) {
	// MSIE 4 DOM
	return document.all(objectId).style;
    } else if (document.layers && document.layers[objectId]) {
	// NN 4 DOM.. note: this won't find nested layers
	return document.layers[objectId];
    } else {
	return false;
    }
}