jQuery(function () {

	// Preload all rollovers
	jQuery("#nav img, .roll").each(function(){
		// Set the original src
		rollsrc = jQuery(this).attr("src");
		rollON = rollsrc.replace(".gif","_on.gif");
		jQuery("<img>").attr("src", rollON);
	});
	// Navigation rollovers
	jQuery("#nav img, .roll").mouseover(function(){
		imgsrc = jQuery(this).attr("src");
		matches = imgsrc.match(/_on/);
		// don't do the rollover if state is already ON
		if (!matches) {
			imgsrcON = imgsrc.replace(".gif","_on.gif"); // strip off extension
			jQuery(this).attr("src", imgsrcON);
		}
		
	});
	jQuery("#nav img, .roll").mouseout(function(){
		jQuery(this).attr("src", imgsrc);
	});
	// 
	// $("ol li").each(function (index) {
	//                     $(this).wrapInner("<span>&nbsp;<span />");
	//                 });
	//                 $("ol").css("font-weight", "bold");
	//                 $("ol li span").css("font-weight", "normal");
	
	var slider = $('#slider1').bxSlider({auto: true, pause: 7000, 
		
			  onAfterSlide: function(currentSlide){
			    $('.thumbs a').removeClass('pager-active');
			    $('.thumbs a').eq(currentSlide).addClass('pager-active');
			  }
		
		});

	        $('.thumbs a').click(function(){
	            var thumbIndex = $('.thumbs a').index(this);
	            slider.goToSlide(thumbIndex);
	            $('.thumbs a').removeClass('pager-active');
	            $(this).addClass('pager-active');
	            return false;
	        });

	        $('.thumbs a:first').addClass('pager-active');
	
	$('.clickable').bind('click', function() {
		window.location = $(this).attr("data-href");
		return false;
	});
	
	jQuery(".click-link").click(function(){
		window.location = jQuery(this).attr("data-href");
	});
	
	jQuery(".year").live('click', function() {
		jQuery('.year_text').removeClass('bold');
		jQuery(this).find('.year_text').addClass("bold");
		jQuery('.months').hide();
		jQuery(this).find('.months').toggle();
	});
	
	jQuery("li.year").each(function(){
		var windowPath = window.location.pathname;
		var dataYear = jQuery(this).attr('data-year');

		if(windowPath.indexOf(dataYear) >= 0){
			jQuery(this).find('.months').show();
			jQuery(this).find('.year_text').addClass("bold");
		};
		
	});
	
	jQuery(".archive-month").each(function(){
		var windowPath = window.location.pathname;
		var dataYearMonth = jQuery(this).attr('data-year-month');

		if(windowPath.indexOf(dataYearMonth) >= 0){
			jQuery(this).addClass("bold");
		};
		
	});
	
	jQuery("#nav img").each(function(){
		navSrc = jQuery(this).attr("src");
		navOn = navSrc.replace(".gif","_on.gif");
		
		if (jQuery(this).attr('href')==window.location.pathname){
			jQuery(this).attr("src", navOn);
		}
		
	});
	
});
