
function FlashTag(src, width, height)
{
	this.src       = src;
	this.width     = width;
	this.height    = height;
	this.version   = '8,0,0,0';
	this.bgcolor   = 'ffffff';
	this.classid   = 'clsid:d27cdb6e-ae6d-11cf-96b8-444553540000';
	this.id        = null;
	this.flashVars = null;
}

FlashTag.prototype.setId = function(id)
{
    this.id = id;
}

FlashTag.prototype.setBgcolor = function(bgc)
{
    this.bgcolor = bgc;
}

FlashTag.prototype.setFlashvars = function(fv)
{
    this.flashVars = fv;
}

FlashTag.prototype.toString = function()
{
    var ie = (navigator.appName.indexOf("Microsoft") != -1) ? true : false;
    var flashTag = new String();

    if(ie === true)
    {
        flashTag += '<object classid="' + this.classid + '" ';

        if(this.id != null)
        {
            flashTag += 'id="' + this.id + '" ';
        }

        flashTag += 'codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=' + this.version + '" width="' + this.width + '" height="' + this.height + '">';
	flashTag += '<param name="allowScriptAccess" value="sameDomain" />';
	flashTag += '<param name="allowFullScreen" value="false" />';
        flashTag += '<param name="quality" value="high" />';
	flashTag += '<param name="movie" value="' + this.src + '" />';
        flashTag += '<param name="bgcolor" value="#' + this.bgcolor + '" />';

        if(this.flashVars != null)
        {
            flashTag += '<param name="flashvars" value="' + this.flashVars + '" />';
        }

        flashTag += '</object>';
    }
    else
    {
        flashTag += '<embed src="' + this.src + '" ';
        flashTag += 'quality="high" '; 
        flashTag += 'bgcolor="#' + this.bgcolor + '" ';
        flashTag += 'width="' + this.width + '" ';
        flashTag += 'height="' + this.height + '" ';
        flashTag += 'type="application/x-shockwave-flash" ';

        if(this.flashVars != null)
        {
            flashTag += 'flashvars="' + this.flashVars + '" ';
        }

        if(this.id != null)
        {
            flashTag += 'name="' + this.id + '" ';
        }

        flashTag += 'pluginspage="http://www.macromedia.com/go/getflashplayer"></embed>';
    }

    return flashTag;
}

FlashTag.prototype.write = function(doc)
{
    doc.write(this.toString());
}

var flashTag = new FlashTag('http://www.oxygeno2.jp/fun/blogparts/swf/checker.swf', 150, 220);
flashTag.setFlashvars('wid='+wid);
flashTag.setId('BMI');
flashTag.write(document);
