define(['scripts/knockout-3.3.0','scripts/ACTComponent.js'], function(ko, ACTComponent) {

    function BrowserComponentViewModel(params, element) {
		this.base = new ACTComponent($(element), params);
	
		this.elements = ko.observableArray([]);
		
		this.base.onRefresh = function(obj) {
			for (var i=0;i<obj.Elements.length;i++) {
				var elementObj = obj.Elements[i];

				elementObj.click = function(e) {
					//params.baseModel.onTriggerAction("TriggerClick", [this.Name]);
					this.__click();
				}
				this.base.addCallback(elementObj, "__click", "SelectedCB", []);
			}

			this.elements(obj.Elements);
		}.bind(this);		
		
		this.base.initialize();
		params.ready(true);
    }

	return {
		createViewModel: function(params, componentInfo) {
            return new BrowserComponentViewModel(params, componentInfo.element);
        }
	};

});

