
function getPWClientSize()
{
  var theWidth, theHeight;
  
  if (window.innerWidth)
  {
    theWidth=window.innerWidth;
  }
  else if (document.documentElement && document.documentElement.clientWidth) 
  {
    theWidth=document.documentElement.clientWidth;
  }
  else if (document.body) 
  {
    theWidth=document.body.clientWidth;
  };
  
  if (window.innerHeight) 
  {
    theHeight=window.innerHeight;
  }
  else if (document.documentElement && document.documentElement.clientHeight) 
  {
    theHeight=document.documentElement.clientHeight;
  }
  else if (document.body) 
  {
    theHeight=document.body.clientHeight;
  };
  
  return new Object({Width:theWidth, Height:theHeight});
};

function showWait()
{
  if (typeof(jQuery) != "undefined" && typeof(jQuery.ui) != "undefined")
  {
    if (!jQuery('#waitDiv').length)
      jQuery("<div id='waitDiv' class='waitDiv'><span class='ui-icon ui-icon-clock' style='float: left; margin-right: 4px;'></span><strong>Please Wait...</strong></div>").appendTo("body");
    
    jQuery('#waitDiv').dialog(
    {
      modal : true,
      height : 'auto',
      width : 300,
      title : 'Please Wait...',
      resizable : false,
      closeOnEscape:false,
      open: function(event, ui) { $(".ui-dialog-titlebar-close", ui.dialog).hide(); }
    });
  }
  else
  {
    var size = getPWClientSize();
    
    var waitbg = document.createElement("div");
    waitbg.style.position = "fixed";
    waitbg.style.left = "0px";
    waitbg.style.top = "0px";
    waitbg.style.height = "100%";
    waitbg.style.width = "100%";
    waitbg.style.background = "black";
    waitbg.id = "waitBg";
    if (((navigator.userAgent.toLowerCase().indexOf("msie") != -1) && (navigator.userAgent.toLowerCase().indexOf("opera") == -1)))
    {
      waitbg.style.filter = 'alpha(opacity=30)';
    }
    else // for mozilla
    {
      waitbg.style.opacity = 0.3;
    };
    document.body.appendChild(waitbg);
    
    var waitDiv = document.createElement("div");
    waitDiv.id = "waitDiv";
    waitDiv.style.position = "fixed";
    waitDiv.style.width = "200px";
    waitDiv.style.height = "150px";
    var x = ((size.Width/2) < 100)?(0):((size.Width/2)-100);
    var y = ((size.Height/2) < 75)?(0):((size.Height/2)-75);
    waitDiv.style.left = x + "px";
    waitDiv.style.top = y + "px";
    waitDiv.style.background = "#dddddd";
    waitDiv.style.border = "1px solid black";
    waitDiv.style.color = "black";
    waitDiv.style.font = "bold 18px Tahoma";
    waitDiv.style.paddingTop = "40px";
    waitDiv.style.textAlign = "center";
    waitDiv.innerHTML = "Please Wait...<br/><br/><img src='/scripts/pleasewait.gif' />";
    document.body.appendChild(waitDiv);
  };
};

function hideWait()
{
  if (typeof(jQuery) != "undefined" && typeof(jQuery.ui) != "undefined")
  {
    jQuery('#waitDiv').dialog("close");
  }
  else
  {
    try
    {
      document.body.removeChild(document.getElementById('waitDiv'));
      document.body.removeChild(document.getElementById('waitBg'));
    }
    catch (er)
    {
    };
  };
};
