// JavaScript Document
var the_timeout;
var theStyle; 
var xpos;
var ypos;
var new_left;
var current_left;
var new_top;
var current_top;
var sString;
var str;
var layer;
var maxPos;
var minPos;
var yposLayer;
var xposLayer;


function moveDiv(str){
//local variables





	str = str.split(':');
    layer = str[0];
	minPos = str[1];
	maxPos = str[2];
	
	//get the position of the outer Layer
	 yposLayer= getY(document.getElementById(layer));
	 xposLayer= getX(document.getElementById(layer));
	 


	
	//get the position x and y
	ypos= getY(document.getElementById(layer));
	xpos= getX(document.getElementById(layer));
	
	ypos = ypos - yposLayer;
	xpos = xpos - xposLayer;

	
	  // get the stylesheet
	if (document.layers) {
          theStyle=document.getElementById(layer);  //getStyleObject('x');
     }
    else {
          theStyle=document.getElementById(layer).style;

        } 
	
	if(xpos >= maxPos){
		str = layer+":"+minPos+":"+maxPos;
		returnDiv(str);
	}
	
	
  
else{		
//moving foreward		
  if (theStyle)
  {
	  	 	
    // get the current coordinate and add 2 (speed of the movement)
    //
    current_left = parseInt(theStyle.left+xpos);
	new_left = current_left + 10;

 
    // set the left property of the DIV, add px at the
    // end unless this is NN4
    //
    if (document.layers) 
    {
      theStyle.left = new_left;
    }
    else 
    {  
      theStyle.left = new_left + "px";

    }
 
    // if we haven't gone to far, call moveDiv() again in a bit
    // 
    if (new_left < maxPos) {
		sString = layer+":"+minPos+":"+maxPos;
        the_timeout = setTimeout("moveDiv('"+sString+"');",10);
    }
  }
 }
}


//move back
function returnDiv(str){


	yposLayer= getY(document.getElementById(layer));
	xposLayer= getX(document.getElementById(layer));

	str = str.split(':');
    layer = str[0];
	minPos = str[1];
	maxPos = str[2];





  // get the stylesheet
	if (document.layers) {
          theStyle=document.getElementById(layer);  //getStyleSheet;
     }
    else {
          theStyle=document.getElementById(layer).style;

        } 
		
		 if (theStyle)
  {
	  	 	
    // get the current coordinate and add 2 (speed of the movement)
    //
    current_left = maxPos;
	new_left = current_left - 10;
	maxPos =  new_left;

 
    // set the left property of the DIV, add px at the
    // end unless this is NN4
    //
    if (document.layers) 
    {
      theStyle.left = new_left;
    }
    else 
    {  
      theStyle.left = new_left + "px";

    }
 
    // if we haven't gone to far, call moveDiv() again in a bit
    // 
    if (new_left > minPos) {
		sString = layer+":"+minPos+":"+maxPos;
       the_timeout = setTimeout("returnDiv('"+sString+"');",10);
    }
  }
}


//get the Y position
function getY (el){
	 var y = el.offsetTop;
      if (!el.offsetParent) return y;
      else return (y+getY(el.offsetParent));
	  }
//get the X Position
function getX (el){
	x = el.offsetLeft;
    if (!el.offsetParent) return x;
    else return (x+getX(el.offsetParent));
	}