﻿var timer;
var slides = new Array();

// You can have as many slides as you want -- just add to the end of the array.
//slides    FILENAME  ALT URL
slides[0] = ["/portals/48/skinrelated/images/homeSlide01.jpg", "Healthy 100. What do you want to do when you're 100", "http://www.healthy100.org"];
slides[1] = ["/portals/48/skinrelated/images/homeSlide02.jpg", "Florida Hospital Nationally Ranked as One of the Best Hospitals", "/News/tabid/6696/articleType/ArticleView/articleId/8158/Florida-Hospital-Nationally-Ranked-as-One-of-the-Best-Hospitals.aspx"];
slides[2] = ["/portals/48/skinrelated/images/homeSlide03.jpg", "SHARE YOUR STORY. Discover stories of hope, health, and healing at Florida Hospital.", "/AboutUs/Mission/OurStories.aspx"];
slides[3] = ["/portals/48/skinrelated/images/homeSlide04.jpg", "2010 Sterling Award Winner. Florida Hospital Receives Prestigious Governor's Streling Award for Performance Excellence.", "http://www.floridahospital.com/AboutUs/SterlingAward.aspx"];



function getCurrentSlide() {

  var obj = document.getElementById("hdnSlideIndex");
  return parseInt(obj.value);

}

function saveCurrentSlide(slideIndex) {

  var obj = document.getElementById("hdnSlideIndex");
  obj.value = slideIndex;

}

function NextSlide() {

  ChangeSlide(getCurrentSlide() + 1);

}

function ChangeSlide(newSlideIndex) {

  clearTimeout(timer);

  if (newSlideIndex >= slides.length || newSlideIndex < 0) {
    newSlideIndex = 0;
  }

  jQuery("#mainBody").css("background", "none");
  jQuery("#main-body-bg").fadeOut("slow", function() {
    jQuery("#main-body-bg").css("background", "url(" + slides[newSlideIndex][0] + ") no-repeat top left");
    jQuery("#main-body-bg").fadeIn("slow");
  });

  SetSlideLink(newSlideIndex);

  saveCurrentSlide(newSlideIndex);

  timer = setTimeout("NextSlide()", 7000);

}

function SetSlideLink(slideIndex) {

  if (slideIndex >= slides.length || slideIndex < 0) {
    slideIndex = 0;
  }

  jQuery("#slideOverlay").attr("alt", slides[slideIndex][1]);
  jQuery("#image-map-learnmore").attr("href", slides[slideIndex][2]);

}

jQuery(document).ready(function() {

  jQuery(document).pngFix();
  
  SetSlideLink(0);
  timer = setTimeout("NextSlide()", 7000);

});

