$(document).ready(function(){
	
	// Все малые фото должны быть залиты по адресу: http://kanalizaciya.com//userfiles/images/Otzivi/small/dzhol.jpg
	
	// Все увеличенные фото должны быть залиты по адресу: http://kanalizaciya.com/userfiles/images/Otzivi/big/dzhol.jpg и иметь такое же имя как и малые фото
	$("#thanksBack").css("opacity","0.6");
	$(".thanksTable tr td img").click(function(){
		srcSmall = $(this).attr("src");
		sed = srcSmall.split("/");
		sedLength = sed.length - 1;
		imgName = sed[sedLength];
		newAdress = "http://kanalizaciya.com/userfiles/images/Otzivi/big/" + imgName;
		$("#thanksWrapper img").attr("src",newAdress);
				
		screenW = $(window).width();
		screenH = $(window).height();
		windowTop = $(window).scrollTop();
		
		$("#thanksWrapper").fadeIn();
		$("#thanksWrapper img").load(function(){
			imgW = $("#thanksWrapper img").width();
			imgH = $("#thanksWrapper img").height();
			divLeft = ( screenW - imgW ) / 2;
			divTop = ( screenH - imgH ) / 2;
			$("#thanksBack").css({
				width: screenW + "px",
				height: screenH + "px"
			});	
			H = $(window).scrollTop();
			if (divTop < 0){
				$("#thanksWrapper").css({
					left: divLeft + "px",
					top: H + "px"
				});
				
			}else{
				$("#thanksWrapper").css({
					left: divLeft + "px",
					top: H + "px"
				});
				
			}
		});
		$("#thanksBack").fadeIn();
		
	});
	$("#thanksBack").click(function(){
		$(this).hide();
		$("#thanksWrapper").fadeOut();
	});
	$("#thanksWrapper").click(function(){
		$(this).fadeOut();
		$("#thanksBack").hide();
	});
	/*-------------------------------*/
	
	$(".pp_arrow_next").hover(function(){
		$(".wellright").css({
			background: "url(http://kanalizaciya.com/img/rightBut.png) right center no-repeat"			
		});
		$(this).css({
			background: "url(../../../img/sprite.png) -264px -73px no-repeat"
		});
	},function(){
		$(".wellright").css({
			background: "none"			
		});
		$(this).css({
			background: "url(../../../img/sprite.png) -264px 0px no-repeat"
		});
	});
	
	$(".pp_arrow_previous").hover(function(){
		$(".wellleft").css({
			background: "url(http://kanalizaciya.com/img/leftBut.png) left center no-repeat"			
		});
		$(this).css({
			background: "url(../../../img/sprite.png) -219px -50px no-repeat"
		});
	},function(){
		$(".wellleft").css({
			background: "none"			
		});
		$(this).css({
			background: "url(../../../img/sprite.png) -264px -36px no-repeat"			
		});
	});
	
	$(".wellright").hover(function(){
		$(".pp_arrow_next").css({
			background: "url(../../../img/sprite.png) -264px -73px no-repeat"			
		});
		
	},function(){
		$(".pp_arrow_next").css({
			background: "url(../../../img/sprite.png) -264px 0px no-repeat"			
		});
	});
	
	$(".wellleft").hover(function(){
		$(".pp_arrow_previous").css({
			background: "url(../../../img/sprite.png) -219px -50px no-repeat"			
		});
	},function(){
		$(".pp_arrow_previous").css({
			background: "url(../../../img/sprite.png) -264px -36px no-repeat"			
		});
	});
	
	
	
});
