$(document).ready(function() {
  
  
// ER Wait - pub date in foot
  jQuery('.ehc-er-wait-wrap-header .ehc-er-facility-select').change(function() {  
    var pub_date = jQuery('.ehc-er-wait-wrap-header .ehc-er-pubdate').html();
    jQuery('.ehc-er-wait-wrap-footer .ehc-er-pubdate').html(pub_date).show();
  });

  
  
//er wait time 'mins' to 'min'
  
jQuery('.er-wait-time span.time').each(function(){
  var er_time = jQuery(this).text();
  jQuery(this).html(er_time.replace('Mins','<span>min</span>'));
});
  

  // dropdown nav
  $('#nav-main ul').superfish({ 
    delay:       1000,                            // one second delay on mouseout 
    animation:   {opacity:'show',height:'show'},  // fade-in and slide-down animation 
    speed:       'fast',                          // faster animation speed 
    autoArrows:  true,                           // disable generation of arrow mark-up 
    dropShadows: true                            // disable drop shadows 
  });

  // Events and News tabs
  $('#home #content-sub1').tabs();

  // Cycle the home tabs
  $('#promo-tabs-container') 
  .after('<ul id="promo-tabs-selectors">') 
  .cycle({ 
    cleartype:  1, 
    timeout: 8000, 
    effect: 'fade',
    speed: 500,
    pause: true,
    pager:  '#promo-tabs-selectors',
    pagerEvent:   'click',
    pagerAnchorBuilder: function(idx, slide) { 
      return '<li class="' + jQuery(slide).attr("id") + ' "><a href="#"><span class="wrap">' + jQuery(slide).find("div.tab-text").html() + '</span><span class="extra"></span></a></li>'; 
    }
  });
  $('#promo ul').hover(function(){
    $('#promo-tabs-container').cycle("pause");
  }, function(){
    $('#promo-tabs-container').cycle("resume");
  });

  // Map tooltip
  $('#map a.tooltip').tooltip({ 
    bodyHandler: function() { 
      return $(this).children('span').html(); 
    }, 
    fade: 250,
    positionLeft: false,
    track: true,
    showURL: false 
  });

  // Call Center Form tooltip
  $('#callCenterForm label.tooltip').tooltip({ 
    bodyHandler: function() { 
      return $(this).children('span').html(); 
    }, 
    fade: 250,
    positionLeft: false,
    track: true,
    showURL: false,
    extraClass: "class-description" 
  });

  // Equal Heights
  function equalHeight(group) { 
    tallest = 0;
    group.each(function() {
      thisHeight = $(this).height();
      if(thisHeight > tallest) {
        tallest = thisHeight;
      }
    });
    group.height(tallest);
  }
  
  equalHeight($(".column"));

});


  // Cycle the home tabs
  $('#promo-tabs-container') 
  .after('<ul id="promo-tabs-selectors">') 
  .cycle({ 
    cleartype:  1, 
    timeout: 8000, 
    effect: 'fade',
    speed: 500,
    pause: true,
    pager:  '#promo-tabs-selectors',
    pagerEvent:   'click',
      pagerAnchorBuilder: function(idx, slide) { 
          return '<li class="' + jQuery(slide).attr("id") + ' "><a href="#"><span class="wrap">' + jQuery(slide).find("div.tab-text").html() + '</span><span class="extra"></span></a></li>'; 
      }
  });
  $('#promo ul').hover(function(){
    $('#promo-tabs-container').cycle("pause");
  }, function(){
    $('#promo-tabs-container').cycle("resume");
  });

