//==============================================================================
// Javascript Library (c) Virtooz 2006-2008
//
// LIBRARY: uDialog.js
//
// DESCRIPTION
// Functions for the dialog window in the Loopbaanscan
//==============================================================================

//------------------------------------------------------------------------------
// dialogShow
//
// Show or hide the dialog 
//------------------------------------------------------------------------------

function dialogShow(flag) {
  var dlg = document.getElementById('dialog');
  if (dlg) {
    if (flag) {
      dlg.style.display    = '';
      dialogCenter();
      dlg.style.visibility = 'visible';
    }
    else {
      dlg.style.display    = 'none';
      dlg.style.visibility = 'hidden';
    }
  }
}

//------------------------------------------------------------------------------
// dialogCenter
//
// Position the dialog in the center of the screen
//------------------------------------------------------------------------------

function dialogCenter() {
  var dlg = document.getElementById('dialog');
  if (dlg) {
    var screenWidth = parseInt(document.getElementById('screen').offsetWidth);
    var screenHeight = parseInt(document.getElementById('screen').offsetHeight);
    var dialogWidth = parseInt(dlg.offsetWidth);
    var dialogHeight = parseInt(dlg.offsetHeight);
    //alert((screenWidth - dialogWidth) / 2 + 'px' + ' - ' + ((screenHeight - dialogHeight) / 2 + 5) + 'px');
    dlg.style.left = (screenWidth - dialogWidth) / 2 + 'px';
    dlg.style.top  = ((screenHeight - dialogHeight) / 2 + 5) + 'px';
  }
}

//------------------------------------------------------------------------------
// dialogEnableYes
//
// Enable or disable dialog YES button
//------------------------------------------------------------------------------

function dialogEnableYes(flag) {
  var btn = document.images['btnYes'];
  if (btn) {
    if (flag) {
      btn.src = 'images/main_dialog_btnyes_n.png';
      btn.className = 'dialog_button_enabled';
    }
    else {
      btn.src = 'images/main_dialog_btnyes_d.png';
      btn.className = 'dialog_button_disabled';
    }
  }
}

//------------------------------------------------------------------------------
// dialogEnableNo
//
// Enable or disable dialog NO button
//------------------------------------------------------------------------------

function dialogEnableNo(flag) {
  var btn = document.images['btnNo'];
  if (btn) {
    if (flag) {
      btn.src = 'images/main_dialog_btnno_n.png';
      btn.className = 'dialog_button_enabled';
    }
    else {
      btn.src = 'images/main_dialog_btnno_d.png';
      btn.className = 'dialog_button_disabled';
    }
  }
}

//------------------------------------------------------------------------------
// showDialog(title, text)
//
// Show dialog with YES button showing title and text
//------------------------------------------------------------------------------

function showDialog(title, text) {
  var dlgTitle = document.getElementById('dialog_title');
  var dlgContent = document.getElementById('dialog_content');
  dlgTitle.innerHTML = title;
  dlgContent.innerHTML = text;
  dialogShow(true);
}


