$(document).ready(function(){
	
	// relative path based on where these images are viewed, not this file
	$.imgpreload(['img/home/meet-the-dentists-1.jpg','img/home/meet-the-dentists-2.jpg','img/home/meet-the-dentists-3.jpg','img/home/meet-the-dentists-4.jpg','img/home/meet-the-dentists-5.jpg'],
	{
		all: function()
		{
			// start slider
			/* $("#slider").easySlider({
				speed: 800,
				pause: 3200,
				auto: true, 
				continuous: true,
				controlsShow: false
			}); */
			
			// fade dentist photos instead of sliding
			initialDentistAnimation();
			ourDentistClick();
		}
	});
	
	randomizeFocusArea();
	
});

function initialDentistAnimation()
{
	$("ul#dentistPhotos li:eq(0)")
		.css({opacity: 0})
		.show()
		.animate(
			{opacity: 1},
			{
				duration: 750,
				easing: 'easeInSine',
				complete: function()
				{
					automateDentistPhotos();
				}
			}
		);
}


function photoTransition()
{
	$("ul#dentistPhotos li").fadeOut(1000);
	$("ul#dentistPhotos li:eq(" + current_photo + ")").fadeIn(1500);
}


function rotateDentistPhotos()
{
	if ( current_photo == photo_count_less_one )
	{
		current_photo = 0;
		photoTransition();
	}
	else
	{
		current_photo++;
		photoTransition();
	}
}

function automateDentistPhotos()
{
	rotating = setInterval("rotateDentistPhotos();", 3000);
	photo_count = $("ul#dentistPhotos li").length;
	photo_count_less_one = photo_count - 1;
	current_photo = 0;
}







function randomizeFocusArea()
{
	var focusDisplay = Math.floor(Math.random()*3) + 1;
	$("div#contentFocus div:nth-child(" + focusDisplay + ")").show();
}

function ourDentistClick()
{
	
	// add click to entire meetOurDentists focus area
	$("div#meetOurDentists").click(function(){
		window.location = "our-dentists/index.asp";
	});
	$("div#meetOurDentists").hover(
		function(){
		 $(this).find("a").css({ backgroundPosition: "0px -48px" });
		},
		function(){
		 $(this).find("a").css({ backgroundPosition: "0px 0px" });
		}
	);	
}
