function rotateHome() {
		var currentImage = $("div#main img.current");
		var nextImage = currentImage.next();
		if (nextImage.length == 0) {
			nextImage = $("div#main img:first");
		}
		
		nextImage.css({ opacity : 0.0 }).addClass("current").animate({ opacity: 1.0 }, 2000,
			function() {
				currentImage.removeClass("current");
			});
	}

$(document).ready(function() {
	
	setInterval("rotateHome()", 6000);
	
	var scrollUpButton = $('img#upArrow');
	var scrollDownButton = $('img#downArrow');
	var nameList = $('div.scroller ul');
	var window = $('div.scroller div.window');
	var profile = $('div.widget.all_doctors div.profile');
	
	var names = $('div.scroller ul li a');
		
	
	names.click(function(){
		$.get(
			'/providers/basic/' + $(this).attr('class'), 
			null,
			function(data)
			{
				profile.html(data)
			}
		);
	});
	
	
	scrollDownButton.click(function()
	{
		
		
		if(nameList.filter(':animated').size())
		{
			nameList.stop(true, true);
		}
		
		var shift = window.height();
		var height = nameList.height();
		var top = nameList.position().top;
		
		top = top - shift;
		if(top < -height + shift)
		{
			top = -height + shift;
		}

		nameList.animate({'top' : top}, 300, 'swing');
	});
	
	scrollUpButton.click(function()
	{
	
		if(nameList.filter(':animated').size())
		{
			nameList.stop(true,true);
		}

		var shift = window.height();
		var top = nameList.position().top;
			
		top = top + shift;
		if(top > 0)
		{
			top = 0;
		}
		
		nameList.animate({'top' : top}, 300, 'swing');
	});
	
	
});
