﻿var _flashtag = flashtag = function (id, src, w, h, opts) {
    var element = function (tag, attributes, html) {
        var ele = document.createElement(tag);
        if (attributes) {
            for (var n in attributes) {
                if (attributes.hasOwnProperty(n)) {
                    ele.setAttribute(n, attributes[n]);
                }
            }
        }
        if (html) {
            ele.innerHTML = html;
        }
        try {
            return ele;
        } finally {
            ele = null;
        }
    };
    var s = element('ins'), html;
    s.style.fontSize = 0;
    s.style.lineHeight = 0;
    s.style.display = 'block';

    if (Number(w)) {
        s.style.width = w + 'px';
    } else {
        s.style.width = w;
    }
    if (Number(h)) {
        s.style.height = h + 'px';
    } else {
        s.style.height = h;
    }
    opts = opts || {};
    if (opts) {
        if (!opts.wmode) {
            opts.wmode = 'transparent';
        }
        if (!opts.allowscriptaccess) {
            opts.allowscriptaccess = 'always';
        }
        if (!opts.menu) {
            opts.menu = 'false';
        }
        if (!opts.flashvars) {
            opts.flashvars = 'flashvars';
        }
        if (!opts.scale) {
            opts.scale = 'noscale';
        }
    }
    if (window.ActiveXObject) {
        html = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" id="' + id + '" name="' + id + '" border="0" width="' + w + '" height="' + h + '"><param name="movie" value="' + src + '" /><param name="quality" value="high" /><param name="allowScriptAccess" value="always" /><param name="menu" value="false" /><param name="allowFullScreen" value="true" /><param name="wmode" value="' + opts.wmode + '" /><param name="flashvars" value="' + opts.flashvars + '" /><param name="scale" value="' + opts.scale + '"</objcet>';
    } else {
        html = '<embed  id="' + id + '" name="' + id + '" width="' + w + '" height="' + h + '" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" allowScriptAccess="always" allowFullScreen="true" quality="high" menu="false" wmode="' + opts.wmode + '" flashvars="' + opts.flashvars + '" scale="' + opts.scale + '" src="' + src + '" />';
    }
    s.innerHTML = html;
    try {
        return s;
    } finally {
        s = null;
    }
}
