// Javascript document

function FSClass_click(item) {
	if(document.adminform.FSType.options[3].selected == true) {
		document.adminform.FSTruman.disabled = true
		document.adminform.FSOLP.disabled = true
		document.adminform.FSPhoto.disabled = true
		document.adminform.FSBio.disabled = true
		document.adminform.FSExp.disabled = true
		document.adminform.FSTeaching.disabled = true
		document.adminform.FSResearch.disabled = true
		document.adminform.FSService.disabled = true
		document.adminform.FSADJDept.disabled = false
	}	
	else {
		document.adminform.FSTruman.disabled = false
		document.adminform.FSOLP.disabled = false
		document.adminform.FSPhoto.disabled = false
		document.adminform.FSBio.disabled = false
		document.adminform.FSExp.disabled = false
		document.adminform.FSTeaching.disabled = false
		document.adminform.FSResearch.disabled = false
		document.adminform.FSService.disabled = false
		document.adminform.FSADJDept.disabled = true
	}
	
	checkFTitle(item);
}

function checkFTitle(item) {
	var a = document.getElementById("FSType")
	var b = document.getElementById("FSTruman")
	var c = document.getElementById("FTitle")
	var d = document.getElementById("FSTitle")
	var e = document.getElementById("FSCV")

	if(a.value == '0' && b.checked == true && item != 9){
		c.disabled = false;
		d.disabled = true;
	}
	else if (a.value == '0' && b.checked == true && item == 9){
		c.disabled = false;
		d.disabled = false;
	}
	else {
		c.disabled = true;
		d.disabled = false;
	}

	if((a.value == '0' || a.value == '2') && b.checked == true){
		e.disabled = false;
	}
	else {
		e.disabled = true;
	}
}

function submit_facultystaff(){
	var a = document.getElementById("FSType") // this is the drop down box to classify the faculty/staff person
	var b = document.getElementById("FSTruman")  //this is the check box for if the person is a TSPA faculty
	var c = document.getElementById("FTitle") // this is the sub classification for faculty only

	if (a.value == '0' && b.checked == true && c.value == ''){
		alert("You must select a faculty category for this faculty member");
		c.focus();
	}
	else {
		document.adminform.submit();
	}
}

function submit_publication(){
	var a = document.getElementsByName("PAcademic")
	var b = document.getElementById("1_Academic")
	var c = document.getElementById("2_Applied")

	if (a[0].checked == true && (b.value == '0' || b.value == '')) {
		alert("You must specify an \"Acadmic/Applied\"  as well as \"Publication\" Type")
		a[0].focus();
	}
	else if (a[1].checked == true && (c.value == '0' || c.value == '')) {
		alert("You must specify an \"Acadmic/Applied\"  as well as \"Publication\" Type")
		a[0].focus();
	}
	else if (a[0].checked == false && a[1].checked == false) {
		alert("You must specify an \"Acadmic/Applied\"  as well as \"Publication\" Type")
		a[0].focus();
	}
	else {
		document.form1.submit();
	}

	//		for(var x=0; x<a.length; x++){
	//			if(a[x].checked == true){
	//			}	
	//		}
}

function TogglePTypes(item){
	// item = 1 is academic
	// item = 2 is applied
	var a = document.getElementById("1_Academic")
	var b = document.getElementById("2_Applied")
	var c = document.getElementById("hiddendiv_academic")	
	var d = document.getElementById("hiddendiv_applied")

	if(item == "1"){
		a.disabled = false;
		c.style.display = "block";

		b.disabled = true;
		d.style.display = "none";
	}
	else if(item == "2"){
		a.disabled = true;
		c.style.display = "none";
		
		b.disabled = false;
		d.style.display = "block";
	}
}

function  setPJtitle(item, item2) {
	// item is the id of the select box we are working with
	var a = document.getElementById(item)
	var b = document.getElementById(item2)
	
	if (a.value == 2 || a.value == 3 || a.value == 4 || a.value == 5){
		b.disabled = false;
		b.style.background = '#fff';
	}
	else {
		b.disabled = true;
		b.style.background = '#EEEEEE';
	}
}

function loadPage(siteid)  {
	if (siteid == 'htmlFormatting') {
		siteid = '/_includes/formattinginstructions.htm'
	}
	var newWindow = window.open(siteid,"aWin","height=800,width=800,toolbar=0,scrollbars=1,location=0,resizable=1,menubar=0,statusbar=0");
}
