// 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 = 'none';
	} else if(document.datatelform.ALL_HON.checked == true){
	   document.getElementById('ReMarkLink').style.display = 'none';
	} else{
	   document.getElementById('ReMarkLink').style.display = 'none';
	}
	
	for (var i=0, option; option = document.datatelform.FIELD_Department.options[i]; i++) {
		if (option.disabled) {
			option.style.color = "graytext";
		}else{
			option.style.color = "menutext";
		}
	}

	
}

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;
	}
}

//function checkMFL() {
//	var selection = document.datatelform.FIELD_Department.value;
//	if(selection == "ARABIC" || selection == "ASL" || selection == "CHINESE") {
//		document.datatelform.FIELD_Department.selectedIndex = 39;
//	}
//}

function checkMFL() {
	var selection = document.datatelform.FIELD_Department.value;
	if(selection == "MFL") {
		document.datatelform.FIELD_Department.selectedIndex = 39;
	}
}

