/***********************************************************************
 * (C) SCC Informationssysteme GmbH 2000 - 2004                        *
 ***********************************************************************/

/*
+ ---------------------------------------------------------------------------------+
| Purpose..: The ListControl object provides some javascript helper functions
|            
|
| Date        Author            Notice
| ----------  ----------------  ----------------------------------------------------
| 08.04.2004  G.Schulz (SCC)    Erstversion
|
+ ---------------------------------------------------------------------------------+
*/
function ListControl(id) {
	this.id = id;
}
function ListControl_handleCheckState(obj, column, selectMode) {
	var items = this.getCheckBoxes(column);

	// if mode is set to single select
	// delete all checkboxes
	if (selectMode == SelectMode.SINGLE && items.length > 1) {
		ListHelp.uncheck(items);

		// check the one which was checked at least
		obj.checked = true;
	}
}
function ListControl_getSpan() {
	// return the node where the control is embedded
	return document.getElementById(this.id);
}
function ListControl_getCheckBoxes(column) {
	var elements = new Array();
	var root = this.getSpan();
	
	var arr = root.getElementsByTagName('Input');

	for (var i=0; i < arr.length; i++) {
		if ( arr[i].type == 'checkbox' ) {
		
			if (null != arr[i].id && "" != arr[i].id) {
				var name = arr[i].id.split('_');

				// belongs the checkbox to the column?
				if (name.length == 2 && name[0] == column) {
					elements[elements.length] = arr[i];
				}
			}
		}
	}

	return elements;
}

new ListControl();
ListControl.prototype.handleCheckState  = ListControl_handleCheckState;
ListControl.prototype.getSpan           = ListControl_getSpan;
ListControl.prototype.getCheckBoxes     = ListControl_getCheckBoxes;


