// Embed °³Ã¼ »ðÀÔ ÇÔ¼ö.. by redpoppy

function embedObject()
{
  var mObjectType = new String;   // °³Ã¼ Çü½Ä
  var mFileName = new String;     // ¼Ò½ºÆÄÀÏ¸í
  var mParameters = new Array();  // ÆÄ¶ó¹ÌÅÍ
  var mWidth = new String;        // ³ÐÀÌ
  var mHeight = new String;       // ³ôÀÌ
  var mObjectID = new String;     // °³Ã¼ ID

  var mCodeBase = new String;
  var mClassID = new String;
  var mPluginPage = new String;
  var mEmbedType = new String;

  var mHTMLCODE = new String;

  // ÃÊ±â°ª ¼ÂÆÃ (Çü½Ä, ¼Ò½ºÆÄÀÏ¸í, ³ÐÀÌ, ³ôÀÌ, °³Ã¼ ID, ½ºÅ¸ÀÏ)
  this.init = function (pType, pFile, pWidth, pHeight, pID, pStyle)
  {
    mObjectType = pType;
    if (mObjectType == "FLASH"){
      mCodeBase   ="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0";
      mClassID    ="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000";
      mPluginPage ="http://www.macromedia.com/go/getflashplayer";
      mEmbedType  ="application/x-shockwave-flash";
    } else if (mObjectType == "MOVIE"){
      mCodeBase   ="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=6,4,5,715";
      mClassID    ="CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6";
      mPluginPage ="http://www.microsoft.com/windows/mediaplayer/download/default.asp";
      mEmbedType  ="application/x-oleobject";
    }

    mFileName = pFile;
    mWidth    = pWidth;
    mHeight   = pHeight;
    mObjectID = this.setObjectID(pID)
		mStyle		= pStyle;
  }

  // HTML ÅÂ±× Ãâ·Â
  this.printObject = function (pType)
  {
    var sHTML = new String;
    var sEmbed = new String;
    var sObject = new String;

    if (this.isValid(mClassID)){
      //sObject = "<object "+ mObjectID +" classid=\""+ mClassID +"\" codebase=\""+ mCodeBase +"\" width=\""+ mWidth +"\" height=\""+ mHeight +"\">\n"
      sObject = "<object "+ mObjectID +" classid=\""+ mClassID +"\" width=\""+ mWidth +"\" height=\""+ mHeight +"\"" + mStyle + ">\n"
      sObject += "<param name=\"movie\" value=\""+ mFileName +"\">\n" + this.getParameterString("OBJECT");
    }

    sEmbed = "<embed src=\""+ mFileName +"\" "+ this.getParameterString("EMBED") +" pluginspage=\""+ mPluginPage +"\" type=\""+ mEmbedType +"\" width=\""+ mWidth +"\" height=\""+ mHeight +"\"></embed>"

    if (this.isValid(sObject)) {
      sHTML = sObject + sEmbed + "\n</object>";
    } else {
      sHTML = sEmbed;
    }

    if (this.isValid(pType)) alert(sHTML);
    mHTMLCODE = sHTML;
    document.write(sHTML);
  }

  this.getCode = function ()
  {
    return mHTMLCODE;
  }

  // ÆÄ¶ó¹ÌÅÍ Ãß°¡
  this.addParameter = function (pName, pValue)
  {
    mParameters.push(new Array(pName, pValue));
  }

  // ÆÄ¶ó¹ÌÅÍ Ãâ·Â
  this.getParameterString = function (pType)
  {
    var i, sTemp = new String, iParamLen;
    iParamLen = mParameters.length;
    for (i=0;i<iParamLen;i++){
      if (pType == "OBJECT")
      {
        sTemp += "<param name=\""+ mParameters[i][0] +"\" value=\""+ mParameters[i][1] +"\">\n";
      } else {
        sTemp += mParameters[i][0] +"=\""+ mParameters[i][1] +"\" ";
      }
    }
    return sTemp;
  }

  // °³Ã¼ ¾ÆÀÌµð Ãâ·Â... -_ -;;
  this.setObjectID = function (pName)
  {
    var sTemp = new String;
    if(this.isValid(pName)){
      sTemp = "id=\""+ pName +"\"";
    }
    return sTemp;
  }

  // À¯È¿°ª °Ë»ç.. 0 == null !!
  this.isValid = function (pVal)
  {
    var bTemp = false;
    if(pVal != "" && pVal != null && typeof(pVal) != "undefined")
    {
      bTemp = true;
    } else {
      //alert((pVal != "") + "/"+ (pVal != null) + "/" + typeof(pVal));
    }
    return bTemp;
  }

}


function __ShowEmbedObject(__ELEMENT_ID) {
  document.write( __ELEMENT_ID.innerHTML );
  __ELEMENT_ID.id = "";
}



