$(function() {

    $('#nav li').hover(function() {
        $(this).addClass('hover');
    }, function() {
        $(this).removeClass('hover');
    });

	$('input').each(function() { $(this).addClass(this.type); });
	$('.flash').css({visibility: 'visible', opacity: 0}).animate({opacity: 1});

	$('#news p').hide();
	$('#news h2').click(function() {
		$('+ p', this).slideToggle();
	});
	
	$('a.shoot-shove-shame').attr('target', '_blank');

});

$(window).load(function() { 
	
	$('.scrollable').scroller();
	
    var curr = 0, slides = $('#image-list .scrollable a');
        
    slides.click(function() {
      var newImage = $('img', this).attr('src').replace('thumb', 'large');
      $('#main-image').css('backgroundImage', 'url(' + newImage + ')');
      $('#caption').html($('img', this).attr('alt') || '');
      curr = slides.index(this);
      return false;
    });
    
    $('#gallery .prev').click(function() {
      var prev = curr - 1;
      if (prev < 0) prev = slides.length - 1;
      $('#image-list a:eq(' + prev + ')').click();
      return false;
    });
    
    $('#gallery .next').click(function() {
      var next = curr + 1;
      if (next == slides.length) next = 0;
      $('#image-list a:eq(' + next + ')').click();
      return false;
    });
    
});