﻿function ActivatedControl() {
    this.Properties = new ActivatedControl_Params();
    this.Params = new ActivatedControl_Params();
    this.Embeds = new ActivatedControl_Params();
}

ActivatedControl.prototype.Init = function() {
    var ctl = "<object "
    
    var props = this.Properties.GetItems();
    for (var i = 0; i < props.length; i++) {
        ctl += " "+props[i].name+"='"+props[i].value+"' ";
    }

    ctl += ">";

    var items = this.Params.GetItems();
    for (var i = 0; i < items.length; i++) {
        ctl += " <param name='"+items[i].name+"' value='"+items[i].value+"' />";
    }
    
    var embeds = this.Embeds.GetItems();
    if(embeds.length > 0) {
        ctl += "<embed ";
        for (var i = 0; i < embeds.length; i++) {
            ctl += " "+embeds[i].name+"='"+embeds[i].value+"' ";          
        }
        ctl += "></embed>";
    }
    
    ctl += "</object>";
    
    document.write(ctl);
}

function ActivatedControl_Params() {
    this._items = new Array();
}
ActivatedControl_Params.prototype.Add = function(name,value) {
    this._items[this._items.length] = new ActivatedControl_Param(name, value);
}

ActivatedControl_Params.prototype.GetItems = function() {
    return this._items;
}

function ActivatedControl_Param(name, value) {
    this.name = name;
    this.value = value;
}

//<Control:Head runat="server" ID="h" Visible="true">
//    <add tagname="script" type="text/javascript" language="javascript" src="/scripts/ActivatedControl.js"></add>
//</Control:Head>

//<script type="text/javascript" language="javascript">
//    var ctl = new ActivatedControl();
//    ctl.Properties.Add("id", "AstralBlueMan_fr");
//    ctl.Properties.Add("height", "60px");
//    ctl.Properties.Add("width", "380px");
//    ctl.Properties.Add("codebase", "http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0");
//    ctl.Properties.Add("classid", "clsid:D27CDB6E-AE6D-11cf-96B8-444553540000");
//    ctl.Params.Add("src", "http://www.pcm.qc.ca/sites/pcm/multimedias/pubgolf_nolink.swf");
//    ctl.Embeds.Add("src", "http://www.pcm.qc.ca/sites/pcm/multimedias/pubgolf_nolink.swf");
//    ctl.Embeds.Add("quality", "high");
//    ctl.Embeds.Add("height", "60px");
//    ctl.Embeds.Add("width", "380px");
//    ctl.Embeds.Add("name", "AstralBlueMan_fr");
//    ctl.Embeds.Add("type", "application/x-shockwave-flash");
//    ctl.Embeds.Add("pluginspage", "http://www.macromedia.com/go/getflashplayer");
//    ctl.Init();
//</script>
