(function () {
    YAHOO.namespace('example');

    var Dom = YAHOO.util.Dom;

    // Slider has a range of 200 pixels
    var range = 280;

    // No ticks for this example
    var tickSize = 0;

    // We'll set a minimum distance the thumbs can be from one another
    var minThumbDistance = 10;

    // Initial values for the thumbs
    var initValues = [0,49];

    // Conversion factor from 0-200 pixels to 100-1000
    // Note 20 pixels are subtracted from the range to account for the
    // thumb values calculated from their center point (10 pixels from
    // the center of the left thumb + 10 pixels from the center of the
    // right thumb)
    var cf = 900/(range - 20);

    // Set up a function to convert the min and max values into something useful
    var convert = function (val) {
        return Math.round(val * cf + 700);
    };

    // Slider set up is done when the DOM is ready
    YAHOO.util.Event.onDOMReady(function () {
        var ptac_bg = Dom.get("ptac_bg"),
            info    = Dom.get("ptac_info"),
            from    = Dom.get("ptac_from"),
            to      = Dom.get("ptac_to");

        // Create the DualSlider
        var slider = YAHOO.widget.Slider.getHorizDualSlider(ptac_bg,
            "ptac_min_thumb", "ptac_max_thumb",
            range, tickSize, initValues);

        slider.minRange = minThumbDistance;
        
        // Custom function to update the text fields, the converted value
        // report and the slider's title attribute
        var updateUI = function () {
            from.value = slider.minVal;
            to.value   = slider.maxVal;

            // Update the converted values and the slider's title.
            // Account for the thumb width offsetting the value range by
            // subtracting the thumb width from the max value.
            var min = convert(slider.minVal),
                max = convert(slider.maxVal - 20);

            info.innerHTML = "<div class='mini'>" + min + "kg</div>" +
                             "<div class='maxi'>" + max + "kg</div>";
            ptac_bg.title  = "Current range " + min + " - " + max;
			
			
        };

        // Subscribe to the dual thumb slider's change and ready events to
        // report the state.
        slider.subscribe('ready', updateUI);
        slider.subscribe('change', updateUI);

        // Attach the slider to the YAHOO.example namespace for public probing
        YAHOO.example.slider = slider;
    });
})();


(function () {
    YAHOO.namespace('example');

    var Dom = YAHOO.util.Dom;

    // Slider has a range of 200 pixels
    var range = 280;

    // No ticks for this example
    var tickSize = 0;

    // We'll set a minimum distance the thumbs can be from one another
    var minThumbDistance = 10;

    // Initial values for the thumbs
    var initValues = [0,60];

    // Conversion factor from 0-200 pixels to 100-1000
    // Note 20 pixels are subtracted from the range to account for the
    // thumb values calculated from their center point (10 pixels from
    // the center of the left thumb + 10 pixels from the center of the
    // right thumb)
    var cf = 4/(range - 20);

    // Set up a function to convert the min and max values into something useful
    var convert = function (val) {
        return Math.round(val * cf + 3);
    };

    // Slider set up is done when the DOM is ready
    YAHOO.util.Event.onDOMReady(function () {
        var couchage_bg = Dom.get("couchage_bg"),
            info    = Dom.get("couchage_info"),
            from    = Dom.get("couchage_from"),
            to      = Dom.get("couchage_to");

        // Create the DualSlider
        var slider = YAHOO.widget.Slider.getHorizDualSlider(couchage_bg,
            "couchage_min_thumb", "couchage_max_thumb",
            range, tickSize, initValues);

        slider.minRange = minThumbDistance;
        
        // Custom function to update the text fields, the converted value
        // report and the slider's title attribute
        var updateUI = function () {
            from.value = slider.minVal;
            to.value   = slider.maxVal;

            // Update the converted values and the slider's title.
            // Account for the thumb width offsetting the value range by
            // subtracting the thumb width from the max value.
            var min = convert(slider.minVal),
                max = convert(slider.maxVal - 20);

            info.innerHTML = "<div class='mini'>" + min + "</div>" +
                             "<div class='maxi'>" + max + "</div>";
            couchage_bg.title  = "Current range " + min + " - " + max;
        };

        // Subscribe to the dual thumb slider's change and ready events to
        // report the state.
        slider.subscribe('ready', updateUI);
        slider.subscribe('change', updateUI);

        // Attach the slider to the YAHOO.example namespace for public probing
        YAHOO.example.slider = slider;
    });
})();


(function () {
    YAHOO.namespace('example');

    var Dom = YAHOO.util.Dom;

    // Slider has a range of 200 pixels
    var range = 280;

    // No ticks for this example
    var tickSize = 0;

    // We'll set a minimum distance the thumbs can be from one another
    var minThumbDistance = 10;

    // Initial values for the thumbs
    var initValues = [0,35];

    // Conversion factor from 0-200 pixels to 100-1000
    // Note 20 pixels are subtracted from the range to account for the
    // thumb values calculated from their center point (10 pixels from
    // the center of the left thumb + 10 pixels from the center of the
    // right thumb)
    var cf = 18000/(range - 20);

    // Set up a function to convert the min and max values into something useful
    var convert = function (val) {
        return Math.round(val * cf + 8000);
    };

    // Slider set up is done when the DOM is ready
    YAHOO.util.Event.onDOMReady(function () {
        var prix_bg = Dom.get("prix_bg"),
            info    = Dom.get("prix_info"),
            from    = Dom.get("prix_from"),
            to      = Dom.get("prix_to");

        // Create the DualSlider
        var slider = YAHOO.widget.Slider.getHorizDualSlider(prix_bg,
            "prix_min_thumb", "prix_max_thumb",
            range, tickSize, initValues);

        slider.minRange = minThumbDistance;
        
        // Custom function to update the text fields, the converted value
        // report and the slider's title attribute
        var updateUI = function () {
            from.value = slider.minVal;
            to.value   = slider.maxVal;

            // Update the converted values and the slider's title.
            // Account for the thumb width offsetting the value range by
            // subtracting the thumb width from the max value.
            var min = convert(slider.minVal),
                max = convert(slider.maxVal - 20);

            info.innerHTML = "<div class='mini'>" + min + "€</div>" +
                             "<div class='maxi'>" + max + "€</div>";
            prix_bg.title  = "Current range " + min + " - " + max;
        };

        // Subscribe to the dual thumb slider's change and ready events to
        // report the state.
        slider.subscribe('ready', updateUI);
        slider.subscribe('change', updateUI);

        // Attach the slider to the YAHOO.example namespace for public probing
        YAHOO.example.slider = slider;
    });
})();
