// preload the swap image

var preload = new Image(); 
preload.src = "tape_pix/brush_pink.jpg"; 

// set the initial direction to right
var go_right = true;

// a function to move a <div> across the page
function set_sail()
{   
  // get the div object
  var obj = document.getElementById("boat"); 

  // get the window width
  var ext = document.body.clientWidth;            

    // if direction is right 
    if(go_right ) 
    // move right by 1 pixel                                  
    obj.style.left = (parseInt(obj.style.left)+1)+"px";   
    else 
    // otherwise move left by 1 pixel
    obj.style.left = (parseInt(obj.style.left)-1)+"px";


    // when the layer's left edge is 15 pixels beyond the window's right edge
    if(parseInt(obj.style.left ) >= ( ext - 325 ) ) 

    {               
      // change the direction to left
      go_right=false;
      // swap the image to a left-facing version                 
      document.getElementById("boat_image").src = "tape_pix/brush_pink.jpg"; 
    }

    // when the layer's left edge is 975 pixels beyond the window's left edge
    if(parseInt(obj.style.left) <= -775) 
    {          
      // change the direction to right
      go_right = true;
	
      // swap the image to a right-facing version                           
      document.getElementById("boat_image").src = "tape_pix/brush_pink.jpg"; 
    }               

    // set the interval to call this function
    window.setTimeout("set_sail()", 15);
                        
}



// start the routine
set_sail();




















