<?php
  //  ini_set("display_errors", 1);
    include_once(PATH_TO_ROOT."/webcati/_plugins/slider/class/class.slider.plugin.php");
    $data = new SliderPlugin($db);
    $data->load($projectId, $q->id);
   /* print "<pre>";
    var_dump($q);
    print "</pre>";
    print "#############################################################################################################################################################";*/
    
?>
		<meta charset="UTF-8">
		<link rel="stylesheet" href="<?php echo PATH_TO_ROOT."/webcati/_plugins/slider/web";?>/slider_css.css" type="text/css" media="all">
        <style type="text/css">
            #min<?php echo $q->q_name; ?> {
                margin-top: 3px;
                margin-right: -32px;
                width: 50px; 
                z-index: 1;
                position: relative;
                height: 50px; 
                border-radius: 50px;
                border-style: solid;
                border-width: 1px; 
                font-size: 13px;
                font-family: Verdana; 
                color: #000; 
                line-height: 50px; 
                text-align: center; 
                background: #FF9933;
            }
            #max<?php echo $q->q_name; ?> {
                margin-top: 3px;
                margin-left: -30px;
                width: 50px; 
                position: relative;
                z-index: 1;
                height: 50px; 
                border-radius: 50px;
                border-style: solid;
                border-width: 1px; 
                font-size: 13px;
                font-family: Verdana; 
                color: #000; 
                line-height: 50px; 
                text-align: center; 
                background: #FF9933; 
            }
            #slider<?php echo $q->q_name; ?> .ui-slider-horizontal {
            }
            #slider<?php echo $q->q_name; ?> .ui-slider-range { background: #ef2929; }
            
        </style>
        
		<script>
		    $(function() {
                
                //radio gumb za 'No answer'
                $("#no_answer<?php echo $q->q_name; ?>").change(function(){
                    $("#slider<?php echo $q->q_name; ?>").find(".ui-slider-handle").text('<?php echo $data->getVal('default_text'); ?>'); 
                    $("#slider<?php echo $q->q_name; ?>").slider("value", 100 );
                    setHiddenValue<?php echo $q->q_name; ?>('<?php echo $data->getVal('null_value'); ?>');
                });
                
                if(<?php echo $data->getVal('disable_next_button'); ?>)
                {
                    $('input[name=questSubmit]').attr('disabled', true)
                }
                  
                /* SKALA ZA ČAS */
               // if($('#time_scale').is(':checked')) { FillTimeScale(); UnlimitedTimeSlider(); }
                
                <?php 
                    if($data->getVal('scale_type') == 2)
                    {
                        if($data->getVal('show_scale') == 1)
                        {
                            echo 'FillTimeScale' . $q->q_name . '();';
                        }
                        if(strlen($data->getVal('lower_bound')) > 0 && strlen($data->getVal('upper_bound')) >0 )
                        {
                            
                            print 'LimitedTimeSlider' . $q->q_name . '();';      
                        }
                        else 
                        { 
                            print 'UnlimitedTimeSlider' . $q->q_name . '();';
                        }
                        
                    }
                    else if($data->getVal('scale_type') == 1)
                    {
                        if($data->getVal('show_scale') == 1)
                        {
                           print " FillIntervalScale" . $q->q_name . "(' " . $data->getVal('slider_width') . "');";
                        }
                        if(strlen($data->getVal('lower_bound')) > 0 || strlen($data->getVal('upper_bound')) >0 )
                        {
                            
                            print "LimitedIntervalSlider" . $q->q_name . "(' " . $data->getVal('slider_width') . "');";      
                        }
                        else 
                        { 
                            print "UnlimitedIntervalSlider" . $q->q_name . "(' " . $data->getVal('slider_width') . "');";
                        }
                    }
					
					//default_value
                ?>
                SetStyle<?php echo $q->q_name; ?>();
            });
            
            // nastavitve stilov
            
            //nastavitev velikosti pisave
      
            
            
            /* FUNCTIONS */
            
            function SetStyle<?php echo $q->q_name; ?>()
            {
                
                $("#min<?php echo $q->q_name; ?>, #max<?php echo $q->q_name; ?>").css("margin-top", '0px');
                var margin = 0;
                var size = 44;
                if(size > 11){
                    margin = -5;
                }
                $(".steps").css("font-size", size + "px");
                $(".steps" ).css("margin-top", margin + "px");
                $(".tick").css("margin-top", margin + "px");
                
                $(".steps").css({ "font-family": '<?php echo $data->getVal('scale_font'); ?>' });
                $(".steps").css("color", '<?php echo $data->getVal('scale_font_color'); ?>');
                
                
                $("#min<?php echo $q->q_name; ?>, #max<?php echo $q->q_name; ?>").css("background", '<?php echo $data->getVal('extreme_circle_color'); ?>');
                
                /*$("#min, #max").css("background-image", "url(http://www.accucutcraft.com/media/catalog/product/cache/2/image/9df78eab33525d08d6e5fb8d27136e95/B/1/B1053.jpg)");
                $("#min, #max").css("background-position", "center");
                $("#min, #max").css("background-attachment", "fixed");  */
               // $("#min, #max").css("background-image", "url(<?php echo PATH_TO_ROOT."/webcati/_plugins/slider/web";?>/pole.png)");  
                $("#min<?php echo $q->q_name; ?>, #max<?php echo $q->q_name; ?>").css("borderWidth", "<?php echo $data->getVal('extreme_border_width'); ?>");
                $("#min<?php echo $q->q_name; ?>, #max<?php echo $q->q_name; ?>").css("color", '<?php echo $data->getVal('extreme_font_color'); ?>');
               $("#slider<?php echo $q->q_name; ?>").css('height', '5px');
               
               $("#slider<?php echo $q->q_name; ?>").find(".ui-slider-handle").css("color", '<?php echo $data->getVal('slider_font_color'); ?>');
               $("#slider<?php echo $q->q_name; ?>").find(".ui-slider-handle").css("font-size", '<?php echo $data->getVal('slider_font_size'); ?>px');
               $("#slider<?php echo $q->q_name; ?>").find(".ui-slider-handle").css("font-family", '<?php echo $data->getVal('slider_font'); ?>');
               
               <?php
               if(strlen($data->getVal('slider_handle_image')) > 0)
               {?>
                   $("#slider<?php echo $q->q_name; ?>").find(".ui-slider-handle").css("background-image", "url('<?php echo $data->getVal('slider_handle_image'); ?>')");
                   $("#slider<?php echo $q->q_name; ?>").find(".ui-slider-handle").css("border-width", "0");
                   $("#slider<?php echo $q->q_name; ?>").find(".ui-slider-handle").css("background-color", "transparent");              
                   $("#slider<?php echo $q->q_name; ?>").find(".ui-slider-handle").css("background-repeat", "no-repeat");
                   $("#slider<?php echo $q->q_name; ?>").find(".ui-slider-handle").css("background-position", "top");
                   
              <?php 
               }
               ?>
               
             /*  var slider_width = parseInt(<?php echo $data->getVal('slider_width'); ?>);
               slider_width = slider_width -25;
               
               
               $('#max').css('margin-left',slider_width + 'px');
               $('#max').css('margin-top','-25px');
               $("#slider").css('width', '<?php echo $data->getVal('slider_width'); ?>px');*/
               
               $("#min<?php echo $q->q_name; ?>").css({ "border-radius": '<?php echo $data->getVal('extreme_radius'); ?>px' });
               $("#max<?php echo $q->q_name; ?>").css({ "border-radius": '<?php echo $data->getVal('extreme_radius'); ?>px' });
               

                <?php
                
             /*   if($data->getVal('slider_type') == 1)
                {
                ?>
                    $("#slider<?php echo $q->q_name; ?>").find(".ui-slider-handle").css({
                    "margin-left": "-2.7em",
                    "width": "5.4em", 
                    "border-radius": "5em" });
                <?php
                }else 
                {
                ?>
                    $("#slider<?php echo $q->q_name; ?>").find(".ui-slider-handle").css({
                        "margin-left": "-1.7em", 
                        "width": "3.4em",
                        "border-radius": "5px" 
                    });
                <?php    
                }
                    $userInput = null;
                    $default = true;
                   foreach($fieldsValues as $key=>$value)
                   {
                        if(!empty($value))
                        {
                            print "setDefaultValue('".$value."');";
                            print "$('input[name=questSubmit]').attr('disabled', false);";
                            $userInput = $value;
                            $default = false;
                        }
                        
                   } 
                    if($data->getVal('default_value') != null && $default)
                    {
                        $val = $data->getVal('default_value');
                        print "setDefaultValue('".$val."');";
                    }
                    
                   
                  if(strlen($data->getVal('scale_values')) > 0)
                  { 
                 ?>
                        var str = "<?php echo $data->getVal('scale_values'); ?>";
                        
                        arr = str.split(';');
                        arr.splice(0,1);
                        if(<?php echo $data->getVal('show_scale'); ?> == 1)
                            FillCustomScale(arr); 
                 
                  <?php
                     if(strlen($data->getVal('lower_bound')) > 0  || strlen($data->getVal('upper_bound')) >0 )
                        print "LimitedCustomSlider(arr);";
                     else 
                        print "UnlimitedCustomSlider(arr);"; 
                        
                  ?>                         
                            
                        setDefaultValue('<?php echo ($userInput != null)?$userInput:$data->getVal('default_value'); ?>', arr);    
                <?php
                  }
                  if(strlen($data->getVal('pole_image')))
                  {
                  ?>
                        $("#min<?php echo $q->q_name; ?>, #max<?php echo $q->q_name; ?>").html('<img src="<?php echo $data->getVal('pole_image'); ?>" />');    
                 <?php 
                  }*/
                ?> 
                
                
            }
            function ClickMinMax<?php echo $q->q_name; ?>(selector)
            {
                var value = $(selector).val();
                if( typeof arr != 'undefined')
                    setDefaultValue<?php echo $q->q_name; ?>(value, arr);
                else
                    setDefaultValue<?php echo $q->q_name; ?>(value);
            }
            
            //default_value
            function setDefaultValue<?php echo $q->q_name; ?>(val, arr){
                var value = val;
                
                var lowerBound = '<?php echo $data->getVal('lower_bound'); ?>';
                var upperBound = '<?php echo $data->getVal('upper_bound'); ?>';
           //     console.log(lowerBound, upperBound);
                if(arr)
                {
                    value = arr.indexOf(val) + 1;
                   // console.log(lowerBound, upperBound);
                    lowerBound = arr.indexOf(lowerBound) + 1;
                    upperBound = arr.indexOf(upperBound) + 1;
                    
                   // console.log(arr, val);
                }
                
                var setValue = false;
                lowerBound = parseInt(lowerBound);
                upperBound = parseInt(upperBound);
                
                if(lowerBound && value >= lowerBound)
                {
                    if(upperBound && value <= upperBound)
                    {
                	   setValue = true;
                    }else if(!upperBound)
                    {
                       setValue = true;
                    }
                }  else if(upperBound && value <= upperBound) 
                {
                   if(lowerBound && value >= lowerBound)
                    {
                       setValue = true;
                    }else if(!lowerBound)
                    {
                       setValue = true;
                    }
                }else if(!lowerBound && !upperBound)
                {
                    setValue = true;
                }   

                if(setValue)
                {
                    $('#slider<?php echo $q->q_name; ?>').slider('value', value);
                   $("#slider<?php echo $q->q_name; ?>").find(".ui-slider-handle").text(val);
                   setHiddenValue<?php echo $q->q_name; ?>(val);
                }     
            }
            
            function setHiddenValue<?php echo $q->q_name; ?>(val)
            {
                $('#singlevar<?php echo $q->q_name; ?>').val(val);
            }
            
            function LimitedTimeSlider<?php echo $q->q_name; ?>(){
                var minValue = parseInt('<?php echo $data->getVal('lower_bound'); ?>');
                var maxValue = parseInt('<?php echo $data->getVal('upper_bound'); ?>');
                var min = minValue * 60;
                var max = maxValue * 60;
                //var minValueText = $("#sp_meja option[value='"+ minValue +"']").text();
                
                $("#slider<?php echo $q->q_name; ?>").find(".ui-slider-handle").text(minValue);
                $("#slider<?php echo $q->q_name; ?>").slider({
                    value: min,
                    min: 0,
                    max: 1440,
                    step: <?php echo $data->getVal('step'); ?>,
                    slide: function(event, ui) {
                        $('input[name=questSubmit]').attr('disabled', false);
                        if(ui.value >= min && ui.value <= max){
                            var hours = Math.floor(ui.value / 60);
                            var minutes = Math.round(ui.value % 60);
                            
                            if(hours.toString().length == 1)
                                hours = "0" + hours;
                            if(minutes.toString().length == 1)
                                minutes = "0" + minutes;
                            ui.value = hours + ":"+ minutes;
                            $(this).find('.ui-slider-handle').text(ui.value);
                        } else {
                            return false;
                        }
                        
                        //resetiranje radio gumba
                        $("#no_answer<?php echo $q->q_name; ?>").prop("checked", false);
                        
                        setHiddenValue<?php echo $q->q_name; ?>(ui.value);
                    }
                })
                $("#slider<?php echo $q->q_name; ?>").find(".ui-slider-handle").text('<?php echo $data->getVal('lower_bound'); ?>');
            }
            
            //slider z omejeno skalo
            function LimitedIntervalSlider<?php echo $q->q_name; ?>(sliderWidth){
                
                   if(sliderWidth != null){
                    $("#slider<?php echo $q->q_name; ?>").width(sliderWidth);
                }
                
                
                var min = '<?php echo $data->getVal('lower_bound'); ?>';
                min = min.length>0?parseInt(min):parseFloat('<?php echo $data->getVal('interval_from'); ?>');
                
                var max = '<?php echo $data->getVal('upper_bound'); ?>';
                max = max.length>0?parseInt(max):parseFloat('<?php echo $data->getVal('interval_to'); ?>');
              /*  var min = parseInt('<?php echo $data->getVal('lower_bound'); ?>');
                var max = parseInt('<?php echo $data->getVal('upper_bound'); ?>');*/
                var from = parseFloat('<?php echo $data->getVal('interval_from'); ?>');
                var to = parseFloat('<?php echo $data->getVal('interval_to'); ?>');;
                
                $("#slider<?php echo $q->q_name; ?>").find(".ui-slider-handle").text(min);
                $("#slider<?php echo $q->q_name; ?>").slider({
                    value: min,
                    min: from,
                    max: to,
                    step: <?php echo $data->getVal('step'); ?>,
                    slide: function(event, ui) {
                        $('input[name=questSubmit]').attr('disabled', false);
                        if(ui.value >= min && ui.value <= max){
                            $(this).find('.ui-slider-handle').text(ui.value);
                        } else {
                            return false;
                        }
                        //resetiranje radio gumba
                        $("#no_answer<?php echo $q->q_name; ?>").prop("checked", false);
                        setHiddenValue<?php echo $q->q_name; ?>(ui.value);
                    },
                    create: function(event, ui){                        
                        $(this).find(".ui-slider-handle").text(min);
                        
                    }
                })
            }
            
            //časovni slider brez omejene skale
            function UnlimitedTimeSlider<?php echo $q->q_name; ?>(){
                $("#slider<?php echo $q->q_name; ?>").find(".ui-slider-handle").text("00:00");
            
                $("#slider<?php echo $q->q_name; ?>").slider({
                    value:0,
                    min: 0,
                    max: 1440,
                    step: <?php echo $data->getVal('step'); ?>,
                    slide: function(event, ui) {
                        $('input[name=questSubmit]').attr('disabled', false);
                        var hours = Math.floor(ui.value / 60);
                        var minutes = Math.round(ui.value % 60);
                        
                        if(hours.toString().length == 1)
                            hours = "0" + hours;
                        if(minutes.toString().length == 1)
                            minutes = "0" + minutes;
                        ui.value = hours + ":"+ minutes;
                        $(this).find('.ui-slider-handle').text(ui.value);
                        
                        setHiddenValue<?php echo $q->q_name; ?>(ui.value);
                        //resetiranje radio gumba
                        $("#no_answer<?php echo $q->q_name; ?>").prop("checked", false);
                    },
                    create: function(event, ui){                        
                        $(this).find(".ui-slider-handle").text("00:00");
                        
                    }
                });
            }
            
            //intervalni slider brez omejene skale
            function UnlimitedIntervalSlider<?php echo $q->q_name; ?>(sliderWidth){
                if(sliderWidth != null){
                    $("#slider<?php echo $q->q_name; ?>").width(sliderWidth);
                }
                
                var from = parseFloat('<?php echo $data->getVal('interval_from'); ?>');
                var to = parseFloat('<?php echo $data->getVal('interval_to'); ?>');;
                
                $("#slider<?php echo $q->q_name; ?>").find(".ui-slider-handle").text(from);
                $("#slider<?php echo $q->q_name; ?>").slider({
                    value: from,
                    min: from,
                    range: 'min',
                    max: to,
                    step: <?php echo $data->getVal('step'); ?>,
                    slide: function(event, ui) {
                        $('input[name=questSubmit]').attr('disabled', false);
                        $(this).find('.ui-slider-handle').text(ui.value);
                        setHiddenValue<?php echo $q->q_name; ?>(ui.value);
                        //resetiranje radio gumba
                        $("#no_answer<?php echo $q->q_name; ?>").prop("checked", false);
                    },
                    create: function(event, ui){                        
                        $(this).find(".ui-slider-handle").text(from);
                        
                    }
                });
            }
            
            
            function FillTimeScale<?php echo $q->q_name; ?>(){
         /*       $("#sp_meja").empty();
                $("#zg_meja").empty();
                $(".steps").empty();*/
            
                $("#min<?php echo $q->q_name; ?>").text("00:00");
                $("#max<?php echo $q->q_name; ?>").text("24:00");
                
                //polnjenje lestvice z urami od 00:00 do 24:00
                for(var i=0; i<24; i++){
                    var pos = (100/24)*i;
                    if(i > 0){
                        jQuery("<span/>", {
                            'class': 'tick',
                            style: "left: " + pos + "%;",
                            val: i,
                            //html: i+ ":00<br>|"
                            html: "<span class='time'>"+i+":00</span><br />|"
                        }).appendTo(".steps");
                    }
                }
                //polnjenje comboboxa za nastavitev spodnje meje
              /*  for(var i=0; i<24; i++){
                    if(i.toString().length == 1)
                        i = "0" + i;
                    
                    jQuery("<option/>", {
                        value: i,
                        text: i+":00",
                    }).appendTo("#sp_meja");
                }*/
            }
            
         /*   function FillIntervalScale(){
                $("#sp_meja").empty();
                $("#zg_meja").empty();
                $(".steps").empty();
                
                var scale_step ='<?php echo $data->getVal('scale_steps');?>'.length>0?parseInt('<?php echo $data->getVal('scale_steps');?>'):1;
                var num1 = parseInt('<?php echo $data->getVal('interval_from'); ?>');
                var num2 = parseInt('<?php echo $data->getVal('interval_to'); ?>');
                var n = num2/scale_step;
                
                var x = <?php echo $data->getVal('slider_width'); ?>/8;
                
                $("#min").text(num1);
                $("#max").text(num2);
                
                $("#hiddenmin").val(num1);
                $("#hiddenmax").val(num2);
                
                //polnjenje lestvice z števili od num1 do num2
                var j = 0;
                for(var i=num1; i<num2; i+=scale_step){
                    var pos = (x/n)*j;
                    if(j > 0){
                        jQuery("<span/>", {
                            'class': 'tick',
                            style: "left: " + pos + "%;",
                            //html: i+ "<br>|"
                            html: "<span onclick='setDefaultValue(" + i + ")' class='number'>"+i+"</span><br />|"
                        }).appendTo(".steps");
                    }
                    j++;
                }
                
            }*/
           
           function FillIntervalScale<?php echo $q->q_name; ?>(sliderWidth){
                $("#sp_meja").empty();
                $("#zg_meja").empty();
                $(".steps").empty();
                
               // $("#slider").slider( "disable" );
                
                var scale_step ='<?php echo $data->getVal('scale_steps');?>'.length>0?parseInt('<?php echo $data->getVal('scale_steps');?>'):1;
                var num1 = parseInt('<?php echo $data->getVal('interval_from'); ?>');
                var num2 = parseInt('<?php echo $data->getVal('interval_to'); ?>');
                var n = num2 - num1;
                
                
                $("#hiddenmin<?php echo $q->q_name; ?>").val(num1);
                $("#hiddenmax<?php echo $q->q_name; ?>").val(num2);
                
                $("#min<?php echo $q->q_name; ?>").text(num1);
                $("#max<?php echo $q->q_name; ?>").text(num2);
                
                //polnjenje lestvice z števili od num1 do num2
                var j = 0;
                for(var i=num1; i<num2; i+=scale_step){
                    var pos = (100/n)*j;
                    if(j > 0){
                        jQuery("<span/>", {
                            'class': 'tick',
                            style: "left: " + pos + "%;",
                            //html: i+ "<br>|"
                            html: "<span class='number'>"+i+"</span><br />|"
                        }).appendTo(".steps");
                    }
                    j+=scale_step;
                }
              /*  //polnjenje comboboxa za nastavitev spodnje meje
                for(var i=num1; i<num2; i++){
                    jQuery("<option/>", {
                        value: i,
                        text: i,
                    }).appendTo("#sp_meja");
                }
                //polnjenje comboboxa za nastavitev zgornje meje
                for(var i=num1; i<=num2; i++){
                    jQuery("<option/>", {
                        value: i,
                        text: i,
                    }).appendTo("#zg_meja");
                }*/
                
                if(sliderWidth != null){
                    $(".steps").width(sliderWidth);
                }
            }
            function CustomScaleClick<?php echo $q->q_name; ?>(val)
            {
                setDefaultValue<?php echo $q->q_name; ?>(val,arr);
            }
            function FillCustomScale<?php echo $q->q_name; ?>(array) {
                $("#sp_meja").empty();
                $("#zg_meja").empty();
                $(".steps").empty();
                $("#min<?php echo $q->q_name; ?>").text(array[0]);
                $("#max<?php echo $q->q_name; ?>").text(array[array.length - 1]);
                var n = array.length;
                
                //polnjenje lestvice z števili od num1 do num2
                var j = 0;
                for(var i=0; i<n; i++){
                    var pos = (i/(n-1)) * 100;
                    if(j > 0){
                        jQuery("<span/>", {
                            'class': 'tick',
                            style: "left: " + pos + "%;",
                            html: "<span onclick=CustomScaleClick('" + array[i] + "') class='number'>"+array[i]+"</span><br />|"
                        }).appendTo(".steps");
                    }
                    j++;
                }
                
                //polnjenje comboboxa za nastavitev spodnje meje
             /*   for(var i=0; i<n-1; i++){
                    jQuery("<option/>", {
                        value: i,
                        text: array[i],
                    }).appendTo("#sp_meja");
                }
                //polnjenje comboboxa za nastavitev zgornje meje
                for(var i=1; i<n; i++){
                    jQuery("<option/>", {
                        value: i,
                        text: array[i],
                    }).appendTo("#zg_meja");
                }*/
            }
            
            //intervalni slider brez omejene skale
            function UnlimitedCustomSlider<?php echo $q->q_name; ?>(array){
                
                var n = array.length;
                
                $("#slider<?php echo $q->q_name; ?>").find(".ui-slider-handle").text(array[0]);
                $("#slider<?php echo $q->q_name; ?>").slider({
                    value: 1,
                    min: 1,
                    max: n,
                    step: 1,
                    slide: function(event, ui) {
                        $('input[name=questSubmit]').attr('disabled', false);
                        var val = array[ui.value - 1];
                        $(this).find('.ui-slider-handle').text(val);
                        //resetiranje radio gumba
                        $("#no_answer<?php echo $q->q_name; ?>").prop("checked", false);
                        setHiddenValue<?php echo $q->q_name; ?>(array[ui.value - 1]);
                       // console.log(ui.value);
                    },
                    create: function(event, ui){                        
                        $(this).find(".ui-slider-handle").text(array[0]);
                        
                    }
                });
            }
            
            //slider z omejeno skalo
            function LimitedCustomSlider<?php echo $q->q_name; ?>(array){
                var min = '<?php echo $data->getVal('lower_bound'); ?>';
                min = min.length>0?array.indexOf(min) + 1:0;
                
                var max = '<?php echo $data->getVal('upper_bound'); ?>';
                max = max.length>0?array.indexOf(max) + 1:array.length;
             //   console.log(min, max);
                /*var min = array.indexOf('<?php echo $data->getVal('lower_bound'); ?>') + 1;
                var max = array.indexOf('<?php echo $data->getVal('upper_bound'); ?>') + 1;*/
                
              //  console.log(min,max);
                var n = array.length;
                
                $("#slider<?php echo $q->q_name; ?>").find(".ui-slider-handle").text(array[min - 1]);
                $("#slider<?php echo $q->q_name; ?>").slider({
                    value: min,
                    min: 1,
                    max: n,
                    step: 1,
                    slide: function(event, ui) {
                        $('input[name=questSubmit]').attr('disabled', false);
                        if(ui.value >= min && ui.value <= max){
                            var val = array[ui.value - 1];
                            $(this).find('.ui-slider-handle').text(val);
                        } else {
                            return false;
                        }
                        //resetiranje radio gumba
                        setHiddenValue<?php echo $q->q_name; ?>(array[ui.value - 1]);
                        $("#no_answer<?php echo $q->q_name; ?>").prop("checked", false);
                    },
                    create: function(event, ui){                        
                        $(this).find(".ui-slider-handle").text(array[min - 1]);
                        
                    }
                })
                
            }
		</script>
	
<?php $html.= '<table id="table1">
            <tr>
                <td><div style="width:' . $data->getVal('text_box_width') . 'px;text-align:right;">' .  $data->getVal('left_text') . '</div></td>
                <td><div onclick="ClickMinMax'. $q->q_name . '(\'#hiddenmin'. $q->q_name . '\')" id="min'. $q->q_name . '">trallll  </div></td>
                <input type="hidden" id="hiddenmin'. $q->q_name . '" >
                <td>
                    <div class="steps"> </div>
                    <div id="slider' . $q->q_name . '"> </div>
                   
                </td>
                <td> <div onclick="ClickMinMax'. $q->q_name . '(\'#hiddenmax'. $q->q_name . '\')" id="max'. $q->q_name . '"> </div></td>
                <td max-width="100px"><div style="width:'. $data->getVal('text_box_width') . 'px;">' . $data->getVal('right_text') . '</div> <td>
                <input type="hidden" id="hiddenmax'. $q->q_name . '" >
            </tr>
            <tr style="height:' . $data->getVal('space_after_slider') . 'px;">
                <td>&nbsp;</td>
            </tr>
        </table>';
 if(!$data->getVal('hide_no_answer'))
 {
     $html .= '<br /><br /><br />
            <input type="radio" id="no_answer'. $q->q_name . '" />'. $data->getVal('no_answer_text') .'
            <br />';
 }

 $html .= '<input type="hidden" name="answers['.$q->q_name.']" value="0" id="singlevar'. $q->q_name . '">';
   
?>
        
