varhandleHeight=Math.round((1-proportion)*$('#scroll-pane').height());//set the proportional height - round it to make sure everything adds up correctly later on
handleHeight-=handleHeight%2;
$("#scroll-pane").after('<\div id="slider-wrap"><\div id="slider-vertical"><\/div><\/div>');//append the necessary divs so they're only there if needed
$("#slider-wrap").height($("#scroll-pane").height());//set the height of the slider bar to that of the scroll pane
//set up the slider
$('#slider-vertical').slider({
orientation:'vertical',
min:0,
max:100,
value:100,
slide:function(event,ui){//used so the content scrolls when the slider is dragged
vartopValue=-((100-ui.value)*difference/100);
$('#scroll-content').css({top:topValue});//move the top up (negative value) by the percentage the slider has been moved times the difference in height
},
change:function(event,ui){//used so the content scrolls when the slider is changed by a click outside the handle or by the mousewheel
vartopValue=-((100-ui.value)*difference/100);
$('#scroll-content').css({top:topValue});//move the top up (negative value) by the percentage the slider has been moved times the difference in height
}
});
//set the handle height and bottom margin so the middle of the handle is in line with the slider