
var obj, w, goRight;

function setSail()
{
  var pos = parseInt( obj.style.left, 10 );

  ( goRight ) ? pos++ : pos-- ;
  obj.style.left = pos + "px";

  if( pos > (w + 40) ) 
  {
    obj.style.background="url(/images/cabinAlaSlightlyPsychadelic.jpg)";
    goRight = false;
  }

  if( pos < -400 ) 
  {
   obj.style.background="url(/images/cabinAlaSlightlyPsychadelic.jpg)";
   goRight = true;
  }
 
  setTimeout( setSail , 20 );
}


function init()
{
  var preload=new Image();
  preload.src="/images/cabinAlaSlightlyPsychadelic.jpg";

  obj = document.getElementById("boat"); 
  w = document.body.clientWidth;
  goRight = true;

  obj.style.position="absolute";
  obj.style.left="-400px";

  setSail();

}
onload=init;

