
// The slider can move 0 pixels up
var topConstraint = 0;

// Custom scale factor for converting the pixel offset into a real value
var scaleFactor = 1.0;

var Event = YAHOO.util.Event,
	Dom   = YAHOO.util.Dom,
	lang  = YAHOO.lang,
	bg="slider-bg",
	thumb="slider-thumb"

	Event.onDOMReady(function() {

	slider = YAHOO.widget.Slider.getHorizSlider(bg, 
					 thumb, topConstraint, bottomConstraint, pixelIncrement);

	// Sliders with ticks can be animated without YAHOO.util.Anim
	slider.animate = true;
	slider.valueChangeSource = 2;

	slider.getRealValue = function() {
		return Math.round(this.getValue() * scaleFactor);
	}
	
	slider.startSlide = function() {
		fiche_photos_lockNumero = true;
	}
	
	slider.endSlide = function() {
		fiche_photos_lockNumero = false;
		fiche_photos_hideNumPhotos();
	}
	
	var firstCheck = true;
	
	slider.updateControl = function() {
		// use the scale factor to convert the pixel offset into a real
		// value
		var actualValue = slider.getRealValue();
		terminalValue = ((actualValue / pixelIncrement) + 1);
		
		var obj_scroll	= document.getElementById('fiche_photos_scroll');
		var new_left = '-' + ((92 + 11) * (terminalValue - 1)) + 'px';
		
		if ( firstCheck ) {
			firstCheck = false;
			setTimeout('slider.updateControl();', 50);
		} else if ( new_left != obj_scroll.style.left ) {
			setTimeout('slider.updateControl();', 50);
		}
		
		obj_scroll.style.left = new_left;
	}
	
	slider.subscribe("change", function(offsetFromStart) {
		// Mettre à jour le contrôle associé
		this.updateControl();
		
		// Update the title attribute on the background.  This helps assistive
		// technology to communicate the state change
		Dom.get(bg).title = "slider value = " + actualValue;
	});

	slider.subscribe("slideStart", function() {
			this.startSlide();
			YAHOO.log("slideStart fired", "warn");
		});

	slider.subscribe("slideEnd", function() {
			YAHOO.log("slideEnd fired", "warn");
			this.endSlide();
		});
});

