var CALdisplayTimer;
var CALhideTimer;
var CALsaveCal;
var CALdisplayInterval = 050;
var CALhideInterval    = 300;
var CALposx            = 0;
var CALposy            = 0;

function CALshowPopupDiv() {
    var strDiv           = document.getElementById('divCal');
    var strIframe        = document.getElementById('iframeCal');
    var strAnchor        = document.getElementById('anchorCal');
    strDiv.style.display = 'block';
    strDiv.style.top     = CALposy;
    strDiv.style.left    = CALposx;

    strIframe.src  = CALsaveCal;
    
}

function CALstartDisplayTimer(e, strCal) {

  // var strPleaseWaitDiv = document.getElementById('divCalPleaseWait');
  // strPleaseWaitDiv.style.display = 'block';

  CALsaveCal = strCal;
  CALclearHideTimer();
  CALdisplayTimer = window.setTimeout(CALdisplayOptions, CALdisplayInterval);

  if (!e) {
     var e = event
  }
  
  if (e.pageX || e.pageY) {
     CALposx = e.pageX;
     CALposy = e.pageY;
  } else if (e.clientX || e.clientY) {
     CALposx = e.clientX + document.body.scrollLeft + document.documentElement.scrollLeft;
     CALposy = e.clientY + document.body.scrollTop  + document.documentElement.scrollTop;
  }
  
  if (CALposx > 725) {
     CALposx = CALposx - 275;
  }
  
}

function CALstartHideTimer() {
  CALclearDisplayTimer();
  CALhideTimer = window.setTimeout(CALhideOptions, CALhideInterval);
}

function CALclearDisplayTimer() {
  window.clearTimeout(CALdisplayTimer);
}

function CALclearHideTimer() {
  window.clearTimeout(CALhideTimer);
}

function CALdisplayOptions() {
   CALshowPopupDiv();
}

function CALhideOptions() {
   divCal.style.display = 'none' ;
}



