/* 
This function allows us to remove the superfluous commas from the faculty member lists.
  It should only be necessary for the demos we are giving, but maybe it's also a permanent solution. */
  
function trimLastCommaFromFacultyLists() {
	var categoryList = getElementsByClassName("faculty-category");


	for (var x = 0; x < categoryList.length; x++) {
		//get the parent paragraph (categoryList[x].parentNode) and then find all faculty-title spans and trim the last one of its comma and ending space.
		var membersList = getElementsByClassName("faculty-title", "span", categoryList[x].parentNode);
		var lastMember = membersList[membersList.length -1];
		//alert("Last member inner html is: " + lastMember.innerHTML);
		//alert("new version should be: " + lastMember.innerHTML.substring(0, lastMember.innerHTML.length -2));
		lastMember.innerHTML =lastMember.innerHTML.substring(0, lastMember.innerHTML.length -2);
	}
}

/*When a title isn't displayed a hyphen still shows up, so we remove it using javascript */
function removeHyphenFromEmptyTitles() {
	var facultyList = getElementsByClassName("faculty-member");

	var emptyTitle 			= />, /g;
	var titleSeparator		= /> - </g;
	var titleSeparatorEmpty	= "><";
	for (var x = 0; x < facultyList.length; x++) {
		//alert(facultyList[x].innerHTML);
	
		if (facultyList[x].innerHTML.match(emptyTitle)) {
			//alert(facultyList[x].innerHTML);
			//remove the hyphen
			facultyList[x].innerHTML = facultyList[x].innerHTML.replace(titleSeparator, "><");
		}
		//get the parent paragraph (categoryList[x].parentNode) and then find all faculty-title spans and trim the last one of its comma and ending space.
		//var membersList = getElementsByClassName("faculty-title", "span", categoryList[x].parentNode);
		//var lastMember = membersList[membersList.length -1];
		//alert("Last member inner html is: " + lastMember.innerHTML);
		//alert("new version should be: " + lastMember.innerHTML.substring(0, lastMember.innerHTML.length -2));
		//lastMember.innerHTML =lastMember.innerHTML.substring(0, lastMember.innerHTML.length -2);
	}
}

function showProcessingFeesDialog() {
	if (window.showModalDialog) {
		window.showModalDialog("/programs/processing-fees.aspx","fees","dialogWidth:650px;dialogHeight:600px");
	} else {
		window.open('/programs/processing-fees.aspx','fees','height=600,width=650,toolbar=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no ,modal=yes');
	}
} 

//warning, this onload will crush other ones, should use one from a framework that appends.
onload = function() {
	removeHyphenFromEmptyTitles();
	trimLastCommaFromFacultyLists();
		
}


