/* * * * * * * * * * * * * * * * * * * * * * * * */
/* * v v v PERSONNEL v v v * * * * * * * * * * * */
/* * * * * * * * * * * * * * * * * * * * * * * * */

function switchPersonnelTab(newtab)
{
	var tabArray = $$('.navigationalTab');
	for (j = 0; j < tabArray.length; j++)
	{
//		console.log(tabArray[j].className + " / " + tabArray[j].id);
		if(tabArray[j].id == newtab)
		{
			tabArray[j].className = tabArray[j].className.replace(/passive/g, "active");
		}
		else
		{
			tabArray[j].className = tabArray[j].className.replace(/active/g, "passive");
		}
	}

	$('personnelTabContainer').innerHTML = $(newtab + 'Source').innerHTML;

}

/* * * * * * * * * * * * * * * * * * * * * * * * */
/* * ^ ^ ^ PERSONNEL ^ ^ ^ * * * * * * * * * * * */
/* * * * * * * * * * * * * * * * * * * * * * * * */

function resetDropDown(source)
{
	var fileName =
	location.pathname.substring(location.pathname.lastIndexOf('/')+1, location.pathname.lastIndexOf('.'))

	if(fileName == "professoren" || fileName == "adjunct-faculty")
	{
		fileName = 0;
	}
	if(source == "lehrstuhl")
	{
		$('lehrstuhlDropdown').value = unescape(fileName);
	}
	else if(source == "personen")
	{
		$('filterDropdown').value = unescape(fileName);
	}

}
function populatePersons()
{
	alert("hier");
	url = hostRoot + "/fileadmin/includes/php/populatePersonDropdown.php";
	params = "";

	var ajaxRequest = new Ajax.Request(url, {
    	method:       'post',
    	parameters:   params,
    	asynchronous: true,
    	onComplete:   makeDropDown
	});


}
function redirectFilter(source, target)
{
	if(source == "personen")
	{
		window.location.href = "/fakultaet-forschung/" + target + "/studiengang/" + $('filterDropdown').value + ".html?no_cache=1";
	}
	else if(source == "lehrstuhl")
	{
		window.location.href = "/fakultaet-forschung/" + target + "/lehrstuehle/" + escape($('lehrstuhlDropdown').value) + ".html";
	}
}

function makeDropDown(response)
{
	oldContent = $('personenDropdown').innerHTML;
	$('personenDropdown').innerHTML = oldContent + "\n" + response.responseText;
}

function redirectPerson()
{
	window.location.href = 'fakultaet-forschung/professoren/person/' + $('personenDropdown').value + '.html?no_cache=1';
}

/**
 * Helper object to collect all content specific javascript
 * S. Teuber 18.12.09
 */
var contentFX = {
	/**
 	 * Set the height of any teaser in the content column to the height of the surrounding
 	 * row element (in order to get the same border-boxes for adjacent teasers).
 	 * S. Teuber 18.12.09
 	 */
	setTeaserHeight : function() {
		// Get content column teasers
		$$('.teaserRow').each(
			function (e) {
				var tHeight = e.getHeight();
				var teasers = e.getElementsByClassName('teaserSmall');
				for (var i = 0; i < teasers.length; i++) {
					teasers[i].setStyle({
						height:	tHeight+'px'
					});
				}
			}
		);
	}
}

Event.observe(window, 'load', function() {
 	contentFX.setTeaserHeight();
});