// Place your application-specific JavaScript functions and classes here
// This file is automatically included by javascript_include_tag :defaults
sfHover = function() {
	var sfEls = document.getElementById("navigation").getElementsByTagName("LI");
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			this.className+=" sfhover";
		}
		sfEls[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
		}
	}
}

window.onload = function() {
	sfHover();
	stretch_banners();
	if (document.getElementById('news-ticker')) startScroll();
};

var auto_direction=1;
function autoScroll(amount) {
	var div=document.getElementById('news-ticker');
	div.scrollLeft += (amount*auto_direction);
	if ((div.scrollWidth-div.scrollLeft==div.offsetWidth && auto_direction > 0)  || (div.scrollLeft == 0 && auto_direction < 0 )) {
		auto_direction=auto_direction*-1;
	}
}

function startScroll() {
	i=document.getElementById('news-ticker');
	i.scrollLeft=0;
	setInterval('autoScroll(1)',50);
}

function stretch_banners() {
	if ($('banners') && $('content')) {
		b_height = $('banners').getHeight();
		c_height = $('content').getHeight();
		if (b_height > c_height) {
			$('content').style.height = b_height-30+'px';
		} else {
			$('banners').style.height = c_height+'px';
		}
	}
}