/* master javascript file */

/* PAGE INITIALIZATION */
function init() {
	displayNews();
}



/* START HEADER NEWS SCROLLER */

// initial variable setup
var currNews = 1;
var prevNews = false;

// function to start news
function displayNews() {
	cycleNews();
	setInterval('cycleNews()',5000);
}


// function to show/hide news in sequence
function cycleNews()	{
	// find total news items based on class name
	// var newsArray = new Array();
	newsArray = $("div#js-news").find("div.js-news-item");
	newsTotal = newsArray.length;
	
	// if news showing, hide it
	if(prevNews) {
		$("div#news-item-"+prevNews).slideUp("slow");
	}
	
	// show news item
	$("div#news-item-"+currNews).slideDown("slow");
	
	// increment loop
	prevNews = currNews;
	currNews++;
	if(currNews > newsTotal)	{
		currNews = 1;
	}
}

/* END HEADER NEWS SCROLLER */


/* MISC SITEWIDE FUNCTIONS */

// function to resizeIframe based on its content; pass function id of the iframe
function resizeIframe(myIframe)	{
	var the_height = document.getElementById(myIframe).contentWindow.document.body.scrollHeight;
	document.getElementById(myIframe).height = the_height;
}


