/*
  file: displayflash.js
  does: fix ie6+ swf message 'click here to activate'
  author: Oria Adam 
  date: 2007-08
  last update: 2007-11-19
  updates:
    2007-11-19: add comments
  
  functions reference:
    displayFlash(oParams,doc)
      does: creates a flash element
      input:
        oParams - associative JASON array containing all the flash object parameters.
          for example:
            oParams = { 
              src:"images/myfile.swf",
              width:277,
              height:77,
              loop:true,
              id:'idMyFlashMovie'
            };
        doc - optional. document to load strings into. default current window.document. when set to false, return an html string
      output: nothing or html string (see doc parameter)
      
*/


function displayFlash(oParams,doc) {
  
 //alert('runing flash 1');

  if (typeof(doc)=="undefined") {
    doc=window.document; 
  }
   
  //alert('runing flash 2');

  if (oParams) {
  //alert('runing flash 3');

    if (oParams.src || oParams.movie) {
      // prepare params and defaults
      var src=oParams.src || oParams.movie;
      oParams.src=src;
      oParams.movie=src;
      oParams.quality=oParams.quality || "high";
      oParams.loop=oParams.loop || "false";
      oParams.menu=oParams.menu || "false";      
      oParams.wmode=oParams.wmode || "Transparent";
      oParams.type=oParams.type || "application/x-shockwave-flash";      
      oParams.pluginspage=oParams.pluginspage || "https://www.macromedia.com/go/getflashplayer";      
     
      var s=''; // the output string
      // create embed
      s="<embed ";
      for (var i in oParams) {
        s+=' '+i+'="'+oParams[i]+'" ';
      }
      s+=" ></embed>";
      
      if (doc && doc.write) {
        doc.write(s);
      } else {
        return s;
      }
    }
  }
}
