var dialogBox = {
  init: function() {
    if(!document.getElementById) return;
    
    if(document.getElementById('dialogbox_show')) {
      addEvent(document.getElementById('dialogbox_show'), 'click', dialogBox.showBox);
      document.getElementById('dialogbox_show').onclick = function() { return false; };
    }
    
    if(document.getElementById('dialogbox_hide')) {
      addEvent(document.getElementById('dialogbox_hide'), 'click', dialogBox.hideBox);
      document.getElementById('dialogbox_hide').onclick = function() { return false; };
    }
  },
  
  showBox: function() {
    // fix positioning in IE (using conditional comments)
    /*@cc_on @*/
    /*@if (@_win32)
      dialogBox.fixIE('100%', 'hidden');
      dialogBox.toggleSelects();
    /*@end @*/
  
    document.getElementById('overlay').style.display = 'block';
    document.getElementById('form').style.top = '40%';    
  },

  hideBox: function() {
    // fix positioning in IE (using conditional comments)
    /*@cc_on @*/
    /*@if (@_win32)
      dialogBox.fixIE('auto', 'auto');
      dialogBox.toggleSelects();
    /*@end @*/
  
    document.getElementById('form').style.display = 'block';
    document.getElementById('overlay').style.display = 'none';    
  },
  
  // fix issues with IE
  fixIE: function(height, overflow){
    bod = document.getElementsByTagName('body')[0];
    bod.style.height = height;
    bod.style.overflow = overflow;

    htm = document.getElementsByTagName('html')[0];
    htm.style.height = height;
    htm.style.overflow = overflow; 
  },
  
  // hides select elements in IE so they don't overlap dialog box
  toggleSelects: function() {
    var selects = document.getElementById('main').getElementsByTagName('select');
    for(var i = 0; i < selects.length; i++) {
      selects[i].style.visibility = (selects[i].style.visibility == 'hidden') ? 'visible' : 'hidden';
    }
  }
}

addEvent(window, 'load', dialogBox.init);