// JavaScript Document

function sliderLeft(){
	if(!$("a.sliderRight").hasClass("noActive")){									  
			$("a.sliderLeft").removeClass("noActive");
			var $oneWidth = parseInt($("div#banners p:first").width());
			var $totalWidth = $oneWidth;
			$("div#banners p").each(function(){
				$totalWidth -= parseInt($(this).width());
			});
			var $nowLeft = parseInt($("div#banners").css("left"));
			$nowLeft = $nowLeft - $oneWidth;
			if($nowLeft < $totalWidth){$nowLeft = 0;}
			$("div#banners").animate({left: $nowLeft}, {duration: 'slow'});
		}
}


$(function(){		
		   

$("a.sliderRight").click(function(){
$sliderLeft	=	window.clearInterval($sliderLeft)								  
		if(!$(this).hasClass("noActive")){									  
			$("a.sliderLeft").removeClass("noActive");
			var $oneWidth = parseInt($("div#banners p:first").width());
			var $totalWidth = $oneWidth;
			$("div#banners p").each(function(){
				$totalWidth -= parseInt($(this).width());
			});
			var $nowLeft = parseInt($("div#banners").css("left"));
			$nowLeft = $nowLeft - $oneWidth;
			if($nowLeft <= $totalWidth){$nowLeft = $totalWidth; $(this).addClass("noActive");}
			$("div#banners").animate({left: $nowLeft}, {duration: 'slow'});
		}
		return false;
	});

	$("a.sliderLeft").click(function(){
	$sliderLeft	=	window.clearInterval($sliderLeft);
		if(!$(this).hasClass("noActive")){
			$("a.sliderRight").removeClass("noActive");
			var $oneWidth = parseInt($("div#banners p:first").width());
			var $totalWidth = 0;
			
			var $nowLeft = parseInt($("div#banners").css("left"));
			$nowLeft = $nowLeft + $oneWidth;
			if($nowLeft >= $totalWidth){$nowLeft = $totalWidth; $(this).addClass("noActive");}
			$("div#banners").animate({left: $nowLeft}, {duration: 'slow'});
		}
		return false;
	});
	
	if($('#gall').html() != null){
		$('#gall a').lightBox({
			overlayBgColor: '#000',
			overlayOpacity: 0.6,
			imageLoading: '/images/lightbox-btn-loading.gif',
			imageBtnClose: '/images/lightbox-btn-close.gif',
			imageBtnPrev: '/images/lightbox-btn-prev.gif',
			imageBtnNext: '/images/lightbox-btn-next.gif',
			imageBlank : '/images/lightbox-blank.gif',
			containerResizeSpeed: 200,
			txtImage: 'Фото',
			txtOf: 'из'
  		}); 
	}

	var $sliderLeft = self.setInterval("sliderLeft()",3000);
	
});






  
  
  
  