﻿var speed = 20;
var slidelength = 20; // 
var slidesnumber = 0;
var slidesnumbervisible = Math.round(100/slidelength);

function Repeat(f){
   var iterations = 5;
   var iteration = 0;
   var t = setInterval(function(){
      var stop = f();
      iteration++;
      if(stop || iteration==iterations){
         clearInterval(t);
         t = null;
      }
   },speed);
}

function Slide(obj,start,end) {
   var s = $(obj);
   var process = start;
   var steplength = 20;
   var step = Math.round( (end-start)*steplength/100 );
   var doit = false;
   Repeat(function(){
      process += step;
         if( start < end ) { doit = ( process<end ? true : false ); }
         else  { doit = ( process>end ? true : false ); }
      if(doit){
         s.style.top = process+"px";
      } else {
         s.style.top = end+"px";
         document.body.style.overflowX = '';
         return true; //stop;
      }
   });
}

function ShowLogin(){
   var lb = $('login-block');
   if(lb.offsetHeight){
      lb.hide();
   } else {
      document.body.style.overflowX = 'hidden';
      lb.style.top=-100;
      lb.show();
      Slide(lb,-100,5);
      if($('login-input').offsetHeight) $('login-input').focus();
   }
}
