/**
 * Flash-handling utilities by Travis Beckham
 * 
 */

/**
 * Flash Object
 */
WOL.thirdparty.flash = function (required_version) {
   if (navigator.mimeTypes && navigator.mimeTypes["application/x-shockwave-flash"] && navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin) {
      this.description = navigator.plugins["Shockwave Flash"].description;
      this.version = parseInt(this.description.charAt(this.description.indexOf(".") - 1));
      return this.version >= required_version;
   }
   if (navigator.appVersion.indexOf ("Windows") != -1 && window.execScript) {
      this.hasVersionResult = null;
      execScript ('on error resume next: WOL.thirdparty.flash.hasVersionResult=IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.' + required_version + '"))', 'VBScript');
      return this.hasVersionResult;
   }
   return false;
}

/**
 * Flash Tag
 */
WOL.thirdparty.flashTag = function (version, movie, width, height, name) {
   this.version = version;
   this.movie = movie;
   this.width = width;
   this.height = height;
   this.name = name;
   this.props = new Array();
   this.vars = new Array();
}

WOL.thirdparty.flashTag.prototype.addProperty = function (name, value) {
   this.props[name] = value;
}

WOL.thirdparty.flashTag.prototype.addVariable = function (name, value) {
   this.vars[name] = value;
}

WOL.thirdparty.flashTag.prototype.render = function () {
   var fvars = "";
   for (var i in this.vars) fvars += i + "=" + escape (this.vars[i]) + "&"; 
   this.addProperty ("FlashVars", fvars);
   var tag = '<object';
   tag += ' width="' + this.width + '"';
   tag += ' height="' + this.height + '"';
   tag += ' id="'+ this.name +'"';
   tag += ' classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"';
   tag += ' codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=' + this.version + ',0,0,0">';
   tag += '<param name="movie" value="' + this.movie + "?" + fvars + '" />';
   for (var i in this.props) tag += '<param name="' + i + '" value="' + this.props[i] + '" />';
   tag += '<embed src="' + this.movie + "?" + fvars + '"';
   tag += ' type="application/x-shockwave-flash"';
   tag += ' pluginspage="http://www.macromedia.com/go/getflashplayer"';
   tag += ' width="' + this.width + '"';
   tag += ' height="' + this.height + '"';
   tag += ' name="'+ this.name +'"';
   for (var i in this.props) tag += ' ' + i + '="' + this.props[i] + '"';
   tag += '><\/embed>';
   tag += '<\/object>';
   document.write (tag);
}