/**
 * Part of the lightbox project
 * http://www.huddletogether.com/projects/lightbox2/
 * Licence: http://creativecommons.org/licenses/by/2.5/
 */
// -----------------------------------------------------------------------------------
//
//	Lightbox v2.03.3
//	by Lokesh Dhakar - http://www.huddletogether.com
//	5/21/06
//
//	For more information on this script, visit:
//	http://huddletogether.com/projects/lightbox2/
//
//	Licensed under the Creative Commons Attribution 2.5 License - http://creativecommons.org/licenses/by/2.5/
//
//	Credit also due to those who have helped, inspired, and made their code available to the public.
//	Including: Scott Upton(uptonic.com), Peter-Paul Koch(quirksmode.com), Thomas Fuchs(mir.aculo.us), and others.
//
//
// -----------------------------------------------------------------------------------

var canceltext = 'Abbrechen';
if(SystemLang == 'en') {
  canceltext = 'Cancel';
}

//
//	Additional methods for Element added by SU, Couloir
//	- further additions by Lokesh Dhakar (huddletogether.com)
//
Object.extend(Element, {
	getWidth: function(element) {
	   	element = $(element);
	   	return element.offsetWidth;
	},
	setWidth: function(element,w) {
	   	element = $(element);
    	element.style.width = w +"px";
	},
	setHeight: function(element,h) {
   		element = $(element);
    	element.style.height = h +"px";
	},
	setTop: function(element,t) {
	   	element = $(element);
    	element.style.top = t +"px";
	},
	setLeft: function(element,l) {
	   	element = $(element);
    	element.style.left = l +"px";
	},
	setSrc: function(element,src) {
    	element = $(element);
    	element.src = src;
	},
	setHref: function(element,href) {
    	element = $(element);
    	element.href = href;
	},
	setInnerHTML: function(element,content) {
		element = $(element);
		element.innerHTML = content;
	}
});

// -----------------------------------------------------------------------------------


//
// getPageScroll()
// Returns array with x,y page scroll values.
// Core code from - quirksmode.com
//
function getPageScroll(){

	var xScroll, yScroll;

	if (self.pageYOffset) {
		yScroll = self.pageYOffset;
		xScroll = self.pageXOffset;
	} else if (document.documentElement && document.documentElement.scrollTop){	 // Explorer 6 Strict
		yScroll = document.documentElement.scrollTop;
		xScroll = document.documentElement.scrollLeft;
	} else if (document.body) {// all other Explorers
		yScroll = document.body.scrollTop;
		xScroll = document.body.scrollLeft;
	}

	arrayPageScroll = new Array(xScroll,yScroll)
	return arrayPageScroll;
}

// -----------------------------------------------------------------------------------

//
// getPageSize()
// Returns array with page width, height and window width, height
// Core code from - quirksmode.com
// Edit for Firefox by pHaez
//
function getPageSize(){

	var xScroll, yScroll;

	if (window.innerHeight && window.scrollMaxY) {
		xScroll = window.innerWidth + window.scrollMaxX;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}

	var windowWidth, windowHeight;

//	console.log(self.innerWidth);
//	console.log(document.documentElement.clientWidth);

	if (self.innerHeight) {	// all except Explorer
		if(document.documentElement.clientWidth){
			windowWidth = document.documentElement.clientWidth;
		} else {
			windowWidth = self.innerWidth;
		}
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}

	// for small pages with total height less then height of the viewport
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else {
		pageHeight = yScroll;
	}

//	console.log("xScroll " + xScroll)
//	console.log("windowWidth " + windowWidth)

	// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth){
		pageWidth = xScroll;
	} else {
		pageWidth = windowWidth;
	}
//	console.log("pageWidth " + pageWidth)

	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight)
	return arrayPageSize;
}

// -----------------------------------------------------------------------------------

function showSelectBoxes(doc){
	var selects = doc.getElementsByTagName("select");
	for (i = 0; i != selects.length; i++) {
		selects[i].style.visibility = "visible";
	}
}

// ---------------------------------------------------

function hideSelectBoxes(doc){
	var selects = doc.getElementsByTagName("select");
	for (i = 0; i != selects.length; i++) {
		selects[i].style.visibility = "hidden";
	}
}

// ---------------------------------------------------

function showFlash(doc){
	var flashObjects = doc.getElementsByTagName("object");
	for (i = 0; i < flashObjects.length; i++) {
		flashObjects[i].style.visibility = "visible";
	}

	var flashEmbeds = doc.getElementsByTagName("embed");
	for (i = 0; i < flashEmbeds.length; i++) {
		flashEmbeds[i].style.visibility = "visible";
	}
}

// ---------------------------------------------------

function hideFlash(doc){
	var flashObjects = doc.getElementsByTagName("object");
	for (i = 0; i < flashObjects.length; i++) {
		flashObjects[i].style.visibility = "hidden";
	}

	var flashEmbeds = doc.getElementsByTagName("embed");
	for (i = 0; i < flashEmbeds.length; i++) {
		flashEmbeds[i].style.visibility = "hidden";
	}

}



/**
 * Custom code (not part of lightbox)
 */

function blurPageCheckResize() {
	var arrayPageSize = getPageSize();
	Element.setWidth('overlay', arrayPageSize[0]);
	Element.setHeight('overlay', arrayPageSize[1]);
}

function showInputfields(doc){
	var inputs = doc.getElementsByTagName("input");
	for (i = 0; i != inputs.length; i++) {
		inputs[i].style.visibility = "visible";
	}
}

function hideInputfields(doc){
	var inputs = doc.getElementsByTagName("input");
	for (i = 0; i != inputs.length; i++) {
		inputs[i].style.visibility = "hidden";
	}
}

function hideAllForOverlay(doc) {
	hideSelectBoxes(doc);
  hideInputfields(doc)
  hideFlash(doc);
}

function showAllForOverlay(doc) {
	showSelectBoxes(doc);
  showInputfields(doc)
  showFlash(doc);
}

function blurPage(afterFinish) {
	var arrayPageSize = getPageSize();
	var objBody = document.getElementsByTagName("body").item(0);
	var objOverlay = document.createElement("div");

	if(!afterFinish) afterFinish = function() {};

	objOverlay.setAttribute('id','overlay');
	objOverlay.style.display = 'none';
	objBody.appendChild(objOverlay);

	hideAllForOverlay(document);

	window.oldonresize = window.onresize;
	window.onresize = blurPageCheckResize;

	Element.setWidth('overlay', arrayPageSize[0]);
	Element.setHeight('overlay', arrayPageSize[1]);

	Effect.Appear('overlay', { duration: 0.5, from: 0.0, to: 0.65, afterFinish:afterFinish});
}

function focusPage() {
  var objBody = document.getElementsByTagName("body").item(0);
	var objOverlay = $('overlay');

	window.onresize = window.oldonresize;

	Effect.Fade(objOverlay, { duration: 0.5, afterFinish: function() {
		if(objOverlay) {
		  objBody.removeChild(objOverlay);
			showAllForOverlay(document);
		}}}
	);
}

function modalBoxShow(level,width,height) {
  alert('Bitte die neue ModalBox nutzen.');
  var objBody = document.getElementsByTagName('body').item(0);
  var layer = document.createElement('div');
  var layer_inner = document.createElement('div');
	var table = document.createElement('table');
	var rows = new Array();
	var cells = new Array();
	var smallWidths = [ 0,2,3,5,6,8 ];
	var smallHeight = [ 0,1,2,6,7,8 ];
	var bigWidth = [ 1,4,7 ];
	var bgAppendix = [ 'tl','tc','tr','cl','','cr','bl','bc','br' ];

  objBody.appendChild(layer);

	layer.id = 'modalbox_'+level;
	layer.className = 'modal-box';
	if(width) {
		layer.style.width = width;
	}
	layer.style.top = '100px';
	// IE error
	try {
		layer.style.left = window.innerWidth/2-(width/2)+'px';
	} catch(e) {
		layer.style.left = document.documentElement.clientWidth/2-(width/2)+'px';
	}
	//layer.style.display = 'none';

	layer_inner.className='modal-inner';

	table.id = 'modalbox_table_'+level;

	layer.style.zIndex = 100+level;
	table.setAttribute('border', 0);
	table.setAttribute('cellpadding',0);
	table.setAttribute('cellspacing',0);
	table.setAttribute('cellmargin', 0);
	var k = 0;
	for(var i=0;i<3;i++) {
    rows[i] = document.createElement('tr');
		for(j=0;j<3;j++) {
			cells[k] = document.createElement('td');
			rows[i].appendChild(cells[k]);
			k++;
		}
		table.appendChild(rows[i]);
	}
	for(var i=0;i<smallWidths.length;i++) {
		cells[smallWidths[i]].style.width = '10px';
	}
	for(var i=0;i<smallHeight.length;i++) {
		cells[smallHeight[i]].style.height = '10px';
	}
	if(width) {
		for(var i=0;i<bigWidth.length;i++) {
			cells[bigWidth[i]].style.width = width+'px';
		}
	}
	for(var i=0;i<bgAppendix.length;i++) {
	  if(bgAppendix[i]) {
			if(bgAppendix[i].indexOf('c')==0) {
				cells[i].style.background = 'url(/images/modalshadow_'+bgAppendix[i]+'.png) top left repeat-y';
		  } else if(bgAppendix[i].indexOf('c')==1) {
		  	cells[i].style.background = 'url(/images/modalshadow_'+bgAppendix[i]+'.png) top left repeat-x';
		  } else {
			  cells[i].style.background = 'url(/images/modalshadow_'+bgAppendix[i]+'.png) top left no-repeat';
			}
		}
	}

	if(height) {
		var heightImage = document.createElement('img');
		heightImage.src = '/ADMIN/images/s.gif';
		heightImage.width = 1;
		heightImage.height = height;
		cells[3].appendChild(heightImage);
	}
	cells[4].style.width = (width-10)+'px';
	cells[4].style.backgroundColor = '';
	cells[4].valign = 'top';
  cells[4].appendChild(layer_inner);
  layer.appendChild(table);
	layer_inner.style.border = '';
	layer.style.display = '';
	layer.style.border = "2px solid blue";
	table.style.border = "2px dashed red";
	layer.style.height = "200px";

  centerBox(layer,width);
	return layer_inner;
}

function modalBoxDestroy(level) {
	var box = $('modalbox_'+level);
	if(box) {
		box.parentNode.removeChild(box);
	}
}

function centerBox(boxId,width) {
  var layer = $(boxId);
  layer.style.top = '100px';
  try {
    layer.style.left = window.innerWidth/2-(width/2)+'px';
  } catch(e) {
    layer.style.left = document.documentElement.clientWidth/2-(width/2)+'px';
  }
}

function showDialog(sType, sTitle, sText, oOnClick)
{
	alert('-y-OLD-y-');
	/*
  var oDialog = $('GlobalDialog');
  if (!oDialog)
    return;

  oDialog.addClassName(sType);

  var oHeader = $('GlobalDialogHeader');
  var oText = $('GlobalDialogText');
  var oAction = $('GlobalDialogAction');

  oHeader.innerHTML = sTitle;
  oText.innerHTML = sText;
  if(!oOnClick) {
  	oOnClick = function() {
  		closeDialog();
  	}
  }
  oAction.onclick = oOnClick;
  oDialog.show();
  */
}

function showConfirmDialog(sType, sTitle, sText, oOnYes, oOnNo, oAppendToContent)
{
	alert('-x-OLD-x-');
	/*
  var oDialog = $('GlobalConfirmDialog');
  if (!oDialog)
    return;

  oDialog.addClassName(sType);

  var oHeader = $('GlobalConfirmDialogHeader');
  var oText = $('GlobalConfirmDialogText');
  var oActionYes = $('GlobalConfirmDialogActionYes');
  var oActionNo = $('GlobalConfirmDialogActionNo');

  oHeader.innerHTML = sTitle;
  oText.innerHTML = sText;
  if (oAppendToContent)
    oText.appendChild(oAppendToContent);
  oActionYes.onclick = oOnYes;
  oActionNo.onclick = oOnNo;
  oDialog.show();
  */
}

function closeDialog() { $('GlobalDialog').hide(); }
function closeConfirmDialog() { $('GlobalConfirmDialog').hide(); }

/* New modal box */
var oMBBlurLayer = null;
var iNumModalBoxes = 0;
var Modal = Class.create();

Modal.prototype = {

  iLevel: 100,
  iWidth: 400,
  iHeight: 300,
  sTitle: '',
  aPageSize: null,
  oFrame: null,
  oRoot: null,
  oCloseFunction: null,
  oDOMParent: null,
  oDOMNextSibling: null,

  initialize: function(iLevel, iWidth, iHeight)
  {
    iNumModalBoxes++;
    this.iLevel = iLevel;
    this.iWidth = iWidth;
    this.iHeight = iHeight;
    this.aPageSize = getPageSize();
    this.oRoot = document.getElementsByTagName('body')[0];

    this._vConstruct();
  },

  _vBlurPage: function()
  {
    var _this = this;

    // Hide select boxes
    if (IE && !IE7)
    {
  		hideSelectBoxes(document);
  		showSelectBoxes(this.oFrame);
    }

    oMBBlurLayer = $('MBBlurLayer');

    if (!oMBBlurLayer)
    {
      oMBBlurLayer = document.createElement('div');
      oMBBlurLayer.id = 'MBBlurLayer';
      oMBBlurLayer.style.display = 'none';
      this.oRoot.appendChild(oMBBlurLayer);
    }

    oMBBlurLayer.style.width = this.aPageSize[0] + 'px';
    oMBBlurLayer.style.height = this.aPageSize[1] + 'px';

    Effect.Appear(oMBBlurLayer,
    {
      from: 0.0,
      to: 0.45,
      duration: 0.5,
      afterFinish: function() { oMBBlurLayer.bBlurred = true; _this._vShowFrame(); }
    });

  },

  _vConstruct: function()
  {
    this.oFrame = document.createElement('div');
    this.oFrame.className = 'MBFrame';

    // For Safari
    this.oFrame.style.position = 'absolute';

    this.oFrame.style.width = this.iWidth + 'px';
    this.oFrame.style.height = this.iHeight ? this.iHeight + 'px' : 'auto';
    this.oFrame.style.display = 'none';
    this.oFrame.style.zIndex = 100 + this.iLevel;

    this.oFrame.oHeader = document.createElement('h2');
    this.oFrame.oHeader.appendChild(document.createTextNode(this.sTitle));
    this.oFrame.appendChild(this.oFrame.oHeader);

    this.oFrame.oErrorHint = document.createElement('p');
    this.oFrame.oErrorHint.className = 'MBErrorHint';
    this.oFrame.oErrorHint.style.display = 'none';
    this.oFrame.appendChild(this.oFrame.oErrorHint);

    this.oFrame.oNotifications = document.createElement('p');
    this.oFrame.oNotifications.className = 'MBNotifications';
    this.oFrame.oNotifications.style.display = 'none';
    this.oFrame.oNotifications.style.width = this.iWidth - 60 + 'px';
    this.oFrame.appendChild(this.oFrame.oNotifications);

    this.oFrame.oContent = document.createElement('div');
    this.oFrame.oContent.className = 'MBContent';
    this.oFrame.appendChild(this.oFrame.oContent);

    this.oFrame.oFooter = document.createElement('div');
    this.oFrame.oFooter.className = 'MBFooter';
    this.oFrame.appendChild(this.oFrame.oFooter);

    this.oFrame.oClose = document.createElement('a');

    this.oFrame.oClose.className = 'MBClose';
    this.oFrame.oClose.appendChild(document.createTextNode('Close'));
    this.oFrame.oClose.oModal = this;
    Event.observe(this.oFrame.oClose, 'click', function(e) { Event.element(e).oModal.Close(); });
    this.oFrame.oHeader.appendChild(this.oFrame.oClose);

    if (!$('MBLoader'+this.iLevel))
    {
      this.oFrame.oLoader = document.createElement('img');
      this.oFrame.oLoader.src = '/pics/loading.gif';
      this.oFrame.oLoader.id = 'MBLoader'+this.iLevel;
      this.oFrame.oLoader.style.display = 'none';
      this.oFrame.oHeader.appendChild(this.oFrame.oLoader);
    }

    this.oRoot.appendChild(this.oFrame);

    // Draggable-ize our modal box
    this.oFrame.oDraggable = new Draggable(this.oFrame,
      { handle: this.oFrame.oHeader, starteffect: null, endeffect: null }
    );
  },

  _vShowFrame: function()
  {
    // disabled blinddown due to screen glitches
    /*Effect.BlindDown(this.oFrame, { duration: 0.5 });*/
    $(this.oFrame).show();
  },

  DefineCloseFunction: function(oFunction)
  {
    this.oCloseFunction = oFunction;
  },

  ReloadOnExit: function()
  {
    this.DefineCloseFunction(function() { window.location.reload(); });
  },

  MoveDOMContent: function(oDOMObject)
  {
    this.oDOMObject = oDOMObject;
    this.oDOMParent = this.oDOMObject.parentNode;
    this.oDOMNextSibling = this.oDOMObject.nextSibling;
    $(this.oDOMObject).toggle(); // Switch between visible and invisible state

    this.oFrame.oContent.innerHTML = '';
    this.oFrame.oContent.appendChild(this.oDOMObject);

    // Finishing commands to restore e.g tinyMCE functionality
    if (tinyMCE)
    {
      $A(this.oDOMObject.getElementsByTagName('textarea')).each(
        function(oTextarea)
        {
          if (oTextarea.id)
            tinyMCE.execCommand('mceAddControl', false, oTextarea.id);
        }
      );
    }
  },

  RestoreDOMContent: function()
  {
    // Finishing commands to restore e.g tinyMCE functionality
    if (this.oDOMObject)
    {
      if (tinyMCE)
        $A(this.oDOMObject.getElementsByTagName('textarea')).each(
          function(oTextarea)
          {
            if (oTextarea.id)
              tinyMCE.execCommand('mceRemoveControl', false, oTextarea.id);
          }
        );

      // Restore original position of inserted DOM objects
      if (this.oDOMNextSibling)
        this.oDOMParent.insertBefore(this.oDOMObject, this.oDOMNextSibling);
      else
        this.oDOMParent.appendChild(this.oDOMObject);

      $(this.oDOMObject).toggle();

      this.oDOMObject = null;
    }
  },

  CenterOnPage: function()
  {
    this.iHeight = this.oFrame.getHeight();
    this.aPageSize = getPageSize();
    this.oFrame.style.left = (Math.round(this.aPageSize[0] / 2) - Math.round(this.iWidth / 2)) + 'px';

    var iOffset = Math.round(this.aPageSize[3] / 2)
                          - (this.iHeight ? Math.round(this.iHeight / 2) : 300)
                          + getPageScroll()[1];

    if (iOffset < 0) {
    	this.oFrame.style.top = 0;
    }
    else {
    	this.oFrame.style.top = iOffset + 'px';
    }
  },

  Show: function(sTitle, mContentHTML)
  {
    this.HideErrorHint();
    this.HideNotification();

    this.SetTitle(sTitle);
    this.oFrame.className = 'MBFrame';

    this.RestoreDOMContent();

    if (mContentHTML)
    {
      if (typeof mContentHTML == 'object')
        this.MoveDOMContent(mContentHTML);
      else
        this.oFrame.oContent.innerHTML = mContentHTML;
    }

    if (!oMBBlurLayer || !oMBBlurLayer.bBlurred)
    {
      this._vBlurPage();
    }
    else
    {
      if (this.oFrame.style.display == 'none')
      {
        this._vShowFrame();
      }
      this.RemoveButtons();
    }
    this.CenterOnPage();
    this.SetFocus();
  },

  SetTitle: function(sTitle)
  {
    this.oFrame.oHeader.firstChild.nodeValue = sTitle;
  },

  AddContent: function(mContentHTML)
  {
    this.HideNotification();

    if (typeof mContentHTML == 'object')
      this.oFrame.oContent.appendChild(mContentHTML);
    else
      this.oFrame.oContent.innerHTML += mContentHTML;
  },

  ShowSuccess: function(sTitle, sContentHTML, oOnClick)
  {
    this.Show(sTitle, sContentHTML);
    $(this.oFrame).addClassName('MBFSuccess');
    this.RemoveCancelButton();
    oOnClick ? this.AddButton('OK', oOnClick, this) : this.AddButton('OK', this.Close, this);
  },

  ShowError: function(sTitle, sContentHTML, oOnClick)
  {
    this.Show(sTitle, sContentHTML);
    $(this.oFrame).addClassName('MBFError');
    this.RemoveCancelButton();
    oOnClick ? this.AddButton('OK', oOnClick, this) : this.AddButton('OK', this.Close, this);
  },

  ShowAutoClose: function(sTitle, sContentHTML, iTimeout, oOnClick)
  {
    this.Show(sTitle, sContentHTML);
    $(this.oFrame).addClassName('MBFSuccess');
    this.RemoveCancelButton();
    var _this = this;
    oOnClick
      ? new PeriodicalExecuter(function(oPE) { oPE.stop(); oOnClick(); }, iTimeout ? iTimeout : 3)
      : new PeriodicalExecuter(function(oPE) { oPE.stop(); _this.Close(); }, iTimeout ? iTimeout : 3);
  },

  ShowErrorHint: function(sContent)
  {
    this.oFrame.oErrorHint.innerHTML = sContent;
    $(this.oFrame.oErrorHint).show();
  },

  HideErrorHint: function()
  {
    $(this.oFrame.oErrorHint).hide();
  },

  ShowNotification: function(sContent)
  {
    this.oFrame.oNotifications.innerHTML = sContent;
    $(this.oFrame.oNotifications).show();
  },

  HideNotification: function()
  {
    $(this.oFrame.oNotifications).hide();
  },

  SetFocus: function(sField)
  {
    if (!sField)
    {
      var aFields = this.oFrame.oContent.getElementsByTagName('input');
      if (!aFields[0] || !aFields[0].id)
        return;

      sField = aFields[0].id;
    }

    if (!$(sField))
      return;

    window.setTimeout("MBFocus('"+sField+"')", 1000);
  },

  Close: function(e)
  {
    var oController = this;
    if (e && Event.element(e) && Event.element(e).oController)
      var oController = Event.element(e).oController;

    if (oController.oCloseFunction)
    {
      oController.oCloseFunction(oController);
      return;
    }

    oController.Destroy();
  },

  Destroy: function(oAfterFinish, bLeaveBlurred)
  {
    var _this = this;
    iNumModalBoxes--;
    Effect.BlindUp(_this.oFrame,
    {
      duration: 0.5,
      afterFinish: function()
      {
        _this.RestoreDOMContent();
        _this.oFrame.oDraggable.destroy();
        _this.RemoveButtons();
        _this.RemoveCancelButton();
        $(_this.oFrame).remove();
        if (oAfterFinish)
          oAfterFinish();

        if (!bLeaveBlurred && iNumModalBoxes < 1)
        {
          Effect.Fade(oMBBlurLayer,
          {
            duration: 0.5,
            afterFinish: function()
            {
              oMBBlurLayer.bBlurred = false;

              // Re-show select boxes on IE < 7.x
              if (IE && !IE7)
                showSelectBoxes(document);
            }
          });
        }
      }
    });
  },

  AddButton: function(sTitle, oAction, oController, sId)
  {
    var oButton = document.createElement('a');
    if (oController)
      oButton.oController = oController;

    if (sId)
    {
      oButton.Identifier = sId;
      oButton.id = sId;
    }

    oButton.appendChild(document.createTextNode(sTitle));
    oButton.className = 'link-button';
    oButton.href = 'javascript:void(0)';
    this.oFrame.oFooter.insertBefore(oButton, this.oFrame.oFooter.lastChild);
    Event.observe(oButton, 'click', oAction);
  },

  RemoveButton: function(iButtonIdx)
  {
    switch (iButtonIdx)
    {
      case 'all':
        $A(this.oFrame.oFooter.getElementsByTagName('a')).each(
          function(oButton)
          {
            if (oButton.Identifier == 'MBCancel') return;
            $(oButton).remove();
          });
        break;

      case 'cancel':
        $A(this.oFrame.oFooter.getElementsByTagName('a')).each(
          function(oButton)
          {
            if (oButton.Identifier == 'MBCancel') $(oButton).remove();
          });
        break;

      default:
        var oButton = this.oFrame.oFooter.getElementsByTagName('a')[iButtonIdx];
        if (oButton)
          $(oButton).remove();
    }
  },

  RemoveButtons: function()
  {
    this.RemoveButton('all');
  },

  RemoveCancelButton: function()
  {
    this.RemoveButton('cancel');
  },

  SetCancelButtonTitle: function(sTitle)
  {
    this.oFrame.oFooter.lastChild.firstChild.nodeValue = sTitle;
  }
}

function MBFocus(sField)
{
  try
  {
    document.getElementById(sField).focus();
  }
  catch(e)
  {}
}

