var be2_eas_listRequestID = 0;
var be2_eas_listKeyPos = -1;

function be2_getHiddenFieldsToString()
{
	var bugID = $('bugAjax_bugID') ? $F('bugAjax_bugID') : '';
	var reparatur = $('bugAjax_reparatur') ? $F('bugAjax_reparatur') : '';
	var firmenID = $('firmenID') ? $F('firmenID') : '';
	var auftraggeberID = $('bugAjaxSelect_auftraggeber') ? parseInt($F('bugAjaxSelect_auftraggeber'), 10) : '';
	var auftragDurchID = $('bugAjax_auftragDurchID') ? $F('bugAjax_auftragDurchID') : '';
	var extTicketID = $('bugAjaxInput_extTicketID') ? $F('bugAjaxInput_extTicketID') : '';
	var kundeBenachrichtigen = $('bugAjax_kundeBenachrichtigen') ? $('bugAjax_kundeBenachrichtigen').value : '';
	var zugewiesenMitarbeiterID = $('bugAjax_zugewiesenMitarbeiterID') ? $('bugAjax_zugewiesenMitarbeiterID').value : '';
	var zugewiesenAbteilungID = $('bugAjax_zugewiesenAbteilungID') ? $('bugAjax_zugewiesenAbteilungID').value : '';
	var niederlassung = $('bugAjax_niederlassung') ? $F('bugAjax_niederlassung') : '';
	var prioritaet = $('bugAjax_prioritaet') ? $F('bugAjax_prioritaet') : '';
	var statusID = $('bugAjax_statusID') ? $F('bugAjax_statusID') : '';
	var statusNachSpeichern = $('bugAjax_statusNachSpeichern') ? $F('bugAjax_statusNachSpeichern') : '';
	var closeTaskOnSubmit = $('bugAjax_closeTaskOnSubmit') ? $F('bugAjax_closeTaskOnSubmit') : '';
	var typID = $('bugAjaxSelect_typ') ? parseInt($('bugAjaxSelect_typ').options[$('bugAjaxSelect_typ').selectedIndex].value, 10) : '';
	var ueberschrift = $('bugAjaxInput_ueberschrift') ? $F('bugAjaxInput_ueberschrift') : '';
	var inhalt = $('bugAjaxText_inhalt') ? $F('bugAjaxText_inhalt') : '';
	var zubehoer = $('bugAjaxText_zubehoer') ? $F('bugAjaxText_zubehoer') : '';
	var linkTypID = '';
	var linkID = '';
	var selectedKompID = '';
	if ($('linkTypID'))
	{
		if ($('linkTypID').options[$('linkTypID').selectedIndex].value != 0)
		{
			linkTypID = $('linkTypID').options[$('linkTypID').selectedIndex].value;
			linkID = $('selectedLinkID') ? $F('selectedLinkID') : '';
			selectedKompID = $('selectedKompID') ? $F('selectedKompID') : '';
		}
	}
	var faellig_datum = $('faellig_datum') ? $F('faellig_datum') : '';
	var faellig_datum_stunde = $('faellig_datum_stunde') ? $F('faellig_datum_stunde') : '';
	var faellig_datum_minute = $('faellig_datum_minute') ? $F('faellig_datum_minute') : '';
  var faellig_grundangabe = $('faellig_grundangabe') ? $F('faellig_grundangabe') : '';
	var keine_faelligkeit = '';
	if ($('keine_faelligkeit'))
	{
		switch ($('keine_faelligkeit').checked)
		{
			case true:
				keine_faelligkeit = 'Y';
				break;
			case false:
				keine_faelligkeit = 'N';
				break;
		}
	}
	var erinnerung_datum = $('erinnerung_datum') ? $F('erinnerung_datum') : '';
	var erinnerung_datum_stunde = $('erinnerung_datum_stunde') ? $F('erinnerung_datum_stunde') : '';
	var erinnerung_datum_minute = $('erinnerung_datum_minute') ? $F('erinnerung_datum_minute') : '';
	var keine_erinnerung = '';
	if ($('keine_erinnerung'))
	{
		switch ($('keine_erinnerung').checked)
		{
			case true:
				keine_erinnerung = 'Y';
				break;
			case false:
				keine_erinnerung = 'N';
				break;
		}
	}
	var ee_in_tage = $('bugAjaxInput_ee_in_tage') ? $F('bugAjaxInput_ee_in_tage') : '';
	var ee_in_stunden = $('bugAjaxInput_ee_in_stunden') ? $F('bugAjaxInput_ee_in_stunden') : '';
	var eea_tage = $('bugAjaxInput_eea_tage') ? $F('bugAjaxInput_eea_tage') : '';
	var eea_stunden = $('bugAjaxInput_eea_stunden') ? $F('bugAjaxInput_eea_stunden') : '';
	
	var save_erstellt_date = $('save_erstellt_date') ? $('save_erstellt_date').value : '';
	var bug_erstellt_date = $('bug_erstellt_date') ? $('bug_erstellt_date').value : '';
	var bug_erstellt_date_stunde = $('bug_erstellt_date_stunde') ? $F('bug_erstellt_date_stunde') : '';
	var bug_erstellt_date_minute = $('bug_erstellt_date_minute') ? $F('bug_erstellt_date_minute') : '';

  var pauschal = '';
  if ($('t_pauschal')) {
    pauschal = $('t_pauschal').checked == true ? 'Y' : 'N';
  }
  var pauschalBetrag = $('t_pauschalBetrag') ? $F('t_pauschalBetrag') : '';
  var eigen = '';
  if ($('t_eigen')) {
    eigen = $('t_eigen').checked == true ? 'Y' : 'N';
  }
	var dl_datum = $('dl_datum') ? $F('dl_datum') : '';
	var dl_datum_stunde = $('dl_datum_stunde') ? $F('dl_datum_stunde') : '';
	var dl_datum_minute = $('dl_datum_minute') ? $F('dl_datum_minute') : '';
	var keine_dl = '';
	if ($('keine_dl'))
	{
		switch ($('keine_dl').checked)
		{
			case true:
				keine_dl = 'Y';
				break;
			case false:
				keine_dl = 'N';
				break;
		}
	}
  var masse = '0';
  if ($('masseModus')) {
    masse = $F('masseModus');
  }
  var masseBeschr = '';
  if ($('masseBeschr')) {
    masseBeschr = encodeURIComponent($F('masseBeschr'));
  }

	var postStr = 'bugID='+encodeURIComponent(bugID)+
								'&reparatur='+encodeURIComponent(reparatur)+
								'&firmenID='+encodeURIComponent(firmenID)+
								'&auftraggeberID='+encodeURIComponent(auftraggeberID)+
								'&auftragDurchID='+encodeURIComponent(auftragDurchID)+
								'&extTicketID='+encodeURIComponent(extTicketID)+
								'&kundeBenachrichtigen='+encodeURIComponent(kundeBenachrichtigen)+
								'&zugewiesenMitarbeiterID='+zugewiesenMitarbeiterID+
								'&zugewiesenAbteilungID='+zugewiesenAbteilungID+
								'&niederlassung='+encodeURIComponent(niederlassung)+
								'&prioritaet='+prioritaet+
								'&statusID='+statusID+
								'&statusNachSpeichern='+encodeURIComponent(statusNachSpeichern)+
								'&closeTaskOnSubmit='+encodeURIComponent(closeTaskOnSubmit)+
								'&typID='+typID+
								'&ueberschrift='+encodeURIComponent(ueberschrift)+
								'&inhalt='+encodeURIComponent(inhalt)+
								'&zubehoer='+encodeURIComponent(zubehoer)+
								'&linkTypID='+linkTypID+
								'&linkID='+linkID+
								'&selectedKompID='+encodeURIComponent(selectedKompID)+
								'&faellig_grundangabe='+encodeURIComponent(faellig_grundangabe)+
								'&faellig_datum='+faellig_datum+
								'&faellig_datum_stunde='+faellig_datum_stunde+
								'&faellig_datum_minute='+faellig_datum_minute+
								'&keine_faelligkeit='+encodeURIComponent(keine_faelligkeit)+
								'&erinnerung_datum='+erinnerung_datum+
								'&erinnerung_datum_stunde='+erinnerung_datum_stunde+
								'&erinnerung_datum_minute='+erinnerung_datum_minute+
								'&keine_erinnerung='+encodeURIComponent(keine_erinnerung)+
								'&ee_in_tage='+ee_in_tage+
								'&ee_in_stunden='+ee_in_stunden+
								'&eea_tage='+eea_tage+
								'&eea_stunden='+eea_stunden+
								'&save_erstellt_date='+save_erstellt_date+
								'&bug_erstellt_date='+bug_erstellt_date+
								'&bug_erstellt_date_stunde='+bug_erstellt_date_stunde+
								'&bug_erstellt_date_minute='+bug_erstellt_date_minute+
                '&pauschal='+pauschal+
                '&pauschalBetrag='+pauschalBetrag+
                '&eigen='+eigen+
                '&skills='+encodeURIComponent(($('skillListHiddenInput') ? $('skillListHiddenInput').value : ''))+
                '&eigen='+eigen+
								'&dl_datum='+dl_datum+
								'&dl_datum_stunde='+dl_datum_stunde+
								'&dl_datum_minute='+dl_datum_minute+
								'&keine_dl='+encodeURIComponent(keine_dl)+
								'&masse='+masse+
								'&masseBeschr='+masseBeschr+
                '&bezLTID='+($('bezLTID') ? $F('bezLTID') : "0")+
                '&bezLID='+($('bezLID') ? $F('bezLID') : "0")+
                ($('ogNeu') ? '&ogNeu='+encodeURIComponent($F('ogNeu')) : '');
  return postStr;
}

function be2_deleteBug(bugID)
{
	if (ajax_delete_item('bug', bugID, '', false))
	{
		location.href = 'index.php?section=bug';
	}
}

function be2_checkFaelligkeitChangedChangeform()
{
  var ret = true;
  if ($('bugAjax_bugID') && $('faellig_grundangabe')) {
    new Ajax.Request('ajax/srv/bug_edit.php?typ=be2_checkFaelligkeitChangedChangeform', {
      asynchronous: false,
      postBody: be2_getHiddenFieldsToString(),
      onComplete: function (t) {
        var json = t.responseText.evalJSON();
        if (json.isChanged) {
          ret = false;
          var grund = '';
          if (grund = prompt(getLang("bug", "be2_changeFReason"), '')) {
            if (!grund.blank()) {
              $('faellig_grundangabe').value = grund;
              ret = true;
            }
          }
        }
      }
    });
  }
  return ret;
}

function be2_submitForm(saveAndExit)
{
	showInfoDivContainer('', 'ajax');
  if (!be2_checkFaelligkeitChangedChangeform())
  {
    showInfoDivContainer(getLang("all", "haveToSetReason"), 'fehler');
    return;
  }
  be2_checkFirmaChangedLeist();
	var postStr = be2_getHiddenFieldsToString();
	var response = '';
	var reloadPage = false;
  if (be2_submitPruefungen() == true) {
    new Ajax.Request('ajax/srv/bug_edit.php?typ=save', {
        method: 'post',
        postBody: postStr,
        asynchronous: false,
        onSuccess: function (transport) {
          response = transport.responseText.evalJSON();
          if (response.pauschal == 'N') {
            if (confirm(getLang("bug", "be2_fixNoMore"))) {
              new Ajax.Request('ajax/srv/bug_edit.php?typ=fixNoMore', {
                parameters: 'bugID=' + $F('bugAjax_bugID'),
                asynchronous: false
              });
            }
          }
          showInfoDivContainer(getLang("all", "edit_successfully"));
          if ($('be2Save')) {
            $('be2Save').disable();
          }
          if ($('be2SaveAndExit')) {
            $('be2SaveAndExit').disable();
          }
        }
      }
    );
    if ($('bugAjax_backtoString')) {
      if (saveAndExit == true || ($('masseModus') && $F('masseModus') > 0)) {
        window.location.href = 'index.php?'+$F('bugAjax_backtoString');
      } else {
        if (($F('bugAjax_bugID') == 0) || (reloadPage == true)) {
          if ($('be2HasRight2Edit') && ($('be2HasRight2Edit').value == 'N')) {
            window.location.href = 'index.php?section=bug&sub=view&bugID=' + response.id;
          } else {
            window.location.href = 'index.php?section=bug&sub=edit&init=1&bugID=' + response.id;
          }
        } else {
          if ($('bugAjax_submit')) {
            $('bugAjax_submit').disabled = false;
          }
          be2_refreshSelection();
          be2_refreshSupport();
        }
      }
    }
  }
}

function be2_checkFirmaChangedLeist()
{
	var firmenID = $('firmenID') ? parseInt($('firmenID').value, 10) : 0;
	var firmenIDDB = $('bugAjax_firmenIDDB') ? parseInt($('bugAjax_firmenIDDB').value, 10) : 0;
	var bugID = $('bugAjax_bugID') ? parseInt($('bugAjax_bugID').value, 10) : 0;
	if (firmenID != firmenIDDB) {
		var url = 'ajax/srv/bug_edit.php?typ=checkLeistFirm&firmenID='+encodeURIComponent(firmenID)+'&bugID='+encodeURIComponent(bugID);
		new Ajax.Request(url, {
				method: 'get',
				asynchronous: false,
				onSuccess: function (transport) {
					var response = transport.responseText;
					if (parseInt(response, 10) > 0) {
						ticket_firmenID_changed(bugID, firmenID, getLang("bug", "changeform_chkComanyChanged"));
					}
				}
			}
		);
	}
}

function be2_getFromAjax(containerName, typ)
{
	var postStr = be2_getHiddenFieldsToString();
	($(containerName)) ? $(containerName).innerHTML = be2_showLoadIcon() : true;
	var url = 'ajax/srv/bug_edit.php?typ='+encodeURIComponent(typ);
	new Ajax.Request(url, {
			method: 'post',
			postBody: postStr,
			onComplete: function (transport)
			{
				var response = transport.responseText;
				($(containerName)) ? $(containerName).innerHTML = response : true;
			}
		}
	);
}

function be2_toggleFirma()
{
	hideSucheContainer();
	if ($('bugAjaxShowDiv_firma') && $('bugAjaxSelectDiv_firma')) {
		$('bugAjaxShowDiv_firma').toggle();
		$('bugAjaxSelectDiv_firma').toggle();		
	}
	if ($('bugAjaxSelectDiv_firma')) {
		if ($('bugAjaxSelectDiv_firma').style.display != 'none') {
			($('bugAjaxInput_firma')) ? $('bugAjaxInput_firma').focus() : true;
		}		
	}
}

function be2_toggleFirma_sendForm()
{
	hideSucheContainer();
	if ($('sendFormToCustomerForm_firmaShowDiv') && $('sendFormToCustomerForm_firmaInputDiv')) {
		$('sendFormToCustomerForm_firmaShowDiv').toggle();
		$('sendFormToCustomerForm_firmaInputDiv').toggle();		
	}
	if ($('sendFormToCustomerForm_firmaInputDiv')) {
		if ($('sendFormToCustomerForm_firmaInputDiv').style.display != 'none') {
			($('sendFormToCustomerForm_firmaInput')) ? $('sendFormToCustomerForm_firmaInput').focus() : true;
		}
	}
}

function be2_toggleAuftraggeber()
{
	if ($('bugAjaxShowDiv_auftraggeber') && $('bugAjaxSelectDiv_auftraggeber')) {
		$('bugAjaxShowDiv_auftraggeber').toggle();
		$('bugAjaxSelectDiv_auftraggeber').toggle();		
	}
}

function be2_statusChange()
{
	if ($('bugAjaxShowDiv_status') && $('bugAjaxSelectDiv_status')) {
		$('bugAjaxShowDiv_status').toggle();
		$('bugAjaxSelectDiv_status').toggle();
	}
}

function be2_typChange()
{
	if ($('bugAjaxShowDiv_typID') && $('bugAjaxSelectDiv_typID')) {
		$('bugAjaxShowDiv_typID').toggle();
		$('bugAjaxSelectDiv_typID').toggle();
	}
}

function be2_prioritaetChange()
{
	if ($('bugAjaxShowDiv_prioritaet') && $('bugAjaxSelectDiv_prioritaet')) {
		$('bugAjaxShowDiv_prioritaet').toggle();
		$('bugAjaxSelectDiv_prioritaet').toggle();
	}
}

function be2_statusChangeSelect_popup(const_erledigt, bugID)
{
	var submitForm = true;
	if ((($('bugFormPopup_popupStatusID')) ? $('bugFormPopup_popupStatusID').value : 0) == const_erledigt)
	{
		new Ajax.Request('ajax/srv/count_ticket_comments.php?bugID='+encodeURIComponent(bugID),
			{
				method: 'get',
				asynchronous: false,
				onComplete: function (t)
				{
					if (t.responseText == '---')
					{
            alert(getLang('bug', 'changeform_mustHaveSupp'));
            $('bugFormPopup_popupStatusID').value = $('bugFormPopup_hiddenStatusID').value;
            submitForm = false;
					}
					if (t.responseText == '0')
					{
						if (!confirm(getLang("bug", "edit_ticketNoEntries")))
						{
							$('bugFormPopup_popupStatusID').value = $('bugFormPopup_hiddenStatusID').value;
							submitForm = false;
						}
					}
				}
			}
		);
		if ((submitForm == true) && $('bugFormPopup_closeTaskOnSubmit'))
		{
			new Ajax.Request('ajax/srv/count_ticket_tasks.php?bugID='+encodeURIComponent(bugID),
				{
					method: 'get',
					asynchronous: false,
					onComplete: function (t)
					{
						var res = parseInt(t.responseText, 10);
						if (res > 0)
						{
							if (confirm(getLang("bug", "edit_ticketTask")))
							{
								$('bugFormPopup_closeTaskOnSubmit').value = 'Y';
							}
						}
					}
				}
			);
		}
	}
}

function be2_statusChangeSelect(const_erledigt, bugID)
{
	if ($('bugAjax_statusID') && $('bugAjaxSelect_status'))
	{
		var newStatusID = parseInt($F('bugAjaxSelect_status'), 10);
    if (newStatusID == parseInt(const_erledigt, 10))
		{
			var submitForm = false;
			new Ajax.Request('ajax/srv/count_ticket_comments.php?bugID='+encodeURIComponent(bugID), {
				method: 'get',
				asynchronous: false,
				onComplete: function (transport) {
					var response = transport.responseText;
					if (response == '---') {
            setSelectToValue($('bugAjaxSelect_status'), $F('bugAjax_statusID'));
            alert(getLang('bug', 'changeform_mustHaveSupp'));
          }
					if (response == '0') {
						if (confirm(getLang("bug", "edit_ticketNoEntries"))) {
							submitForm = true;
						} else {
              setSelectToValue($('bugAjaxSelect_status'), $F('bugAjax_statusID'));
						}
					} else {
						submitForm = true;
					}
				}
			});
      if (submitForm == true) {
        submitForm = false;
        new Ajax.Request('ajax/srv/bug_edit.php?typ=checkListTest&bugID='+encodeURIComponent(bugID), {
          asynchronous: false,
          onComplete: function (t) {
            var json = t.responseText.evalJSON();
            if (json.ok == true) {
              submitForm = true;
            } else {
              showInfoDivContainer(json.msg, 'fehler');
              setSelectToValue($('bugAjaxSelect_status'), $F('bugAjax_statusID'));
            }
          }
        });
      }
			if ((submitForm == true) && $('bugAjax_closeTaskOnSubmit')) {
				new Ajax.Request('ajax/srv/count_ticket_tasks.php?bugID='+encodeURIComponent(bugID), {
					method: 'get',
					asynchronous: false,
					onComplete: function (transport) {
						var response = parseInt(transport.responseText, 10);
						if (response > 0) {
							if (confirm(getLang("bug", "edit_ticketTask"))) {
								$('bugAjax_closeTaskOnSubmit').value = 'Y';
							}
						}
					}
				});
			}
      if (submitForm == true) {
        $('bugAjax_statusID').value = newStatusID;
      }
		} else {
			$('bugAjax_statusID').value = newStatusID;
		}
	}
}

function be2_statusSpeichernChangeSelect()
{
	if ($('bugAjax_statusNachSpeichern') && $('bugAjaxSelect_statusSpeichern'))
	{
		$('bugAjax_statusNachSpeichern').value = parseInt($('bugAjaxSelect_statusSpeichern').options[$('bugAjaxSelect_statusSpeichern').selectedIndex].value, 10);
	}
}

function be2_getFirma()
{
	if ($('bugAjaxTD_firma'))
	{
		var bugID = ($('bugAjax_bugID')) ? $('bugAjax_bugID').value : '';
		var firmenID = ($('firmenID')) ? $('firmenID').value : '';
		$('bugAjaxTD_firma').innerHTML = be2_showLoadIcon();
		var url = 'ajax/srv/bug_edit.php?typ=firma';
		new Ajax.Request(url,
			{
				method: 'post',
				postBody: 'bugID='+encodeURIComponent(bugID)+'&firmenID='+encodeURIComponent(firmenID),
				onComplete: function (t)
				{
					var res = t.responseText;
					$('bugAjaxTD_firma').innerHTML = res;
				}
			}
		);
	}
}

function be2_getFirma_sendForm()
{
	if ($('sendFormToCustomerForm_firmaShowTD'))
	{
		var bugID = ($('sendFormToCustomerForm_bugID')) ? $('sendFormToCustomerForm_bugID').value : '';
		var firmenID = ($('sendFormToCustomerForm_firmenID')) ? $('sendFormToCustomerForm_firmenID').value : '';
		$('sendFormToCustomerForm_firmaShowDiv').innerHTML = be2_showLoadIcon();
		var url = 'ajax/srv/bug_edit.php?typ=firma_sendForm';
		new Ajax.Request(url,
			{
				method: 'post',
				postBody: 'bugID='+encodeURIComponent(bugID)+'&firmenID='+encodeURIComponent(firmenID),
				onComplete: function (t)
				{
					var res = t.responseText;
					$('sendFormToCustomerForm_firmaShowTD').innerHTML = res;
				}
			}
		);
	}
}

function be2_firma_change()
{
	be2_getFirma();
	$('bugAjaxSelect_auftraggeber') ? $('bugAjaxSelect_auftraggeber').selectedIndex = 0 : true;
	$('bugAjax_auftragDurchID') ? $('bugAjax_auftragDurchID').value = 0 : true;
	$('bugAjaxSelect_auftragDurch') ? $('bugAjaxSelect_auftragDurch').selectedIndex = 0 : true;
  var bugID = ($('bugAjax_bugID')) ? $('bugAjax_bugID').value : 0;
  if (bugID == 0) {
    $('bugAjax_zugewiesenMitarbeiterID') ? $('bugAjax_zugewiesenMitarbeiterID').value  = 0 : true;
  }
	be2_auftragDurch_change();
	be2_auftraggeberInfo();
	be2_getAuftraggeber();
	be2_resetZuweisung();
	be2_refreshMitarbeiter();
	be2_refreshBez();
}

function be2_firma_change_sendForm(firmenID)
{
	($('sendFormToCustomerForm_firmenID')) ? $('sendFormToCustomerForm_firmenID').value = firmenID : true;
	($('sendFormToCustomerForm_auftraggeberSelect')) ? $('sendFormToCustomerForm_auftraggeberSelect').selectedIndex = 0 : true;
	($('sendFormToCustomerForm_auftraggeberID')) ? $('sendFormToCustomerForm_auftraggeberID').value = 0 : true;
	be2_getFirma_sendForm();
	be2_getAuftraggeber_sendForm();
}

function be2_refreshMitarbeiter()
{
	if ($('bugAjaxTD_zuwMA') && $('bugAjaxSelect_zugewiesenMitarbeiter') && $('bugAjaxSelect_zugewiesenAbteilung')) {
    var ltID = 0;
    var lID = 0;
    if ($('linkTypID')) ltID = $F('linkTypID');
    if ($('selectedLinkID')) lID = $F('selectedLinkID');
		var bugID = ($('bugAjax_bugID')) ? $('bugAjax_bugID').value : 0;
		new Ajax.Request('ajax/srv/bug_edit.php?typ=zugewMA', {
			parameters: 'firmenID=' + $F('firmenID') +
			            '&maID=' + $F('bugAjaxSelect_zugewiesenMitarbeiter') +
			            '&abtID=' + $F('bugAjaxSelect_zugewiesenAbteilung') +
                  '&ltID=' + ltID +
                  '&lID=' + lID +
                  '&bugID=' + bugID,
			onSuccess: function(t) {
				$('bugAjaxTD_zuwMA').innerHTML = t.responseText;
			}
		});
	}
}

function be2_getZuweisungAuswahl()
{
	if ($('bugAjaxTD_zuweisung'))
	{
		var zentrale = '';
		if ($('bug_zuwZentrale') && $('bug_zuwZentrale').checked == true)
		{
			var zentrale = '&zentrale=1';
		}
		$('bugAjaxTD_zuweisung').innerHTML = be2_showLoadIcon();
		var bugID = ($('bugAjax_bugID')) ? $('bugAjax_bugID').value : '';
		var firmenID = ($('firmenID')) ? $('firmenID').value : '';
		var linkTypID = '';
		var linkID = '';
		if ($('linkTypID'))
		{
			if ($('linkTypID').options[$('linkTypID').selectedIndex].value != 0)
			{
				var linkTypID = $('linkTypID').options[$('linkTypID').selectedIndex].value;
				var linkID = $('selectedLinkID') ? $('selectedLinkID').value : '';
			}
		}
		var url = 'ajax/srv/bug_edit.php?typ=zuweisungAuswahl2';
		new Ajax.Request(url,
			{
				method: 'post',
				postBody: 'bugID='+bugID+
									'&firmenID='+firmenID+
									'&linkTypID='+linkTypID+
									'&linkID='+linkID+
									zentrale,
				onComplete: function (t)
				{
					var res = t.responseText;
					$('bugAjaxTD_zuweisung').innerHTML = res;
				}
			}
		);
	}
}

function be2_getAuftraggeber(aID)
{
	if ($('bugAjaxDiv_auftraggeber'))
	{
		$('bugAjaxDiv_auftraggeber').innerHTML = be2_showLoadIcon();
		var bugID = ($('bugAjax_bugID')) ? $('bugAjax_bugID').value : '';
		var firmenID = ($('firmenID')) ? $('firmenID').value : '';
		var auftraggeberID = $('bugAjaxSelect_auftraggeber') ? parseInt($F('bugAjaxSelect_auftraggeber'), 10) : ((typeof aID != 'undefined') ? parseInt(aID, 10) : '');
		var url = 'ajax/srv/bug_edit.php?typ=auftraggeber';
		new Ajax.Request(url,
			{
				method: 'post',
				postBody: 'bugID='+encodeURIComponent(bugID)+
									'&firmenID='+encodeURIComponent(firmenID)+
									'&auftraggeberID='+encodeURIComponent(auftraggeberID),
				onComplete: function (t)
				{
					var res = t.responseText;
					$('bugAjaxDiv_auftraggeber').innerHTML = res;
				}
			}
		);
	}
}

function be2_getAuftraggeber_sendForm()
{
	if ($('sendFormToCustomerForm_auftraggeberShowTD'))
	{
		$('sendFormToCustomerForm_auftraggeberShowTD').innerHTML = be2_showLoadIcon();
		var bugID = ($('sendFormToCustomerForm_bugID')) ? $('sendFormToCustomerForm_bugID').value : '';
		var firmenID = ($('sendFormToCustomerForm_firmenID')) ? $('sendFormToCustomerForm_firmenID').value : '';
		var auftraggeberID = $('sendFormToCustomerForm_auftraggeberID') ? parseInt($F('sendFormToCustomerForm_auftraggeberID'), 10) : '';
		var url = 'ajax/srv/bug_edit.php?typ=auftraggeber_sendForm';
		new Ajax.Request(url,
			{
				method: 'post',
				postBody: 'bugID='+encodeURIComponent(bugID)+
									'&firmenID='+encodeURIComponent(firmenID)+
									'&auftraggeberID='+encodeURIComponent(auftraggeberID),
				onComplete: function (t)
				{
					var res = t.responseText;
					$('sendFormToCustomerForm_auftraggeberShowTD').innerHTML = res;
				}
			}
		);
	}
}

function be2_auftraggeber_change()
{
	if ($('bugAjaxSelect_auftraggeber'))
	{
		be2_auftragDurch_change();
		be2_auftraggeberInfo();
	}
}

function be2_auftraggeber_change_sendForm()
{
	if ($('sendFormToCustomerForm_auftraggeberSelect') && $('sendFormToCustomerForm_auftraggeberID'))
	{
		$('sendFormToCustomerForm_auftraggeberID').value = $('sendFormToCustomerForm_auftraggeberSelect').options[$('sendFormToCustomerForm_auftraggeberSelect').selectedIndex].value;
	}
}

function be2_showLoadIcon()
{
	return '<div><img src=\"media/hp/ajaxrequest.gif\"></div>';
}

function be2_auftragDurch_change()
{
	if ($('bugAjaxSelect_auftraggeber') && $('bugAjax_auftragDurchID') && $('bugAjaxDiv_auftragDurch') && $('bugAjaxSelect_auftragDurch'))
	{
		if (parseInt($('bugAjaxSelect_auftraggeber').options[$('bugAjaxSelect_auftraggeber').selectedIndex].value, 10) > 0)
		{
			$('bugAjax_auftragDurchID').value = parseInt($('bugAjaxSelect_auftragDurch').options[$('bugAjaxSelect_auftragDurch').selectedIndex].value, 10);
			$('bugAjaxDiv_auftragDurch').show();
		}
		else
		{
			$('bugAjaxDiv_auftragDurch').hide();
			$('bugAjax_auftragDurchID').value = 0;
			$('bugAjaxSelect_auftragDurch').selectedIndex = 0;
		}
	}
	if (!$('bugAjaxSelect_auftraggeber') && $('bugAjaxDiv_auftragDurch'))
	{
		$('bugAjaxDiv_auftragDurch').hide();
	}
}

function be2_auftraggeberInfo()
{
	if ($('bugAjaxDiv_auftraggeberInfo'))
	{
		$('bugAjaxDiv_auftraggeberInfo').innerHTML = be2_showLoadIcon();
		var bugID = ($('bugAjax_bugID')) ? $('bugAjax_bugID').value : '';
		var auftraggeberID = ($('bugAjaxSelect_auftraggeber')) ? parseInt($F('bugAjaxSelect_auftraggeber'), 10) : '';
		var url = 'ajax/srv/bug_edit.php?typ=auftraggeberInfo';
		new Ajax.Request(url,
			{
				method: 'post',
				postBody: 'bugID='+encodeURIComponent(bugID)+'&auftraggeberID='+encodeURIComponent(auftraggeberID),
				onComplete: function (t)
				{
					var res = t.responseText;
					$('bugAjaxDiv_auftraggeberInfo').innerHTML = res;
				}
			}
		);
	}
}

function be2_kundeBenachrichtigen_change()
{
	if ($('bugAjaxCheckbox_kundeBenachrichtigen') && $('bugAjax_kundeBenachrichtigen')) {
		switch ($('bugAjaxCheckbox_kundeBenachrichtigen').checked) {
			case true:
				$('bugAjax_kundeBenachrichtigen').value = 'Y';
				break;
			case false:
				$('bugAjax_kundeBenachrichtigen').value = 'N';
				break;
		}
	}
}

function be2_niederlassung_change()
{
	if ($('bugAjaxCheckbox_niederlassung') && $('bugAjax_niederlassung')) {
		switch ($('bugAjaxCheckbox_niederlassung').checked) {
			case true:
				$('bugAjax_niederlassung').value = 'Y';
				break;
			case false:
				$('bugAjax_niederlassung').value = 'N';
				break;
		}
	}
}

function be2_prioritaet_change()
{
	if ($('bugAjaxSelect_prioritaet') && $('bugAjax_prioritaet')) {
		$('bugAjax_prioritaet').value = parseInt($('bugAjaxSelect_prioritaet').options[$('bugAjaxSelect_prioritaet').selectedIndex].value, 10);
		/*
		var hgFarben = new Array('', '#dadada', '#d0d0d0', '#dacaca', '#dac0c0', '#dababa', '#dab0b0', '#daaaaa', '#da9090', '#da8a8a');
		if (hgFarben[parseInt($('bugAjax_prioritaet').value, 10)])
		{
			$('bugAjaxTD_prioLeft').setStyle({backgroundColor: hgFarben[parseInt($('bugAjax_prioritaet').value, 10)]});
			$('bugAjaxTD_prio').setStyle({backgroundColor: hgFarben[parseInt($('bugAjax_prioritaet').value, 10)]});
		}
		*/
	}
}

function be2_zugewiesenMitarbeiter_change()
{
	if ($('bugAjaxSelect_zugewiesenMitarbeiter') && $('bugAjax_zugewiesenMitarbeiterID'))
	{
		$('bugAjax_zugewiesenMitarbeiterID').value = parseInt($('bugAjaxSelect_zugewiesenMitarbeiter').options[$('bugAjaxSelect_zugewiesenMitarbeiter').selectedIndex].value, 10);
		if ($('bugAjaxTD_zuwAbt'))
		{
			be2_getZugewiesenAbteilung()
		}
    be2_zeitstrahl_akt();
	}
}

function be2_getZugewiesenAbteilung()
{
	if ($('bugAjaxTD_zuwAbt'))
	{
		$('bugAjaxTD_zuwAbt').innerHTML = be2_showLoadIcon();
		var bugID = ($('bugAjax_bugID')) ? $('bugAjax_bugID').value : 0;
		var zugewiesenMitarbeiterID = $('bugAjax_zugewiesenMitarbeiterID') ? $('bugAjax_zugewiesenMitarbeiterID').value : '';
		var zugewiesenAbteilungID = $('bugAjax_zugewiesenAbteilungID') ? $('bugAjax_zugewiesenAbteilungID').value : '';
		var url = 'ajax/srv/bug_edit.php?typ=zugewiesenAbteilung';
		new Ajax.Request(url,
			{
				method: 'post',
				postBody: 'bugID='+encodeURIComponent(bugID)+
									'&zugewiesenMitarbeiterID='+encodeURIComponent(zugewiesenMitarbeiterID)+
									'&zugewiesenAbteilungID='+encodeURIComponent(zugewiesenAbteilungID),
				onComplete: function (t)
				{
					var res = t.responseText;
					$('bugAjaxTD_zuwAbt').innerHTML = res;
				}
			}
		);
	}
}

function be2_zugewiesenAbteilung_changePopup()
{
	if ($('bugFormPopup_zugewiesenAbteilung') && $('bugFormPopup_zugewiesenMitarbeiterTD') && $('bugFormPopup_zugewiesenMitarbeiter'))
	{
		var tmp_ma = $('bugFormPopup_zugewiesenMitarbeiter').value;
		$('bugFormPopup_zugewiesenMitarbeiterTD').innerHTML = be2_showLoadIcon();
		var bugID = ($('bugFormPopup_bugID')) ? $('bugFormPopup_bugID').value : 0;
		var url = 'ajax/srv/bug_edit.php?typ=zugewiesenMitarbeiterPopup';
		new Ajax.Request(url,
			{
				method: 'post',
				postBody: 'bugID='+encodeURIComponent(bugID)+
									'&zugewiesenMitarbeiterID='+encodeURIComponent(tmp_ma)+
									'&zugewiesenAbteilungID='+encodeURIComponent($('bugFormPopup_zugewiesenAbteilung').value),
				onComplete: function (t)
				{
					$('bugFormPopup_zugewiesenMitarbeiterTD').innerHTML = t.responseText;
				}
			}
		);
	}
}

function be2_zugewiesenMitarbeiter_changePopup()
{
	if ($('bugFormPopup_zugewiesenMitarbeiter') && $('bugFormPopup_zugewiesenAbteilungTD') && $('bugFormPopup_zugewiesenAbteilung'))
	{
		var tmp_ateilung = $('bugFormPopup_zugewiesenAbteilung').value;
		$('bugFormPopup_zugewiesenAbteilungTD').innerHTML = be2_showLoadIcon();
		var bugID = ($('bugFormPopup_bugID')) ? $('bugFormPopup_bugID').value : 0;
		var url = 'ajax/srv/bug_edit.php?typ=zugewiesenAbteilungPopup';
		new Ajax.Request(url,
			{
				method: 'post',
				postBody: 'bugID='+encodeURIComponent(bugID)+
									'&zugewiesenMitarbeiterID='+encodeURIComponent($('bugFormPopup_zugewiesenMitarbeiter').value)+
									'&zugewiesenAbteilungID='+encodeURIComponent(tmp_ateilung),
				onComplete: function (t)
				{
					$('bugFormPopup_zugewiesenAbteilungTD').innerHTML = t.responseText;
				}
			}
		);
	}
}

function be2_zugewiesen_change_VIEW(bugID, what)
{
	var maID = ($('bugAjaxSelect_zugewiesenMitarbeiter')) ? $('bugAjaxSelect_zugewiesenMitarbeiter').value : 0;
	var abtID = ($('bugAjaxSelect_zugewiesenAbteilung')) ? $('bugAjaxSelect_zugewiesenAbteilung').value : 0;
	var firmenID = ($('firmenID')) ? $('firmenID').value : 0;
	if ($('bugAjaxTD_zuwMA') && $('bugAjaxTD_zuwAbt'))
	{
		switch (what)
		{
			case 'abt':
				$('bugAjaxTD_zuwMA').innerHTML = show_load();
				break;
			case 'ma':
				$('bugAjaxTD_zuwAbt').innerHTML = show_load();
				break;
		}
		var url = 'ajax/srv/bug_edit.php?typ=zugewiesen_change_VIEW&what='+encodeURIComponent(what);
		new Ajax.Request(url,
			{
				method: 'post',
				postBody: 'bugID='+encodeURIComponent(bugID)+
									'&maID='+encodeURIComponent(maID)+
									'&abtID='+encodeURIComponent(abtID)+
									'&firmenID='+encodeURIComponent(firmenID),
				onComplete: function (t)
				{
					var res = t.responseText;
					switch (what)
					{
						case 'abt':
							$('bugAjaxTD_zuwMA').innerHTML = res;
							break;
						case 'ma':
							$('bugAjaxTD_zuwAbt').innerHTML = res;
							break;
					}
				}
			}
		);
	}
}

function be2_zugewiesenAbteilung_change()
{
	if ($('bugAjaxSelect_zugewiesenAbteilung') && $('bugAjax_zugewiesenAbteilungID'))
	{
		$('bugAjax_zugewiesenAbteilungID').value = parseInt($('bugAjaxSelect_zugewiesenAbteilung').options[$('bugAjaxSelect_zugewiesenAbteilung').selectedIndex].value, 10);
		if ($('bugAjaxTD_zuwMA'))
		{
			be2_getZugewiesenMitarbeiter();
		}
	}
}

function be2_getZugewiesenMitarbeiter()
{
	if ($('bugAjaxTD_zuwMA'))
	{
		$('bugAjaxTD_zuwMA').innerHTML = be2_showLoadIcon();
		var bugID = ($('bugAjax_bugID')) ? $('bugAjax_bugID').value : 0;
		var zugewiesenMitarbeiterID = $('bugAjax_zugewiesenMitarbeiterID') ? $('bugAjax_zugewiesenMitarbeiterID').value : '';
		var zugewiesenAbteilungID = $('bugAjax_zugewiesenAbteilungID') ? $('bugAjax_zugewiesenAbteilungID').value : '';
    var faell = $('faellig_datum') ? $F('faellig_datum') : '';
    var faellStd = $('faellig_datum_stunde') ? $F('faellig_datum_stunde') : '';
    var faellMin = $('faellig_datum_minute') ? $F('faellig_datum_minute') : '';
    var ltID = 0;
    var lID = 0;
    if ($('linkTypID')) ltID = $F('linkTypID');
    if ($('selectedLinkID')) lID = $F('selectedLinkID');
		var url = 'ajax/srv/bug_edit.php?typ=zugewiesenMitarbeiter';
		new Ajax.Request(url, {
      method: 'post',
      postBody: 'bugID='+encodeURIComponent(bugID)+
                '&zugewiesenMitarbeiterID='+encodeURIComponent(zugewiesenMitarbeiterID)+
                '&zugewiesenAbteilungID='+encodeURIComponent(zugewiesenAbteilungID) + 
                '&firmenID=' + $F('firmenID') + '&ltID=' + ltID + '&lID=' + lID +
                '&faell=' + faell + '&faellStd=' + faellStd + '&faellMin=' + faellMin,
      onComplete: function (t)
      {
        var json = t.responseText.evalJSON();
        $('bugAjaxTD_zuwMA').innerHTML = json.html;
        if (bugID == 0) {
          $('bugAjax_zugewiesenMitarbeiterID').value = json.maID;
          if (json.auto != '') {
            showInfoDivContainer(json.auto, 'ok');
          }
          if (json.vt != '') {
            showInfoDivContainer(json.vt, 'ok');
          }
        }
      }
    });
	}
}

function be2_typChangeSelect()
{
	/*
	if ($('bugAjaxSelect_typ') && $('bugAjax_typID'))
	{
		$('bugAjax_typID').value = parseInt($('bugAjaxSelect_typ').options[$('bugAjaxSelect_typ').selectedIndex].value, 10);
	}
	*/
}

function be2_reparaturChange()
{
	if ($('bugAjaxCheckbox_reparatur') && $('bugAjax_reparatur')) {
		switch ($('bugAjaxCheckbox_reparatur').checked) {
			case true:
				$('bugAjax_reparatur').value = 'Y';
				$('bugAjaxTR_zubehoer') ? $('bugAjaxTR_zubehoer').show() : true;
				break;
			case false:
				$('bugAjax_reparatur').value = 'N';
				$('bugAjaxTR_zubehoer') ? $('bugAjaxTR_zubehoer').hide() : true;
				break;			
		}
	}
}

function be2_erinnerungToggle(prefix)
{
	(typeof prefix == 'undefined') ? prefix = '' : true;
	if ($(prefix+'keine_erinnerung')) {
		if ($(prefix+'keine_erinnerung').checked == true) {
			($('bugAjaxInput_ee_in_tage')) ? $('bugAjaxInput_ee_in_tage').disabled = true : true;
			($('bugAjaxInput_ee_in_stunden')) ? $('bugAjaxInput_ee_in_stunden').disabled = true : true;
			($('bugAjaxInput_eea_tage')) ? $('bugAjaxInput_eea_tage').disabled = true : true;
			($('bugAjaxInput_eea_stunden')) ? $('bugAjaxInput_eea_stunden').disabled = true : true;
			($(prefix+'eea_tage')) ? $(prefix+'eea_tage').disabled = true : true;
			($(prefix+'eea_stunden')) ? $(prefix+'eea_stunden').disabled = true : true;
			($(prefix+'erinnerung_datum')) ? $(prefix+'erinnerung_datum').disabled = true : true;
			($(prefix+'erinnerung_datum_stunde')) ? $(prefix+'erinnerung_datum_stunde').disabled = true : true;
			($(prefix+'erinnerung_datum_minute')) ? $(prefix+'erinnerung_datum_minute').disabled = true : true;
		} else {
			($('bugAjaxInput_ee_in_tage')) ? $('bugAjaxInput_ee_in_tage').disabled = false : true;
			($('bugAjaxInput_ee_in_stunden')) ? $('bugAjaxInput_ee_in_stunden').disabled = false : true;
			($('bugAjaxInput_eea_tage')) ? $('bugAjaxInput_eea_tage').disabled = false : true;
			($('bugAjaxInput_eea_stunden')) ? $('bugAjaxInput_eea_stunden').disabled = false : true;
			($(prefix+'eea_tage')) ? $(prefix+'eea_tage').disabled = false : true;
			($(prefix+'eea_stunden')) ? $(prefix+'eea_stunden').disabled = false : true;
			($(prefix+'erinnerung_datum')) ? $(prefix+'erinnerung_datum').disabled = false : true;
			($(prefix+'erinnerung_datum_stunde')) ? $(prefix+'erinnerung_datum_stunde').disabled = false : true;
			($(prefix+'erinnerung_datum_minute')) ? $(prefix+'erinnerung_datum_minute').disabled = false : true;
		}
	}
}

function be2_keineFaelligkeitToggle(prefix)
{
	(typeof prefix == 'undefined') ? prefix = '' : true;
	if ($(prefix+'keine_faelligkeit'))
	{
		if ($(prefix+'keine_faelligkeit').checked == true)
		{
			($(prefix+'faellig_datum')) ? $(prefix+'faellig_datum').disabled = true : true;
			($(prefix+'faellig_datum_stunde')) ? $(prefix+'faellig_datum_stunde').disabled = true : true;
			($(prefix+'faellig_datum_minute')) ? $(prefix+'faellig_datum_minute').disabled = true : true;
		}
		else
		{
			($(prefix+'faellig_datum')) ? $(prefix+'faellig_datum').disabled = false : true;
			($(prefix+'faellig_datum_stunde')) ? $(prefix+'faellig_datum_stunde').disabled = false : true;
			($(prefix+'faellig_datum_minute')) ? $(prefix+'faellig_datum_minute').disabled = false : true;
		}
	}
}

function be2_keineDeadlineToggle(prefix)
{
	(typeof prefix == 'undefined') ? prefix = '' : true;
	if ($(prefix+'keine_dl'))
	{
		if ($(prefix+'keine_dl').checked == true)
		{
			$(prefix+'dl_datum').disabled = true;
			$(prefix+'dl_datum_stunde').disabled = true;
			$(prefix+'dl_datum_minute').disabled = true;
		}
		else
		{
			$(prefix+'dl_datum').disabled = false;
			$(prefix+'dl_datum_stunde').disabled = false;
			$(prefix+'dl_datum_minute').disabled = false;
		}
	}
}

function be2_resetZuweisung()
{
	if ($('bugAjaxTD_zuweisung'))
	{
		($('linkTypID')) ? $('linkTypID').value = 0 : true;
		($('selectedLinkID')) ? $('selectedLinkID').value = 0 : true;
		($('selectedKompID')) ? $('selectedKompID').value = 0 : true;
		($('devSuchFilter')) ? $('devSuchFilter').value = '' : true;
		//be2_getFromAjax('bugAjaxTD_zuweisung', 'zuweisungAuswahl2');
		be2_getZuweisungAuswahl();
		if ($('bugAjax_bugID'))
		{
			if (parseInt($('bugAjax_bugID').value, 10) == 0)
			{
				ajax_linkID_changed(0);
			}
		}
	}
}

function be2_getFromAjax_2(containerName, typ)
{  
	if ($(containerName))
	{
    $(containerName).innerHTML = be2_showLoadIcon();
		var bugID = ($('bugAjax_bugID')) ? $('bugAjax_bugID').value : 0;
		var url = 'ajax/srv/bug_edit.php?typ='+encodeURIComponent(typ);
		new Ajax.Request(url,
			{
				method: 'post',
				postBody: 'bugID='+encodeURIComponent(bugID),
				onComplete: function (t)
				{
					var res = t.responseText;
					$(containerName).innerHTML = res;
				}
			}
		);
	}
}

function be2_refreshCommentsWithTimeout()
{
	window.setTimeout('be2_refreshComments()', 30);
}

function be2_toggleCommentEdit(commentID)
{
  if ($('be_commentEDIT_'+commentID)) $('be_commentEDIT_'+commentID).toggle();
  if ($('be_commentSHOW_'+commentID)) $('be_commentSHOW_'+commentID).toggle();
}

function be2_refreshComments()
{
	//be2_getFromAjax_2('bugKommentareDiv', 'kommentare');
  var bugID = ($('bugAjax_bugID')) ? $('bugAjax_bugID').value : 0;
  if (bugID > 0 && $('bugKommentareDiv')) {
    new Ajax.Request('ajax/srv/bug_edit.php?typ=commentList', {
      postBody: 'bugID='+encodeURIComponent(bugID),
      onComplete: function (t) {
        $('bugKommentareDiv').innerHTML = t.responseText;
      }
    });
    be2_refreshSupport();
  }
}

function be2_refreshScreenshots()
{
	//be2_getFromAjax_2('bugScreenshotsDiv', 'screenshots');
  var bugID = ($('bugAjax_bugID')) ? $('bugAjax_bugID').value : 0;
  if (bugID > 0 && $('bugScreenshotsDiv')) {
    new Ajax.Request('ajax/srv/bug_edit.php?typ=screenshots', {
      postBody: 'bugID='+encodeURIComponent(bugID),
      onComplete: function (t) {
        $('bugScreenshotsDiv').innerHTML = t.responseText;
      }
    });
  }
}

function be2_refreshDocumentsWithTimeout()
{
	window.setTimeout('be2_refreshDocuments()', 30);
}

function be2_refreshDocuments()
{
	//be2_getFromAjax_2('bugDocumentsDiv', 'documents');
  var bugID = ($('bugAjax_bugID')) ? $('bugAjax_bugID').value : 0;
  if (bugID > 0 && $('bugDocumentsDiv')) {
    new Ajax.Request('ajax/srv/bug_edit.php?typ=documents', {
      postBody: 'bugID='+encodeURIComponent(bugID),
      onComplete: function (t) {
        $('bugDocumentsDiv').innerHTML = t.responseText;
      }
    });
  }
}

function be2_deleteComment(typ, theID)
{
	switch (typ)
	{
		case 'mail':
			if (askDeleteMail())
			{
				var url = 'ajax/srv/bug_edit.php?typ=deleteMail&delKomID='+encodeURIComponent(theID);
				new Ajax.Request(url,
					{
						method: 'get',
						asynchronous: false,
						onSuccess: function (transport)
						{
							var response = transport.responseText;
							be2_refreshComments();
						}
					}
				);
			}
			break;
		case 'comment':
			if (be2_askDeleteComment())
			{
				var url = 'ajax/srv/bug_edit.php?typ=deleteComment&delKomID='+encodeURIComponent(theID);
				new Ajax.Request(url,
					{
						method: 'get',
						asynchronous: false,
						onSuccess: function (transport)
						{
							var response = transport.responseText;
							be2_refreshComments();
						}
					}
				);
			}
			break;
	}
}

function be2_editComment(typ, postingID, divID, rowCount)
{
	switch (typ)
	{
		case 'comment':
			($(divID)) ? $(divID).innerHTML = be2_showLoadIcon() : true;
			var url = 'ajax/srv/bug_edit.php?typ=commentEditForm&postingID='+encodeURIComponent(postingID)+
								'&rowCount='+encodeURIComponent(rowCount);
			new Ajax.Request(url,
				{
					method: 'get',
					onSuccess: function (transport)
					{
						var response = transport.responseText;
						($(divID)) ? $(divID).innerHTML = response : true;
					}
				}
			);
			break;
	}
}

function be2_editComment2(postingID)
{
  if ($('be_commentEDIT_form_'+postingID)) {
    new Ajax.Request('ajax/srv/bug_edit.php?typ=saveCommentEdit', {
      postBody: $('be_commentEDIT_form_'+postingID).serialize(),
      onComplete: function (t) {
        be2_refreshComments();
      }
    });
  }
}

function be2_askDeleteComment()
{
	return (confirm(getLang("bug", "edit_delComment"))) ? true : false;
}

function be2_toggleCommentEmailTr(inputElement)
{
	if ($('commentEmailTr') && inputElement)
	{
		inputElement.checked ? $('commentEmailTr').hide() : $('commentEmailTr').show();
	}
}

function be2_emailBugCommentAdd(typ)
{
  var fremdeMitarbeiterChecked = false;
  var fremdeMitarbeiter = $$('input.emailBugCommentMitarbeiter');
  for (var i = 0, len = fremdeMitarbeiter.length; i < len; i++) {
    if (fremdeMitarbeiter[i].checked)
      fremdeMitarbeiterChecked = true;
  }
  if (fremdeMitarbeiterChecked && $('comment_intern'))
    $('comment_intern').checked = false;
  
	switch (typ)
	{
		case 'an':
		case 'cc':
		case 'bcc':
			if ($('bug_comment_mail_'+typ))
			{
				$('bug_comment_mail_'+typ).value = '';
				var objects = $$('input.emailBugCommentAddCheckbox');
				if (objects.length > 0)
				{
					for (var i = 0; i < objects.length; i++)
					{
						if (objects[i].checked == true)
						{
							($('bug_comment_mail_'+typ).value.length > 0) ? $('bug_comment_mail_'+typ).value += ',' : true;
							$('bug_comment_mail_'+typ).value += objects[i].value;
						}
					}
				}
			}
			break;
	}
}

function be2_fillCurrentTimestamp()
{
	if ($('comment_time_start'))
	{
		var url = 'ajax/srv/bug_edit.php?typ=getCurrentTimestamp';
		new Ajax.Request(url,
			{
				method: 'get',
				asynchronous: false,
				onComplete: function (t)
				{
					$('comment_time_start').value = t.responseText;
				}
			}
		);
	}	
}

function be2_showCommentForm()
{
	($('commentAddTr')) ? $('commentAddTr').hide() : true;
	($('commentAddTable')) ? $('commentAddTable').show() : true;
	be2_fillCurrentTimestamp();
}

function be2_addComment2(bugID)
{
	if ($('commentAdd_form'))
	{
		showInfoDivContainer('', 'ajax');
		var check = false;
		var doIt = true;
		if ($('comment_intern') && $('comment_send_infos') && $('bug_comment_mail_an') && $('comment_intern').checked && $('comment_send_infos').checked && $F('bug_comment_mail_an') != '') {
			check = true;
		}
		if (check == true) {
			doIt = confirm(getLang("bug", "be2_mailInfoQuestion"));
		}
		if (doIt == true) {
      showInfoDivContainer('', 'ajax');
			if ($('comment_submit')) $('comment_submit').disabled = true;
			var url = 'ajax/srv/bug_edit.php?typ=addComment2&bugID='+encodeURIComponent(bugID)+'&firmenID='+encodeURIComponent($('firmenID').value);
			new Ajax.Request(url,
				{
					method: 'post',
					postBody: $('commentAdd_form').serialize(),
					onComplete: function (transport)
					{
						var response = transport.responseText;
						var json = response.evalJSON();
						if (json.ok == true)
						{
							if ($('comment_ueberschrift')) $('comment_ueberschrift').value = '';
							if ($('comment_inhalt')) $('comment_inhalt').value = '';
							if ($('bug_comment_mail_an')) $('bug_comment_mail_an').value = '';
							if ($('bug_comment_mail_cc')) $('bug_comment_mail_cc').value = '';
							if ($('bug_comment_mail_bcc')) $('bug_comment_mail_bcc').value = '';
							if ($('bug_emailAttachmentsListHidden')) $('bug_emailAttachmentsListHidden').innerHTML = '';
              if ($('bug_emailDokuAttachments')) $('bug_emailDokuAttachments').value = '';
              if ($('bug_emailImageAttachments')) $('bug_emailImageAttachments').value = '';
              be2_refreshComments();
              be2_refreshEmailAttachmentsList();
						}
						showInfoDivContainer(json.meldung, json.ok == true ? 'ok' : 'fehler');
						if ($('comment_submit')) $('comment_submit').disabled = false;
					}
				}
			);
		} else {
			hideShowInfoDivContainer();
		}
	}
}

function be2_addComment(bugID)
{
	var ueberschrift = ($('comment_ueberschrift')) ? $('comment_ueberschrift').value : '';
	var inhalt = ($('comment_inhalt')) ? $('comment_inhalt').value : '';
	var intern = 'N';
	if ($('comment_intern'))
	{
		($('comment_intern').checked == true) ? intern = 'Y' : true;
	}
	var ma = ($('bug_comment_ma')) ? $('bug_comment_ma').options[$('bug_comment_ma').selectedIndex].value : 0;
	var mail = ($('bug_comment_mail')) ? $('bug_comment_mail').value : '';
	var postStr = 'ueberschrift='+encodeURIComponent(ueberschrift)+
								'&inhalt='+encodeURIComponent(inhalt)+
								'&intern='+encodeURIComponent(intern)+
								'&ma='+encodeURIComponent(ma)+
								'&mail='+encodeURIComponent(mail)+
								'&bugID='+encodeURIComponent(bugID);
	var url = 'ajax/srv/bug_edit.php?typ=addComment';
	new Ajax.Request(url,
		{
			method: 'post',
			postBody: postStr,
			onSuccess: function (transport)
			{
				var response = transport.responseText;
				var json = response.evalJSON();
				if (json.ok == true)
				{
					be2_refreshComments();
					($('comment_ueberschrift')) ? $('comment_ueberschrift').value = '' : true;
					($('comment_inhalt')) ? $('comment_inhalt').value = '' : true;
					($('comment_intern')) ? $('comment_intern').checked = false : true;
					($('bug_comment_ma')) ? $('bug_comment_ma').selectedIndex = 0 : true;
					($('bug_comment_mail')) ? $('bug_comment_mail').value = '' : true;
					($('bug_comment_ma_info')) ? $('bug_comment_ma_info').hide() : true;
					($('commentInternTr')) ? $('commentInternTr').show() : true;
				}
				showInfoDivContainer(json.meldung, json.ok == true ? 'ok' : 'fehler');
			}
		}
	);
}

function be2_addScreenshot(bugID)
{
	window.open('ajax/srv/bug_edit.php?typ=showScreenshotForm&bugID='+encodeURIComponent(bugID), 'addScreenshotWindow', 'top=50, left=50, height=200, width=500, resizable=yes, scrollbars=yes, status=yes');
}

function be2_addDocument(bugID)
{
	window.open('ajax/srv/bug_edit.php?typ=showDocumentsForm&bugID='+encodeURIComponent(bugID), 'addDocumentWindow', 'top=50, left=50, height=200, width=500, resizable=yes, scrollbars=yes, status=yes');
}

function be2_updateComment(komID)
{
	var ueberschrift = ($('commentEdit_ueberschrift_'+komID)) ? $('commentEdit_ueberschrift_'+komID).value : '';
	var inhalt = ($('commentEdit_inhalt_'+komID)) ? $('commentEdit_inhalt_'+komID).value : '';
	var intern = ($('commentEdit_intern_'+komID) && ($('commentEdit_intern_'+komID).checked == true)) ? 'Y' : 'N';
	var postStr = 'ueberschrift='+encodeURIComponent(ueberschrift)+
								'&inhalt='+encodeURIComponent(inhalt)+
								'&intern='+encodeURIComponent(intern)+
								'&komID='+encodeURIComponent(komID);
	var url = 'ajax/srv/bug_edit.php?typ=updateComment';
	new Ajax.Request(url,
		{
			method: 'post',
			postBody: postStr,
			onSuccess: function (transport)
			{
				var response = transport.responseText;
				be2_refreshComments();
			}
		}
	);
}

function be2_changeViewZugewiesenMitarbeiter()
{
	if ($('bugAjaxSelect_zugewiesenMitarbeiter') && $('bugAjax_bugID') && $('bugAjax_zugewiesenMitarbeiterID') && $('bugAjax_zugewiesenAbteilungID'))
	{
		$('bugAjax_zugewiesenMitarbeiterID').value = parseInt($('bugAjaxSelect_zugewiesenMitarbeiter').options[$('bugAjaxSelect_zugewiesenMitarbeiter').selectedIndex].value, 10);
		var bugID = parseInt($('bugAjax_bugID').value, 10);
		var url = 'ajax/srv/bug_edit.php?typ=changeZugewiesenMitarbeiter'+
							'&maID='+encodeURIComponent($('bugAjax_zugewiesenMitarbeiterID').value);
		($('bugAjaxTD_zuwMA')) ? $('bugAjaxTD_zuwMA').innerHTML = be2_showLoadIcon() : true;
		new Ajax.Request(url,
			{
				method: 'post',
				asynchronous: false,
				postBody: 'bugID='+encodeURIComponent(bugID),
				onSuccess: function (transport)
				{
					var response = transport.responseText;
					($('bugAjaxTD_zuwMA')) ? $('bugAjaxTD_zuwMA').innerHTML = response : true;
				}
			}
		);
		var url = 'ajax/srv/bug_edit.php?typ=refreshZugewiesenAbteilung';
		($('bugAjaxTD_zuwAbt')) ? $('bugAjaxTD_zuwAbt').innerHTML = be2_showLoadIcon() : true;
		new Ajax.Request(url,
			{
				method: 'post',
				asynchronous: false,
				postBody: 'bugID='+encodeURIComponent(bugID),
				onSuccess: function (transport)
				{
					var response = transport.responseText;
					($('bugAjaxTD_zuwAbt')) ? $('bugAjaxTD_zuwAbt').innerHTML = response : true;
				}
			}
		);
	}
}

function be2_changeViewZugewiesenAbteilung()
{
	if ($('bugAjaxSelect_zugewiesenAbteilung') && $('bugAjax_bugID') && $('bugAjax_zugewiesenMitarbeiterID') && $('bugAjax_zugewiesenAbteilungID'))
	{
		$('bugAjax_zugewiesenAbteilungID').value = parseInt($('bugAjaxSelect_zugewiesenAbteilung').options[$('bugAjaxSelect_zugewiesenAbteilung').selectedIndex].value, 10);
		var bugID = parseInt($('bugAjax_bugID').value, 10);
		var url = 'ajax/srv/bug_edit.php?typ=changeZugewiesenAbteilung'+
							'&abtID='+encodeURIComponent($('bugAjax_zugewiesenAbteilungID').value);
		($('bugAjaxTD_zuwAbt')) ? $('bugAjaxTD_zuwAbt').innerHTML = be2_showLoadIcon() : true;
		new Ajax.Request(url,
			{
				method: 'post',
				asynchronous: false,
				postBody: 'bugID='+encodeURIComponent(bugID),
				onSuccess: function (transport)
				{
					var response = transport.responseText;
					($('bugAjaxTD_zuwAbt')) ? $('bugAjaxTD_zuwAbt').innerHTML = response : true;
				}
			}
		);
		var url = 'ajax/srv/bug_edit.php?typ=refreshZugewiesenMitarbeiter';
		($('bugAjaxTD_zuwMA')) ? $('bugAjaxTD_zuwMA').innerHTML = be2_showLoadIcon() : true;
		new Ajax.Request(url,
			{
				method: 'post',
				asynchronous: false,
				postBody: 'bugID='+encodeURIComponent(bugID),
				onSuccess: function (transport)
				{
					var response = transport.responseText;
					($('bugAjaxTD_zuwMA')) ? $('bugAjaxTD_zuwMA').innerHTML = response : true;
				}
			}
		);
	}
}

function be2_refreshSelection()
{
	if ($('showFunctionsTyp') && $('showNewSelectionDiv') && $('bugAjax_bugID')) {
		if (($('showFunctionsTyp').value == 'view') || ($('showFunctionsTyp').value == 'edit')) {
			var url = 'ajax/srv/bug_edit.php?typ=refreshSelection&selTyp='+encodeURIComponent($('showFunctionsTyp').value);
			new Ajax.Request(url, {
        method: 'post',
        postBody: 'bugID='+encodeURIComponent($('bugAjax_bugID').value),
        onComplete: function (t) {
          $('showNewSelectionDiv').innerHTML = t.responseText;
        }
			});
		}
	}
}

function be2_setNewStatus(erledigtID)
{
	if ($('bugAjaxSelect_status') && $('bugAjax_bugID')) {
		var bugID = $('bugAjax_bugID').value;
		if (parseInt($F('bugAjaxSelect_status'), 10) != erledigtID)	{
			be2_checkErinnerungFaelligkeitPopup(parseInt($F('bugAjaxSelect_status'), 10), bugID, erledigtID);
		} else {
			be2_setNewStatusExec(erledigtID);
		}
	}
}

function be2_setNewStatusExec(erledigtID)
{
	if ($('bugAjaxSelect_status') && $('bugAjax_bugID') && $('bugAjax_statusID') && $('bugAjax_closeTaskOnSubmit')) {
		var bugID = $('bugAjax_bugID').value;
		$('bugAjax_statusID').value = parseInt($F('bugAjaxSelect_status'), 10);
		var url = 'ajax/srv/bug_edit.php?typ=setNewStatusFromView'+
							'&statusID='+encodeURIComponent($('bugAjax_statusID').value)+
							'&closeTaskOnSubmit='+encodeURIComponent($('bugAjax_closeTaskOnSubmit').value);
		($('bugAjaxTD_status')) ? $('bugAjaxTD_status').innerHTML = be2_showLoadIcon() : true;
		new Ajax.Request(url, {
				method: 'post',
				asynchronous: false,
				postBody: 'bugID='+encodeURIComponent(bugID),
				onSuccess: function (transport) {
					var response = transport.responseText;
					($('bugAjaxTD_status')) ? $('bugAjaxTD_status').innerHTML = response : true;
				}
			}
		);
		if (parseInt(erledigtID, 10) == parseInt($('bugAjax_statusID').value, 10)) {
			if (confirm($F('erlFrage'))) {
				window.location.href = $F('bugAjax_backtoString');
			} else {
				be2_refreshSupport();
				be2_refreshSelection();
			}
		}
		else {
			be2_refreshSelection();
		}		
	}
}

function be2_checkErinnerungFaelligkeitPopup(newStatusID, bugID, erledigtID)
{
	var url = 'ajax/srv/bug_edit.php?typ=checkErinnerungFaelligkeitPopup'+
						'&newStatusID='+encodeURIComponent(newStatusID)+
						'&bugID='+encodeURIComponent(bugID);
	new Ajax.Request(url,
		{
			method: 'get',
			onComplete: function (transport)
			{
				var response = transport.responseText;
				var json = response.evalJSON();
				if (json.popup == true)	{
					be2_showErinnerungFaelligkeitPopup();
				} else {
					be2_setNewStatusExec(erledigtID);
				}
			}
		}
	);
}

function be2_showErinnerungFaelligkeitPopup_portal(bugID, updatelist)
{
	if ($('erinnerungFaelligkeitPopupContainer'))
	{
		showInfoDivContainer('', 'ajax');
		var url = 'ajax/srv/bug_edit.php?typ=showErinnerungFaelligkeitPopup&portal=1';
		if (updatelist) url += '&updatelist=1';
		new Ajax.Request(url,
			{
				method: 'post',
				postBody: 'bugID='+encodeURIComponent(bugID),
				onComplete: function (transport)
				{
					hideShowInfoDivContainer();
					var response = transport.responseText;
					$('erinnerungFaelligkeitPopupContainer').innerHTML = response;
					$('erinnerungFaelligkeitPopupContainer').show();
					be2_erinnerungToggle('bugFormPopup_');
					be2_keineFaelligkeitToggle('bugFormPopup_');
					be2_tanssDateTimePicker('bugFormPopup_erinnerung_datum', 'bugFormPopup_div1');
					be2_tanssDateTimePicker('bugFormPopup_faellig_datum', 'bugFormPopup_div2');
				}
			}
		);
	}
}

function be2_showErinnerungFaelligkeitPopup()
{
	if ($('erinnerungFaelligkeitPopupContainer'))
	{
		showInfoDivContainer('', 'ajax');
		var url = 'ajax/srv/bug_edit.php?typ=showErinnerungFaelligkeitPopup'
		new Ajax.Request(url,
			{
				method: 'post',
				postBody: 'bugID='+encodeURIComponent($('bugAjax_bugID').value),
				onComplete: function (transport)
				{
					hideShowInfoDivContainer();
					var response = transport.responseText;
					$('erinnerungFaelligkeitPopupContainer').innerHTML = response;
					$('erinnerungFaelligkeitPopupContainer').show();
					$('bug_view_OKButton').disabled = true;
					be2_erinnerungToggle('bugFormPopup_');
					be2_keineFaelligkeitToggle('bugFormPopup_');
					be2_tanssDateTimePicker('bugFormPopup_erinnerung_datum', 'bugFormPopup_div1');
					be2_tanssDateTimePicker('bugFormPopup_faellig_datum', 'bugFormPopup_div2');
				}
			}
		);
	}
}

function be2_showErinnerungFaelligkeitPopup2(theID, thePosition)
{
	if ($('erinnerungFaelligkeitPopupContainer'))
	{
		showInfoDivContainer('', 'ajax');
		var url = 'ajax/srv/bug_edit.php?typ=showErinnerungFaelligkeitPopup2&position='+encodeURIComponent(thePosition);
		new Ajax.Request(url,
			{
				method: 'post',
				postBody: 'bugID='+encodeURIComponent(theID),
				onComplete: function (transport)
				{
					hideShowInfoDivContainer();
					var response = transport.responseText;
					$('erinnerungFaelligkeitPopupContainer').innerHTML = response;
					$('erinnerungFaelligkeitPopupContainer').show();
					be2_erinnerungToggle('bugFormPopup_');
					be2_keineFaelligkeitToggle('bugFormPopup_');
					be2_keineDeadlineToggle('bugFormPopup_');
          jQuery('#bugFormPopup_erinnerung_datum').datepicker();
          jQuery('#bugFormPopup_faellig_datum').datepicker();
          jQuery('#bugFormPopup_dl_datum').datepicker();
				}
			}
		);
	}
}

function be2_calenderDivContainer_datumAendern_bugFormPopup_erinnerung_datum(jahr, monat, tag)
{
	$('bugFormPopup_erinnerung_datum').value = ((tag < 10) ? '0' + tag : tag).toString() + ((monat < 10) ? '0' + monat : monat).toString() + jahr.toString().substr(2,2);
}

function be2_calenderDivContainer_datumAendern_bugFormPopup_faellig_datum(jahr, monat, tag)
{
	$('bugFormPopup_faellig_datum').value = ((tag < 10) ? '0' + tag : tag).toString() + ((monat < 10) ? '0' + monat : monat).toString() + jahr.toString().substr(2,2);
}

function be2_calenderDivContainer_datumAendern_bugFormPopup_dl_datum(jahr, monat, tag)
{
	$('bugFormPopup_dl_datum').value = ((tag < 10) ? '0' + tag : tag).toString() + ((monat < 10) ? '0' + monat : monat).toString() + jahr.toString().substr(2,2);
}

function be2_tanssDateTimePicker(targetInputElementID, targetDivElementID)
{
	if ($(targetDivElementID))
	{
		if (!$('be2_calenderDivContainer'))
		{
			var theDiv = document.createElement('div');
			theDiv.style.backgroundColor = '#fff';
			theDiv.style.visibility = 'hidden';
			theDiv.style.position = 'fixed';
			theDiv.style.top = '0px';
			theDiv.style.left = '0px';
			theDiv.style.zIndex = 100000;
			theDiv.id = 'be2_calenderDivContainer';
			theDiv.name = 'be2_calenderDivContainer';
			$('body_element').appendChild(theDiv);
		}
		var theImg = document.createElement('img');
		theImg.src = 'media/hp/tep/navi_kal.gif';
		var theAnchor = document.createElement('a');
		theAnchor.href = '#';
		theAnchor.onclick = function () {window['cal_'+targetInputElementID].select($(''+targetInputElementID+''), 'calendar_anchor_'+targetInputElementID , 'ddMMyy');return false;}
		theAnchor.id = 'calendar_anchor_'+targetInputElementID;
		theAnchor.name = 'calendar_anchor_'+targetInputElementID;
		theAnchor.appendChild(theImg);
		$(targetDivElementID).appendChild(theAnchor);
		window['cal_'+targetInputElementID] = new CalendarPopup('be2_calenderDivContainer');
		window['cal_'+targetInputElementID].setReturnFunction('be2_calenderDivContainer_datumAendern_'+targetInputElementID);
	}
}

function be2_refreshSupport()
{
	if ($('be2SupportDiv'))
	{
		var bugID = $('bugAjax_bugID') ? $('bugAjax_bugID').value : '';
		var inView = $('bugAjax_inView') ? $('bugAjax_inView').value : '1';
		new Ajax.Request('ajax/srv/bug_edit.php?typ=refreshSupport&inView='+encodeURIComponent(inView),
			{
				method: 'post',
				postBody: 'bugID='+encodeURIComponent(bugID),
				onComplete: function(transport)
				{
					var response = transport.responseText;
					$('be2SupportDiv').innerHTML = response;
				}
			}
		);
	}
}

function be2_checkPopupErinnerungFaelligkeitEntries()
{
	var errors = [];
	if ($('bugFormPopup_keine_erinnerung') && ($('bugFormPopup_keine_erinnerung').checked == false))
	{
		if ($('bugFormPopup_erinnerung_datum') && $('bugFormPopup_erinnerung_datum_stunde') && $('bugFormPopup_erinnerung_datum_minute') && $('bugFormPopup_eea_tage') && $('bugFormPopup_eea_stunden'))
		{
			if (trimString($('bugFormPopup_erinnerung_datum').value).search(/^[0-9]{6}$/) == -1)
			{
				errors[errors.length] = getLang("pc", "chkFormValues_date");
			}
			if (trimString($('bugFormPopup_erinnerung_datum_stunde').value).search(/^[0-9]{1,2}$/) == -1)
			{
				errors[errors.length] = 'fehler 2';
			}
			if (trimString($('bugFormPopup_erinnerung_datum_minute').value).search(/^[0-9]{1,2}$/) == -1)
			{
				errors[errors.length] = 'fehler 3';
			}
		}		
	}
	if ($('bugFormPopup_keine_aaerinnerung') && ($('bugFormPopup_keine_aaerinnerung').checked == false))
	{
		if ($('bugFormPopup_faellig_datum') && $('bugFormPopup_faellig_datum_stunde') && $('bugFormPopup_faellig_datum_minute'))
		{
			if (trimString($('bugFormPopup_faellig_datum').value).search(/^[0-9]{6}$/) == -1)
			{
				errors[errors.length] = getLang("pc", "chkFormValues_date");
			}
			if (trimString($('bugFormPopup_faellig_datum_stunde').value).search(/^[0-9]{1,2}$/) == -1)
			{
				errors[errors.length] = 'fehler 6';
			}
			if (trimString($('bugFormPopup_faellig_datum_minute').value).search(/^[0-9]{1,2}$/) == -1)
			{
				errors[errors.length] = 'fehler 7';
			}
		}		
	}
	var errorString = '';
	for (var i = 0; i < errors.length; i++)
	{
		errorString += errors[i];
		(errors[i+1]) ? errorString += '\n' : true;
	}
	if (errorString != '')
	{
		alert(getLang("all", "checkInputs"));
	}
	return (errors.length == 0) ? true : false;
}

function be2_checkFaelligkeitGeaendert()
{
	var ret = false;
	if ($('bugFormPopup'))
	{
		var url = 'ajax/srv/bug_edit.php?typ=checkFaelligkeitGeaendert';
		new Ajax.Request(url,
			{
				asynchronous: false,
				postBody: $('bugFormPopup').serialize(),
				onComplete: function (t)
				{
					var json = t.responseText.evalJSON();
					if ((typeof json.status != 'undefined') && (json.status == true)) {
						ret = true;
          }
				}
			}
		);
	}
	return ret;
}

function be2_savePopupErinnerungFaelligkeitExec(thePosition)
{
	($('erinnerungFaelligkeitPopupContainer')) ? $('erinnerungFaelligkeitPopupContainer').hide() : true;
	showInfoDivContainer('', 'ajax');
	var url = 'ajax/srv/bug_edit.php?typ=savePopupErinnerungFaelligkeit';
	new Ajax.Request(url, {
			method: 'post',
			postBody: $('bugFormPopup').serialize(),
			asynchronous: false,
			onComplete: function (t)
			{
				switch (thePosition)
				{
					case 'ticket_list':
						al_show('al_ticket', 'ticket', '', '1', '');
						break;
					case 'ticket_list_portal':
						if ($('p4_inh_allgemeineTickets') && $('p4_inh_allgemeineTickets').style.display != 'none') {
							p4_window_inhalt_akt('allgemeineTickets');
						}
						if ($('p4_inh_eigeneTickets') && $('p4_inh_eigeneTickets').style.display != 'none') {
							p4_window_inhalt_akt('eigeneTickets');
						}
						if ($('p4_inh_firmenTickets') && $('p4_inh_firmenTickets').style.display != 'none') {
							p4_window_inhalt_akt('firmenTickets');
						}
						if ($('p4_inh_nZugewTickets') && $('p4_inh_nZugewTickets').style.display != 'none') {
							p4_window_inhalt_akt('nZugewTickets');
						}
						if ($('p4_inh_reparaturTickets') && $('p4_inh_reparaturTickets').style.display != 'none') {
							p4_window_inhalt_akt('reparaturTickets');
						}
						if ($('p4_inh_ticketsAllerTechniker') && $('p4_inh_ticketsAllerTechniker').style.display != 'none') {
							p4_window_inhalt_akt('ticketsAllerTechniker');
						}
						try {
							le2_ticket_aendern();
						} catch (ex) {};
						break;
					case 'ticket_view':
						var json = t.responseText.evalJSON();
						if ((typeof $$('a.generatedBacklink')[0] != 'undefined') && (json.erledigt == true)) {
							if (confirm(getLang("all", "goToPreviousPage"))) {
								location.href = $$('a.generatedBacklink')[0];
							} else {
								be2_reloadViewContent();
								be2_refreshComments();
                be2_refreshSelection();
							}
						} else {
							be2_reloadViewContent();
							be2_refreshComments();
              be2_refreshSelection();
						}
						break;
				}
				var json2 = t.responseText.evalJSON();
        if (json2.err == true) {
    			showInfoDivContainer(json2.errMsg, 'fehler');
        } else {
					hideShowInfoDivContainer();
        }
        if (json.keinZugriff == true) {
					location.href = $$('a.generatedBacklink')[0];
        }
			}
		}
	);
}

function be2_savePopupErinnerungFaelligkeit(thePosition)
{
	if ($('bugFormPopup'))
	{
		if (be2_checkPopupErinnerungFaelligkeitEntries())
		{
			var grund = '';
			if (be2_checkFaelligkeitGeaendert() && $('bugFormPopup_faelligkeitGrund'))
			{
				if (grund = prompt(getLang("bug", "be2_changeFReason"), ''))
				{
					if (grund.strip() != '')
					{
						if ($('bugFormPopup_faelligkeitGrund')) $('bugFormPopup_faelligkeitGrund').value = grund;
						be2_savePopupErinnerungFaelligkeitExec(thePosition);
					}
					else
					{
						alert(getLang("all", "haveToSetReason"));
					}
				}
				else
				{
					alert(getLang("all", "haveToSetReason"));
				}
			}
			else
			{
				be2_savePopupErinnerungFaelligkeitExec(thePosition);
			}
		}
	}
}

function be2_reloadViewContent()
{
	if ($('bugAjax_bugID'))
	{
		var url = 'ajax/srv/bug_edit.php?typ=reloadViewContent&bugID='+encodeURIComponent($('bugAjax_bugID').value);
		new Ajax.Request(url,
			{
				method: 'get',
				onComplete: function (t)
				{
					var json = t.responseText.evalJSON();
					if ($('bugAjaxTD_status')) $('bugAjaxTD_status').innerHTML = json.status;
					if ($('bugAjaxTD_zuwMA')) $('bugAjaxTD_zuwMA').innerHTML = json.zuwMA;
					if ($('bugAjaxTD_zuwAbt')) $('bugAjaxTD_zuwAbt').innerHTML = json.zuwAbt;
					if ($('bugAjaxTD_gesichtet')) $('bugAjaxTD_gesichtet').innerHTML = json.letzteStatus;
					if ($('bugAjaxTD_naechsteErinnerung')) $('bugAjaxTD_naechsteErinnerung').innerHTML = json.erinnerung;
					if ($('bugAjaxTD_faelligkeit')) $('bugAjaxTD_faelligkeit').innerHTML = json.faelligkeit;
					be2_refreshSupport();
				}
			}
		);
	}
}

function be2_mail_intern(id)
{
	new Ajax.Request('ajax/srv/ajax.php?t=mailIntern&id=' + id, {
		onSuccess: function(t) {
			try {
				be2_refreshComments();
			} catch (ex) {}
		}
	});
}

function be2_showEmailAttachmentForm()
{
	window.open('ajax/srv/bug_edit.php?typ=emailAttachmentPopup', 'bugEmailPopup', 'top=50, left=50, height=200, width=500, resizable=yes, scrollbars=yes, status=yes');
}

function be2_setEmailAttachments(attachments)
{
  if ($('bug_emailAttachmentsListHidden')) {
    var att = attachments.evalJSON();
    for (var i = 0, len = att.length; i < len; ++i) {
      var input_hidden = new Element('input', {'type': 'hidden', 'name': 'bug_mailFileAttachment[]', 'value': att[i], 'class': 'bug_mailFileAttachment'});
      $('bug_emailAttachmentsListHidden').appendChild(input_hidden);
    }
    be2_removeEmailAttachmentAdmin();
    be2_refreshEmailAttachmentsList();
  }
}

function be2_auflistungTicketKommentareSelectChange(bugID)
{
	if ($('auflistungTicketKommentareTypSelect') && $('auflistungTicketKommentareDiv'))
	{
		$('auflistungTicketKommentareDiv').innerHTML = show_load(true);
		var url = 'ajax/srv/bug_edit.php?typ=auflistungTicketKommentareSelectChange&new='+encodeURIComponent($('auflistungTicketKommentareTypSelect').value);
		new Ajax.Request(url,
			{
				method: 'post',
				postBody: 'bugID='+encodeURIComponent(bugID),
				onComplete: function (t)
				{
					$('auflistungTicketKommentareDiv').innerHTML = t.responseText;
				}
			}
		);
	}
}

function be2_closeCustomerForm()
{
  if ($('sendFormToCustomerDiv')) $('sendFormToCustomerDiv').remove();
}

function be2_customerFormSubmit()
{
  if (!($('sendFormToCustomerForm_xmlpdfID') && ($('sendFormToCustomerForm_xmlpdfID').value > 0))) {
    showInfoDivContainer(getLang("all", "sendBugFormError3"), 'fehler');
  } else {
    be2_generateXMLPDF();
  }
}

function be2_generateXMLPDF()
{
  if ($('sendFormToCustomerForm')) {
    new Ajax.Request('ajax/srv/bug_edit.php?typ=generateXMLPDF', {
      postBody: $('sendFormToCustomerForm').serialize(),
      onComplete: function (t) {
        var json = t.responseText.evalJSON();
        if (json.pdf) {
          (json.email) ? showInfoDivContainer(getLang("mail", "emailSendingOK")) : showInfoDivContainer(getLang("all", "formCreatedOK"));
          if ($('sendFormToCustomerDiv')) $('sendFormToCustomerDiv').remove();
          be2_refreshComments();
          window.open('cache/'+json.name, '_blank', 'top=50, left=50, width=950, height=600');
        } else {
          showInfoDivContainer('Fehlgeschlagen', 'fehler');
        }
      }
    });
  }
}

function be2_sendFormToCustomer()
{
	showInfoDivContainer('', 'ajax');
	be2_closeCustomerForm();
	var url = 'ajax/srv/bug_edit.php?typ=createSendFormToCustomer';
	new Ajax.Request(url,
		{
			method: 'post',
			postBody: 'bugID='+encodeURIComponent(($('bugAjax_bugID') ? $('bugAjax_bugID').value : ''))+
								'&firmenID='+encodeURIComponent(($('firmenID') ? $('firmenID').value : ''))+
								'&auftraggeberID='+encodeURIComponent(($('bugAjaxSelect_auftraggeber') ? parseInt($F('bugAjaxSelect_auftraggeber'), 10) : '')),
			onComplete: function (t)
			{
				var _div = document.createElement('div');
				_div.id = 'sendFormToCustomerDiv';
				document.body.appendChild(_div);
				_div.innerHTML = t.responseText;
				hideShowInfoDivContainer();
			}
		}
	);
}

function be2_ticketFreigeben(bugID)
{
	showInfoDivContainer('', 'ajax');
	var url = 'ajax/srv/bug_edit.php?typ=ticketFreigeben&bugID='+encodeURIComponent(bugID);
	new Ajax.Request(url,
		{
			onComplete: function (t)
			{
				hideShowInfoDivContainer();
				location.reload();
			}
		}
	);
}

function be2_ticketSperren(bugID)
{
	showInfoDivContainer('', 'ajax');
	var url = 'ajax/srv/bug_edit.php?typ=ticketSperren&bugID='+encodeURIComponent(bugID);
	new Ajax.Request(url,
		{
			onComplete: function (t)
			{
				hideShowInfoDivContainer();
				location.reload();
			}
		}
	);
}

function be2_merge_init(currID)
{
	var div = document.createElement("div");
	div.id = "mergeDiv_" + currID;
	div.className = "bugMergeDiv";
	div.style.width = '400px';
	document.body.appendChild(div);
	new Ajax.Request('ajax/srv/bug_edit.php?typ=mergeDiv', {
		parameters: 'bugID=' + currID,
		onSuccess: function(t) {
			if ($('mergeGfx_' + currID))
			{
				div.innerHTML = t.responseText;
				div.style.left = $('mergeGfx_' + currID).cumulativeOffset()[0] - 120 + "px";
				div.style.top = $('mergeGfx_' + currID).cumulativeOffset()[1] + "px";
			}
		}
	});
}

function be2_merge_selected(currID, selID)
{
	var div = $('mergeDiv_' + currID);
	new Ajax.Request('ajax/srv/bug_edit.php?typ=mergeSelected', {
		parameters: 'bugID=' + currID + '&selID=' + selID,
		onSuccess: function(t) {
			div.innerHTML = t.responseText;
		}
	});
}

function be2_merge_do(currID, selID)
{
	var div = $('mergeDiv_' + currID);
	new Ajax.Request('ajax/srv/bug_edit.php?typ=mergeDo', {
		parameters: 'bugID=' + currID + '&selID=' + selID,
		onSuccess: function(t) {
			div.innerHTML = t.responseText;
		}
	});
}

function be2_merge_reload()
{
	var aktHref = window.location.href;
	aktHref = aktHref.replace("#", ""),
	window.location.href = aktHref;
}

function be2_delPrc(prcID, id)
{
  if (confirm(getLang('prc', 'prc_delQ'))) {
    new Ajax.Request('ajax/srv/bug_edit.php?typ=delPrc', {
      parameters: 'bugID=' + id + '&prcID=' + prcID,
      onSuccess: function(t) {
        be2_refreshCheck(id);
      }
    });
  }
}

function be2_addPrc(id)
{
  if ($('prc2add') && $F('prc2add') > 0) {
    new Ajax.Request('ajax/srv/bug_edit.php?typ=addPrc', {
      parameters: 'bugID=' + id + '&prcID=' + $F('prc2add'),
      onSuccess: function(t) {
        be2_refreshCheck(id);
      }
    });
  }
}

function be2_rangPrc(prcID, id, dir)
{
  new Ajax.Request('ajax/srv/bug_edit.php?typ=rangPrc', {
    parameters: 'bugID=' + id + '&prcID=' + prcID + '&dir=' + dir,
    onSuccess: function(t) {
      be2_refreshCheck(id);
    }
  });
}

function be2_refreshCheck(id) {
  if ($('be_check')) {
    new Ajax.Request('ajax/srv/bug_edit.php?typ=editCheckDiv', {
      parameters: 'bugID=' + id,
      onSuccess: function(t) {
        $('be_check').innerHTML = t.responseText;
      }
    });
  }
}

function be2_ipCheck() {
  if ($('t_pauschal')) {
    if ($('t_pauschal').checked == true) {
      $('t_pauschal_div').show();
    } else {
      $('t_pauschal_div').hide();
    }
  }
}

function be2_updOGdiv(id) {
  if($('updOGdiv')) {
    $('updOGdiv').remove();
  }
	var div = document.createElement("div");
	div.id = "updOGdiv";
	document.body.appendChild(div);
  new Ajax.Request('ajax/srv/bug_edit.php?typ=updOGdiv', {
    parameters: 'bugID=' + id,
    onSuccess: function(t) {
      $('updOGdiv').innerHTML = t.responseText;
      div.style.left = $('updOGimg').cumulativeOffset()[0] + "px";
      div.style.top = $('updOGimg').cumulativeOffset()[1] + "px";
    }
  });
}

function be2_updOGself(id) {
  showInfoDivContainer('', 'ajax');
  new Ajax.Request('ajax/srv/bug_edit.php?typ=updOG', {
    parameters: 'bugID=' + id + '&betrag=' + encodeURIComponent($F('ogNeuBetrag')),
    onSuccess: function(t) {
      $('bugAjaxTD_og').innerHTML = t.responseText;
      $('updOGdiv').remove();
      showInfoDivContainer(getLang("bug", "ticket_9"), 'ok');
    }
  });
}

function be2_updOGmail(id) {
  if ($('ogMailUser')) {
    showInfoDivContainer('', 'ajax');
    if ($F('ogMailUser') > 0) {
      new Ajax.Request('ajax/srv/bug_edit.php?typ=updOGmail', {
        parameters: 'bugID=' + id + '&userID=' + $F('ogMailUser'),
        onSuccess: function(t) {
          showInfoDivContainer(getLang("bug", "og_userMailSent"), 'ok');
          $('updOGdiv').remove();
        }
      });
    } else {
      showInfoDivContainer(getLang("bug", "og_userSelectErr"), 'fehler');
    }
  }
}

function be2_check_dl() {
  var ok = true;
  new Ajax.Request('ajax/srv/bug_edit.php?typ=check_dl', {
    parameters: be2_getHiddenFieldsToString(),
    asynchronous: false,
    onSuccess: function(t) {
      var json = t.responseText.evalJSON();
      ok = json.ok;
      if (json.ok == false) {
        showInfoDivContainer(json.msg, 'fehler');
      }
    }
  });
  return ok;
}

function be2_submitPruefungen() {
  var check_dl = be2_check_dl();
  if (check_dl == true) {
    return true;
  }
  return false;
}

function be2_assignSelf() {
  new Ajax.Request('ajax/srv/bug_edit.php?typ=assignSelf', {
    parameters: 'bugID=' + $F('bugAjax_bugID'),
    onSuccess: function(t) {
      be2_reloadViewContent();
    }
  });
}

function be2_quickStatus(st) {
  new Ajax.Request('ajax/srv/bug_edit.php?typ=quickStatus', {
    parameters: 'bugID=' + $F('bugAjax_bugID') + '&st=' + st,
    onSuccess: function(t) {
      be2_reloadViewContent();
    }
  });
}

function be2_linkID_changed() {
  $('be2Save').enable();
  $('be2SaveAndExit').enable();
  if ($F('bugAjax_bugID') == 0) {
    be2_getZugewiesenMitarbeiter();
  }
}

function be2_linkTypID_changed(val) {
  ajax_linkTypID_changed(val);
  if ($F('bugAjax_bugID') == 0) {
    be2_getZugewiesenMitarbeiter();
  }
}

function be2_switchToEmailBox(what, emailID)
{
  // HTML
  if ($('mailShowHTML_'+emailID) && (what == 'html'))
  {
    $('mailShowHTML_'+emailID).show();
    $('mailSelectionHTML_'+emailID).addClassName('active');
  }
  else
  {
    $('mailShowHTML_'+emailID).hide();
    $('mailSelectionHTML_'+emailID).removeClassName('active');
  }
  // Plain
  if ($('mailShowPlainText_'+emailID) && (what == 'plain'))
  {
    $('mailShowPlainText_'+emailID).show();
    $('mailSelectionPLAIN_'+emailID).addClassName('active');
  }
  else
  {
    $('mailShowPlainText_'+emailID).hide();
    $('mailSelectionPLAIN_'+emailID).removeClassName('active');
  }
  // Source
  if ($('mailShowHTMLSource_'+emailID) && (what == 'source'))
  {
    $('mailShowHTMLSource_'+emailID).show();
    $('mailSelectionSOURCE_'+emailID).addClassName('active');
  }
  else
  {
    $('mailShowHTMLSource_'+emailID).hide();
    $('mailSelectionSOURCE_'+emailID).removeClassName('active');
  }
  // Header
  if ($('mailShowHeaders_'+emailID) && (what == 'header'))
  {
    $('mailShowHeaders_'+emailID).show();
    $('mailSelectionHEADER_'+emailID).addClassName('active');
  }
  else
  {
    $('mailShowHeaders_'+emailID).hide();
    $('mailSelectionHEADER_'+emailID).removeClassName('active');
  }
}

function be2_showEmailAttachmentAdmin()
{
  be2_removeEmailAttachmentAdmin();
  showInfoDivContainer('', 'ajax');
  new Ajax.Request('ajax/srv/bug_edit.php?typ=emailAttachmentPopup', {
    onComplete: function (t) {
      var div = new Element('div', {'id': 'be2_emailAttachmentAdmin'});
      document.body.appendChild(div);
      div.innerHTML = t.responseText;
      hideShowInfoDivContainer();
    }
  });
}

function be2_addUploadFiled(_id, _name)
{
  if ($(_id)) {
    var div = new Element('div');
    $(_id).appendChild(div);
    var fileinput = new Element('input', {'type': 'file', 'class': 'bug_fileInput', 'name': _name, 'onchange': 'be2_addUploadFiled(\''+_id+'\', \''+_name+'\');'});
    div.appendChild(fileinput);
  }
}

function be2_removeEmailAttachmentAdmin()
{
  if ($('be2_emailAttachmentAdmin')) $('be2_emailAttachmentAdmin').remove();
}

function be2_refreshEmailAttachmentsList()
{
  var attsElements = $$('input.bug_mailFileAttachment');
  var dokuAttachments = ($('bug_emailDokuAttachments')) ? $('bug_emailDokuAttachments').value : '';
  var imgAttachments = ($('bug_emailImageAttachments')) ? $('bug_emailImageAttachments').value : '';
  var atts = [];
  if ($('bug_emailAttachmentsList')) {
    for (var i = 0, len = attsElements.length; i < len; ++i) {
      atts[atts.length] = attsElements[i].value;
    }
    new Ajax.Request('ajax/srv/bug_edit.php?typ=emailAttachmentsList', {
      postBody: 'attachments='+encodeURIComponent(atts)+
                '&dokuAttachments='+encodeURIComponent(dokuAttachments)+
                '&imgAttachments='+encodeURIComponent(imgAttachments),
      onComplete: function (t) {
        $('bug_emailAttachmentsList').innerHTML = t.responseText;
      }
    });
  }
}

function be2_refreshEmailAttachmentsListSendAgain()
{
  if ($('bug_emailAttachmentsListSendAgain')) {
    var attsElements = $$('input.bug_mailFileAttachmentSendAgain');
    var atts = [];
    if (attsElements.length) {
      for (var i = 0, len = attsElements.length; i < len; i++) {
        atts[atts.length] = attsElements[i].value;
      }
    }
    new Ajax.Request('ajax/srv/bug_edit.php?typ=emailAttachmentsListSendAgain', {
      postBody: 'attachments='+encodeURIComponent(atts),
      onComplete: function (t) {
        $('bug_emailAttachmentsListSendAgain').innerHTML = t.responseText;
      }
    });
  }
}

function be2_setDokuAttachment(dokuID)
{
  if ($('bug_emailDokuAttachments')) {
    var dokuAtt = ($('bug_emailDokuAttachments').value.blank()) ? [] : $('bug_emailDokuAttachments').value.split(',');
    var alreadyExists = false;
    for (var i = 0, len = dokuAtt.length; i < len; ++i) {
      if (dokuAtt[i] == dokuID) alreadyExists = true;
    }
    if (!alreadyExists) {
      dokuAtt[dokuAtt.length] = dokuID;
      $('bug_emailDokuAttachments').value = dokuAtt;
      be2_refreshEmailAttachmentsList();
    }
  }
}

function be2_setImageAttachment(imgID)
{
  if ($('bug_emailImageAttachments')) {
    var imgAtt = ($('bug_emailImageAttachments').value.blank()) ? [] : $('bug_emailImageAttachments').value.split(',');
    var alreadyExists = false;
    for (var i = 0, len = imgAtt.length; i < len; ++i) {
      if (imgAtt[i] == imgID) alreadyExists = true;
    }
    if (!alreadyExists) {
      imgAtt[imgAtt.length] = imgID;
      $('bug_emailImageAttachments').value = imgAtt;
      be2_refreshEmailAttachmentsList();
    }
  }
}

function be2_removeDokuAttachmentFromList(dokuID)
{
  if ($('bug_emailDokuAttachments')) {
    var newDokuAtt = [];
    var dokuAtt = ($('bug_emailDokuAttachments').value.blank()) ? [] : $('bug_emailDokuAttachments').value.split(',');
    for (var i = 0, len = dokuAtt.length; i < len; ++i) {
      if (dokuAtt[i] != dokuID) newDokuAtt[newDokuAtt.length] = dokuAtt[i];
    }
    $('bug_emailDokuAttachments').value = newDokuAtt;
    be2_refreshEmailAttachmentsList();
  }
}

function be2_removeImageAttachmentFromList(imgID)
{
  if ($('bug_emailImageAttachments')) {
    var newImgAtt = [];
    var imgAtt = ($('bug_emailImageAttachments').value.blank()) ? [] : $('bug_emailImageAttachments').value.split(',');
    for (var i = 0, len = imgAtt.length; i < len; ++i) {
      if (imgAtt[i] != imgID) newImgAtt[newImgAtt.length] = imgAtt[i];
    }
    $('bug_emailImageAttachments').value = newImgAtt;
    be2_refreshEmailAttachmentsList();
  }
}

function be2_removeAttachmentFromList(attName)
{
  var atts = $$('input.bug_mailFileAttachment');
  for (var i = 0, len = atts.length; i < len; ++i) {
    if (atts[i].value == attName) atts[i].remove();
  }
  be2_refreshEmailAttachmentsList();
}

function be2_removeAttachmentFromListSendAgain(attName)
{
  var atts = $$('input.bug_mailFileAttachmentSendAgain');
  for (var i = 0, len = atts.length; i < len; ++i) {
    if (atts[i].value == attName) atts[i].remove();
  }
  be2_refreshEmailAttachmentsListSendAgain();
}

function be2_showUploadFrame(what, bugID)
{
  be2_removeUploadFrame();
  showInfoDivContainer('', 'ajax');
  new Ajax.Request('ajax/srv/bug_edit.php?typ=showUploadFrame'+
                   '&what='+encodeURIComponent(what)+
                   '&bugID='+encodeURIComponent(bugID), {
    onComplete: function (t) {
      hideShowInfoDivContainer();
      var uploadFrame = be2_createUploadFrame();
      uploadFrame.innerHTML = t.responseText;
    }
  });
}

function be2_createUploadFrame()
{
  var div = new Element('div', {'id': 'be2_uploadFrame'});
  document.body.appendChild(div);
  return div;
}

function be2_removeUploadFrame()
{
  if ($('be2_uploadFrame')) $('be2_uploadFrame').remove();
}

function be2_bezSel() 
{
  if ($('bezLstDiv')) {
    $('bezLstDiv').remove();
  }
  var theDiv = document.createElement('div');
  theDiv.id = 'bezLstDiv';
  theDiv.className = 'ttDivGen';
  theDiv.style.width = '700px';
  document.body.appendChild(theDiv);
  theDiv.style.left = ($('bugAjaxTD_bez').cumulativeOffset()[0]-50)+'px';
  theDiv.style.top = ($('bugAjaxTD_bez').cumulativeOffset()[1])+'px';
  new Ajax.Request('ajax/srv/bug_edit.php?typ=getBezListe', {
    parameters: 'ltID=2&lID=' + $F('firmenID'),
    onSuccess: function(t) {
      theDiv.innerHTML = t.responseText;
    }
  });
}

function be2_bezSelOK(ltID, lID) 
{
  $('bezLTID').value = ltID;
  $('bezLID').value = lID;
  TT(null, false, '');
  if ($('bezLstDiv')) {
    $('bezLstDiv').remove();
  }
  be2_bezAkt();
  be2_linkID_changed();
}

function be2_bezAkt() 
{
  new Ajax.Request('ajax/srv/bug_edit.php?typ=bezAkt', {
    parameters: 'fID=' + $F('firmenID') + '&ltID=' + $F('bezLTID') + '&lID=' + $F('bezLID'),
    onSuccess: function(t) {
      $('bugAjaxTD_bez').innerHTML = t.responseText;
    }
  });
}

function be2_refreshBez() {
  if ($('bezLstDiv')) {
    $('bezLstDiv').remove();
  }
  $('bezLTID').value = 0;
  $('bezLID').value = 0;
  new Ajax.Request('ajax/srv/bug_edit.php?typ=bezExists', {
    parameters: 'fID=' + $F('firmenID'),
    onSuccess: function(t) {
      var json = t.responseText.evalJSON();
      $('bugAjaxTD_bez').innerHTML = json.bezRow;
      if (json.bezAnz > 0) {
        $('bugAjaxTR_bez').show();
      } else {
        $('bugAjaxTR_bez').hide();
      }
    }
  });
}

function be2_showAutoTechs(techs, fID) {
  if ($('autoTechDiv')) {
    $('autoTechDiv').remove();
  }
  var theDiv = document.createElement('div');
  theDiv.id = 'autoTechDiv';
  theDiv.className = 'ttDivGen';
  theDiv.style.width = '400px';
  document.body.appendChild(theDiv);
  theDiv.style.left = ($('bugAjaxTD_zuwMA').cumulativeOffset()[0]-50)+'px';
  theDiv.style.top = ($('bugAjaxTD_zuwMA').cumulativeOffset()[1])+'px';
  var ltID = 0;
  var lID = 0;
  if ($('linkTypID')) ltID = $F('linkTypID');
  if ($('selectedLinkID')) lID = $F('selectedLinkID');
  new Ajax.Request('ajax/srv/bug_edit.php?typ=autoTechs', {
    parameters: 'techs=' + techs + '&fID=' + fID + '&ltID=' + ltID + '&lID=' + lID,
    onSuccess: function(t) {
      theDiv.innerHTML = t.responseText;
    }
  });
}

function be2_autoTech(id) {
  setSelectToValue($('bugAjaxSelect_zugewiesenMitarbeiter'), id);
  ajax_enableSubmitter('be2Save');
  be2_zugewiesenMitarbeiter_change();
  if ($('autoTechDiv')) {
    $('autoTechDiv').remove();
  }
}

function be2_zeitstrahl_toggle() {
	var img = $('bugZeitImg');
	if (img.src.indexOf("tree2.gif") > 0) {
		img.src = "media/katbrowser/tree1.gif";
		$('bugZeitShow').value = 1;
	} else {
		img.src = "media/katbrowser/tree2.gif";
		$('bugZeitShow').value = 0;
	}
	be2_zeitstrahl_akt()
}

function be2_zeitstrahl_akt() {
	if ($F('bugZeitShow') == 1) {
		new Ajax.Updater('bugAjaxTD_zeitStrahl', 'ajax/srv/leistung2_ajax.php?t=zeitstrahl&maID=' + $F('bugAjaxSelect_zugewiesenMitarbeiter') + '&bugAnsicht=1');
		$('bugAjaxTR_zeitStrahl').show();
	} else {
		$('bugAjaxTR_zeitStrahl').hide();
	}
}

function be2_showEml(id) {
	window.open('ajax/srv/mail_ajax.php?t=eml&mail=' + id, 'mailEmlWindow', 'top=50, left=50, height=200, width=500, resizable=yes, scrollbars=yes, status=yes');
}
