// JavaScript Document

function locationSelectionCheck() {
	var length = document.datatelform.FIELD_Location.options.length;
	var found = 0;
	for(var i = 0; i < length; i++) {
		if(document.datatelform.FIELD_Location.options[i].value == 'UC') {
			if(document.datatelform.FIELD_Department.value != "" ||
			   document.datatelform.ALL_ONL.checked == true ||
			   document.datatelform.ALL_HYB.checked == true ||
			   document.datatelform.ALL_HON.checked == true) {
				    AddUCToLocation();
			}
			else {
				RemoveUCFromLocation(i);
			}
			found = 1;
		}
	}
	if(found == 0)
		AddUCToLocation();
	
	if(document.datatelform.ALL_ONL.checked == true || document.datatelform.ALL_HYB.checked == true) {
	   document.getElementById('ReMarkLink').style.display = 'block';
	} else {
	   document.getElementById('ReMarkLink').style.display = 'none';
	}
}

function RemoveUCFromLocation(myID) {
    if(document.datatelform.FIELD_Location.options[myID].value == 'UC')
		document.datatelform.FIELD_Location.options[myID] = null;
}

function AddUCToLocation() {
	var length = document.datatelform.FIELD_Location.options.length;
	var found = 0;	
	for(var i = 0; i < length; i++) {
		if(document.datatelform.FIELD_Location.options[i].value == 'UC')
			found = 1;
	}
	
	if(found == 0) {
		var option = new Option("UC - SVSU Main Campus", "UC");
		document.datatelform.FIELD_Location.options[length] = option;
	}
}
