$(document).ready(function(){
	dir=-1;
	interval=100;
	$('#gallery .forward').mousedown(function(){
		dir=-10;
		interval=10;
	});
	$('#gallery .forward').mouseup(function(){
		dir=-1;
		interval=100;
	});
	$('#gallery .forward').mouseleave(function(){
		dir=-1;
		interval=100;
	});
	$('#gallery .back').mousedown(function(){
		dir=10;
		interval=10;
	});
	$('#gallery .back').mouseup(function(){
		dir=-1;
		interval=100;
	});
	$('#gallery .back').mouseleave(function(){
		dir=-1;
		interval=100;
	});
	mover();
});
function mover(){
	cur=$('.photos').css('left').substr(0, $('.photos').css('left').length-2) ;
	cur=parseInt(cur);
	if(dir!=0){
		cur+=dir;
		$('.photos').css('left',cur+'px');
	}
	if(cur<0){
		$('#gallery .back').css('display','block');
	} else {
		$('#gallery .back').css('display','none');
		dir=-1;
		interval=100;
	}	
	if($('.photos').width()+cur <= $('.photos_cont').width()) {
		$('#gallery .forward').css('display','none');
		cur=$('.photos_cont').width()-$('.photos').width();
		if(cur>0){cur=0;}
		$('.photos').css('left',cur+'px');
		dir=0;
	} else {
		$('#gallery .forward').css('display','block');
	}
	setTimeout("mover()", interval);
}

