define(['scripts/knockout-3.3.0', 'mod/properties/propertyutils'], function(ko, PropertyUtils) {

    function PropertyBooleanViewModel(params, element) {
		this.utils = new PropertyUtils();
		this.utils.Init(this, params, element);

		var label = $(element).find(".boolean-label")[0];
		var checkBox = $(element).find(".boolean-checkbox")[0];
		var checkboxId = "checkbox_" + params.Id;
		checkBox.setAttribute("id", checkboxId);
		label.setAttribute("for", checkboxId);
		params.valueB = ko.observable(params.value()=="True");
		params.valueB.subscribe(function(newVal) {
			if (newVal) {
				params.value("True");
			}
			else {
				params.value("False");
			}
		});

		params.value.subscribe(function(newVal) {
			if (newVal === "True") {
				params.valueB(true);
			}
			else if (newVal === "False") {
				params.valueB(false);
			}
		});
		this.utils.Ready(params);
		return params;
    }

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

});
