/*
Autor:   Thomas Konrad
Version: 1.0 RC1
Datum:   07.09.2009
*/


function fb_show (append, mess)
{
  if ($('floatbox'))
    $('floatbox').remove();

  mess = (mess) ? mess : 'Bitte warten...';

  var div = new Element('div',
  {
    style: 'z-index: 3; background-color: #ffffff; position: absolute;',
    id: 'floatbox'
  }).observe('click', function(event)
  {
    fb_alert('Mitteilung', mess, 'Verstanden', 'fb_hide(1);');
  }).setOpacity(0);

  document.body.appendChild(div);

  $('floatbox').clonePosition($(append));
}

function fb_alert(head, body, but1, f1, but2, f2, but3, f3)
{
  var buttons = '';

  for (i = 2; i < 7; i += 2)
  {
    if (fb_alert.arguments[i])
      buttons += '<input type="submit" value="' + fb_alert.arguments[i] + '" onclick="' + fb_alert.arguments[i + 1] + '" />&nbsp;&nbsp;';
  }

  pos = (Prototype.Browser.IE6) ? 'height: 1000px; position: absolute; ' : 'height: 100%; position: fixed; ';

  var div = new Element('div',
  {
    style: 'z-index: 4; background-color: #000000; width: 100%; ' + pos + 'top: 0; left: 0;',
    id: 'floatbox_alert1'
  }).setOpacity(0.5);

  var div_ = new Element('div',
  {
    style: 'z-index: 5; background-color: #e0e0e0; border: 1px solid #505050; width: 400px; padding: 10px; position: absolute; top: 250px; left: 50%; margin-left: -211px;',
    id: 'floatbox_alert2'
  }).update('<h1>' +  head + '</h1><br />' + body + '<br /><br />' + buttons);

  document.body.appendChild(div);
  document.body.appendChild(div_);

  $('floatbox_alert2').down().next('input').id = 'first_butt';
}

function fb_hide (mode)
{
  switch (mode)
  {
    case 1:
      $('floatbox_alert1').remove();
      $('floatbox_alert2').remove();
      break;
    case 2:
    default:
      $('floatbox').remove();
      break;
  }
}
