$(document).ready(function(){
// create accordion
$('.day').accordion({ header: 'a.header',  active: false, collapsible: true   });	// event: 'mouseover' 

// date nav scroll on click
$('#nav li a').click(function(){
  	if ($.browser.msie && $.browser.version < 7) return;
	var linkclass = $(this).parent().attr('class').split('-').slice(0,1);

	$.scrollTo( '#' + linkclass, 800,  { offset:-359 } );

	return false;
	});	

$('#about a.more-link').click(function(){
  	if ($.browser.msie && $.browser.version < 7) return;
	$('html,body').stop();
	$.scrollTo( '#more-expanded', 800,  { offset:-359 } );
	});	

$('.contact-link a').click(function(){
  	if ($.browser.msie && $.browser.version < 7) return;
	$('html,body').stop();
	$.scrollTo( '#contact-expanded', 800,  { offset:-359 } );
	});	

// date nav change on hover
// this is mostly c/- http://jqueryfordesigners.com/image-fade-revisited/ - big ups
$('#nav li').find('a').prepend('<span class="nav-hover"></span>').each(function () {
      // ie <=8 + alpha pngs + opacity = sadness
  	  if ($.browser.msie && $.browser.version < 9) return;

 	   // disable css :hover 
       $(this).parent().parent().removeClass('nojs');
	
      // cache a copy of the span, at the same time changing the opacity
      // to zero in preparation of the page being loaded
      var $span = $('> span.nav-hover', this).css('opacity', 0);
      
      // when the user hovers in and out of the anchor
      $(this).hover(function () {
        // on hover					
      	$(this).css("cursor","pointer");
        // stop any animations currently running, and fade to opacity: 1
        $span.stop().fadeTo(500, 1);
      }, function () {
        // off hover

      	$(this).css("cursor","pointer");
        
        // again, stop any animations currently running, and fade out
        $span.stop().fadeTo(500, 0);
      });
    });


// day show spike on hover
$('.day').hover(function () {
	// ie <=8 + alpha pngs + opacity = sadness
  	if ($.browser.msie && $.browser.version < 9) return;
    
	var dayid = $(this).attr('id');
    $('#' + dayid + ' .spike').fadeIn("normal");
      }, function () {                     
		var dayid = $(this).attr('id');
	    $('#' + dayid + ' .spike').fadeOut("slow");
      }
    );


	// event title change on hover
	// this is mostly c/- http://jqueryfordesigners.com/image-fade-revisited/ - big ups
	$('.vevent').find('a.header').addClass('nojq').prepend('<span class="event-hover"></span>').each(function () {
	      // ie <=8 + alpha pngs + opacity = sadness
	  	  if ($.browser.msie && $.browser.version < 9) return;

	 	   // disable css :hover 
	       $(this).removeClass('nojq');

	      // cache a copy of the span, at the same time changing the opacity
	      // to zero in preparation of the page being loaded
	      var $span = $('> span.event-hover', this).css('opacity', 0);

	      // when the user hovers in and out of the anchor
	      $(this).hover(function () {
	        // on hover					

	        // stop any animations currently running, and fade to opacity: 1
	        $span.stop().fadeTo(250, 1);
	      }, function () {
	        // off hover

	        // again, stop any animations currently running, and fade out
	        $span.stop().fadeTo(250, 0);
	      });
	    });


});

