// Mark Royer
// This must be used with DHTMLapi.js to work correctly

function floatObject() {

  if (window.innerHeight) // netscape
    var startX = getInsideWindowWidth()-getObjectWidth("image")-20;
  else // explorer
    var startX = getInsideWindowWidth()-getObjectWidth("image");


  var startY = getObjectHeight("floatingDiv")+10;

  var el= getRawObject("floatingDiv");


  var currentX = startX;
  var currentY = (getInsideWindowHeight()+getPageYOffset())/2;
  currentY -= startY;


  // move to position and show element
  el.style.left = currentX+"px";


  el.style.top = currentY+"px";
  el.style.visibility = "visible";  

  // Add event handler to window	
  window.floatToSpot = function()
  {

    var scrolledAmount = getInsideWindowHeight()+getPageYOffset();
    // Adjust amount of division to slow movement
    currentY += (scrolledAmount - startY - currentY)/speed;
    
    // Update position of object
    el.style.left = currentX+"px";
    el.style.top = currentY+"px";

    // Call event every 10 miliseconds
    if (getInsideWindowWidth() > 1000) 
      setTimeout("floatToSpot()", 5);
    else // Stop if the window gets too small for div
    {
      hide("floatingDiv");
      getRawObject("floatingDiv").style.left = 0+"px"; // put on left side
      getRawObject("floatingDiv").style.top = 0+"px"; // put on left side    
      return;
    }
  }
  floatToSpot();
}

function realign() {

  refresh();  
  startup();

}

// Adjust this for speed, smaller number faster, bigger number slower
var speed = 12;

window.onload = startup;
window.onresize = realign;

function startup() {				 

  initDHTMLAPI();
  if (getInsideWindowWidth() > 1000) // Check for big enough screen
    floatObject();
  else
    hide("floatingDiv"); // hide the div
 
}  

