// Slideshows on landing pages

$(document).ready(function(){
  // Reparent so slideshow will work
  if ( $('.boxgrid.caption').size() ) {
    $('.panel-col-top').append($('<div class="slideshow"></div>'));
  }
  $('.panel-col-top .slideshow').append($('.boxgrid.caption'));
  // Set top of each section
  $('.boxgrid.caption').each(function(){
    var boxgrid = $(this);
    var cover = $('.cover', boxgrid);
    var hidden_height = 350 - $('h3', cover).outerHeight() - 14 + 'px';
    var exposed_height = 350 - cover.outerHeight() + 'px';
    
    cover.css({top: hidden_height });
		boxgrid.hover(function(){
			cover.stop().animate({top: exposed_height },{queue:false,duration:160});
		}, function() {
			cover.stop().animate({top: hidden_height },{queue:false,duration:160});
		});
    
  });
  $('.panel-col-top .slideshow').cycle({
    fx: 'fade',
    timeout: 7 * 1000,
    pause: 1
  });
  
  $('#banners').append('<div id="tower_ad" style="position: absolute;"></div>');
  $('#tower_ad').append($('#tower-banner-slideshow'));
  //if (jQuery.browser.msie) { $('#top-banner-slideshow').css({'top': '-100px'}) }
  
  $('#top-banner-slideshow').cycle({
    fx: 'fade',
    timeout: 4 * 1000
  });
  $('#right-banner-slideshow').cycle({
    fx: 'fade',
    timeout: 4 * 1000
  });
  $('.boxgrid.caption').css({ visibility: 'visible' });
  $('.slideshow').css({ visibility: 'visible' });
  $('#top-banner-slideshow, #right-banner-slideshow').css({ visibility: 'visible' });
  
  // Keep filters when selecting a date
  $('#menu-event-times a').each(function () {
    this.href = this.href + document.location.search;
  });
  
});

