/**
 * SWFer v1.1
 *
 * SWFer is (c) 2006 Compile S.r.l. and is released under the MIT License:
 * http://www.opensource.org/licenses/mit-license.php
 */
if (typeof SWFerObject == "undefined") var SWFerObject = new Object();
if (typeof SWFerObject.SWFer == "undefined")
{
  SWFerObject.SWFer = function(swfUrl,swfId,w,h,bgCol,ver,checkPlugin)
  {
      this.swfParameters = new Object();
      this.swfAttributes = new Object();
      if (typeof document.getElementById == "undefined") return;
      if (typeof swfUrl == "undefined") return;
      if (typeof swfId == "undefined") return;
      this.setAttribute("swfUrl",swfUrl);
      this.setAttribute("swfId",swfId);
      if (typeof w != "undefined") this.setAttribute("swfWidth",w);
      if (typeof h != "undefined") this.setAttribute("swfHeight",h);
      if (typeof ver != "undefined") this.setAttribute("swfVer",ver);
      if (typeof checkPlugin != "undefined" && ver != null) this.setAttribute("checkPlugin",checkPlugin);
      if (typeof bgCol != "undefined") this.setParameter("bgCol",bgCol);
      this.setParameter("quality", "high");
      return this;
  }
  
  SWFerObject.SWFer.prototype = {
      setAttribute : function(name,value)
      {
          this.swfAttributes[name]=value;
      },
      setParameter : function(name,value)
      {
          this.swfParameters[name]=value;
          return this;
      },
      getAttribute : function(name)
      {
          return this.swfAttributes[name];
      },
      getParameter : function(name)
      {
          return this.swfParameters[name];
      },
      createXHTML : function()
      {
          var strNode = "";
          if (navigator.plugins && navigator.mimeTypes && navigator.mimeTypes.length)
          {
              strNode = '<embed type="application/x-shockwave-flash" src="'+ this.getAttribute('swfUrl') +'" width="'+ this.getAttribute('swfWidth') +'" '+
                        'height="'+ this.getAttribute('swfHeight') +'" id="'+ this.getAttribute('swfId') +'" name="'+ this.getAttribute('swfId') +'" ';
              for(var key in this.swfParameters) strNode += key +'="'+ this.getParameter(key) +'" '; 
              strNode += '/>';
          }
          else
          {
              strNode = '<object id="'+ this.getAttribute('swfId') +'" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" '+
                        'width="'+ this.getAttribute('swfWidth') +'" height="'+ this.getAttribute('swfHeight') +'">';
              strNode += '<param name="movie" value="'+ this.getAttribute('swfUrl') +'" />';
              for(var key in this.swfParameters)  strNode += '<param name="'+ key +'" value="'+ this.getParameter(key) +'" />';
              strNode += "</object>";
          }
          return strNode;
      },
      checkVersion : function()
      {
          return this.getPlayerVersion() >= this.getAttribute("swfVer");
      },
      getPlayerVersion : function()
      {
          if(navigator.plugins && navigator.mimeTypes.length)
          {
              if(navigator.plugins["Shockwave Flash"] && navigator.plugins["Shockwave Flash"].description) 
                  return parseInt(navigator.plugins["Shockwave Flash"].description.replace(/([a-zA-Z]|\s)+/, "").replace(/(\s+r|\s+b[0-9]+)/, ".").split(".")[0]);
  		}
          else
          {
              try
              {
                  var axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash."+this.getAttribute("swfVer"));
                  return axo.GetVariable("$version").split(" ")[1].split(",")[0];
              }
              catch (e)
              { 
                  try
                  {
                      var axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash");
                      return axo.GetVariable("$version").split(" ")[1].split(",")[0];
                  }
                  catch (e)
                  {}
              }
          }
          return -1;
      },
      insert : function(divId)
      {
          if (this.getAttribute("checkPlugin") && !this.checkVersion()) return this;
          var node = null;
          if (typeof divId == "string") node = document.getElementById(divId);
          if (typeof divId != "undefined" && typeof divId.innerHTML != "undefined") node = divId;
          if (node == null)
          {
              var c = 0;
              var divName = this.getAttribute('swfId')+'SWFerDiv'+(c++);
              while (document.getElementById(divName) != null) divName = this.getAttribute('swfId')+'SWFerDiv'+(c++);
              document.write('<div id="'+divName+'">.</div>');
              node = document.getElementById(divName);
          }
          node.innerHTML= this.createXHTML();
          return this;
      }
  }
  var SWFer = SWFerObject.SWFer;
}

