$(document).ready(function() {
  
  $('.login_overlay').trigger('click');
  $('.login_overlay').removeClass('login_overlay');
    
  setTimeout ("slider_scrollbar()", 500);
});

function slider_scrollbar(){
var count = $('.demo').length;

  for(var i=0; i<count; i++){
  var length_content = $($(".demo")[i]).find('.scroll-content').height() - $($(".demo")[i]).find('.scroll-pane').height();/* + 10 -$(this).parent().parent().find('.scroll-pane').height();  */
  if(length_content > 0)
    {
      $($(".demo")[i]).find('.scroll-bar').slider({
      orientation: "vertical",
      range: "max",
      min: 0,
      max: 100,
      value: 100,
      slide: function(event, ui) {
        var difference = $(this).parent().parent().find('.scroll-content').height() + 10 -$(this).parent().parent().find('.scroll-pane').height();
        var topValue = -((100-ui.value)*difference/100);
        $(this).parent().parent().find('.scroll-content').css({top:topValue});//move the top up (negative value) by the percentage the slider has been moved times the difference in height
      }
      });
    }
  else
    {
    }
  }
}
