$(document).ready(function()
{		
	var offset=0;
	var iloscZdjec=6;
	var ileZdjecPrzesuwac=2;
	var idRight=iloscZdjec;
	var	leftClick=0;
	var r=85;
	var b=0;
	opcjeZdjeciaMouseOver();
/*
 * Ustawienie marginesow dla wszystkich zdjec
 */
 	$('#rightArrow').mouseover(function(event) { $(this).css('background','url('+adresURL+'images/strzalka-zw-prawo-over.gif) no-repeat 33px 50px'); return false; }).mouseout(function(event) { $(this).css('background','url('+adresURL+'images/strzalka-zw-prawo.gif) no-repeat 33px 50px'); return false; });
$('#leftArrow').mouseover(function(event) { $(this).css('background','url('+adresURL+'images/strzalka-zw-lewo-over.gif) no-repeat 43px 50px'); return false; }).mouseout(function(event) { $(this).css('background','url('+adresURL+'images/strzalka-zw-lewo.gif) no-repeat 43px 50px'); return false; });

	$('.foto').each(function(){
		var startMargin=12;
		rgb='rgb('+r+',128,'+b+')';
		r-=10;
		b+=10;
		margin=startMargin+offset
		$(this).css({'margin-left':margin /*,'background': rgb*/});
		offset+=112;
		leftClick++
			})

			leftClick=leftClick-iloscZdjec;
			var	rightClick=0;
			var move=true;
			$('#rightArrow').click(function(){
				if(move && leftClick>0){
					moveLeft();
					leftClick--;
					rightClick++;
					idRight++;
				//	$("#foto"+idRight).show();
				}
			})
				
			$('#leftArrow').click(function(){
				if(move && rightClick>0){
					moveRight();
					leftClick++
				//	$("#foto"+rightClick).show();
					rightClick--;				
				}
			})
	
function moveLeft(){
				move=false
				var	margin=parseInt($('#photos').css('margin-left'));
				margin=margin-112;
				$('#photos').animate({'margin-left': margin},activeMoveLeft);
			}
function moveRight(){
			move=false
			var	margin=parseInt($('#photos').css('margin-left'));
			margin=margin+112;
			$('#photos').animate({'margin-left': margin},activeMoveRight);
}
function activeMoveLeft(){
	move=true;
	//$("#foto"+rightClick).css('display','none');
	}
function activeMoveRight(){
	move=true;
	//$("#foto"+idRight).css('display','none');
	idRight--;
	}	
})

function opcjeZdjeciaMouseOver(){
	$('.avs').mouseover(function(){ $(this).attr('src',adresURL+'images/avatar-set-on.jpg');
		$('<div id="avs" class="alert" style="line-height:11px; width:88px; font-size:10px;">ustaw jako awatar</div>').insertAfter($(this).parent().parent().parent().parent().parent().parent());
	}).mouseout(function() { $(this).attr('src',adresURL+'images/avatar-set.jpg'); $('#avs').remove();});
	
	$('.avd').mouseover(function(){ $(this).attr('src',adresURL+'images/avatar-del-on.jpg');
		$('<div id="avd" class="alert" style="line-height:11px; width:88px; font-size:10px;">skasuj zdjecie</div>').insertAfter($(this).parent().parent().parent().parent().parent().parent());
	}).mouseout(function() { $(this).attr('src',adresURL+'images/avatar-del.jpg'); $('#avd').remove(); });
}
