u_DialogBox = function(isModal) {
  if (arguments.length==0) return;
  this.isModal = isModal;
  if (isModal) u_DialogBox.veilInit();

  this.container = document.createElement('div');
  this.container.className = u_DialogBox.className;
  this.container.dialogBox = this;

  var mainTable = document.createElement('table');
  mainTable.setAttribute('cellSpacing', '0');
  mainTable.setAttribute('cellPadding', '0');
  mainTable.setAttribute('border', '0');

  var tBodyM = document.createElement('tbody');
  var rowM = document.createElement('tr');
  var cellM = document.createElement('td');

  var titleTable = document.createElement('table');
  titleTable.setAttribute('cellSpacing', '0');
  titleTable.setAttribute('cellPadding', '0');
  titleTable.setAttribute('border', '0');
  titleTable.setAttribute('width', '100%');

  var tBodyT = document.createElement('tbody');
  var rowT = document.createElement('tr');
  var cellT = document.createElement('td');
  rowT.appendChild(cellT);

  cellM.appendChild(titleTable);
  rowM.appendChild(cellM);
  tBodyM.appendChild(rowM);

  rowM = document.createElement('tr');
  cellM = document.createElement('td');

  this.contentArea = document.createElement('div');
  this.contentArea.className = "ContentArea";
  cellM.appendChild(this.contentArea);

  rowM.appendChild(cellM);
  tBodyM.appendChild(rowM);
  mainTable.appendChild(tBodyM);
  this.container.appendChild(mainTable);
  document.body.appendChild(this.container);
  }

u_DialogBox.prototype.show = function() {
  this.container.style.display = "block";
  this.container.style.zIndex = 1000;
  if (this.isModal) u_DialogBox.veilShow(true);
  }

u_DialogBox.prototype.hide = function(ok) {
  this.container.style.display = "none";
  if (this.isModal) u_DialogBox.veilShow(false);
  }

u_DialogBox.prototype.moveTo = function(x, y) {
  if (x == -1) x = Math.round((document.documentElement.clientWidth - this.container.offsetWidth) / 2);
  if (y == -1) y = Math.round((document.documentElement.clientHeight - this.container.offsetHeight) / 2) + document.documentElement.scrollTop;
  this.container.style.left = x + "px";
  this.container.style.top = y + "px";
  }

u_DialogBox.prototype.setContent = function(content) {
    while(this.contentArea.firstChild!=null) {
        this.contentArea.removeChild(this.contentArea.firstChild);
    }
    this.contentArea.appendChild(content);
  }

u_DialogBox.prototype.setWidth = function(width) {
  this.contentArea.style.width = width + "px";
  }

u_DialogBox.prototype.getContentNode = function() {
  return this.contentArea;
  }

u_DialogBox.veilInit = function() {
  if (u_DialogBox.veilOverlay == null) {
    u_DialogBox.veilOverlay = document.createElement('div');
    u_DialogBox.veilOverlay.className = "u_DialogBoxVeil";
    u_DialogBox.veilOverlay.style.zIndex = u_DialogBox.veilZ;
    u_DialogBox.veilOverlay.innerHTML = "&nbsp;";
    document.body.appendChild(u_DialogBox.veilOverlay);
    u_DialogBox.addListener(window, "resize", u_DialogBox.veilSetWidth);
    }
  }

u_DialogBox.veilShow = function(showIt) {
  u_DialogBox.veilSetWidth();
  u_DialogBox.veilOverlay.style.display = showIt ? "block" : "none";
  }


u_DialogBox.className = "u_DialogBox";
u_DialogBox.closeIcon = null;
u_DialogBox.veilOverlay = null;
u_DialogBox.veilZ = 900;
u_DialogBox.openList = new Array();
u_DialogBox.maxDepth = 5;

u_DialogBox.veilSetWidth = function() {
    yScroll = 0;
    if (window.innerHeight && window.scrollMaxY || window.innerWidth && window.scrollMaxX) {
        yScroll = window.innerHeight + window.scrollMaxY;
        xScroll = window.innerWidth + window.scrollMaxX;

        var deff = document.documentElement;
        var wff = (deff&&deff.clientWidth) || document.body.clientWidth || window.innerWidth || self.innerWidth;
        var hff = (deff&&deff.clientHeight) || document.body.clientHeight || window.innerHeight || self.innerHeight;

        xScroll -= (window.innerWidth - wff);
        yScroll -= (window.innerHeight - hff);
    }
    else if (document.body.scrollHeight > document.body.offsetHeight || document.body.scrollWidth > document.body.offsetWidth) {
        yScroll = document.body.scrollHeight;
        xScroll = document.body.scrollWidth;
    }
    else {
        yScroll = document.body.offsetHeight;
        xScroll = document.body.offsetWidth;
    }
    u_DialogBox.veilOverlay.style.width = xScroll + 'px';
    u_DialogBox.veilOverlay.style.height = yScroll + 'px';
  }

u_DialogBox.addListener = function(obj, evType, fn) {
  if (obj.addEventListener) {
    obj.addEventListener(evType, fn, false);
    return true;
    }
  else if (obj.attachEvent) return obj.attachEvent('on' + evType, fn);
  else return false;
  }

function u_valPx(pixels) {
  return pixels + "px";
  }

function u_moveTo(obj, x, y) {
  obj.style.left = u_valPx(x);
  obj.style.top = u_valPx(y);
  }

function u_Point(x, y) {
  this.x = x;
  this.y = y;
  }

function u_getOffsetXY(obj, findID, point) {
  if (point) {
    point.x = obj.offsetLeft;
    point.y = obj.offsetTop;
    }
  else point = new u_Point(obj.offsetLeft, obj.offsetTop);
  var parent = obj.offsetParent;
  while (parent != null) {
    if (findID && (parent.id == findID)) break;
    point.x += parent.offsetLeft;
    point.y += parent.offsetTop;
    parent = parent.offsetParent;
    }
  return point;
  }

var veilBox = null;
function showLoginBox() {
    if (veilBox == undefined) {
        veilBox = new u_DialogBox(true);
        veilBox.setContent(document.getElementById('loginWrapper'));
    }
    veilBox.show();
    veilBox.moveTo(-1, -1);
    document.getElementById('loginInput').focus();
  }

function hideLoginBox() {
    if (veilBox != null) {
        veilBox.hide();
    }
    //document.getElementById('langSelect').style.visibility = 'visible';
}