/* 	
	------------------------------------------------------------------------------
	/framework/classes/js/page.js
	
	Page bevat een array waarin alle controls zitten - handig om te loopen
	
 	------------------------------------------------------------------------------
*/

function Page() {

	// methods
	this.controls = new Array();
	this.numControls = 0;
	
	this.addControl = Page_addControl;
	this.removeControl = Page_removeControl;
	
	this.hasErrors = false;
	
}

function Page_addControl(obj) {
	//alert("Adding object " + obj + " to Page");
	
	if (obj) {
		if (obj.id) {
			this.controls[this.numControls] = obj;
			this.numControls++;
		}
	}
}

function Page_removeControl(obj) {
	
	var foundAt = -1;
	for (i=0;i < this.numControls; i++) {
		if (this.controls[i].id == obj.id) {
			foundAt = i;
		}
	}
	
	// if we found it at, f.e. 5, 6->5, 7->6, until end of array (f.e. length = 8)
	if (foundAt > 0) {
		for(i=foundAt+1; i <= this.numControls; i++) {
			this.controls[i-1] = this.controls[i]; 
		}
		this.numControls--;
	}
	else if (foundAt == 0) {
		this.controls[0] = null;
		this.numControls = 0;
	}
	else {}	
	
}

