// JavaScript Document
jQuery(function( $ ){		
	var urls = [ 'maternityCenter', 'primaryCareCenter2', 'committedToHealth', 'oneHundredFifteenYears' ];
	$.preload( urls, {
		base:'/imgs/slideshow/',
		ext:'.jpg',
		onComplete:function( data ){
			var img = new Image();
			img.src = data.image;
		},
		onFinish:function(){
			rotateImages(4);
		}
	});
});
var homeBanner = new Array();
homeBanner[0] = new Array();
homeBanner[0]['image'] = "/imgs/slideshow/maternityCenter.jpg";
homeBanner[0]['header'] = "Newly renovated, state-of-the-art maternity center.";
homeBanner[0]['text'] = "This fall we reintroduce our maternity center, designed with a focus on you and your family. Beautifully renovated suites offer all the comfort, amenities, and privacy of home. &nbsp;<a href=\"/clinicalservices18.cfm\">More &raquo;</a>";
homeBanner[0]['link'] = "/clinicalservices18.cfm";
homeBanner[1] = new Array();
homeBanner[1]['image'] = "/imgs/slideshow/primaryCareCenter2.jpg";
homeBanner[1]['header'] = "Primary/specialty care centers: comprehensive care close by.";
homeBanner[1]['text'] = "Our eight primary/specialty care centers are conveniently located to offer you and your whole family an extensive, seamless coordination of care. With complete access to technology on-site at the hospital, it's treatment you can trust. &nbsp;<a href=\"/specialtycarecenters.cfm\">More &raquo;</a>";
homeBanner[1]['link'] = "/specialtycarecenters.cfm";
homeBanner[2] = new Array();
homeBanner[2]['image'] = "/imgs/slideshow/committedToHealth.jpg";
homeBanner[2]['header'] = "Committed to your health<br />and wellness.";
homeBanner[2]['text'] = "Nathan Littauer Hospital and Nursing Home is second to none in providing outpatient and inpatient care to the region, combining the most progressive technology with a devoted and caring staff of experts. &nbsp;<a href=\"/about.cfm\">More &raquo;</a>";
homeBanner[2]['link'] = "/about.cfm";
homeBanner[3] = new Array();
homeBanner[3]['image'] = "/imgs/slideshow/oneHundredFifteenYears.jpg";
homeBanner[3]['header'] = "For our community, for your health&ndash;for 115 years.";
homeBanner[3]['text'] = "We’ve been proud to serve the communities of Fulton, Hamilton and Montgomery Counties, continually expanding our network of services to provide the best health care available. We are dedicated to being on the cutting-edge of technology&mdash;big city medicine right where you are. &nbsp;<a href=\"/history.cfm\">More &raquo;</a>";
homeBanner[3]['link'] = "/history.cfm";
var loopCounter = 0; var slideshowStop = 0;
function rotateImages(imagesLength) {
	if(loopCounter == (imagesLength - 1)) { loopCounter = 0; } else { loopCounter++; }
	if(slideshowStop == 1) { return false; }
	$("#homeBanner").fadeTo(7500, 1.0, function() {
		$("#homeBannerDouble > .homeBannerImage > img").attr("src", homeBanner[loopCounter]['image']);
		$("#homeBannerDouble > .homeBannerImage > img").attr("alt", homeBanner[loopCounter]['header']);
		$("#homeBannerDouble > .homeBannerText > h1 > a").html(homeBanner[loopCounter]['header']);
		$("#homeBannerDouble > .homeBannerText > h1 > a").attr("href", homeBanner[loopCounter]['link']);
		$("#homeBannerDouble > .homeBannerText > p").html(homeBanner[loopCounter]['text']);
		if(slideshowStop == 1) { return false; }
		$("#homeBanner").fadeTo(2000, 0.0, function() {
			if(slideshowStop == 1) { return false; }
			$("#item"+(loopCounter + 1)).addClass("slideshowActive");
			$("#item"+(loopCounter + 1)).siblings("a").removeClass("slideshowActive");
			if(loopCounter == (imagesLength - 1)) { loopCounter = 0; } else { loopCounter++; }
			$("#homeBanner > .homeBannerImage > img").attr("src", homeBanner[loopCounter]['image']);
			$("#homeBanner > .homeBannerImage > img").attr("alt", homeBanner[loopCounter]['header']);
			$("#homeBanner > .homeBannerText > h1 > a").html(homeBanner[loopCounter]['header']);
			$("#homeBanner > .homeBannerText > h1 > a").attr("href", homeBanner[loopCounter]['link']);
			$("#homeBanner > .homeBannerText > p").html(homeBanner[loopCounter]['text']);
			if(slideshowStop == 1) { return false; }
			$("#homeBanner").fadeTo(7500, 0.0, function() {
			if(slideshowStop == 1) { return false; }
			$("#item"+(loopCounter + 1)).addClass("slideshowActive");
			$("#item"+(loopCounter + 1)).siblings("a").removeClass("slideshowActive");
				if(slideshowStop == 1) { return false; }
				$("#homeBanner").fadeTo(2000, 1.0, function() { if(slideshowStop == 1) { return false; } rotateImages(imagesLength); });
			});
		});
	});
}
$(document).ready(function() {
	$(".homeBannerNav").removeClass("noShow");
	$("#homeBanner > .homeBannerImage > img").attr("src", homeBanner[0]['image']);
	$("#homeBanner > .homeBannerImage > img").attr("alt", homeBanner[0]['header']);
	$("#homeBanner > .homeBannerText > h1 > a").html(homeBanner[0]['header']);
	$("#homeBanner > .homeBannerText > h1 > a").attr("href", homeBanner[0]['link']);
	$("#homeBanner > .homeBannerText > p").html(homeBanner[0]['text']);
	$("a.slideshow").click(function() {
		slideshowStop = 1;
		$(this).addClass("slideshowActive");
		$(this).siblings("a").removeClass("slideshowActive");
		var selectedItem = $(this).attr("id").substr(4);
		selectedItem = selectedItem - 1;
		if($("#homeBanner").css("opacity") == 1) {
			$("#homeBanner > .homeBannerImage > img").attr("src", homeBanner[selectedItem]['image']);
			$("#homeBanner > .homeBannerImage > img").attr("alt", homeBanner[selectedItem]['header']);
			$("#homeBanner > .homeBannerText > h1 > a").html(homeBanner[selectedItem]['header']);
			$("#homeBanner > .homeBannerText > p").html(homeBanner[selectedItem]['text']);
		}
		else {
			$("#homeBannerDouble").css("z-index", "12");
			$("#homeBannerDouble > .homeBannerImage > img").attr("src", homeBanner[selectedItem]['image']);
			$("#homeBannerDouble > .homeBannerImage > img").attr("alt", homeBanner[selectedItem]['header']);
			$("#homeBannerDouble > .homeBannerText > h1 > a").html(homeBanner[selectedItem]['header']);
			$("#homeBannerDouble > .homeBannerText > p").html(homeBanner[selectedItem]['text']);
		}
		return false;
	});
});