
var embedBase     = 'http://kibelgreen.com/';
var embedCount    = 0;

/** Function: flashInsert()
 *
**/
function flashInsert(swfContainer, swfFile, swfW, swfH, swfData) {

  embedCount++;
  var embedID         = 'flash-embed-' + embedCount;

  // Check if the container exists
  var embedContainer  = document.getElementById(swfContainer);

  if( embedContainer ) {

    if( userBrowser != 'IE' ) {

      // Generate a new object for the flash movie
      var newObject           = document.createElement('object');
          newObject.id        = embedID;

          // Set the object attributes
          newObject.setAttribute('base',      embedBase);
          // newObject.setAttribute('classid',   'clsid:d27cdb6e-ae6d-11cf-96b8-444553540000');
          // newObject.setAttribute('codebase',  'http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0');
          newObject.setAttribute('width',     swfW);
          newObject.setAttribute('height',    swfH);

      // Add the parameters underneath the object
      var paramList           = new Array();
          paramList['movie']  = swfFile;
          paramList['wmode']  = 'transparent';

          for(var paramName in paramList) {
          var newParameter    = document.createElement('param');
              newParameter.setAttribute(paramName, paramList[paramName]);
              newObject.appendChild(newParameter);
          } // ! cycle parameters

      if( swfData != undefined ) {
        paramList['flashvars'] = swfData;
      }

      // Add the embed tag underneath the object
      var newEmbed            = document.createElement('embed');

          // Set the embed attributes
          newEmbed.setAttribute('base',         embedBase);
          newEmbed.setAttribute('type',         'application/x-shockwave-flash');
          newEmbed.setAttribute('src',          swfFile);
          newEmbed.setAttribute('width',        swfW);
          newEmbed.setAttribute('height',       swfH);
          newEmbed.setAttribute('wmode',        'transparent');
          newEmbed.setAttribute('flashvars',    swfData);
          newEmbed.setAttribute('pluginspage',  'http://www.macromedia.com/go/getflashplayer');

          newObject.appendChild(newEmbed);

      // Insert the new object into the page
      embedContainer.appendChild(newObject);

      return true;

    } else {
    // If the user is using Internet Explorer, use a different embed method

      var flashHTML     = '<object'
                        + ' width="' + swfW + '"'
                        + ' height="' + swfH + '"'
                        + ' classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000">' + "\n"
                          // Set some parameters
  	                    + '<param name="movie" value="' + swfFile + '" />' + "\n"
                        + '<param name="wmode" value="transparent" />' + "\n"
                        + '<param name="flashvars" value="' + swfData + '" />' + "\n"
                          // Attempt alternate embed to fix a bug?
            //            + '<embed src="' + swfFile + '" width="' + swfW + '" height="' + swfH + '" wmode="transparent" flashvars="' + swfData + '" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash"></embed>' + "\n"
                        + '</object>' + "\n";

      embedContainer.innerHTML  = flashHTML;

      return true;

    } // ! browser?

  } // ! valid container?

  return false;

} // ! flashInsert()


