var FlashMovie = {

    ok : null,

    check : function () {

        if (null != FlashMovie.ok) return FlashMovie.ok;

        var ok = false;

        with (navigator) {
			var ms = -1 != appName.indexOf('Microsoft');

            if (ms && -1 == appVersion.indexOf('Mac') && !window.opera)
                document.write([
                	'<scr'+'ipt language="VBScript">',
					' On error resume next',
					' fl = False',
					' fl = IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.7"))',
					'</scr'+'ipt>'
				].join('\n'));

            if (!ms || (plugins && plugins.length))
                ok = (plugins && plugins['Shockwave Flash']);

            else if (-1 == appVersion.indexOf('3.1') && null != window.fl)
				ok = window.fl;
        }
        FlashMovie.ok = ok;
        return ok;
    },

    code : function (source, alt_source, width, height, opts) {
        var p = '';
        var e = '';
        if ('object' == typeof opts) {
            for (var i in opts) {
                p += '<param name="' + i + '" value="' + opts[i] + '">';
                e += ' ' + i + '="' + opts[i] + '"';
            }
        }

        return FlashMovie.check() ?
        (
            '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" ' + ( width ? ' width="' + width + '"' : '' ) + ( height ? ' height="' + height + '"' : '' ) + '>' +
            '    <param name="movie" value="' + source + '">' + p +
            '    <embed src="' + source + '" ' + ( width ? ' width="' + width + '"' : '' ) + ( height ? ' height="' + height + '"' : '' ) + ' ' + e + ' pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash"></embed>' +
            '</object>'
        ) : '<img src="' + alt_source + '"/>';
    }
}
