jQuery(document).ready(function() {
		
		// Main page slideshow
		if (jQuery(".slideshow").size())
		{
			if (fade_interval < 250) fade_interval = 250;
			//jQuery(".slideshow-wrapper .current").fadeTo(0, 
			setInterval(function() {
					/*jQuery(".slideshow-wrapper").animate({marginLeft: -940}, 1000, function() {
							jQuery(this).css({marginLeft: 0});
							jQuery(".slideshow-wrapper img:first").appendTo(jQuery(".slideshow-wrapper"));
						});*/
					var items = jQuery(".slideshow-wrapper img");
					var curr = items.index(jQuery(".slideshow-wrapper .current"));
					curr++;
					if (curr >= items.size()) curr = 0;
					var curr_item = jQuery(".slideshow-wrapper .current");
					var next_item = items.eq(curr);
					
					next_item.addClass('current').fadeIn(1000, "linear");
					setTimeout(function() {
							curr_item.removeClass('current').fadeOut(1000, "linear");
						}, 200);
				}, fade_interval);
		}
		
		// Project details page photos
		jQuery(".project-wrapper .project-right .previews img").click(function() {
				if (jQuery(this).hasClass("current")) return false;
				var current_img = this;
				var img = jQuery('<img src="' + jQuery(this).next().html() + '" align="right" alt="" />').css({position: 'absolute', top: -10000, left: -10000, width: 100, height: 100}).bind("load error", function() {
						jQuery(".big-image-container img").fadeOut(300, function() {
								jQuery(this).parent().css({height: img.height() > jQuery(this).height() ? img.height() : jQuery(this).height()});
								jQuery(this).remove();
								img.fadeTo(0, .01).hide();
								jQuery(".big-image-container").append(img);
								img.css({position: 'static', width: 'auto', height: 'auto'}).show().fadeTo(300, 1, function() {
										jQuery(this).parent().css({height: img.height()});
									});
								jQuery(".project-wrapper .project-right .previews img.current").removeClass("current");
								jQuery(current_img).addClass("current");
							});
					}).appendTo("body");
			});
		jQuery(".project-wrapper .project-right .previews img:first").addClass("current");
		jQuery(".big-image-container img").bind("load error", function() {
				jQuery(this).parent().css({height: jQuery(this).height()});
			});
		
	});
