/**
 *  libSupport - Contains common functions
 */

function highlight(id, offOn, cnt){
    var i;
    
    if( offOn == 'on'){
	for (i = 0; i < cnt ; i++){
	    
	    getRef(id + '_' + i).className = "active-row-highlight"

	}
    }
    else{
	for (i = 0; i < cnt ; i++){
	    getRef(id + '_' + i).className = "search-table-row"

	}
    }
}

function etDiv(pName) {
    this.name = pName;
    this.write = _writeDiv;
    this.writeLine = _writeDivLine;
    this.clear = _clearDiv; 
	
	function _writeDiv(str){
		getRef(this.name).innerHTML += str;
	}

	function _writeDivLine(str){
		getRef(this.name).innerHTML += str + "<br />\n";
	}

	function _clearDiv() {
		getRef(this.name).innerHTML = "";
	}
    
}

function getRef(id){
//    return (typeof id == "string") ?  (document.getElementById ? document. getElementById(id)) : (document.all ? document.all[id] : document.layers[id]);
//    return (typeof id == "string") ? document.getElementById(id) : id;
	if (typeof id == "string") {
		return document.getElementById(id);
	}
	else {
		return id;
	}
}

function replaceNull(what, withThis){
    return ( isNothing(what) ) ? withThis : what;
}

function isNothing(what){
    if ( typeof what == 'object' && !what) return true;
    if (typeof what == 'undefined') return true;
    if (typeof what == 'string' && what == '') return true;
    else return false;
}

function setSelectBox(obj, deptID){
    selectBox = getRef(obj);

    for (var i = 0; i < selectBox.length ; i++) {
		if ( DEBUG_FLAG ) objDebug.writeLine("==== " + deptID + " == " + selectBox.options[i].value);
		if (selectBox.options[i].value == deptID){
			if ( DEBUG_FLAG ) objDebug.writeLine("==== Found Option at " + i + selectBox.options[i].value);
			selectBox.selectedIndex = i;
			return true;
		}
    }
}
