function FlashWriter(url, base,  width, height, id, bg){
        // Options here are "window", "opaque", and "transparent"
        var DEFAULT_WINDOW_SETTING = "window";

        // Defaults for optional stuff below
        var quality = "high";
                
        id = (id==undefined) ? "flash_game" :  id

        var wmode = DEFAULT_WINDOW_SETTING;

        var script_access = "allow";
        var sw_live_connect = "true";

        var allow_fullscreen = "false";
        var params = null;
        var has_flash = LookForFlashPlugin();
        var bgcolor = "#000000";
        if (bg!=undefined){
           bgcolor = bg;
        }


        this.SetQuality = function(new_quality)
        {
                quality = new_quality;
        }

        this.SetID = function(new_id)
        {
                id = new_id;
        }

        this.SetTransparent = function(is_transparent)
        {
                wmode = is_transparent ? "transparent" : DEFAULT_WINDOW_SETTING;
        }
        
        this.SetOpaque = function(is_opaque)
        {
                wmode = is_opaque ? "opaque" : DEFAULT_WINDOW_SETTING;
        }

        this.SetFullScreen = function(fullscreen)
        {
                allow_fullscreen = fullscreen ? "true" : "false";
        }

        this.SetScriptAccess = function(new_script_access)
        {
                script_access = new_script_access;
        }

        this.SetParams = function(new_params)
        {
                params = new_params;
        }

        this.ToString = function()
        {
                var str = "";

                if(has_flash)
                {
                        str += '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" width="' + width + '" height="' + height + '" id="' + id + '">';

                        str += '<param name="allowScriptAccess" value="' + script_access + '" />';
                        
                        str += '<param name="swLiveConnect" value="' + sw_live_connect + '" />';
                        str += '<param name="allowFullScreen" value="' + allow_fullscreen + '" />';
                        str += '<param name="movie" value="' + url + '" /><param name="quality" value="' + quality + '" />';
                        str += '<param name="wmode" value="' + wmode + '" />';
                        str += '<param name="bgcolor" value="' + bgcolor + '"/>';
                        str += '<param name="base" value="' + base + '" />';

                        if(params != null)
                        {
                                // IE needs this
                                str += '<param name="flashvars" value="' + params + '" />';
                        }

                        str += '<embed src="' + url + '" quality="' + quality + '" ';

                        if(params != null)
                        {
                                // Non-IE browsers need this
                                str += 'flashvars="' + params + '" ';
                        }
                        //' bgcolor="' +bgcolor+ '"' + 
                        str += ' bgcolor="' +bgcolor+ '"' + ' swLiveConnect="' + sw_live_connect + '" base="' + base + '" wmode="' + wmode + '" width="' + width + '" height="' + height + '" name="' + id + '" allowScriptAccess="' + script_access + '" allowFullScreen="' + allow_fullscreen + '" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />';
                        str += '</object>';

                        //if (window.clipboardData) {
                             // window.clipboardData.setData('Text',str);
                        //}
                        //alert(str);
                }
                else
                {
                        str += '<p style="text-align: center; margin-top: 2em; margin-bottom: 2em; padding-top: 3em; padding-bottom: 3em; background: #333333">You don\'t appear to have <a target="_blank" href="http://get.adobe.com/flashplayer/">Flash</a> installed. <a target="_blank" href="http://get.adobe.com/flashplayer/">Click here</a> to get it (it\'s free).</p>';
                }

                return(str);
        }

        this.Print = function(name)
        {               
                                if (name==undefined){
                        document.write(this.ToString());
                                }else{
                          var g = document.getElementById(name)
                          g.innerHTML = this.ToString();
                                }
        }

        function LookForFlashPlugin()
        {
                var flash_versions = 12;

                // Code swiped from http://www.dangrossman.info/2007/01/03/detecting-flash-and-java-with-javascript/
                if (navigator.plugins && navigator.plugins.length) {
                        // Netscape style plugin detection
                        for (x = 0; x <navigator.plugins.length; x++) {
                                if (navigator.plugins[x].name.indexOf('Shockwave Flash') != -1) {
                                        return(true);
                                }
                        }
                }
                else if (window.ActiveXObject) {
                        // ActiveX style plugin detection
                        for (x = 2; x <= flash_versions; x++) {
                                try {
                                        oFlash = eval("new ActiveXObject('ShockwaveFlash.ShockwaveFlash." + x + "');");
                                        if (oFlash) {
                                                return(true);
                                        }
                                }
                                catch(e) { }
                        }
                }
                
                return(false);
        }
}
