//
// JS routines for interacting with Flash objects
//
//  Clio Soleil (clio@PrettyGetter.TV)
//  PrettyGetter Productions (http://PrettyGetter.TV)
//  

//--------------------------------------------------------------------------------------------------------------------------------------------
function sanityCheck(message, divID) 
// allows one to debug (or not) into the Flash object (& JS & AJAX)
//--------------------------------------------------------------------------------------------------------------------------------------------
{
  // the flash object (& these JS scripts) send debug and 'sanity check' messages...
  // ... very useful for debugging interactions between flash/JS/ajax
  
  //  if specified, put these message in a separate DIV (ala console output)
  if (divID != undefined) 
    document.getElementById(divID).innerHTML += message;
  else
    // view message as popup alert
    alert(message);
}

//--------------------------------------------------------------------------------------------------------------------------------------------
function getFlashComponent(movieName) 
// convenience function for dealing with Bill Gates
//--------------------------------------------------------------------------------------------------------------------------------------------
{
  var isIE = navigator.appName.indexOf("Microsoft") != -1;
  return (isIE) ? window[movieName] : document[movieName];
}

//--------------------------------------------------------------------------------------------------------------------------------------------
function writeFlashOBJ(divID, nameID, url, flashVars, isTrans, bgcolor, width, height)
// replaces the contents of a div with a Flash applet that plays a video clip, if specified
//--------------------------------------------------------------------------------------------------------------------------------------------
{
  if (divID == undefined)
  return

  if ((nameID == undefined) || (url == undefined))
    document.getElementById(divID).innerHTML = nameID + " : " + url;
    
  if (isTrans == undefined)
    isTrans = "window";
    
  if (flashVars == undefined)
    flashVars = "";
    
  if (bgcolor == undefined)
    bgcolor = "#000000";
    
  if (width == undefined)
    width = "100%";
    
  if (height == undefined)
    height = "100%";
    
  document.getElementById(divID).innerHTML = "                                                                       \
    <object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000'                                                   \
          codebase='http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0'         \
          width='" + width + "'                                                                                    \
          height='" + height + "'                                                                                  \
          id='" + nameID + "'                                                                                      \
          align='middle'>                                                                                          \
    <param name='allowScriptAccess' value='sameDomain'>                                                            \
    <param name='allowFullScreen' value='true'>                                                                    \
    <param name='scale' value='scale'>                                                                             \
    <param name='movie' value='" + url + "'>                                                                       \
    <param name='quality' value='high'>                                                                            \
    <param name='wmode' value='$isTrans'>                                                                          \
    <param name='bgcolor' value='" + bgcolor + "'>                                                                 \
    <param name='FlashVars' value='onWeb=true&" + flashVars + "'>                                                  \
    <embed src='" + url + "'                                                                                       \
           quality='high'                                                                                          \
           allowFullScreen='true'                                                                                  \
           scale='scale'                                                                                           \
           wmode='$isTrans'                                                                                        \
           bgcolor='" + bgcolor + "'                                                                               \
           width='" + width + "'                                                                                   \
           height='" + height + "'                                                                                 \
           name='" + nameID + "'                                                                                   \
           id='" + nameID + "'                                                                                     \
           align='middle'                                                                                          \
           allowScriptAccess='sameDomain'                                                                          \
           type='application/x-shockwave-flash'                                                                    \
           pluginspage='http://www.macromedia.com/go/getflashplayer'                                               \
           FlashVars='onWeb=true&" + flashVars + "'>                                                               \
    </object>";
}
