






window.Flash = function(src,width,height){
    if (src){
        this.src=src.toString();
    }
    if (width){
        this.width=parseInt(width);
    }
    if (height){
        this.height=parseInt(height);
    }
}

window.Flash.prototype={
    object:{
        classid:"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000",
        codebase:"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0",
        title:'',
        params:[
            {
                name:'allowScriptAccess',
                value:'sameDomain'
            },
            {
                name:'quality',
                value:'high'
            },
            {
                name:'wmode',
                value:'transparent'
            }
        ]
    },
    embed:{
        quality:'high',
        pluginspage:'http://www.macromedia.com/go/getflashplayer',
        type:'application/x-shockwave-flash',
        wmode:'transparent'
    },
    src:'',
    width:0,
    height:0,
    getParam:function(name){
        for(var c=0;c<this.object.params.length;c++){
            if (this.object.params[c].name==name){
                return this.object.params[c];
            }
        }
    },
    getParamValue:function(name){
        var param=this.getParam(name);
        return param && param.value;
    },
    addParam:function(name,value){
        if (name){
            //-- add to param
            var param=this.getParam(name);
            if (param){
                param.value=value.toString();
            } else {
                this.object.params[this.object.params.length]={
                    name:name.toString(),
                    value:value.toString()
                };
            }
            
            //-- add to embed
            if (this.embed[name]){
                this.embed[name]=value.toString();
            }
        }
    },
    addEmbed:function(name,value){
    },
    addObject:function(name,value){
    },
    echo:function(){
        //-- gather object attributes
        var objectAttributes=[
                'classid="'+this.object.classid+'"',
                'codebase="'+this.object.codebase+'"',
                'width="'+this.width+'"',
                'height="'+this.height+'"',
                'title="'+this.object.title+'"'
            ],
            objectParams=[
                '<param name="movie" value="'+this.src+'" />',
            ],
            embedAttributes=[
                'src="'+this.src+'"',
                'width="'+this.width+'"',
                'height="'+this.height+'"',
            ];
        //-- gather object params
        for(var c=0;c<this.object.params.length;c++){
            var param=this.object.params[c];
            
            objectParams[objectParams.length]='<param name="'+param.name+'" value="'+param.value+'" />';
            //-- add embed attributes
            //if (this.embed[param.name]){
                embedAttributes[embedAttributes.length]=param.name+'="'+param.value+'"';
            //}
        }

        //-- create object
        objectTag='<object '+objectAttributes.join(' ')+">\n"
            + objectParams.join("\n")
            + '<embed '
                + embedAttributes.join(' ')
                + '></embed>'
            + '</object>';
            

        document.write(objectTag);
    }
}