
function FlashTag(src, width, height, transp, bgcolor)
{
    this.src       = src;
    this.width     = width;
    this.height    = height;
    this.version   = '7,0,14,0';
    this.id        = null;
    this.bgcolor   = bgcolor;
    this.flashVars = null;
    if(transp == null){
        this.transparent = true;
    }else{
        this.transparent = transp;
    }
	this.divid = 0;
}

/**
 * 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;
}

/**
 * Sets the background color used in the Flash tag.
 */
FlashTag.prototype.setBgcolor = function(bgc)
{
    this.bgcolor = bgc;
}

/**
 * Sets any variables to be passed into the Flash content. 
 */
FlashTag.prototype.setFlashvars = function(fv)
{
    this.flashVars = fv;
}

/**
 * Get the Flash tag as a string. 
 */
FlashTag.prototype.toString = function()
{
    var ie = (navigator.appName.indexOf ("Microsoft") != -1) ? 1 : 0;
    var flashTag = new String();
	flashTag += '<div style="position:relative; width:'+this.width+'px; height:'+this.height+'px; background-color:'+this.bgcolor+';">';
    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="100%" ';
        flashTag += 'height="100%">';
        flashTag += '<param name="movie" value="'+this.src+'"/>';
        flashTag += '<param name="quality" value="high"/>';
        if(!this.transparent && this.bgcolor)flashTag += '<param name="bgcolor" value="'+this.bgcolor+'"/>';
		flashTag += '<param name="salign" value="lt">';
		flashTag += '<param name="allowScriptAccess" value="sameDomain">';
		flashTag += '<param name="scale" value="noScale">';
		if(this.transparent)flashTag += '<param name="wmode" value="transparent">';
        if (this.flashVars != null)
        {
            flashTag += '<param name="flashvars" value="'+this.flashVars+'"/>';
        }
        flashTag += '</object>';
    }
    else
    {
        flashTag += '<embed src="'+this.src+'" ';
        flashTag += 'quality="high" '; 
        if(!this.transparent && this.bgcolor)flashTag += 'bgcolor="'+this.bgcolor+'" ';
        flashTag += 'width="100%" ';
        flashTag += 'height="100%" ';
        flashTag += 'type="application/x-shockwave-flash" ';
		flashTag += 'salign="lt" ';
		flashTag += 'scaleMode="noScale" ';
		flashTag += 'allowScriptAccess="sameDomain" ';
		if(this.transparent)flashTag += 'wmode="transparent" ';
        if (this.flashVars != null)
        {
            flashTag += 'flashvars="'+this.flashVars+'" ';
        }
        if (this.id != null)
        {
            flashTag += 'name="'+this.id+'" ';
        }
        flashTag += 'pluginspage="http://www.macromedia.com/go/getflashplayer">';
        flashTag += '</embed>';
    }
	flashTag += '</div>';
    return flashTag;
}

/**
 * Write the Flash tag out. Pass in a reference to the document to write to. 
 */
FlashTag.prototype.write = function(doc)
{
	doc.write(this.toString());
}
FlashTag.prototype.writeIntoDocument = function(doc)
{
	target = "ftag_auto_"+this.divid++;
	doc.write("<div id='"+target+"'></div>");
    document.getElementById(target).innerHTML = this.toString();
}
FlashTag.prototype.writeIntoObjectByID = function(id)
{
    document.getElementById(id).innerHTML = this.toString();
}