/**
 *  Moves an div element called "walker" around the
 *  screen.
 */
var x = 5; //Starting Location - left
var y = 5; //Starting Location - top
var interval = 10; //Move 10px every initialization
var dest_x = window_width() - 70;
var dest_y = 30;
var bottom_y = window_height();


function count()  
{
   if ( dest_x == 0 )
   {
     dest_x = window_width() - 70;      
   }
   else
   {
     dest_x = 0;
   }
   
   dest_y = dest_y + 30;
      
   if ( dest_y > window_height() ) 
   {
	  dest_y = 100;   
	  y = 0;
   }
   
} // end function count 

function moveImageRight() {
            
	//Keep on moving the image till the target is achieved
	if(x<dest_x) x = x + interval; 
	if(y<dest_y) y = y + interval/5;
	
	//Move the image to the new location
	document.getElementById("walker").style.top  = y+'px';
	document.getElementById("walker").style.left = x+'px';
	
	if ((x+interval < dest_x) )//&& (y+interval < dest_y)) 
	{
		//Keep on calling this function every 100 microsecond 
		//	till the target location is reached
		window.setTimeout('moveImageRight()',100);
	}
	else
	{
	  count();
	  document['walkerimg'].src = 'imagenes/walker1.gif';
      window.setTimeout('moveImageLeft()',100);
	}
	
} // end function moveImageRight()


function moveImageLeft() {

	//Keep on moving the image till the target is achieved
	if(x>dest_x) x = x - interval; 
	if(y<dest_y) y = y + interval/5;
	
	//Move the image to the new location
	document.getElementById("walker").style.top  = y+'px';
	document.getElementById("walker").style.left = x+'px';
	
	if ((x-interval > dest_x) )//&& (y+interval < dest_y) ) 
	{
		//Keep on calling this function every 100 microsecond 
		//	till the target location is reached
		window.setTimeout('moveImageLeft()',100);
	}
	else
	{
      count();	
	  document['walkerimg'].src = 'imagenes/walker.gif';
      window.setTimeout('moveImageRight()',100);
	}


} // end function moveImageLeft()


function window_width () {
  if (window.innerWidth) {
    return window.innerWidth;
  } else if (document.body && document.body.offsetWidth) {
    return document.body.offsetWidth;
  } else {
    return 0;
  }
}

function window_height () {
  if (window.innerHeight) {
    return window.innerHeight;
  } else if (document.body && document.body.offsetHeight) {
    return document.body.offsetHeight;
  } else {
    return 0;
  }
}

