﻿function makeSlider(cID, minVal, maxVal, valueVal, stepVal,containerID) {
    $("#" + containerID).empty();
    $("#" + containerID).append('<span class="left"></span>');
    $("#" + containerID).append('<div id="' + cID + '" class="slider"></div>');
    $("#" + containerID).append('<span class="right"></span>');
    $("#" + containerID).append('<span class="result"><input type="text" class="droplist" readonly="readonly" name="' + cID + '" value="' + valueVal + '"/></span>');

    $("#" + cID).slider(
        { max: maxVal },
        { min: minVal },
        { value: valueVal },
        { step: stepVal },
        {
            create: function (event, ui) {
                $(this).parent().children("span.left").html($(this).slider("option", "min"));
                $(this).parent().children("span.left").attr("title", "minimální hodnota");
                $(this).parent().children("span.right").html($(this).slider("option", "max"));
                $(this).parent().children("span.right").attr("title", "maximální hodnota");
                //$(this).parent().children("span.result").html($(this).slider("option", "value"));
                $(this).parent().children("span.result").attr("title", "aktuální hodnota");
            }
        },
        {
            change: function (event, ui) {
                $(this).parent().children("span.result").children("input").val($(this).slider("option", "value"));
                //$(this).parent().children("span.result").children('input[name="' + cID + '"]').value = $(this).slider("option", "value");
                //$(this).parent().children("span.result").html($(this).slider("option", "value"));
            }
        },
        {
            slide: function (event, ui) {
                $(this).parent().children("span.result").children("input").val(ui.value);
                //$(ui.handle).attr("title", ui.value);
                // $(this).parent().children('input[name="'+cID+'"]').value = ui.value;
                //$(this).parent().children("span.result").html(ui.value);
            }

        });
}
