/**
 * @author buenger
 */
function Page (a_divId, a_containerClass, a_stepButtonOffset, a_title) {
	
	this.name = "Page"
	this.type = "Element";
	this.title= a_title;
	this.id = a_divId;
	this.containerClass = a_containerClass;
	this.stepButtonOffset = a_stepButtonOffset;
	
	var div;	
	var _pageNum;
	
	var elements = new Array();
	var idMap = new Hash();
	var _isVisible;
	var _isCheckable = true;
	
	var _self = this;


	this.setCheckable = function (a_checkable) {
		$A(elements).each(function (a_item){
			if (a_checkable == false) {
				a_item.tmpCheckable = a_item.getCheckable;
				a_item.getCheckable = _self.getCheckable;
			} else {
				if (a_item.tmpCheckable) {
					a_item.getCheckable = a_item.tmpCheckable;	
				}
			}
		})
		_isCheckable = a_checkable;
		
	}
	
	this.getCheckable = function() {
		return _isCheckable;
	}

	this.getElement = function (a_id) {
		return idMap[a_id];
	}
		
	this.setVisibility = function (a_isVisible) {
		_isVisible = a_isVisible;
		div.style.display = _isVisible ? "block": "none";
		_self.fireEvent("propChange");
	}
	
	this.getVisibility = function () {
		return _isVisible;
	}
	this.setPageNum = function (a_pageNum) {
		_pageNum = a_pageNum;
	}
	
	this.getPageNum = function () {
		return _pageNum;
	}
	
	this.addItem = function (a_element) {
		elements.push(a_element);
		idMap.set(a_element.id, a_element);
	}
	
	this.check = function () {
		var ctrl = true;
		elements.each(function (a_item, a_index) {
			if (a_item.getCheckable() == true && a_item.check() == false) {	
				a_item.error();
				ctrl = false;
			}
		}, _self);
		return ctrl;
	}
	
	function init(a_divId, a_containerClass, a_stepButtonOffset){
		window.addEvent("load", handleWindowLoad);
	}
	
	function handleWindowLoad () {
		window.removeEvent("load", handleWindowLoad);
		div = $(_self.id);
		_self.fireEvent("loadComplete", this);
	}
	
	//MOOTOOLS EVENTS
	$extend(this, new Events());

	init();	
}

