function GetScroll()
 {
  yScroll = 0;
  xScroll = 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)
   { // all but Explorer Mac
    yScroll = document.body.scrollHeight;
    xScroll = document.body.scrollWidth;
   } 
  else 
   { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
    yScroll = document.body.offsetHeight;
    xScroll = document.body.offsetWidth;
   }

  return [xScroll, yScroll];
 }

function GetYScroll()
 {
  var scroll = GetScroll();
  return scroll[1] + 'px';
 }

var LastPopup = '';

function AppearPopup(id, url)
 {
  var s = $('screen');
  s.style.height = GetYScroll();
  s.style.display = 'block';

  new Ajax.Updater(id, url, {asynchronous: true, method: 'get', evalScripts: true});

  var i = $(id);
  i.innerHTML = '<div align="center" class="PopupProgress"><img class="logo" src="/images/logo6.gif" width="82" height="64"><img class="progress" width="190" height="14" src="/images/progress.gif"></div>';
  i.style.display = 'block';

  LastPopup = id;
 }

function DetachPopup()
 {
  var s = $('screen');
  s.style.display = 'none';

  var i = $(LastPopup);
  i.style.display = 'none';
 }

function DoLogin()
 {
  AppearPopup('PopupForm', '/login/?ajax=1');
  return false;
 }

function DoRegister()
 {
  AppearPopup('PopupForm', '/register/?ajax=1');
  return false;
 }

function DoChoose()
 {
  AppearPopup('PopupForm', '/choose/?ajax=1');
  return false;
 }
