/** * Generates a browser-specific Flash tag. Create a new instance, set whatever * properties you need, then call either toString() to get the tag as a string, or * call write() to write the tag out. *//** * Creates a new instance of the FlashTag. * src: The path to the SWF file. * width: The width of your Flash content. * height: the height of your Flash content. */function FlashTag(src, width, height, version){    if (arguments.length <4){		throw ('FlashTagInstantiationError: A new Flash Tag must be instantiated with src, width, height and version arguments.');	}	for (var i=0; i<arguments.length; i++){		if (arguments[i] == null || arguments[i] == undefined){			throw ('FlashTagInstantiationError: All FlashTag arguments must be defined values.');		}	}		// required parameters	this.src       = src;    this.width     = width;    this.height    = height;    this.version   = version;	    this.id        = null;    this.flashVarsString = null;	this.flashVars = null	this.flashParam = new Object();}/** * Sets the Flash version used in the Flash tag. */FlashTag.prototype.setVersion = function(v){    this.version = v;}/** * Sets the ID used in the Flash tag. */FlashTag.prototype.setId = function(id){    this.id = id;}/** * Specifies the location (URL) of the Flash content to be loaded. */FlashTag.prototype.setSource = function(src) {    this.src = src; }/** * Specifies the width of the Flash content in either pixels or percentage of browser window.  */FlashTag.prototype.setWidth = function(w) {    this.width = width; }/** * Specifies the height of the Flash content in either pixels or percentage of browser window.  */FlashTag.prototype.setHeight = function(h) {    this.h = height; }/** * The required version of the Flash Player for the specified content.  */FlashTag.prototype.setVersion = function(v) {    this.version = v;}/** * Sets any variables to be passed into the Flash content.  */FlashTag.prototype.setFlashvarString = function(fvs){    this.flashVarString = fvs;}/** * Used to send root level variables to the Flash content. You can add as many name/value pairs as * you want. The formatting of the Flash vars (turning them into a query string) is handled automatically. */FlashTag.prototype.addFlashVar = function(n, v) {    if (this.flashVars == null) {        this.flashVars = new Object();    }    this.flashVars[n] = v;}/** * Used to remove Flash vars. This is primarily useful if you want to reuse an instance of the FlashTag * but you don't want to send the same variables to more than one piece of Flash content.  */FlashTag.prototype.removeFlashVar = function(n) {    if (this.flashVars != null) {        this.flashVars[n] = undefined;    }}/** * (window, opaque, transparent) Sets the Window Mode property of the Flash content for transparency, * layering, and positioning in the browser.  */FlashTag.prototype.setWmode = function(wm) {    if (wm != 'window' && wm != 'opaque' && wm != 'transparent') {        throw ('UnsupportedFlashTagValue: Supported values are "window", "opaque", and "transparent".');    }    this.flashParam['wmode'] = wm;}/** * (low, high, autolow, autohigh, best) Sets the quality at which the Flash content plays. */FlashTag.prototype.setQuality = function(q) {    if (q != 'low' && q != 'high' && q != 'autolow' && q != 'autohigh' && q != 'best') {        throw ('UnsupportedValueException: Supported values are "low", "high", "autolow", "autohigh", and "best".');    }    this.flashParam['quality'] = q;}/*** sets script access for the flash tag to allow JS access from Flash*/FlashTag.prototype.setScriptAccess = function(sa) {    if (sa != 'always' && sa != 'never') {        throw ('UnsupportedFlashTagValue: Supported values are "always" and "never".');    }    this.flashParam['allowScriptAccess'] = sa;}/*** sets the background color for the swf*/FlashTag.prototype.setBgColor = function(color) {    if (color.charAt(0) != '#') {        color = '#' + color;    }    this.flashParam['bgcolor'] = color;}/** * Get the Flash tag as a string.  */FlashTag.prototype.toString = function(){    var ie = (navigator.appName.indexOf ("Microsoft") != -1) ? 1 : 0;    var flashTag = new String();    if (ie)    {        flashTag += '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" ';        if (this.id != null){            flashTag += 'id="'+this.id+'" ';        }        flashTag += 'codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version='+this.version+'" ';        flashTag += 'width="'+this.width+'" ';        flashTag += 'height="'+this.height+'">';        flashTag += '<param name="movie" value="'+this.src+'"/>';        		for (var n in this.flashParam) {            if (this.flashParam[n] != undefined && this.flashParam[n] != null){                flashTag += '<param name="'+n+'" value="'+this.flashParam[n]+'"/>';            }        }				if (this.flashVars != null || this.flashVarString != null){     		var fvs = this.getFlashVarsAsString();			if (fvs.length >0){				flashTag += '<param name="flashvars" value="'+this.flashVars+'"/>';			} 		}        flashTag += '</object>';    }    else    {        flashTag += '<embed src="'+this.src+'" ';        flashTag += 'width="'+this.width+'" ';        flashTag += 'height="'+this.height+'" ';        flashTag += 'type="application/x-shockwave-flash" ';        if (this.id != null){            flashTag += 'name="'+this.id+'" ';        }				for (var n in this.flashParam) {            if (this.flashParam[n] != undefined && this.flashParam[n] != null){                flashTag += (' '+n+'="'+this.flashParam[n]+'"');            }        }					if (this.flashVars != null || this.flashVarString != null){     		var fvs = this.getFlashVarsAsString();			if (fvs.length >0){	            flashTag += 'flashvars="'+fvs+'" ';			}		}		        flashTag += 'pluginspage="http://www.macromedia.com/go/getflashplayer">';        flashTag += '</embed>';    }    return flashTag;}/* Function: getFlashVarsAsString * ------------------------------ * Iterates throrugh the flashvars object for valid name value pairs * and concats them to a string.  Then concats this string to the  * current flashvar string, if there is one. */FlashTag.prototype.getFlashVarsAsString = function() {	var fvs = "";	for (var n in this.flashVars) {        if (this.flashVars[n] != undefined && this.flashVars[n] != null) {            fvs += (escape(n)+'='+escape(this.flashVars[n])+'&');        }    }		if (this.flashVarString != null) {        return fvs + this.flashVarString;    }    return fvs.substring(0, fvs.length-1);	}/** * Write the Flash tag out. Pass in a reference to the document to write to.  */FlashTag.prototype.write = function(doc){    doc.write(this.toString());}/* Function :fillElementById * ------------------------ * bypasses current limitations in Active Content code with IE by writing the Flash Content * inside of the Flash Tag js file. This bypasses the 'Click To Activate' problem. */FlashTag.prototype.fillElementById = function(e){	var fc = document.getElementById(e);	fc.innerHTML = this.toString();}