var ie,ns,mz,kp,op;


function detectBrowser()
{
	var detect = navigator.userAgent.toLowerCase();
	var OS,browser,version,total,thestring;
	glb_version = parseInt(navigator.appVersion);

	if (checkIt('konqueror'))
	{
		kq=1;
		glb_platform = "linux";
	}
	else if (checkIt('opera')) op=1;
	else if (checkIt('msie')) ie=1;
	else if (!checkIt('compatible'))
	{
		mz=1;
	}

    if(ie) {
      ie_5 = (detect.indexOf("msie 5.0")!=-1);
    }


	if (!OS)
	{
		if (checkIt('linux')) glb_platform = "linux";
		else if (checkIt('mac')) glb_platform = "mac";
		else if (checkIt('win')) glb_platform = "win";
		else OS = glb_platform = "other";
	}


	function checkIt(string)
	{
		place = detect.indexOf(string) + 1;
		thestring = string;
		return place;
	}

}

function getWindowWidth(win) 
{
	if(!win.document) return 0;
	if(!win.document.body) return 0;
	if(ie || ns || mz || kp || op) {
		return win.document.body.clientWidth;
	}
	if(win.innerWidth!=null) {
		return win.innerWidth;
	}
	return win.document.body.clientWidth;
}

function getWindowHeight(win) 
{
    var _body = win.document.body;

	if(!_body) return 0;
	if(ie || ns || mz || kq || op) {
		return _body.clientHeight;
	}
	if(win.innerHeight!=null) {
		return win.innerHeight;
	}
	return _body.clientHeight;
}

function getWindowTop(win)
{
  var wintop = 0;
	if(ie) {
	  if(win.document!=null) {
      return win.document.body.scrollTop;
	  }
	}
	else {
      return win.pageYOffset;
	}
	return wintop;
}

function setWindowTop(win,wintop)
{
	  win.scroll(0,wintop);
}

function getDocumentHeight(win) 
{
    if(!win.document) return 0;
	var _body = win.document.body;	

	if(!_body) return 0;
	// Az ms explorerekre windows alatt
	if(ie && glb_platform!='mac') {
		return _body.scrollHeight;
	}
	else {
		return win.document.documentElement.offsetHeight;
	}
	
}
 












function slide() {
    var slip = document.getElementById('slider_div');
    var s = document.getElementById('slider_limiter');
    
    if(!s) {
      setTimeout("slide();", 10);
      return;        
    }

    var _header     = 0;
    var _footer     = 0;
    var _height   = s.offsetParent.offsetHeight;

    if(_height==0) {
      setTimeout("slide()", 10);
      return;
    }
    var main = window;
  
    var winheight   = getWindowHeight(main.top);
    var wintop      = getWindowTop(main);
    var winsize     = getDocumentHeight(main);
    var _dheight    = winsize - _header - _footer;
    var normal	  = true;

    var pos = wintop -_header;

    //  Csak addig csÄ‚Ĺźsszon, hogy a footert ne takarja ki
    if(pos+_height>_dheight ) {
      pos = _dheight - _height;
      normal = false;
    }
    
    // Visszafele ne szaladjon rÄ‚Ë‡ a footer-re
    if(pos<0) {
      pos=0;
    }
    
    // Az aktuÄ‚Ë‡lis poziciÄ‚Ĺ‚ja
    var cpos = sliderPos; 
    
    // Lefele mozdult
    // ne csÄ‚Ĺźsszon addig, amÄ‚Â­g nem lÄ‚Ë‡thatÄ‚Ĺ‚ az alja
    if(cpos<pos) {
      if(pos+_height+_header>wintop+winheight) {
        pos = wintop+winheight-_height-_header;
        pos = Math.max(0,pos);
	    if(pos+_height+_header+1>winsize-_footer) {
	      pos = _dheight-_height-4;
	    }
      }
    }
    
    if(normal) {
      // ne csÄ‚Ĺźsszon addig, amÄ‚Â­g nem lÄ‚Ë‡thatÄ‚Ĺ‚ a teteje
      if(cpos>pos) {
        if(pos<wintop-_header) {
          setTimeout("slide()", 10);
          return;      
        }
      }
    }
        
    // Mozgatni kell, de csak forozatosan
    if(cpos!=pos) {      
      if(normal) {
        sliderPos += Math.floor((pos-cpos)/8);
      }
      else {
        sliderPos = pos;
      }
      slip.style.top = sliderPos+'px';
    }
    setTimeout("slide()", 10);  
  }

  
  
 var sliderPos = 0;
 detectBrowser(); 
