$(document).ready(function()
{
	var delay = 50;
	var delta = 8;
	if($.browser.msie){
		delay = 34;
		delta = 10;
	}
	
	$("div#topSlider").mouseover(function(e){
		$(this).attr("topScrollInterval", setInterval(doScrollTop, delay));
	});
	
	$("div#topSlider").mouseleave(function(e){
		clearInterval($(this).attr("topScrollInterval"));
	});
	
	$("div#bottomSlider").mouseover(function(e){
		$(this).attr("bottomScrollInterval", setInterval(doScrollBottom, delay));
	});
	
	$("div#bottomSlider").mouseleave(function(e){
		clearInterval($(this).attr("bottomScrollInterval"));
	});
	
	// The function that does the actual scrolling top
	var doScrollTop = function()
	{	
		var currentTop = $("div#brandCont").scrollTop();
		
		currentTop -= 10;
		
		if (currentTop < 0){
			currentTop = 0;
			//$("div#topSlider").css("visibility", "hidden");
		}
		//$("div#bottomSlider").css("visibility", "visible");
		
		$("div#brandCont").scrollTop(currentTop);
	};
	
	// The function that does the actual scrolling bottom
	var doScrollBottom = function()
	{
		var currentTop = $("div#brandCont").scrollTop();
		currentTop += 10;
		
		var listingHeight = $("ul.sc_menu").height();
		var wrapperHeight = $("div#brandCont").height();
		var inactiveMargins = 99;
		var scrollableHeight = listingHeight - wrapperHeight; 
		
		if(currentTop >= scrollableHeight){
			currentTop = scrollableHeight;
			//$("div#bottomSlider").css("visibility", "hidden");
		}
		
		//$("div#topSlider").css("visibility", "visible");
		
		$("div#brandCont").scrollTop(currentTop);
	};
});
