﻿var UPDDLG_tmr;
var UPDDLG_ID;

if(window.addEventListener)
{
  window.addEventListener("onresize",UPDDLG_WindowResize,false);
  window.addEventListener("onscroll",UPDDLG_WindowResize,false);
}
else
{
  window.attachEvent("onresize",UPDDLG_WindowResize);
  window.attachEvent("onscroll",UPDDLG_WindowResize);
}


window.onresize=UPDDLG_WindowResize;

window.onscroll=UPDDLG_WindowResize;





function UPDDLG_WindowResize(){
  if(document.getElementById("UPDDLG_DialogBackDrop")!=null&&document.getElementById("UPDDLG_DialogBackDrop").style.display=="block"){
    UPDDLG_ResizeBackdrop();
  }
}

function UPDDLG_PositionBackDrop(){
  if(UPDDLG_tmr){
    window.clearInterval(UPDDLG_tmr);
    UPDDLG_tmr=null;
  }
  UPDDLG_ResizeBackdrop();
  var dlg=document.getElementById(UPDDLG_ID);
  if(dlg){
    dlg.style.visibility="visible";
    dlg.style.top=((UPDDLG_clientHeight()-dlg.offsetHeight)/2+UPDDLG_scrollTop())+"px";    
    dlg.style.left=((UPDDLG_clientWidth()-dlg.offsetWidth)/2+UPDDLG_scrollLeft())+"px";
  }
}
function UPDDLG_ResizeBackdrop()
{
  var c=document.getElementById("UPDDLG_DialogBackDrop"); 
  document.body.appendChild(c);
  c.style.width=(UPDDLG_scrollWidth())+"px";
  c.style.height=(UPDDLG_scrollHeight())+"px";
  c.style.display="block";
}
function UPDDLG_clientHeight() {
	return UPDDLG_filterResults (
		window.innerHeight ? window.innerHeight : 0,
		document.documentElement ? document.documentElement.clientHeight : 0,
		document.body ? document.body.clientHeight : 0
	);
}
function UPDDLG_clientWidth() {
	return UPDDLG_filterResults (
		window.innerWidth ? window.innerWidth : 0,
		document.documentElement ? document.documentElement.clientWidth : 0,
		document.body ? document.body.clientWidth : 0
	);
}
function UPDDLG_scrollTop() {
	return UPDDLG_filterResults (
		window.pageYOffset ? window.pageYOffset : 0,
		document.documentElement ? document.documentElement.scrollTop : 0,
		document.body ? document.body.scrollTop : 0
	);
}
function UPDDLG_scrollLeft() {
	return UPDDLG_filterResults (
		window.pageXOffset ? window.pageXOffset : 0,
		document.documentElement ? document.documentElement.scrollLeft : 0,
		document.body ? document.body.scrollLeft : 0
	);
}
function UPDDLG_scrollHeight() {	
  if(document.body){
    return UPDDLG_filterResults (
      0,
	    0,
	    document.body ? document.body.scrollHeight : 0
	  );
  }
  else{
    return UPDDLG_filterResults (
      0,
	    document.documentElement ? document.documentElement.scrollHeight : 0,
	    document.body ? document.body.scrollHeight : 0
	  );
  }		
}
function UPDDLG_scrollWidth() {	
  if(document.body){
    return UPDDLG_filterResults (
      0,
	    0,
	    document.body ? document.body.scrollWidth : 0
	  );
  }
  else{
    return UPDDLG_filterResults (
      0,
	    document.documentElement ? document.documentElement.scrollWidth : 0,
	    document.body ? document.body.scrollWidth : 0
	  );
  }		
}
function UPDDLG_filterResults(n_win, n_docel, n_body) {
	var n_result = n_win ? n_win : 0;
	if (n_docel && (!n_result || (n_result > n_docel)))
		n_result = n_docel;
	return n_body && (!n_result || (n_result > n_body)) ? n_body : n_result;
}

function UPDDLG_Help(e,id)
{
  var c=document.getElementById(id);
  c.style.top=((UPDDLG_clientHeight()-c.offsetHeight)/2+UPDDLG_scrollTop())+"px";    
  c.style.left=((UPDDLG_clientWidth()-c.offsetWidth)/2+UPDDLG_scrollLeft())+"px";
  c.style.visibility="visible";
}
function UPDDLG_CloseHelp(id)
{
  document.getElementById(id).style.visibility="hidden";
}