// JavaScript Document
function checkAll(field){
	for (i = 0; i < field.length; i++){
		field[i].checked = true ;
	}
}

function getCheckedValue(radioObj) {
	if(!radioObj)
		return "";
	var radioLength = radioObj.length;
	if(radioLength == undefined)
		if(radioObj.checked)
			return radioObj.value;
		else
			return "";
	for(var i = 0; i < radioLength; i++) {
		if(radioObj[i].checked) {
			return radioObj[i].value;
		}
	}
	return "";
}



function uncheckAll(field){
	for (i = 0; i < field.length; i++){
		field[i].checked = false ;
	}
}

function updateCheckBoxesByValue(CheckBoxToUpdate,inOrOut,ValueList){
	var option1;
	option1 = getCheckedValue(inOrOut);
	var valueArray = ValueList.value.split(",");
	if(option1 == 1){	
		uncheckAll(CheckBoxToUpdate);	
		for(var i=0; i<valueArray.length; i++){
			// j is now the trimmed value to look for in the checkbox value.
			var j = i;			
			for (var x=0; x < CheckBoxToUpdate.length; x++){
				if (CheckBoxToUpdate[x].value == valueArray[j].replace(/^\s+|\s+$/g, '') ){
						CheckBoxToUpdate[x].checked = true;					
				}
			}
		}		
	}else{
		checkAll(CheckBoxToUpdate);	
		for(var i=0; i<valueArray.length; i++){
			// j is now the trimmed value to look for in the checkbox value.
			var j = i;			
			for (var x=0; x < CheckBoxToUpdate.length; x++){
				if (CheckBoxToUpdate[x].value == valueArray[j].replace(/^\s+|\s+$/g, '') ){
						CheckBoxToUpdate[x].checked = false;					
				}
			}
		}		
	}
}
																	 
																	