function WindowClose(aWindow)
{
  if (aWindow)
  {
    aWindow.close();
  } else
  {
    window.close();
  }
}


function WindowSafeClose(aWindow)
{
  try
   {
     WindowClose(aWindow);
   } catch(e)
   {
   }
}


function WindowMoveToCenter(aWindow,w,h)
{
  if (!aWindow) aWindow = window;
  if (aWindow)
  {
    if (!w)
    {
      //w = 300;
      w = aWindow.document.body.offsetWidth+8;
    }    
    if (!h)
    {
      //h = 300;
      h = aWindow.document.body.offsetHeight+27;
    }    
    X = Math.floor((window.screen.width - w) / 2);
    Y = Math.floor((window.screen.height - h) / 2);
    aWindow.moveTo(X,Y);
  }
}


function WindowMoveToMouse(aWindow,w,h)
{
  if (!aWindow) aWindow = window;
  if (aWindow)
  {
    var X = dhtmlMouseScreenX();
    var Y = dhtmlMouseScreenY();
    if (!w)
    {
      //w = 300;
      w = aWindow.document.body.offsetWidth+8;
    }    
    if (!h)
    {
      //h = 300;
      h = aWindow.document.body.offsetHeight+27;
    }    
    if ((X+parseInt())>window.screen.width)
    {
      X=window.screen.width-(w+20);
    }
    if ((Y+h)>window.screen.height)
    {
      Y=window.screen.height-(h+70);
    }
    aWindow.moveTo(X,Y);
  }
}


function WindowSize(aWindow,width,height)
{
   try
    {
      if (aWindow)
      {
      	aWindow.resizeTo(width,height);
      } else
      {
      	window.resizeTo(width,height);
      }
    } catch(e)
    {
    }    
} 


function WindowOpenUrl(windowname,url,w,h,resize,status,menubar,toolbar)
{
  if (!resize) resize='1';
  if (!status) status='1';
  if (!menubar) menubar='0';
  if (!toolbar) toolbar='0';
  if (!w) w='200';
  if (!h) h='200';
  options = "fullscreen=0,toolbar="+toolbar+",location=0,directories=0,status="+status+",menubar="+menubar+",scrollbars=1,resizable="+resize+",titlebar=1";
  if (w!=false) options = options + ",width="+w;
  if (h!=false) options = options + ",height="+h;
  aWindow = window.open(url , windowname, options);
  return aWindow;
}


function WindowOpenUrlHere(windowname,windowtitle,url,w,h,resize,status,menubar,toolbar)
{
  if (!resize) resize='1';
  if (!status) status='1';
  if (!menubar) menubar='0';
  if (!toolbar) toolbar='0';  
  aWindow = WindowOpenUrl(windowname,windowtitle,url,w,h,resize,status,menubar,toolbar);
  return aWindow;
}


function WindowOpen(url)
{
   options = "status=1,scrollbars=1,resizable=1,titlebar=1";  
   window.open(url,'',options);
}


function ShowWindowSize()
{
  alert("Fenster: " + (document.body.offsetWidth+8)  + " x " + (document.body.offsetHeight+27));
} 
