function getyScroll()
 {
  yScroll = 0;
  if (window.innerHeight && window.scrollMaxY || window.innerWidth && window.scrollMaxX)
   {
    yScroll = window.innerHeight + window.scrollMaxY;
    xScroll = window.innerWidth + window.scrollMaxX;
  
    var deff = document.documentElement;
    var wff = (deff&&deff.clientWidth) || document.body.clientWidth || window.innerWidth || self.innerWidth;
    var hff = (deff&&deff.clientHeight) || document.body.clientHeight || window.innerHeight || self.innerHeight;

    xScroll -= (window.innerWidth - wff);
    yScroll -= (window.innerHeight - hff);
   } 
  else if (document.body.scrollHeight > document.body.offsetHeight || document.body.scrollWidth > document.body.offsetWidth)
   { 
    yScroll = document.body.scrollHeight;
    xScroll = document.body.scrollWidth;
   } 
  else 
   { 
    yScroll = document.body.offsetHeight;
    xScroll = document.body.offsetWidth;
   }
  //alert(window.pageYOffset);

  return yScroll;
 }

function getBodyScrollTop()
{
	return self.pageYOffset || (document.documentElement && document.documentElement.scrollTop) || (document.body && document.body.scrollTop);
}

function getDocumentHeight()
{
	return (document.body.scrollHeight > document.body.offsetHeight)?document.body.scrollHeight:document.body.offsetHeight;
}


function wheel(event) {
    if (event.preventDefault)  event.preventDefault();
    event.returnValue = false;
}

function closeForm(e) {
	if (!e) e = window.event;
	
	//alert(e.keyCode);
	switch(e.keyCode)
     {
      case 27:
       hideloginform()
       break;

      case 13:
       $('loginform').send();
       break;
      
      case 32:
       return false;
       break;
     }
}

function showloginform()
 {
  	$('niceloginform').setStyles({display:'block','margin-top': getBodyScrollTop()});
  	$('screen').setStyles({display:'block',height: getyScroll()+window.pageYOffset }); 

	// Cкролл	
	// Нормальные браузеры 
	addHandler(window, 'DOMMouseScroll', wheel);
	// Opera 
	addHandler(window, 'mousewheel', wheel);
	// IE
	addHandler(document, 'mousewheel', wheel);
	
	$('name').focus();
	document.onkeydown = closeForm;
 }

function hideloginform()
 {
 	$('niceloginform').style.display = 'none';
 	$('screen').style.display = 'none';
  	
  	// Cкролл	
	// Нормальные браузеры 
	removeHandler(window, 'DOMMouseScroll', wheel);
	// Opera
	removeHandler(window, 'mousewheel', wheel);
	// IE
	removeHandler(document, 'mousewheel', wheel);
	
	document.onkeydown = null;
 }


disKeyTrap = false;
