// Place your application-specific JavaScript functions and classes here
// This file is automatically included by javascript_include_tag :default
var scrolldirection=1;
var scroll;
function newStopScroll() {
	clearInterval(scroll);
}

function newScroll(id, direction, amount) {
	div=$(id);
	div.scrollLeft += (amount*direction);
	
	if ((div.scrollWidth-div.scrollLeft==div.offsetWidth && direction > 0)  || (div.scrollLeft == 0 && direction < 0 )) {
		scrolldirection=direction*-1;
		clearInterval(scroll);
		setTimeout("newStartScroll('"+id+"',"+direction+",1);", 2000);
	}
	
}

function newStartScroll(id,direction,amount) {
	if (direction!=0) scrolldirection=direction*-1;
	if(scroll) clearInterval(scroll);
	scroll=setInterval("newScroll('"+id+"',"+scrolldirection+","+amount+");", 20);
}


sfHover = function() {
	var sfEls = document.getElementById("nav").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"), "");
		}
	}
}
if (window.attachEvent) window.attachEvent("onload", sfHover);


function detectBrowser() {
	var browser=navigator.appName;
	var version=parseFloat(navigator.appVersion.split("MSIE")[1]);
	if ((browser=="Microsoft Internet Explorer") && (version <= 6)) {
		return false;
	} else return true;
}


document.observe('dom:loaded',function(){
	if ($('scrollbar_content') && detectBrowser()) {
		var scrollbar = new Control.ScrollBar('scrollbar_content','scrollbar_track');
	}
});