jQuery(document).ready(function() {
	$(document).ready(function(){
		$('#showHide a')
		.unbind('click')
		.bind('click',function(){
			if($(this).attr('onoff')=='off'){
				$(this).attr('onoff','on');
				$(this).parent().find("#display").show('slow')
				.animate({opacity: 1.0}, 2000);
				$(this).addClass('open');
			}else{
				$(this).attr('onoff','off');
				$(this).parent().find("#display").hide('slow')
					.animate({opacity: 0}, 2000);
				$(this).removeClass('open');
			}
		});
		$('#deleterowbutton')
			.unbind('click')
			.bind('click', function(e){		
				e.preventDefault();
				$('#uploadedFilesBlock').hide();
				//Отправляем запрос скрипту и удаляем файлы
					$.ajax({
						url: "/scripts/deleteUploadFiles.php",
						global: false,
						type: "POST",
						data: ({}),
						dataType: "html",
						success: function(html){
							//alert(html);
						}
					}
				);
			});
		var count=0;
		$('.middle_box li').each(function(){
			count++;
		});
		if(count<=3){
			$('.ar_top').hide();
			$('.ar_bot').hide();
			$('.ar_right').hide();
			$('.ar_left').hide();
		}
		
		$('.menu-left_mid li:last').addClass('last');
		var src, title, photodescription, download;
		src = $('.middle_box li:first img').attr('realname');
		realpath = $('.middle_box li:first img').attr('realpath');
		src = realpath+'med/'+src;
		alt = $('.middle_box li:first img').attr('alt');
		photodescription = $('.middle_box li:first img').attr('photodescription');
		download = realpath+'real/'+$('.middle_box li:first img').attr('realname');
		downloadhtml = '<a href="'+download+'" target="_blank" style="color: red;">Скачать оригинал</a>'
		$(".b-photogal .viewer img").attr("src", src);
		$(".b-photogal .viewer img").attr("alt", alt);
		
		
		$(".b-photogal2 .viewer img").attr("src", src);
		$(".b-photogal2 .viewer img").attr("alt", alt);
		$(".photodescription").html(photodescription);
		$(".download").html(downloadhtml);
		
	});
});