
function flashObj(src,title,width,height,reqVersion,altImage,altLink,urlparameter) {
   this.str = "";
   this.src = src;
   this.title = title;
   this.width = width;
   this.height = height;
   this.reqVersion = reqVersion;
   this.altImage = altImage;
   this.altLink = altLink;
   this.urlparameter = urlparameter;
}

flashObj.prototype = {
   write: function(bgcolor,wmode) {
      flashVersion = this.getFlashVersion();
      if (flashVersion >= this.reqVersion) {
         bgcolor = bgcolor ? bgcolor : "#fff";
         wmode = wmode ? wmode : "transparent";
         this.str += "<object";
         this.writeParameter("classid","clsid:d27cdb6e-ae6d-11cf-96b8-444553540000");
         this.writeParameter("codebase","http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0");
         this.writeParameter("width",this.width);
         this.writeParameter("height",this.height);
         this.writeParameter("id",this.title);
         this.str += ">";
         this.writeObjectParameter("allowScriptAccess","sameDomain");
         this.writeObjectParameter("movie",this.src);
         this.writeObjectParameter("quality","high");
         this.writeObjectParameter("wmode",wmode);
         if (this.urlparameter)
            this.writeObjectParameter("FlashVars","&"+this.urlparameter);
         this.writeObjectParameter("bgcolor",bgcolor);
         this.writeObjectParameter("allowScriptAccess","sameDomain");
         this.str += "<embed"
         this.writeParameter("src",this.src+((this.urlparameter) ? "?"+this.urlparameter : ""));
         this.writeParameter("quality","high");
         this.writeParameter("wmode",wmode);
         this.writeParameter("bgcolor",bgcolor);
         this.writeParameter("width",this.width);
         this.writeParameter("height",this.height);
         this.writeParameter("name",this.title);
         this.writeParameter("allowScriptAccess","sameDomain");
         this.writeParameter("type","application/x-shockwave-flash");
         this.writeParameter("pluginspage","http://www.macromedia.com/go/getflashplayer");
         this.str += " /></object>";
         document.write(this.str);
      } else if (this.altImage) {
         if (this.altLink) {
            document.write("<a href=\""+this.altLink+"\">");
         }
         document.write("<img src=\""+this.altImage+"\" id=\""+this.title+"\" width=\""+this.width+"\" height=\""+this.height+"\" border=\"0\" />");
         if (this.altLink) {
            document.write("</a>");
         }
      } else if(!this.altImage) {
         if (this.altLink) {
            document.location.href= this.altLink;  
         }  
      }
   },
   
   writeObjectParameter: function(param, value) {
      this.str += "<param name=\""+param+"\" value=\""+value+"\"/>";
   },
   
   writeParameter: function(param, value) {
      this.str += " "+param+"=\""+value+"\"";
   },

   getFlashVersion: function() {
      var flashVersion = 0;
      var agent = navigator.userAgent.toLowerCase();
      if (agent.indexOf("mozilla/3") != -1 && agent.indexOf("msie") == -1) {
         return flashVersion;
      }
      if (navigator.plugins != null && navigator.plugins.length > 0) {
         var flashPlugin = navigator.plugins['Shockwave Flash']; 
         if (typeof flashPlugin == 'object') {
            for (i=25;i>0;i--) {
               if (flashPlugin.description.indexOf(i+'.') != -1) {
                  flashVersion = i;
               }
            }
         }
      } else if ((agent.indexOf("msie") != -1) && (parseInt(navigator.appVersion) >= 4) && (agent.indexOf("win") != -1) && (agent.indexOf("16bit") == -1)) {
         flashVersion = this.getIEFlashVersion();
      }
      return flashVersion;
   },
   
   getIEFlashVersion: function() {
      var swfObj, flashVersion;
      for (i=0;i<25;i++) {
         try {
            swfObj = new ActiveXObject("ShockwaveFlash.ShockwaveFlash."+i);
         } catch(e) {}
         if (swfObj) {
            flashVersion = swfObj.GetVariable("$version").split(" ")[1].split(",")[0];
         }
      }
      return (flashVersion);
   }
}
