Slider min-max-val changes erratic function

Slider min-max-val changes erratic function

When i change the min, max and val attributes with jquery somethings fails, because the value picker goes to the last or the first value, and not to the desired value:

Full and interactive code pasted on http://pastebin.com/MDdH94zV

I have no idea to how to fix it; i tried with refresh, putting 0 and 10000 like min and max before puting the value and restict the range again changing min and max and have not the desired result (a natural exchange between ranges and values under this easy and simple code...

/*Only for expand the range, because some default values are so small in contrast...
$('#val-init').attr('min', 0);
$('#val-init').attr('max', 10000);
$('#val-desired').attr('min', 0);
$('#val-desired').attr('max', 10000);
*/
$('#val-init').attr('value', ref_min);
$('#val-desired').attr('value', ref_max);
$('#val-init').attr('min', min);
$('#val-init').attr('max', max);

$('#val-desired').attr('min', min);
$('#val-desired').attr('max', max);

$('#val-init').slider('refresh');
$('#val-desired').slider('refresh');

$('#page').page();


i have tried with page, but was not enought...

Some suggestion?