// JavaScript Document
var foto_slider = "";
var position = 0;
var fotowidth = "";
var totaalwidth = "";
var thumbaantal = "";


function slide_foto(totalwidth, containerwidth, thumbwidth, aantal)
{
	fotowidth = thumbwidth;
	totaalwidth = totalwidth;
	thumbaantal = aantal;

	foto_slider = new Control.Slider('slide_foto_button','slide_foto_bar',{
		range:$R(0,(totalwidth-containerwidth)),
		minvalue: 0,
		maxvalue: (totalwidth-containerwidth),
		sliderValue: 0,
		onSlide:function(v) {
			document.getElementById('thumbs').style.left = '-' + (v) + 'px';
			position = v;
		},
		onChange:function(v) {
				move = position-v;
				new Effect.MoveBy('thumbs', 0,move);
				position = v;
				foto_slider.setEnabled();
		}
	});
}

function fade_foto(foto, thumb_id)
{
	preload_image = new Image(); 
	preload_image.src = foto;
	
	if(foto_slider)
	{
		foto_slider.setDisabled();
		new Effect.Opacity('detail_foto',  
		{
			duration: 1,
			from: 1, 
			to: 0,
			afterFinish: function() { $('detail_foto').src = foto; }
		});
	
		new Effect.Opacity('detail_foto',  
		{
			delay: 1,
			duration: 1,
			from: 0, 
			to: 1,
			afterFinish: 
			function() { 
				if((thumb_id > 2) && ((thumbaantal - 3) > thumb_id))
				{
					slidervalue = (thumb_id - 2) * fotowidth;
					foto_slider.setValue(slidervalue);
				}
				else if((thumb_id <= 2))
				{
					slidervalue = foto_slider.minvalue;
					foto_slider.setValue(slidervalue);
				}
				else if((thumbaantal - 3) <= thumb_id)
				{
					slidervalue = foto_slider.maxvalue;
					foto_slider.setValue(slidervalue);
				}
			}
		});
	}
	else
	{
		new Effect.Opacity('detail_foto',  
		{
			duration: 1,
			from: 1, 
			to: 0,
			afterFinish: function() { $('detail_foto').src = foto; }
		});
	
		new Effect.Opacity('detail_foto',  
		{
			delay: 1,
			duration: 1,
			from: 0, 
			to: 1
		});
	}
}







