//=====================================================        
//state variables, necessary for stopping a previous movie before starting the next
var lastID = "notSet";
var lastWidth = -1;
var lastHeight = -1;
var lastLoopType = "notSet";
//=====================================================        
//Convenience function - inserts a link to a movie using a png.
function linkToMovie(objectID, width, height, loopType)
{
  document.write("<div id='" + objectID + "'>" +
                 "  <a title='Click to watch' href='JavaScript:startMovie(\"" + 
                       objectID + "\", " + width + ", " + height + ", \"" + loopType + "\")'>" +
                 "    <img src='" + objectID + ".png' border='2'>" +
                 "  </a>" +
                 "</div>");
}
//=====================================================        
//This function replaces the movie thumbnail with the actual movie file and automatically starts playing.
function startMovie(objectID, width, height, loopType) 
{ 
  if(lastID != "notSet" )
  {
    var object = document.getElementById(lastID);
    object.innerHTML = "<a title='Click to watch' href='JavaScript:startMovie(\"" + lastID + "\", " + 
                       lastWidth + ", " + lastHeight + ", \"" + lastLoopType + "\")'>" +
                       "<img src='" + lastID + ".png' border='2'></a>";
  }

  //loop types: false, true, palindrome
  var object = document.getElementById(objectID);
  object.innerHTML = "<table cellpadding='2' cellspacing='0'><tr><td>" +
                     "<embed controller='false" +
                     "' autostart='true' cache='true" +
                     "' src='"      + objectID + ".mov" +
                     "' width='"    + width + 
                     "' height='"   + height + 
                     "' loop='"     + loopType + "'></embed>" +
                     "</td></tr></table>";                                         
  lastID = objectID;
  lastWidth = width;
  lastHeight = height;
  lastLoopType = loopType;
}
//=====================================================        
