$(function() { 
  fadeOutProcessing(); 
  
  var screenHeight = calculateScreenHeight();
  var processorHeight = $(".processing-outer").height();
  var processorWidth = $(".processing-outer").width();
  $(".processing-outer").css("top", (((screenHeight)/2)-processorHeight)+"px");
  $(".processing-outer").css("left", (Math.round(document.body.clientWidth-processorWidth)/2)+"px");
});

function showProcessing() {
  $("#processingOverlayContainer").show().fadeTo("slow", 0.5);
  $(".processing-outer").show().fadeTo("slow", 1.0);
}
function fadeOutProcessing() {
  $(".processing-outer").fadeTo("slow", 0, hideProcessing);
  $("#processingOverlayContainer").fadeTo("slow", 0, hideProcessing);
}
function hideProcessing() {
  $(".processing-outer").hide();
  $("#processingOverlayContainer").hide();
}

function calculateScreenHeight() {
  var pageHeight, yScroll;

  if (window.innerHeight && window.scrollMaxY) yScroll = window.innerHeight + window.scrollMaxY;
  else if (document.body.scrollHeight > document.body.offsetHeight) yScroll = document.body.scrollHeight; // all but Explorer Mac
  else yScroll = document.body.offsetHeight; // Explorer Mac, plus will also work in Explorer 6 Strict, Mozilla and Safari


  if (self.innerHeight) windowHeight = self.innerHeight; // all except Explorer
  else if (document.documentElement && document.documentElement.clientHeight) windowHeight = document.documentElement.clientHeight; // Explorer 6 Strict Mode
  else if (document.body) windowHeight = document.body.clientHeight; // other Explorers

  // for small pages with total height less then height of the viewport
  if (yScroll < windowHeight) pageHeight = windowHeight;
  else pageHeight = yScroll;
  
  return pageHeight;

}

