﻿var YTDLG_tmr;
var YTDLG_ID;

window.attachEvent("onresize",YTDLG_WindowResize);
window.attachEvent("onscroll",YTDLG_WindowResize);

function YTDLG_WindowResize(){
  if(document.getElementById(YT_ID+"DialogBackDrop").style.display=="block"){
    YTDLG_ResizeBackdrop();
  }
}

function YTDLG_PositionBackDrop(){
  if(YTDLG_tmr){
    window.clearInterval(YTDLG_tmr);
    YTDLG_tmr=null;
  }
  YTDLG_ResizeBackdrop();
  var dlg=document.getElementById(YTDLG_ID);
  if(dlg){
    dlg.style.visibility="visible";
    dlg.style.top=((YTDLG_clientHeight()-dlg.offsetHeight)/2+YTDLG_scrollTop())+"px";    
    dlg.style.left=((YTDLG_clientWidth()-dlg.offsetWidth)/2+YTDLG_scrollLeft())+"px";
  }
}
function YTDLG_ResizeBackdrop()
{
  var c=document.getElementById(YT_ID+"DialogBackDrop"); 
  document.body.appendChild(c);
  c.style.width=(YTDLG_scrollWidth())+"px";
  c.style.height=(YTDLG_scrollHeight())+"px";
  c.style.display="block";
}
function YTDLG_clientHeight() {
	return YTDLG_filterResults (
		window.innerHeight ? window.innerHeight : 0,
		document.documentElement ? document.documentElement.clientHeight : 0,
		document.body ? document.body.clientHeight : 0
	);
}
function YTDLG_clientWidth() {
	return YTDLG_filterResults (
		window.innerWidth ? window.innerWidth : 0,
		document.documentElement ? document.documentElement.clientWidth : 0,
		document.body ? document.body.clientWidth : 0
	);
}
function YTDLG_scrollTop() {
	return YTDLG_filterResults (
		window.pageYOffset ? window.pageYOffset : 0,
		document.documentElement ? document.documentElement.scrollTop : 0,
		document.body ? document.body.scrollTop : 0
	);
}
function YTDLG_scrollLeft() {
	return YTDLG_filterResults (
		window.pageXOffset ? window.pageXOffset : 0,
		document.documentElement ? document.documentElement.scrollLeft : 0,
		document.body ? document.body.scrollLeft : 0
	);
}
function YTDLG_scrollHeight() {	
  if(document.body){
    return YTDLG_filterResults (
      0,
	    0,
	    document.body ? document.body.scrollHeight : 0
	  );
  }
  else{
    return YTDLG_filterResults (
      0,
	    document.documentElement ? document.documentElement.scrollHeight : 0,
	    document.body ? document.body.scrollHeight : 0
	  );
  }		
}
function YTDLG_scrollWidth() {	
  if(document.body){
    return YTDLG_filterResults (
      0,
	    0,
	    document.body ? document.body.scrollWidth : 0
	  );
  }
  else{
    return YTDLG_filterResults (
      0,
	    document.documentElement ? document.documentElement.scrollWidth : 0,
	    document.body ? document.body.scrollWidth : 0
	  );
  }		
}
function YTDLG_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 YTDLG_Help(e,id)
{
  var c=document.getElementById(id);
  c.style.top=((YTDLG_clientHeight()-c.offsetHeight)/2+YTDLG_scrollTop())+"px";    
  c.style.left=((YTDLG_clientWidth()-c.offsetWidth)/2+YTDLG_scrollLeft())+"px";
  c.style.visibility="visible";
}
function YTDLG_CloseHelp(id)
{
  document.getElementById(id).style.visibility="hidden";
}
