
 // MsgBox
 var msgBox_randX      = 0;
 var msgBox_randYoben  = 0;
 var msgBox_randYunten = 0;

 var msgBox_IE_stepH   = 10;
 var msgBox_IE_stepW   = 10;
 var msgBox_IE_delayH  = 10;
 var msgBox_IE_delayW  = 10;

 var msgBox_FF_stepH   = 10;
 var msgBox_FF_stepW   = 10;
 var msgBox_FF_delayH  = 20;
 var msgBox_FF_delayW  = 20;

 if( browser.isIE )
 {
	var msgBox_stepH  = msgBox_IE_stepH;
	var msgBox_stepW  = msgBox_IE_stepW;
	var msgBox_delayH = msgBox_IE_delayH;
	var msgBox_delayW = msgBox_IE_delayW;
 } else
   {
	var msgBox_stepH  = msgBox_FF_stepH;
	var msgBox_stepW  = msgBox_FF_stepW;
	var msgBox_delayH = msgBox_FF_delayH;
	var msgBox_delayW = msgBox_FF_delayW;
   }

 var msgBox_active  = 0;
 var myMsgBox       = '';
 var msgBox_x       = 0;
 var msgBox_y       = 0;
 var msgBox_title   = '';
 var msgBox_orgLeft = 0;

 function msgBox_jumpToHeight()
 {
	msgBox_resizeHeight();
 }

 function msgBox_resizeHeight()
 {
	if( msgBox_active != 0 )
	{
		myMsgBox = 'msgBox_'+msgBox_active;

		var theDivHeight = document.getElementById(myMsgBox).offsetHeight;
		var maxHeight    = msgBox_y + msgBox_randYoben + msgBox_randYunten;

		if( theDivHeight < maxHeight )
		{
			document.getElementById(myMsgBox).style.height = theDivHeight + msgBox_stepH;

			var theDivHeight2 = document.getElementById(myMsgBox).offsetHeight;

			if( theDivHeight2 > maxHeight )
			{
				document.getElementById(myMsgBox).style.height = maxHeight;
				msgBox_jumpToWidth();
			} else
			  {
				document.getElementById(myMsgBox).style.height = theDivHeight + msgBox_stepH;
				window.setTimeout('msgBox_jumpToHeight()', msgBox_delayH);
			  }
		} else
		  {
			msgBox_jumpToWidth();
		  }
	}
 }

 function msgBox_jumpToWidth()
 {
	msgBox_resizeWidth();
 }

 function msgBox_resizeWidth()
 {
	if( msgBox_active != 0 )
	{
		myMsgBox = 'msgBox_'+msgBox_active;

		var theDivWidth = document.getElementById(myMsgBox).offsetWidth;
		var theDivLeft  = document.getElementById(myMsgBox).offsetLeft;

		var maxWidth    = msgBox_x + ( 2 * msgBox_randX );

		if( theDivWidth < maxWidth )
		{
			document.getElementById(myMsgBox).style.width = theDivWidth + ( 2 * msgBox_stepW );
			document.getElementById(myMsgBox).style.left  = theDivLeft - msgBox_stepW;

			var theDivWidth2 = document.getElementById('bb_mainBox').offsetWidth;

			if( theDivWidth2 > maxWidth )
			{
				document.getElementById(myMsgBox).style.width = maxWidth;
				msgBox_write();
			} else
			  {
				window.setTimeout('msgBox_jumpToWidth()', msgBox_delayW);
			  }
		} else
		  {
			msgBox_write();
		  }
	}
 }

 function msgBox_write()
 {
	if( msgBox_active != 0 )
	{
		myMsgBox = 'msgBox_'+msgBox_active;

		var boxContentID = 'msgBox_Content_'+msgBox_active;
		var boxContent   = document.getElementById(boxContentID).innerHTML;

		var tabHeight  = msgBox_y - 20;

		var tabHtml_1  = '';
		tabHtml_1     += '<table width="100%" border="0" cellspacing="0" cellpadding="0">';
		tabHtml_1     += '<tr>';
		tabHtml_1     += '<td width="5" height="20" style="margin: 0px; padding:0px; line-height:0px;"><img src="templates/1/img/balken_links.png" style="border:0px; margin:0px;" width="5" height="20" hspace="0" vspace="0"></td>';
		tabHtml_1     += '<td height="10" style="background-image:url(templates/1/img/balken_mitte.png);" align="center">&nbsp;&nbsp;</td>';
		tabHtml_1     += '<td height="20" style="background-image:url(templates/1/img/balken_mitte.png);" align="center"><font color="white"><b>'+msgBox_title+'</b></font></td>';
		tabHtml_1     += '<td height="10" onclick="javascript:msgBox_main(0, msgBox_active, msgBox_x, msgBox_y, \'\');" title="Schlie&szlig;en" style="background-image:url(templates/1/img/balken_mitte.png); cursor: pointer;" align="center"><font color="white"><b>X</b></font></td>';
		tabHtml_1     += '<td width="5" height="20" style="margin: 0px; padding:0px; line-height:0px;"><img src="templates/1/img/balken_rechts.png" style="border:0px; margin:0px;" width="5" height="20" hspace="0" vspace="0"></td>';
		tabHtml_1     += '</tr>';
		tabHtml_1     += '</table>';
		tabHtml_1     += '<table width="100%" border="0" cellspacing="0" cellpadding="5">';
		tabHtml_1     += '<tr>';
		tabHtml_1     += '<td bgcolor="#ffffff" height="'+tabHeight+'" style="border-bottom: 1px solid #1D87C3; border-left: 1px solid #1D87C3; border-right: 1px solid #1D87C3;">';

		var tabHtml_2 = '</td></tr></table>';

		document.getElementById(myMsgBox).style.backgroundColor = '#ffffff';
		document.getElementById(myMsgBox).style.borderLeft      = "0px solid #1D87C3";
		document.getElementById(myMsgBox).style.borderRight     = "0px solid #1D87C3";
		document.getElementById(myMsgBox).style.borderTop       = "0px solid #1D87C3";
		document.getElementById(myMsgBox).style.borderBottom    = "0px solid #1D87C3";
		document.getElementById(myMsgBox).innerHTML             = tabHtml_1 + boxContent + tabHtml_2;
	}
 }

 function msgBox_main(mode, id, x, y, title)
 {
	if( mode == 1 )
	{
		if( msgBox_active == 0 )
		{
			msgBox_active  = id;
			myMsgBox       = 'msgBox_'+id;
			msgBox_x       = x;
			msgBox_y       = y;
			msgBox_title   = title;

			msgBox_orgLeft = document.getElementById(myMsgBox).offsetLeft;

			document.getElementById(myMsgBox).style.width           = 40;
			document.getElementById(myMsgBox).style.height          = 40;
			document.getElementById(myMsgBox).style.backgroundColor = '#ffffff';
			document.getElementById(myMsgBox).style.borderLeft      = "1px solid #1D87C3";
			document.getElementById(myMsgBox).style.borderRight     = "1px solid #1D87C3";
			document.getElementById(myMsgBox).style.borderTop       = "1px solid #1D87C3";
			document.getElementById(myMsgBox).style.borderBottom    = "1px solid #1D87C3";
			document.getElementById(myMsgBox).style.visibility      = "visible";

			msgBox_jumpToHeight();
		}
	} else
	  {
		if( msgBox_active != 0 )
		{
			myMsgBox = 'msgBox_'+msgBox_active;

			document.getElementById(myMsgBox).innerHTML        = '';
			document.getElementById(myMsgBox).style.left       = msgBox_orgLeft;
			document.getElementById(myMsgBox).style.width      = 0;
			document.getElementById(myMsgBox).style.height     = 0;
			document.getElementById(myMsgBox).style.visibility = "hidden";

			msgBox_active = 0;
			myMsgBox      = 'msgBox_'+id;
			myMsgBox      = '';
			msgBox_x      = 0;
			msgBox_y      = 0;
			msgBox_title  = '';
		}
	  }
 }
