// This displays a window in the centre of the screen and dims to gray the rest of the window
function showBox(txt) {
  showMsg(txt,450,200,true);
}

function showAutoBox(txt,timeout) {
  showMsg(txt, 250, 100, false, timeout);
}

function showPopup(txt,w,h) {
  showMsg(txt, w, h, true);
}

function UpdPopup(txt) {  
  var div = document.getElementById("box");
  div.innerHTML = "";
  var p = document.createElement('p');  
  var a = document.createElement('a');
  a.innerHTML = '<img align=right border=0 src="img/icon/btn_close.gif" alt="Close Window">';
  a.href = 'javascript:void(0)';
  a.onclick = function() {
    document.body.removeChild(document.getElementById('layer'));
    document.body.removeChild(document.getElementById('box'));
    try {
      setColor('');
    }
    catch (e) {}
  };
  p.appendChild(a);
  p.className = "popup_msg";
  var dv = document.createElement('div');
  dv.id = 'box_i';
  dv.style.zIndex = 800;
  dv.innerHTML = txt;
  p.appendChild(dv);
  div.appendChild(p);
}

function showAd(ad,width,height) {  
  var o = document.getElementById(ad);
  if (o) {    
    showAdMsg(o.childNodes[0].innerHTML, width, height);
  }
}

function showWelcome(ad, width, height) {
  var o = document.getElementById(ad);
  if (o) {
    showMsg(o.innerHTML, width, height, true);
  }
}

function showMsg(txt,_width,_height,showCloseButton,autoClose){
  var width = document.documentElement.clientWidth + document.documentElement.scrollLeft;  
  var height = screen.availHeight;  
  var layer = document.createElement('div');
  layer.style.zIndex = 700;
  layer.id = 'layer';
  layer.style.position = 'absolute';
  layer.style.top = '0px';
  layer.style.left = '0px';
  //layer.style.height = (document.documentElement.scrollHeight<1024?1024:document.documentElement.scrollHeight) + 'px';
  layer.style.height ="3200px";
  layer.style.width = width + 'px';
  layer.style.backgroundColor = 'black';
  layer.style.opacity = '.7';
  layer.style.filter += ("progid:DXImageTransform.Microsoft.Alpha(opacity=70)");
  document.body.appendChild(layer);

  var div = document.createElement('div');
  div.style.zIndex = 800;
  div.id = 'box';
  div.style.position = (navigator.userAgent.indexOf('MSIE 6') > -1) ? 'absolute' : 'fixed';
  div.style.top = (height-_height>150?50:0)+"px";
  div.style.left = (width / 2) - (_width / 2) + 'px';
  div.style.height = _height+'px';
  div.style.width = _width+'px';
  div.style.backgroundColor = 'white';
  div.style.border = '2px solid #FFA542';
  div.style.padding = '1px';
  document.body.appendChild(div);

  var p = document.createElement('p');
  if (showCloseButton) {
    var a = document.createElement('a');
    a.innerHTML = '<img align=right border=0 src="img/icon/btn_close.gif" alt="Close Window">';
    a.href = 'javascript:void(0)';
    a.onclick = function() {
      document.body.removeChild(document.getElementById('layer'));
      document.body.removeChild(document.getElementById('box'));
      try {
      setColor('');
      }
      catch (e) {}
      };
    p.appendChild(a);
  }
  if (autoClose > 0) setTimeout("ac();", autoClose);
  p.className = "popup_msg";
  var dv = document.createElement('div');
  dv.id = 'box_i';
  dv.style.zIndex = 800;
  dv.innerHTML = txt;
  p.appendChild(dv);
  div.appendChild(p);  
}

function ac() {
  document.body.removeChild(document.getElementById('layer'));
  document.body.removeChild(document.getElementById('box'));
}

function showAdMsg(txt, _width, _height) {
  var width = document.documentElement.clientWidth + document.documentElement.scrollLeft;

  var layer = document.createElement('div');
  layer.style.zIndex = 700;
  layer.id = 'layer';
  layer.style.position = 'absolute';
  layer.style.top = '0px';
  layer.style.left = '0px';  
  layer.style.height = "3200px";
  layer.style.width = '3200px';
  layer.style.backgroundColor = 'black';
  layer.style.opacity = '.7';
  layer.style.filter += ("progid:DXImageTransform.Microsoft.Alpha(opacity=70)");
  document.body.appendChild(layer);

  var div = document.createElement('div');
  div.style.zIndex = 800;
  div.id = 'box';
  div.style.position = (navigator.userAgent.indexOf('MSIE 6') > -1) ? 'absolute' : 'fixed';
  var height = screen.availHeight;  
  div.style.top = (height - _height > 150 ? 50 : 0) + "px";
  div.style.left = (width / 2) - (_width / 2) + 'px';
  div.style.height = _height + 'px';
  div.style.width = _width + 'px';  
  document.body.appendChild(div);

  var p = document.createElement('p');  
  p.className = "popup_msg";
  var dv = document.createElement('div');
  dv.innerHTML = txt;
  p.appendChild(dv);
  div.appendChild(p);  
}
