var matrix = null;;

function pageInit() {
	matrix = new Object;
	var all = document.getElementsByTagName("input");
	for(var i = 0; i < all.length; i++) {
		var node = all[i];
		if (node.type == "radio") {
			if (node.checked) {
				matrix[node.name] = node;
			}
		}
	}
}

function onCheck(uid, chkbox) {
	matrix[uid] = chkbox;
}

function changeFacilitator(uid, facilitatorChkbox) {
	var answer = confirm("Are you sure that you want to change group facilitator?");
	if (answer) {
		var chkbox = document.getElementById("r" + uid + "-1");
		chkbox.disabled = true;
		chkbox.checked = false;
		
		chkbox = document.getElementById("r" + uid + "-2");
		chkbox.disabled = true;
		chkbox.checked = false;
		
		chkbox = document.getElementById("r" + uid + "-3");
		chkbox.disabled = true;
		chkbox.checked = true;
		matrix[uid] = chkbox;
	
	
		chkbox = document.getElementById("r" + currentFacilitatorId + "-1");
		chkbox.disabled = false;
		chkbox.checked = true;
		matrix[currentFacilitatorId] = chkbox;
		
		chkbox = document.getElementById("r" + currentFacilitatorId + "-2");
		chkbox.disabled = false;
		chkbox.checked = false;
		
		chkbox = document.getElementById("r" + currentFacilitatorId + "-3");
		chkbox.disabled = false;
		chkbox.checked = false;
			
		currentFacilitatorId = uid;
		
		document.getElementById("facilitatorIdField").value = currentFacilitatorId;
	}
	else {
		facilitatorChkbox.checked = false;
		matrix[uid].checked = true;		
	}
}
