//  BREADCRUMBS

	/*  Add <span> around breadcrumb links  */
		$(document).ready(function(){
			
			if ($("#insidePage").length) {
			
				$("#breadcrumbs a.selectedPageRoot, #breadcrumbs a.selectedPageParent").wrap(document.createElement("span"));
			
			}
		});
	
	/*  Add hover effect for breadcrumbs  */
		$(document).ready(function(){
			
			if ($("#insidePage").length) {
			
				$("#breadcrumbs span").hover(
					function () {
						$(this).addClass("sfhover");
					}, 
					function () {
						$(this).removeClass("sfhover");
					}
				);
			
			}
		});


//  AUTO SECTION TITLE

		$(document).ready(function(){
			
			if ($("#insidePage").length) {
				
				if ($("#breadcrumbs a.selectedPageParent").length) {
				
					var autoSectionTitle = $("#breadcrumbs a.selectedPageParent:last").text();
				
				} else {
				
					var myDiv = $("#breadcrumbs .bc").clone(); 	
  						myDiv.children("span").remove();
  					var	autoSectionTitle = $.trim(myDiv.text());
  						myDiv.remove();
				}

				$("#sectionTitle h3").replaceWith("<h3>" + autoSectionTitle + "</h3>");
			}
			
		});


//  SWAP OUT ADMIN BUTTONS
	$(document).ready(function(){
	
		if ($("#adminbar").length) {
			
			/*  page settings btn  */
				$("#pagebar img[src='/images/edit_16.gif']").attr("src", "/Websites/aaronhartmanmd/templates/aaronhartmanmd/images/system/settingsBtn16.png");
				
			/*  add page btn  */
				$("#pagebar img[src='/images/add_16.gif']").attr("src", "/Websites/aaronhartmanmd/templates/aaronhartmanmd/images/system/addBtn16.png");
		}
	});


//  HOME PAGE ADJUSTMENTS IN ADMIN MODE
	$(document).ready(function(){
		
		if ($("#homePage").length) {
		
		/*  Admin Mode  */	
			if ($("#adminbar").length) {

				$("#topPanel .column2").css({"overflow" : "visible", "height" : "auto"});
				$("body#homePage #bottomPanel .column1 h3").css({"margin-top" : "0"});
			}
			
		/*  Preview Mode  */	
			if ($("#toolbar").length) {
			
				$("#topPanel .column1").css({"height" : "auto"});
			}
		}
	});


//  HOME SLIDESHOW
	function homeSlideshow(currentPhoto) {
		var numberOfPhotos = $("#homeSlideshow .element").length;
			currentPhoto = currentPhoto % numberOfPhotos;
		var previousPhoto = 0;
			if (currentPhoto == 0) {
				previousPhoto = numberOfPhotos - 1;
			} else {
				previousPhoto = currentPhoto - 1;
			}
		
		$("#homeSlideshow .element").eq(currentPhoto)
			.fadeIn(1800, "easeOutQuad", function() {
				
				/*  hide previousPhoto  */
					$("#homeSlideshow .element").eq(previousPhoto).hide();
				
				/*  re-order z-index  */
					$("#homeSlideshow .element").each(function(i) {
						$(this).css("zIndex", ((numberOfPhotos - i) + currentPhoto) % numberOfPhotos);
					});
	
				setTimeout(function() {homeSlideshow(++currentPhoto);}, 6000);
			});
	}
	
	$(document).ready(function() {	
		/*  All .element(s) must have position:relative in admin mode  */
			if ($('#adminbar').length) {
				$("#homeSlideshow .element").css({"position" : "relative", "display" : "block"});
			} else {
				/*  animate  */
					homeSlideshow(0);
			}
	});
	
//  RANDOMIZE FEATURED DOCTOR
	$(document).ready(function() {
		var numberOfDocs = $('#featuredPhysicianImage .element').length;
		var randomDoc = Math.floor(Math.random() * numberOfDocs);
		
		$('#featuredPhysicianImage .element').hide();
		$('#featuredPhysicianImage .element').eq(randomDoc).show();
		$('#featuredPhysicianInfo .element').hide();
		$('#featuredPhysicianInfo .element').eq(randomDoc).show();
	});
	

