jQuery.preloadImages = function()
{
  for(var i = 0; i<arguments.length; i++)
  {
    jQuery("<img>").attr("src", arguments[i]);
  }
}

$.preloadImages("http://doeringphoto.com/helper/buttons/info.gif", "http://doeringphoto.com/helper/buttons/infohov.gif", "http://doeringphoto.com/helper/buttons/frankon.gif", "http://doeringphoto.com/helper/buttons/abouton.gif", "http://doeringphoto.com/helper/buttons/commissionson.gif", "http://doeringphoto.com/helper/buttons/appearanceon.gif", "http://doeringphoto.com/helper/buttons/printson.gif", "http://doeringphoto.com/helper/buttons/contacton.gif", "http://doeringphoto.com/helper/buttons/coalscapeson.gif", "http://doeringphoto.com/helper/buttons/citieson.gif", "http://doeringphoto.com/helper/buttons/powerplanton.gif", "http://doeringphoto.com/helper/buttons/berlinon.gif", "http://doeringphoto.com/helper/buttons/portraitson.gif", "http://doeringphoto.com/helper/buttons/botanicaon.gif", "http://doeringphoto.com/helper/buttons/seestueckeon.gif", "http://doeringphoto.com/helper/buttons/rtuon.gif",  "http://doeringphoto.com/helper/buttons/pinholeon.gif", "http://doeringphoto.com/helper/buttons/cemeterieson.gif", "http://doeringphoto.com/helper/buttons/berlingraffition.gif", "http://doeringphoto.com/helper/buttons/montgraffition.gif", "http://doeringphoto.com/helper/buttons/hveton.gif", "http://doeringphoto.com/helper/buttons/saveton.gif", "http://doeringphoto.com/helper/buttons/icestormon.gif",  "http://doeringphoto.com/helper/buttons/veniceon.gif",  "http://doeringphoto.com/helper/buttons/ballon.gif", "http://doeringphoto.com/helper/buttons/marsalison.gif", "http://doeringphoto.com/helper/buttons/kentuckyon.gif");

function hovereffect (foo) {
	$('img[alt = "' + foo + '"]').hover(
		function() { // Hover on
			$('img[alt = "' + foo + '"]').stop().fadeTo(0, 0);
			},
		function() { // Hover off
			$('img[alt = "' + foo + '"]').stop().fadeTo(400, 1);
			}
	);
	}


$(document).ready(function() { 

	$('img').mousedown(
		function() { // click on
			$(this).stop().fadeTo(0, 1);
		},
		function() { // click off
			$(this).stop().fadeTo(30, 0);
	});

	$('#navigation img').each(function(){		//joint rollover effect for buttons with the same alt attribute
		hovereffect('"' + $(this).attr('alt') + '"');
	});			


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

});


		

$(document).ready(function(){
	$('.cboxSlideshow_on #cboxSlideshow').live('click', $.fn.colorbox.next); //advances slideshow to next image on start
	$("a[rel='photo']").colorbox({slideshow:true, slideshowAuto:false});
	$(".info").colorbox({width:700, height:"90%", iframe:true});
});

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