
  // getPageSize()
  // Returns array with page width, height and window width, height
  // Core code from - quirksmode.com
  // Edit for Firefox
  //
  function getPageSize(){
    
    var xScroll, yScroll;
    
    if (window.innerHeight && window.scrollMaxY) {  
      xScroll = window.innerWidth + window.scrollMaxX;
      yScroll = window.innerHeight + window.scrollMaxY;
    } else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
      xScroll = document.body.scrollWidth;
      yScroll = document.body.scrollHeight;
    } else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
      xScroll = document.body.offsetWidth;
      yScroll = document.body.offsetHeight;
    }
    
    var windowWidth, windowHeight;
    
    if (self.innerHeight) { // all except Explorer
      if(document.documentElement.clientWidth){
        windowWidth = document.documentElement.clientWidth; 
      } else {
        windowWidth = self.innerWidth;
      }
      windowHeight = self.innerHeight;
    } else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
      windowWidth = document.documentElement.clientWidth;
      windowHeight = document.documentElement.clientHeight;
    } else if (document.body) { // other Explorers
      windowWidth = document.body.clientWidth;
      windowHeight = document.body.clientHeight;
    } 
    
    // for small pages with total height less then height of the viewport
    if(yScroll < windowHeight){
      pageHeight = windowHeight;
    } else { 
      pageHeight = yScroll;
    }

    // for small pages with total width less then width of the viewport
    if(xScroll < windowWidth){  
      pageWidth = xScroll;    
    } else {
      pageWidth = windowWidth;
    }

    arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight) 
    return arrayPageSize;
  }

  // getPageScroll()
  // Returns array with x,y page scroll values.
  // Core code from - quirksmode.com
  //
  function getPageScroll() {

    var xScroll, yScroll;

    if (self.pageYOffset) {
      yScroll = self.pageYOffset;
      xScroll = self.pageXOffset;
    } else if (document.documentElement && document.documentElement.scrollTop){  // Explorer 6 Strict
      yScroll = document.documentElement.scrollTop;
      xScroll = document.documentElement.scrollLeft;
    } else if (document.body) {// all other Explorers
      yScroll = document.body.scrollTop;
      xScroll = document.body.scrollLeft; 
    }

    arrayPageScroll = new Array(xScroll,yScroll) 
    return arrayPageScroll;
  }
  // * * *

  var Ytmd, Mtmd;

  function ClrTimerMonth()
  {
    timerID = Mtmd;
    clearTimeout(timerID);
  }

  function ClrTimerYear()
  {
    timerID = Ytmd;
    clearTimeout(timerID);
  }

  function STimerMonth()
  {
    timerID = setTimeout('HideCalendarMonth()', 1000);
    Mtmd = timerID;
  }

  function STimerYear()
  {
    timerID = setTimeout('HideCalendarYear()', 1000);
    Ytmd = timerID;
  }

  function changeBg(obj) 
  {
    var wdt = obj.width;
    obj.style.backgroundPosition = (obj.style.backgroundPosition == '' || obj.style.backgroundPosition == '0px 0px') ? '-'+wdt+'px 0' : '0px 0px ';
  }

  function setOverlay () 
  {
    obj = document.getElementById('OverLay');
    a = window.screen.availWidth;
    obj.style.width = a;
  }

  function showHidePopup(objId) 
  {
    obj = document.getElementById(objId);
    whatDo = (obj.style.display == 'none') ? "block" : "none";

    jQuery("body").find("select").each(function(){
      if (whatDo == 'block')
        jQuery(this).hide();
      else
        jQuery(this).show();
    });

    jQuery("#"+objId).find("select").each(function(){
      jQuery(this).show();
    });

    document.getElementById("OverLay").style.visibility = (whatDo == 'block') ? 'visible' : 'hidden';

    // * * *
    PageSize   = getPageSize();
    PageScroll = getPageScroll();

    OC_Height = jQuery("#"+objId).height();
 
    if (PageSize[3]>OC_Height) ITop = (PageSize[3] - OC_Height)/2; else ITop = 10;
    if (PageScroll[1]>0) ITop = ITop + PageScroll[1];

    // * * *

    document.getElementById(objId).style.top = (whatDo == 'block') ? ITop+"px" : '0';
    obj.style.display = whatDo;

    if(objId =='reg') sajax.XMLCmd('/ajx/kcaptcha.php',{'event':'GET'},document,'capI','hold','capD');

    return false;
   }

  jQuery(document).ready(function(){

    jQuery("#OverLay").height(jQuery("body").height());//


    ShowCalendarYear = function()
    {
      jQuery("#YearList").css("visibility", "visible");
    }

    HideCalendarYear = function()
    {
      jQuery("#YearList").css("visibility", "hidden");
    }

    ShowCalendarMonth = function()
    {
      jQuery("#MonthList").css("visibility", "visible");
    }

    HideCalendarMonth = function()
    {
      jQuery("#MonthList").css("visibility", "hidden");
    }

  });

