function p4_toggle_window(id)
{
	var img = $('p4_img_' + id);
	var show = false;
	var param = 'id=' + id + '&show=';
	if (img.src.indexOf("head_down.gif") > 0)	{
	 	param += '1';
	 	show = true;
	 	var neuBild = 'media/hp/head_up.gif';
	} else {
		param += '0';
		var neuBild = 'media/hp/head_down.gif';
	}
	new Ajax.Request('ajax/srv/portal_v4_ajax.php?t=toggle', {
		parameters: param,
		onSuccess: function(trans) {
			img.src = neuBild;
			$('p4_inh_' + id).innerHTML = trans.responseText;
			if (show == true) {
				$('p4_inh_' + id).show();
			} else {
				$('p4_inh_' + id).hide();
			}
			p4_spez_window(id, show);
		}
	});
}

function p4_spez_window(id, show)
{
	switch(id) {
		case 'eigeneTickets':
		case 'allgemeineTickets':
		case 'nichtZugewieseneTickets':
		case 'reparaturTickets':
		case 'ticketsAllerTechniker':
		case 'firmenTickets':
		case 'verknuepfungen':
		case 'abgelaufeneLizenzen':
			p4_window_header_akt(id, show);
			break;

		case 'emailSystem':
			break;

		case 'timer':
			if($('p4_img_timer').src.indexOf("head_up.gif") > 0) {
				p4_timer_showContainerPortal(); 
			}
			break;

		case 'timerAlleTechniker':
			if($('p4_img_timerAlleTechniker').src.indexOf("head_up.gif") > 0) {
				p4_timerAll_showContainerPortal();
			}
			break;
	}
}

function p4_window_header_akt(id, show)
{
	var param = 'id=' + id + '&show=' + (show == true ? '1' : '0');
	new Ajax.Request('ajax/srv/portal_v4_ajax.php?t=winHeader', {
		parameters: param,
		onSuccess: function(trans) {
			$('p4_hd_' + id).innerHTML = trans.responseText;
		}
	});
}

function p4_ticket_techniker_ein_aus(maID, ein)
{
	new Ajax.Request('ajax/srv/portal_v4_ajax.php?t=technikerEinAus', {
		parameters: 'maID=' + maID + '&ein=' + ein,
		onSuccess: function(trans) {
			var show = ($('p4_img_ticketsAllerTechniker').src.indexOf("head_down.gif") > 0) ? false : true;
			p4_window_header_akt('ticketsAllerTechniker', show);
			if (show == true) {
				p4_window_inhalt_akt('ticketsAllerTechniker');
			}
		}
	});
}

function p4_window_inhalt_akt(id)
{
	if ($('p4_inh_' + id))
	{
		new Ajax.Request('ajax/srv/portal_v4_ajax.php?t=toggle&akt=' + id, {
			parameters: 'id=' + id + '&show=1',
			onSuccess: function(trans) {
				$('p4_inh_' + id).innerHTML = trans.responseText;
			}
		});		
	}
}

function p4_ticket_details(id, ein)
{
	new Ajax.Request('ajax/srv/portal_v4_ajax.php?t=alleEinblenden', {
		parameters: 'id=' + id + '&ein=' + ein,
		onSuccess: function(trans) {
			p4_window_header_akt(id, ($('p4_img_' + id).src.indexOf("head_down.gif") > 0) ? false : true);
			p4_window_inhalt_akt(id);
		}
	});
}

function p4_link_toggle()
{
	var img = $('newLinkImg');
	if (img.src.indexOf("tree2.gif") > 0)	{
		img.src = 'media/katbrowser/tree1.gif';
		$('newLinkTd').show();
		$$('td.linkHid').invoke('show');
		
	} else {
		img.src = 'media/katbrowser/tree2.gif';
		$('newLinkTd').hide();
		$$('td.linkHid').invoke('hide');
	}
}

function p4_link_new()
{
	new Ajax.Request('ajax/srv/portal_v4_ajax.php?t=newLink', {
		parameters: $('newLinkForm').serialize(),
		onSuccess: function(trans) {
			p4_window_inhalt_akt('verknuepfungen');
			p4_window_header_akt('verknuepfungen', true);
		}
	});
}

function p4_sende_mail()
{
	$('email_submit').disable();
	showInfoDivContainer('', 'ajax');
	new Ajax.Request('ajax/srv/portal_v4_ajax.php?t=mailSenden', {
		parameters: $('portalMailForm').serialize(),
		onSuccess: function (trans) {
			var json = trans.responseText.evalJSON();
			showInfoDivContainer(json.meldung, json.klasse);
			$('email_submit').enable();
			if (json.ok == true) {
				$('mail_firma_id').value = 0;
				$('mail_firma').value = '';
				$('mail_mitarbeiter').value = '';
				$('mail_mitarbeiter_id').value = 0;
				$('mail_telefon').value = '';
				$('mail_text').value = '';
        $('mail_ma_numberSelectionContainer').innerHTML = '';
			} else {
				$(json.field).focus();
			}
		}
	});
}

function p4_send_mail_rr_maOnChange()
{
  if ($('rr_abtTR2')) {
    if ($F('rrNeuAbt2') > 0) {
      setSelectToValue('rrNeuAbt2', 0);
    }
    if ($F('mail_maID') > 0) {
      $('rrNeuAbt2').disable();
    } else {
      $('rrNeuAbt2').enable();
    }
  }
}

function p4_send_mail_rr_abtOnChange()
{
  if ($F('rrNeuAbt2') > 0) {
    setSelectToValue('mail_maID', 0);
  }
  if ($F('rrNeuAbt2') > 0) {
    $('mail_maID').disable();
  } else {
    $('mail_maID').enable();
  }
}

function p4_send_mail_rr_check()
{
	if ($('portal_rr').checked == true) {
		$('mail_grund').disable();
    $('rr_prioTR').show();
		if ($('rr_mail_self')) {$('rr_mail_self').hide();}
    if ($('rr_abtTR2')) {$('rr_abtTR2').show();}
	}	else {
    $('rr_prioTR').hide();
		$('mail_grund').enable();
		if ($('rr_mail_self')) {$('rr_mail_self').show();}
    if ($('rr_abtTR2')) {$('rr_abtTR2').hide();}
    $('mail_maID').enable();
    if ($('rr_abtTR2')) {setSelectToValue('rrNeuAbt2', 0);}
	}
}

function p4_liz_toggle(fenster, id)
{
	var img = $('p4_lizImg_' + fenster + '_' + id);
	var wert = (img.src.indexOf("tree2.gif") > 0) ? 1 : 0;
	new Ajax.Request('ajax/srv/portal_v4_ajax.php?t=lizToggle', {
		parameters: 'id=' + id + '&wert=' + wert,
		onSuccess: function(trans) {
			p4_window_inhalt_akt(fenster);
			p4_window_header_akt(fenster, true);
		}
	});
}

var p4_timer_timeOutIDs = new Array();

function p4_timer_showContainerPortal()
{
	if ($('p4_timer_div'))
	{
		var url = 'ajax/srv/timer.php?typ=showPortal';
		new Ajax.Request(url,
			{
				method: 'get',
				onComplete: function (t)
				{
					var response = t.responseXML;
					var stylesheet = loadStyleSheet('ajax/timer.xsl');
					parseStyleSheet(stylesheet, response, $('p4_timer_div'));
          p4_timer_timeOutsSetzen();
				}
			}
		);		
	}
}

function p4_timerAll_showContainerPortal()
{
	if ($('p4_timer_all_div')) {
		new Ajax.Request('ajax/srv/timer.php?typ=showPortalAll', {
  		onComplete: function (t) {
        $('p4_timer_all_div').innerHTML = t.responseText;
        p4_timer_timeOutsSetzen();
			}
		});
	}
}

function p4_timer_timeOutsSetzen()
{
  if ($('p4_timer_admin_ids') || $('p4_timer_admin_all_ids'))
  {
  	p4_timer_clearTimeOuts();
  }
  if ($('p4_timer_admin_ids'))
	{
  	p4_timer_countTime($('p4_timer_admin_ids').innerHTML);
	}
  if ($('p4_timer_admin_all_ids'))
  {
    p4_timer_countTime($('p4_timer_admin_all_ids').value);
  }
}

function p4_timer_clearTimeOuts()
{
	if (p4_timer_timeOutIDs.length > 0)
	{
		for (var i = 0; i < p4_timer_timeOutIDs.length; i++)
		{
			window.clearTimeout(p4_timer_timeOutIDs[i]);
		}
	}
}

function p4_timer_countTime(jsonStr)
{
	var objArr = eval(jsonStr);
	for (var i = 0; i < objArr.length; i++)
	{
		if ($('p4_timer_admin_td_'+objArr[i].id))
		{
			if (objArr[i].start == 0)
			{
				$('p4_timer_admin_td_'+objArr[i].id).innerHTML = v4_timer_secondsToString(objArr[i].dauer);
			}
			else
			{
				p4_timer_refreshElement(((v4_timer_getCurrentTime() - parseInt(objArr[i].start, 10)) + parseInt(objArr[i].dauer, 10)), 'p4_timer_admin_td_'+objArr[i].id);
			}
		}
	}
}

function p4_timer_refreshElement(theSeconds, theElement)
{
	if ($(theElement))
	{
		$(theElement).innerHTML = v4_timer_secondsToString(theSeconds++);
		p4_timer_timeOutIDs[p4_timer_timeOutIDs.length] = window.setTimeout('p4_timer_refreshElement('+theSeconds+', \''+theElement+'\')', 1000);
	}
}

function p4_timer_toggle(timerID)
{
	showInfoDivContainer('', 'ajax');
	var url = 'ajax/srv/timer.php?typ=toggle&timerID='+encodeURIComponent(timerID);
	new Ajax.Request(url,
		{
			method: 'get',
			onComplete: function (t)
			{
				hideShowInfoDivContainer();
				p4_timer_showContainerPortal();
				v4_timer_hideContainer();
			}
		}
	);
}

function p4_timer_neu()
{
	if ($F('newTimerText') != '')
	{
		showInfoDivContainer('', 'ajax');
		new Ajax.Request('ajax/srv/portal_v4_ajax.php?t=timerNeu', {
			parameters: $('newTimerText').serialize(),
			onSuccess: function(trans) {
				var json = trans.responseText.evalJSON();
				showInfoDivContainer(json.meldung, json.klasse);
				if (json.ok == true) {
					p4_timer_showContainerPortal();
					v4_timer_refreshCurrentTimerCount();
					v4_timer_hideContainer();
					$('newTimerText').value = '';
				}
			}
		});
	}
}

function p4_timer_delete(timerID, timerName)
{
	if (confirm(getLang("menu", "portal_delTimerQuestion").replace("#1#", timerName)))
	{
		new Ajax.Request('ajax/srv/portal_v4_ajax.php?t=timerDel', {
			parameters: 'id=' + timerID,
			onSuccess: function(trans) {
				p4_timer_showContainerPortal();
				v4_timer_refreshCurrentTimerCount();
				v4_timer_hideContainer();
			}
		});
	}
}

function p4_move_toggle(tag)
{
	if ($F('prtMove') == "0") {
		$('prtMove').value = "1";
		tag.innerHTML = getLang("portal", "portal_fixed");
		createDraggables();
		$$('a.prtKlpGfxs').invoke('hide');
		$$('a.prtHidGfxs').invoke('show');
	} else {
		$('prtMove').value = "0";
		tag.innerHTML = getLang("portal", "portal_moveable");
		destroyDraggables();
		$$('a.prtHidGfxs').invoke('hide');
		$$('a.prtKlpGfxs').invoke('show');
	}
}

function p4_window_remove(id)
{
	new Ajax.Request('ajax/srv/portal_v4_ajax.php?t=removeWin', {
		parameters: 'id=' + id + '&modus=' + $F('portalModus'),
		onSuccess: function(t) {
			p4_portalReload();
		}
	});
}

function p4_portalReload()
{
	location.href = 'index.php?section=intern' + ($F('portalModus') == 1 ? 'Firma' : '');
}

function p4_window_insert()
{
	$('p4_fnstEin1').hide();
	$('p4_fnstEin2').show();
}

function p4_window_insertHide()
{
	$('p4_fnstEin2').hide();
	$('p4_fnstEin1').show();
}

function p4_window_insertDB()
{
	new Ajax.Request('ajax/srv/portal_v4_ajax.php?t=insertWin', {
		parameters: 'id=' + $F('p4_fnstEinID') + '&modus=' + $F('portalModus'),
		onSuccess: function(t) {
			p4_portalReload();
		}
	});
}

function p4_sup_hideText(id)
{
	$('hidText_' + id).hide();
	$('prvText_' + id).show();
}

function p4_sup_showText(id)
{
	$('hidText_' + id).show();
	$('prvText_' + id).hide();
}

function p4_abt_toggle(id, pref, abtPref)
{
	new Ajax.Request('ajax/srv/portal_v4_ajax.php?t=abtToggle&pid=' + abtPref + '&id=' + pref, {
		onSuccess: function(t) {
			p4_window_inhalt_akt(id);
		}
	});
}

function p4_sh_anz(id)
{
	$(id + 'S1').hide();
	$(id + 'S2').show();
	$(id).focus();
	$(id).select();
}

function p4_sh_anz_db(id, fensterID)
{
	new Ajax.Request('ajax/srv/portal_v4_ajax.php?t=shAnz&id=' + fensterID + '&anz=' + $F(id), {
		onSuccess: function(t) {
			$(id + 'S2').hide();
			$(id + 'S1').show();
			p4_window_inhalt_akt(fensterID);
		}
	});
}

function p4_firmenMail_maChange()
{
	new Ajax.Request('ajax/srv/portal_v4_ajax.php?t=firmenMailMA', {
		parameters: 'maID=' + $F('firmen_mail_maID') + '&modus=' + $F('firmen_mail_mode'),
		onSuccess: function (t) {
			var json = t.responseText.evalJSON();
			if (json.ok == false) {
				var abbruch = false;
				if (confirm(json.frage)) {
					var mail = prompt(getLang("all", "eMail"), '');
					if (mail != '') {
						new Ajax.Request('ajax/srv/portal_v4_ajax.php?t=firmenMailSet', {
							parameters: 'maID=' + $F('firmen_mail_maID') + '&mail=' + encodeURIComponent(mail)
						});
					} else {
						abbruch = true;
					}
				} else {
					abbruch = true;
				}
				if (abbruch == true) {
					$('firmen_mail_maID').selectedIndex = 0;
				}
			}
		}
	});
}

function p4_firmen_sende_mail()
{
	if ($F('firmen_mail_maID') > 0) {
		if ($F('firmen_mail_text') != '') {
			showInfoDivContainer('', 'ajax');
			new Ajax.Request('ajax/srv/portal_v4_ajax.php?t=firmenSendMail', {
				parameters: $('firmenMailForm').serialize(),
				onSuccess: function(t) {
					var json = t.responseText.evalJSON();
					showInfoDivContainer(json.meldung, json.klasse);
					if (json.ok == true) {
						$('firmen_mail_betreff').value = '';
						$('firmen_mail_text').value = '';
						$('firmen_mail_maID').selectedIndex = 0;
					}
				}
			});
		} else {
			alert(getLang("portal", "mailComp_inputText"));
			$('firmen_mail_text').focus();
		}
	} else {
		alert(getLang("portal", "mailComp_chooseEmpl"));
		$('firmen_mail_maID').focus();
	}
}

function p4_rr_status_toggle(id, typ)
{
	if (typ == 1) {
		$('rr_div1_' + id).hide();
		$('rr_div2_' + id).show();
	} else {
		$('rr_div1_' + id).show();
		$('rr_div2_' + id).hide();
	}
}

function p4_rr_ma_toggle(id, typ)
{
  $('rr_maDiv3_' + id).hide();
  new Ajax.Request('ajax/srv/portal_v4_ajax.php?t=rrMaDiv', {
    parameters: 'rrID=' + id,
    onSuccess: function(t) {
      $('rr_maDiv2_' + id).innerHTML = t.responseText;
      if (typ == 1) {
        $('rr_maDiv1_' + id).hide();
        $('rr_maDiv2_' + id).show();
      } else {
        $('rr_maDiv1_' + id).show();
        $('rr_maDiv2_' + id).hide();
      }
    }
  });
}

function p4_rr_self(id, slf)
{
	new Ajax.Request('ajax/srv/portal_v4_ajax.php?t=rrSetMA', {
		parameters: 'id=' + id + '&maID=' + slf,
		onSuccess: function (t) {
			p4_window_inhalt_akt('rueckrufe');
			p4_window_inhalt_akt('rueckrufe_firma');
		}
	});
}

function p4_rr_abt_toggle(id, typ)
{
  $('rr_maDiv2_' + id).hide();
  new Ajax.Request('ajax/srv/portal_v4_ajax.php?t=rrAbtDiv', {
    parameters: 'rrID=' + id,
    onSuccess: function(t) {
      $('rr_maDiv3_' + id).innerHTML = t.responseText;
      if (typ == 1) {
        $('rr_maDiv1_' + id).hide();
        $('rr_maDiv3_' + id).show();
      } else {
        $('rr_maDiv1_' + id).show();
        $('rr_maDiv3_' + id).hide();
      }
    }
  });
}

function p4_rr_status(id)
{
  var eingabe = '';
  if ($F('rr_stat_' + id) < 10 && $F('rr_stat_' + id) != 3) {
    eingabe = prompt(getLang("phone", "cb_statChangeInfo"), '');
  }
	new Ajax.Request('ajax/srv/portal_v4_ajax.php?t=rrSetStatus', {
		parameters: 'id=' + id + '&status=' + $F('rr_stat_' + id) + '&info=' + encodeURIComponent(eingabe),
		onSuccess: function (t) {
			p4_window_inhalt_akt('rueckrufe');
			p4_window_inhalt_akt('rueckrufe_firma');
      if ($F('rr_stat_' + id) == 10) {
        try {
          notificationRemove(16, id);
        } catch (ex) {}
      }
		}
	});
}

function p4_rr_ma(id)
{
	new Ajax.Request('ajax/srv/portal_v4_ajax.php?t=rrSetMA', {
		parameters: 'id=' + id + '&maID=' + $F('rr_ma_' + id),
		onSuccess: function (t) {
			p4_window_inhalt_akt('rueckrufe');
			p4_window_inhalt_akt('rueckrufe_firma');
		}
	});
}

function p4_rr_abt(id)
{
	new Ajax.Request('ajax/srv/portal_v4_ajax.php?t=rrSetAbt', {
		parameters: 'id=' + id + '&abtID=' + $F('rr_abt_' + id),
		onSuccess: function (t) {
			p4_window_inhalt_akt('rueckrufe');
			p4_window_inhalt_akt('rueckrufe_firma');
		}
	});
}

function p4_rr_eigene_toggle(wert, pref)
{
	new Ajax.Request('ajax/srv/portal_v4_ajax.php?t=rr_eigeneToggle', {
		parameters: 'wert=' + wert + '&pref=' + pref,
		onSuccess: function (t) {
			p4_window_inhalt_akt('rueckrufe');
		}
	});
}

function p4_rr_dauerRefresh()
{
  if ($('p4_inh_rueckrufe') && $('p4_inh_rueckrufe').style.display != 'none') {
  	p4_window_inhalt_akt('rueckrufe');
  }
	window.setTimeout('p4_rr_dauerRefresh()', 120000);
}

function p4_tep_dauerRefresh()
{
  if ($('p4_inh_tepPortal') && $('p4_inh_rueckrufe').style.display != 'none') {
  	p4_window_inhalt_akt('tepPortal');
  }
	window.setTimeout('p4_tep_dauerRefresh()', 121000);
}

function p4_erwRR_dauerRefresh()
{
  if ($('p4_inh_erwartete_rueckrufe') && $('p4_inh_erwartete_rueckrufe').style.display != 'none') {
  	p4_window_inhalt_akt('erwartete_rueckrufe');
  }
	window.setTimeout('p4_erwRR_dauerRefresh()', 122000);
}

function p4_fenster_dauerRefresh(ms, id)
{
  if ($('p4_inh_' + id) && $('p4_inh_' + id).style.display != 'none') {
  	p4_window_inhalt_akt(id);
  }
  var funktion = "p4_fenster_dauerRefresh(" + ms + ", '" + id + "')";
  window.setTimeout(funktion, ms);
}

function p4_rr_check()
{
	new Ajax.Request('ajax/srv/portal_v4_ajax.php?t=rrCheck&id=' + $F('mail_grund'), {
		onSuccess: function(t) {
			var json = t.responseText.evalJSON();
			$('portal_rr').checked = json.rr;
			p4_send_mail_rr_check();			
		}
	});
}

function p4_termine_alle_filter(id, tvPref, maPref)
{
	new Ajax.Request('ajax/srv/portal_v4_ajax.php?t=termin_alle_setFilter&filter=' + $F('termine_alle_filter') + '&tv=' + $F('termine_alle_tv'), {
    parameters: 'tvPref=' + tvPref + '&maPref=' + maPref,
		onSuccess: function(t) {
			p4_window_inhalt_akt(id);
		}
	});
}

function p4_tepPortal_filter()
{
	new Ajax.Request('ajax/srv/portal_v4_ajax.php?t=tepPortal_setFilter&filter=' + $F('tepPortal_filter'), {
		onSuccess: function(t) {
			p4_window_inhalt_akt('tepPortal');
		}
	});
}

function p4_rueckrufe_edit_remove()
{
	($('rr_editContainer')) ? $('rr_editContainer').remove() : true;
}

function p4_rueckrufe_edit(rr_id)
{
	if ($('rr_editHiddenText_'+rr_id))
	{
		showInfoDivContainer('', 'ajax');
		p4_rueckrufe_edit_remove();
		var url = 'ajax/srv/portal_v4_ajax.php?t=rr_editContainer';
		new Ajax.Request(url,
			{
				method: 'post',
				postBody: 'info='+encodeURIComponent($('rr_editHiddenText_'+rr_id).value)+'&id='+encodeURIComponent(rr_id),
				onComplete: function (t)
				{
					var _div = document.createElement('div');
					_div.id = 'rr_editContainer';
					document.body.appendChild(_div);
					_div.innerHTML = t.responseText;
					hideShowInfoDivContainer();
				}
			}
		);
	}
}

function p4_rueckrufe_showLog(rrID)
{
  p4_rueckrufe_removeLog();
  var rrDiv = document.createElement('div');
  rrDiv.id = 'rrLogDiv';
  document.body.appendChild(rrDiv);
  rrDiv.innerHTML = show_load(true);
  new Ajax.Request('ajax/srv/portal_v4_ajax.php?t=rrShowLogInfo&ID='+encodeURIComponent(rrID), {
    onComplete: function (t) {
      rrDiv.innerHTML = t.responseText;
    }
  });
}

function p4_rueckrufe_removeLog()
{
  if ($('rrLogDiv')) $('rrLogDiv').remove();
}

function p4_rueckrufe_edit_submit()
{
	if ($('rr_editContainerId') && $('rr_editContainerInfo'))
	{
		showInfoDivContainer('', 'ajax');
		var url = 'ajax/srv/portal_v4_ajax.php?t=rr_editContainerSubmit';
		new Ajax.Request(url,
			{
				method: 'post',
				postBody: 'info='+encodeURIComponent($('rr_editContainerInfo').value)+'&id='+encodeURIComponent($('rr_editContainerId').value),
				onComplete: function (t)
				{
					var res = t.responseText.evalJSON();
					switch (res.status)
					{
						case 'ok':
							showInfoDivContainer(res.text);
							break;
						case 'error':
							showInfoDivContainer(res.text, 'fehler');
							break;
					}
					p4_rueckrufe_edit_remove();
					p4_window_inhalt_akt('rueckrufe');
				}
			}
		);
	}
}

function p4_erwRR_toggle()
{
	var img = $('erwRRimg');
	if (img.src.indexOf("tree2_mini") > 0)	{
		img.src = 'media/katbrowser/tree1_mini.gif';
		$$('tr.erwRRtr').invoke('show');
	} else {
		img.src = 'media/katbrowser/tree2_mini.gif';
		$$('tr.erwRRtr').invoke('hide');
	}
}

function p4_erwRR_submit()
{
	showInfoDivContainer('', 'ajax');
	new Ajax.Request('ajax/srv/portal_v4_ajax.php?t=newErwRR', {
		parameters: $('erw_rr_form').serialize(),
		onSuccess: function(t) {
			var json = t.responseText.evalJSON();
			showInfoDivContainer(json.msg, json.klasse);
			if (json.ok == true) {
				p4_window_inhalt_akt('erwartete_rueckrufe');
			}
		}
	});
}

function p4_delCall(id)
{
	if (confirm(getLang("phone", "phone_delCallQuestion"))) {
		new Ajax.Request('ajax/srv/portal_v4_ajax.php?t=delCall', {
			parameters: 'id=' + id,
			onSuccess: function(t) {
				p4_window_inhalt_akt('anrufliste');
			}
		});
	}
}

function p4_toggleGarantieFilter()
{
  if ($('gar_filter')) {
  	if ($('gar_filter_img').src.indexOf("tree2.gif") > 0)	{
      $('gar_filter_img').src = 'media/katbrowser/tree1.gif';
      $('gar_filter').show();
    } else {
      $('gar_filter_img').src = 'media/katbrowser/tree2.gif';
      $('gar_filter').hide();
    }
  }
}

function p4_setzeGarantieFilter()
{
  new Ajax.Request('ajax/srv/portal_v4_ajax.php?t=garFilter', {
    parameters: $('gar_filter_form').serialize(),
    onSuccess: function(t) {
      p4_window_inhalt_akt('garantieAblauf');
      p4_window_inhalt_akt('garantieAblauf_firma');
    }
  });
}


function p4_ma_tel_check(maID) 
{
  if ($('mail_firma_id')) {
    new Ajax.Request('ajax/srv/portal_v4_ajax.php?t=checkFaTel', {
      parameters: 'maID=' + maID + '&faID=' + $F('mail_firma_id'),
      onSuccess: function(t) {
        var json = t.responseText.evalJSON();
        if (json.ok == true) {
          $('mail_telefon').value = json.nr;
          $('mail_text').focus();
        }
      }
    });
  }
}

function p4_callFilterToggle(datum)
{
	new Ajax.Request('index.php?section=tep&sub=tagAjax&tag=' + datum + '&override=intern&filterCall=1', {
		onSuccess: function (t) {
			try {
				$('tagesAnzeigePortal').innerHTML = t.responseText;
				$('tepAbstandhalter').style.height = 70;
			} catch (e)	{}
		}
	});
}

function p4_toggle_wait(id, pref)
{
  new Ajax.Request('ajax/srv/portal_v4_ajax.php?t=toggleWait', {
    parameters: 'pref=' + pref,
    onSuccess: function(t) {
      p4_window_header_akt(id, 1);
      p4_window_inhalt_akt(id);
    }
  });
}

function p4_taskFilter()
{
  if ($('lstPortalTask')) {
    new Ajax.Request('ajax/srv/portal_v4_ajax.php?t=lstTaskFilter', {
      parameters: 'setTo=' + ($('lstPortalTask').checked ? '1' : '0'),
      onSuccess: function(t) {
        p4_window_inhalt_akt('leistungen');
      }
    });
  }
}

function p4_alleTicketFilter() {
  if ($('portTickAllFL')) {
  new Ajax.Request('ajax/srv/portal_v4_ajax.php?t=alleTicketFilter', {
      parameters: 'id=' + $F('portTickAllFL'),
      onSuccess: function(t) {
        p4_window_inhalt_akt('ticketsAllerTechniker');
      }
    });
  }
}
