/**
 * @author buenger
 */
function Box (a_divId) {
	
	this.name = "Box";
	this.type = "Element"
	
	this.id;
	
	var div;
	var divId;
	var _self = this;
	var _isVisible;
	
	this.setVisibility = function (a_isVisible) {
		_isVisible = a_isVisible;
		div.style.display = _isVisible ? "block": "none";
		_self.fireEvent("propChange");
	}
	
	this.getVisibility = function () {
		return _isVisible;
	}
	
	this.addDependency = function (a_id, a_valueFnc, a_compareFnc, a_handleFnc) {
		var el = Form.idMap[a_id];
		el.addEvent("propChange", function () {
			var value = el[a_valueFnc]();
			var compareResult = CompareFunctions[a_compareFnc](value);
			_self[a_handleFnc](compareResult);
		});
	}
	
	function init(a_divId) {
		_self.id = a_divId;
		window.addEvent("load", handleWindowLoad);
	}
	
	function handleWindowLoad () {
		window.removeEvent("load", handleWindowLoad);
		div = $(_self.id);
		setTimeout(function () {
			_isVisible = div.style.display != "none";
			_self.fireEvent("propChange");
		}, 50);
	}
	
	//MOOTOOLS EVENTS
	$extend(this, new Events());
	
	init(a_divId);
}

