
	var continueBounce=true;
	var imgs=[];
	var currentscroll=0;
	var numpreviewperpage=5;

	function scrollpic(which)
	{
		$("#gallerycontent").animate({ "margin-left": -1*(which)*550	},500);
	}

	function arrowbounce()
	{
		var speed=800;
		if($("#arrowout").css("opacity")==1.0)
			$("#arrowout").animate({ opacity: 0.5 },speed,function() {
			arrowbounce();
			});
		else
			$("#arrowout").animate({ opacity: 1.0 },speed,function() {if(continueBounce)arrowbounce()});
	}
	
	function showThumbs()
	{
		continueBounce=false;	
		
		$('#arrowout').css("background-image", "url(/img/galleryarrow2.png)");  
		$("#arrowcontent").animate({ "opacity": 1 },1,function() {});
				
		$("#arrowcontent").animate({ width: 420	},500,function() {});
		$('#arrowout').unbind('click');
		$("#arrowout").bind('click', function(){hideThumbs();});
	}
	
	function hideThumbs()
	{
		continueBounce=true;	
		arrowbounce();

		$('#arrowout').css("background-image", "url(/img/galleryarrow.png)");  
		$("#arrowcontent").animate({ width: 0 },500,function() {});
		$('#arrowout').unbind('click');
		$("#arrowout").bind('click', function(){showThumbs();});		
	}

	function scrollPreview(which)
	{
		$("#previewpicscontent").animate({ "margin-left": -1*(which)*310},500);

		var from=0;
		if(which>0)from=which*numpreviewperpage;
		var to=(which+1)*5;
		if(to>imgs.length)to=imgs.length;
		$('#arrowinfopos').html((from+1)+" - "+to);
	}

	function previewPrevious()
	{
		currentscroll--;
		if(currentscroll<0)currentscroll=0;
		scrollPreview(currentscroll);
	}

	function previewNext()
	{
		currentscroll++;
		if(currentscroll*numpreviewperpage>imgs.length)
		{
			currentscroll=Math.floor(imgs.length/numpreviewperpage);
		}
		scrollPreview(currentscroll);
	}

