function showimg(){
	$("#main_image img").css('visibility','visible');

	$("#main_image").css('height', $('#main_image img').height()+20);

	$(window).scrollTo($('#main_image'), 800, {queue:true});
	
}


$(document).ready(function(){
	var act_link = $('.portfolio_work .images li a.act');
	var link_title = act_link.attr('title');

	act_link.attr('title', '');

	$('.portfolio_work .images li a').click(function(){

		if(!$(this).hasClass('act')){

			$("#main_image").css('height', $('#main_image img').height()+20);

			$('.portfolio_work .images li a.act').attr('title', link_title).removeClass('act');
			$(this).addClass('act').attr('title','');

			$("#main_image img").css('visibility','hidden')
							.attr("src", $(this).attr('href'))
							.get(0)
							.onload = showimg;
		}

		return false;
	});

	
	$("p.full-image").each(function(){
		
		var t = $(this);
		var img = t.find("*").eq(0);
		
		if (img.attr("tagName") == "IMG" || img.attr("tagName") == "A") {
			
			img.next("br").remove();
			img.detach();
			t.contents().wrapAll("<span class='full-imagedesc' />");
			t.prepend(img);
			
		} else {
			
			t.contents().wrapAll("<span class='full-imagedesc' />");
			
		}
		
	});

	$("p.full-cut").each(function(){

		var t = $(this);
		t.contents().wrapAll("<span class='full-cut'></span>");

	});

	//var scrollLeft = (2300 - 960) / 2; //670
	var scrollLeft = 715;
	$('#full-autoprotocol-panorama').scrollLeft(scrollLeft);

});

$(window).load(function() {
	var div = $('.work__bigimage');
	if (div.length) {
		div.each(function() {
			var div = $(this);

			div.scrollLeft((div.get(0).scrollWidth - div.width()) / 2);
		});

	}
});

