/* fix IE background image flicker */
try { document.execCommand("BackgroundImageCache", false, true); } catch(err) {}

document.cookie = "tz="+(new Date()).getTimezoneOffset()+"; path=/";

intervalLength = 5000;
exhibitionIndex = 0;

$(document).ready(function() {
  
  $('.nyroModal').nyroModal({type: 'image'});
  
  $('li.nav_tab').hover(
    function()  {
      $(this).children('a').addClass('active').siblings('div').show();
    },
    function()  {
      $(this).children('a').removeClass('active').siblings('div').hide();
  });
  
  $('#display_full_bio').click(function() {
    toggleBio("#hide_full_bio");
  });
  
  $('#hide_full_bio').click(function() {
    toggleBio("#display_full_bio");
  });
  
  $('dt.text_editor').click(function() {
    $(this).toggleClass('open').next('dd').toggle();
  });
  
  $("#search input#q").focus(function () {
    $(this).val('');
  });
  $("#search input#q").blur(function () {
    $(this).val('Search');
  });
  
});

function toggleBio(clicked) {
  $('#full_biography').toggle();
  $('#hide_full_bio').toggle()
  $('#display_full_bio').toggle();
  $(clicked).css('display', 'block');
}

function exhibitionTransition(i1, i2) {
  $(featuredExhibitions[i1]).fadeOut("slow");
  $(featuredExhibitions[i2]).fadeIn("slow");
  $(selectExhibitions[i1]).removeClass("active");
  $(selectExhibitions[i2]).addClass("active");
}

function switchToExhibition(newIndex) {
  if(newIndex != exhibitionIndex) {
    exhibitionTransition(exhibitionIndex, newIndex);
  }    
  clearInterval(exhibitionInterval);
  exhibitionIndex = newIndex;
}

function nextExhibition() {
  prevIndex = exhibitionIndex;
  exhibitionIndex < selectExhibitions.length - 1 ? exhibitionIndex += 1 : exhibitionIndex = 0;
  exhibitionTransition(prevIndex, exhibitionIndex);
}
