/* Author:  Chris Amelung (amelungc@wustl.edu)

*/

var assetsPath = 'assets/';
var selectedNewsTab = 'nr';

function changeImage(img, item) {
	img.src = assetsPath+ '/images/' +item;
}

function highlightNewsTab(t) {
	if( t != selectedNewsTab ) {
		document.getElementById(t+'_news_img').src = assetsPath+ 'images/' +t+ '_news_tab_over.png';
	}
}

function unhighlightNewsTab(t) {
	if( t != selectedNewsTab ) {
		document.getElementById(t+'_news_img').src = assetsPath+ 'images/' +t+ '_news_tab_off.png';
	}
}

function showNewsTabContents(t) {	
	if( t == 'pubs' ) {
        document.getElementsByClassName('home-contents')[0].style.backgroundImage = 'none';
		document.getElementById('news').style.display = 'none';
		document.getElementById('in-news').style.display = 'none';
		document.getElementById('pubs').style.display = 'block';

		document.getElementById('nr_news_img').src = assetsPath+ 'images/nr_news_tab_off.png';
		document.getElementById('nr_news_tab').setAttribute('class', '');
		document.getElementById('nr_news_tab').style.backgroundColor = '#b09978';

		document.getElementById('in_news_img').src = assetsPath+ 'images/in_news_tab_off.png';
		document.getElementById('in_news_tab').setAttribute('class', '');
		document.getElementById('in_news_tab').style.backgroundColor = '#b09978';

		document.getElementById('pubs_news_img').src = assetsPath+ 'images/pubs_news_tab_on.png';
		document.getElementById('pubs_news_tab').setAttribute('class', 'selected-tab');
		document.getElementById('pubs_news_tab').style.backgroundColor = '#8e7453';

		unhighlightNewsTab('nr');
		unhighlightNewsTab('in');

		selectedNewsTab = 'pubs';
	} else if( t == 'in' ) {
        document.getElementsByClassName('home-contents')[0].style.backgroundImage = 'none';
        document.getElementById('news').style.display = 'none';
		document.getElementById('pubs').style.display = 'none';
		document.getElementById('in-news').style.display = 'block';

		document.getElementById('nr_news_img').src = assetsPath+ 'images/nr_news_tab_off.png';
		document.getElementById('nr_news_tab').setAttribute('class', '');
		document.getElementById('nr_news_tab').style.backgroundColor = '#b09978';

		document.getElementById('pubs_news_img').src = assetsPath+ 'images/pubs_news_tab_off.png';
		document.getElementById('pubs_news_tab').setAttribute('class', '');
		document.getElementById('pubs_news_tab').style.backgroundColor = '#b09978';

		document.getElementById('in_news_img').src = assetsPath+ 'images/in_news_tab_on.png';
		document.getElementById('in_news_tab').setAttribute('class', 'selected-tab');
		document.getElementById('in_news_tab').style.backgroundColor = '#8e7453';

		unhighlightNewsTab('nr');
		unhighlightNewsTab('pubs');

		selectedNewsTab = 'in';
	} else {
        document.getElementsByClassName('home-contents')[0].style.background = '#f5f2ed url(\'' +assetsPath+ 'images/media_legend.png\') 35px 98% no-repeat';
		document.getElementById('pubs').style.display = 'none';
		document.getElementById('in-news').style.display = 'none';
		document.getElementById('news').style.display = 'block';

		document.getElementById('pubs_news_img').src = assetsPath+ 'images/pubs_news_tab_off.png';
		document.getElementById('pubs_news_tab').setAttribute('class', '');
		document.getElementById('pubs_news_tab').style.backgroundColor = '#b09978';

		document.getElementById('in_news_img').src = assetsPath+ 'images/in_news_tab_off.png';
		document.getElementById('in_news_tab').setAttribute('class', '');
		document.getElementById('in_news_tab').style.backgroundColor = '#b09978';

		document.getElementById('nr_news_img').src = assetsPath+ 'images/nr_news_tab_on.png';
		document.getElementById('nr_news_tab').setAttribute('class', 'selected-tab');
		document.getElementById('nr_news_tab').style.backgroundColor = '#8e7453';

		unhighlightNewsTab('pubs');
		unhighlightNewsTab('in');

		selectedNewsTab = 'nr';
	}
}

function contactUs() {
	window.location = 'mailto:mpa@wusm.wustl.edu';
}

function search() {
	document.forms[0].submit();
}

function launchPhysiciansDirectory(url) {
	try {
		var pageTracker=_gat._getTracker("UA-4767049-1");
		pageTracker._trackEvent('Home / Find a Doctor', 'Physician Directory');
	} catch(err) {}
	window.location='http://wuphysicians.wustl.edu/directory.aspx';
}

function searchForIt(category, action) {
	if( document.search.q.value != 'Enter search term(s)' ) {
		try {
			var pageTracker=_gat._getTracker("UA-4767049-1");
			pageTracker._trackEvent(category, action);
		} catch(err) {}
		document.search.submit();
	}
}

function recordOutboundLink(link, category, action) {
	try {
		var pageTracker=_gat._getTracker("UA-4767049-1");
		pageTracker._trackEvent(category, action);
		setTimeout('document.location = "' + link.href + '"', 100);
	} catch(err) {}
}
