function updateImageSize() {//serves small pictures to small screens and updates every 10 seconds
	var viewportHeight = window.innerHeight ? window.innerHeight : $(window).height();
	if (viewportHeight < 500) {
			$('#thumbnails a').each(function(){
				this.href = this.href.replace('_lg', '_md');  
			});
	} else {
			$('#thumbnails a').each(function(){
				this.href = this.href.replace('_md', '_lg');  
			});
	};  
	setTimeout("updateImageSize()", 10000);
}

$(document).ready(function() { 

	updateImageSize();

	$(function(){
		var $container = $('#thumbnails');
		$container.imagesLoaded( function(){
			$container.masonry({
				itemSelector : '.item',
				columnWidth : 194,
			});
		});
	});

	$('#content a img').hover(
		function() { // Hover on
			$(this).stop().fadeTo(0, 0);
			},
		function() { // Hover off
			$(this).stop().fadeTo(500, 1);
			}
	);

	$('#content a img').mousedown(function() {
			$(this).stop().fadeTo(0, 1);
	});

	$('.cboxSlideshow_on #cboxSlideshow').live('click', $.fn.colorbox.next); //advances slideshow to next image on start
	$('a.photo').colorbox({rel:'photo', slideshow:true, slideshowAuto:false}); //rel is needed for the colorbox slideshow to work
	$(".info").colorbox({width:700, height:"90%", iframe:true});
	$(".weblink").colorbox({width:"94%", height:"90%", iframe:true});
	$('.inline-anchor').colorbox({width:600, inline:true});

	if(navigator.userAgent.match(/Mobile/i) && navigator.userAgent.match(/Safari/i)){
		$(document).bind('cbox_open, cbox_complete', function(){
			$('#cboxOverlay').css({width:$(document).width(),
				height:$(document).height(), position:'absolute'});
		});
	}; //This makes the overlay cover the entire page on the iPad

	
});

