function emptyList(list){
	$(list).options.length = 0;
}

function selectAllOptions(selStr)
{
  var selObj = document.getElementById(selStr);
  for (var i=0; i<selObj.options.length; i++) {
	selObj.options[i].selected = true;
  }
  return true;
}
		
function addToJobList(jobID,jobName,ele, parentID,targetList){
	// First check that there is no existing job
	
	var sel = $(targetList);
	var i;
	for (i = sel.length -1; i >= 0; i--){
		if (sel.options[i].value == jobID){
			return false;
			// set = true;
			// break;
		}
	}
	
	var opt = document.createElement("option");
	
	sel.options.add(opt);
	
	opt.text = jobName;
	opt.value = jobID;
	
	if (parentID != 0) {
		opt.text = opt.text + " (" + document.getElementById(parentID).firstChild.firstChild.data + ")";
	}
	
	new Effect.Highlight(ele.parentNode);
	
	return true;
}

function removeJobFromList(targetList){
	var sel = $(targetList);
	var i;
	for (i = sel.length -1; i>=0; i--){
		if (sel.options[i].selected){
			sel.remove(i);
		}
	}
}

function classToggle(id, owner){
	// Get all DIVs inside out "owner" tag
	var x=$(owner).getElementsByTagName("div");
	// Loop through DIVs
	for (var i = 0;i<x.length;i++){
		divid = new String(x[i].id);
		if ((divid.substring(0,6))=='parent') {
			if ((x[i].style.display) != 'none') {
				/* This DIV may need closing but we need to check that it does not 
				   contain the DIV we are trying to open */
				var y = x[i].getElementsByTagName("div");
				// Assume we can close this DIV
				ok = true;
				for (j = 0; j<y.length; j++) {
					if (y[j].id == id) {
						// This DIV contains the one we are trying to open so don't close it
						ok = false;
					}
				}
				if (ok == true) {
					new Effect.toggle(x[i],'blind');
				}
			}
			x[i].parentNode.firstChild.className='statementHead';
		}
	}
	$(id).parentNode.firstChild.className = 'statementHeadActive';
	// We've dealt with all the other DIVs now let's open the one we actually want to see
	new Effect.toggle($(id),'blind');
	return false;
}

// Remove selected list items from targetList
function RemoveGroups(targetList) {
	var sel = $(targetList);
	//var sel = document.getElementById('cboLookup8');
	while (sel.firstChild) {
		sel.removeChild(sel.firstChild);
	}
}
