var von_fields=new Array();
var nach_fields=new Array();
function initFldList()
{
  von_csc_id_NumIdx = getNumIndex("job_tour", "tourForm", "von_csc_id");
  von_cs_comp_NumIdx = getNumIndex("job_tour", "tourForm", "von_cs_comp");
  von_tr_person_NumIdx = getNumIndex("job_tour", "tourForm", "von_tr_person");
  von_ad_street_NumIdx = getNumIndex("job_tour", "tourForm", "von_ad_street");
  von_tr_hsno_NumIdx = getNumIndex("job_tour", "tourForm", "von_tr_hsno");
  von_ad_city_NumIdx = getNumIndex("job_tour", "tourForm", "von_ad_city");
  von_ad_zipcode_NumIdx = getNumIndex("job_tour", "tourForm", "von_ad_zipcode");
  von_ad_country_NumIdx = getNumIndex("job_tour", "tourForm", "von_ad_country");
  von_tr_commission_no = getNumIndex("job_tour", "tourForm", "von_tr_commission_no");
  von_tr_tracking_NumIdx = getNumIndex("job_tour", "tourForm", "von_tr_tracking");
  von_tr_mediationarea_id = getNumIndex("job_tour", "tourForm", "von_tr_mediationarea_id");
  hide_von_tr_remark_NumIdx = getNumIndex("job_tour", "tourForm", "hide_von_tr_remark");
  von_tr_remark_NumIdx = getNumIndex("job_tour", "tourForm", "von_tr_remark");
  tr_photo_von_NumIdx = getNumIndex("job_tour", "tourForm", "tr_photo_von");
  tr_ware_from_von_NumIdx = getNumIndex("job_tour", "tourForm", "tr_ware_from_von");
  tr_ware_to_von_NumIdx = getNumIndex("job_tour", "tourForm", "tr_ware_to_von");
  payer_from_NumIdx = getNumIndex("job_tour", "tourForm", "payer_from");

  nach_csc_id_NumIdx = getNumIndex("job_tour", "tourForm", "nach_csc_id");
  nach_cs_comp_NumIdx = getNumIndex("job_tour", "tourForm", "nach_cs_comp");
  nach_tr_person_NumIdx = getNumIndex("job_tour", "tourForm", "nach_tr_person");
  nach_ad_street_NumIdx = getNumIndex("job_tour", "tourForm", "nach_ad_street");
  nach_tr_hsno_NumIdx = getNumIndex("job_tour", "tourForm", "nach_tr_hsno");
  nach_ad_country_NumIdx = getNumIndex("job_tour", "tourForm", "nach_ad_country");
  nach_ad_zipcode_NumIdx = getNumIndex("job_tour", "tourForm", "nach_ad_zipcode");
  nach_ad_city_NumIdx = getNumIndex("job_tour", "tourForm", "nach_ad_city");
  nach_tr_remark_NumIdx = getNumIndex("job_tour", "tourForm", "nach_tr_remark");
  tr_photo_nach_NumIdx = getNumIndex("job_tour", "tourForm", "tr_photo_nach");
  nach_tr_commission_no = getNumIndex("job_tour", "tourForm", "nach_tr_commission_no");
  nach_tr_tracking_NumIdx = getNumIndex("job_tour", "tourForm", "nach_tr_tracking");
  nach_tr_mediationarea_id = getNumIndex("job_tour", "tourForm", "nach_tr_mediationarea_id");
  hide_nach_tr_remark_NumIdx = getNumIndex("job_tour", "tourForm", "hide_nach_tr_remark");
  tr_ware_from_nach_NumIdx = getNumIndex("job_tour", "tourForm", "tr_ware_from_nach");
  tr_ware_to_nach_NumIdx = getNumIndex("job_tour", "tourForm", "tr_ware_to_nach");
  payer_to_NumIdx = getNumIndex("job_tour", "tourForm", "payer_to");

  von_fields = new Array(
    von_csc_id_NumIdx[2], von_cs_comp_NumIdx[2], von_tr_person_NumIdx[2], von_ad_street_NumIdx[2],
    von_tr_hsno_NumIdx[2], von_ad_country_NumIdx[2], von_ad_zipcode_NumIdx[2], von_ad_city_NumIdx[2],
    von_tr_remark_NumIdx[2], tr_photo_von_NumIdx[2], von_tr_commission_no[2], von_tr_tracking_NumIdx[2], hide_von_tr_remark_NumIdx[2],
    tr_ware_from_von_NumIdx[2], tr_ware_to_von_NumIdx[2], payer_from_NumIdx[2], von_tr_mediationarea_id[2]);

  nach_fields = new Array(
    nach_csc_id_NumIdx[2], nach_cs_comp_NumIdx[2], nach_tr_person_NumIdx[2], nach_ad_street_NumIdx[2],
    nach_tr_hsno_NumIdx[2], nach_ad_country_NumIdx[2], nach_ad_zipcode_NumIdx[2], nach_ad_city_NumIdx[2],
    nach_tr_remark_NumIdx[2], tr_photo_nach_NumIdx[2], nach_tr_commission_no[2], nach_tr_tracking_NumIdx[2], hide_nach_tr_remark_NumIdx[2],
    tr_ware_from_nach_NumIdx[2], tr_ware_to_nach_NumIdx[2], payer_to_NumIdx[2], nach_tr_mediationarea_id[2]);
}
var maxTour = parseInt(MASK_MAXTOUR);
function initJobList()
{
var tmpJobList=new Array(maxTour+1);
var tmpJobListJoin=new Array(maxTour+1);
for(var i=0;i<(maxTour+1);i++)
{
tmpJobList[i]=new Array(von_fields.length);
for(var j=0;j<von_fields.length;j++)
tmpJobList[i][j]="";
tmpJobListJoin[i]=tmpJobList[i].join("²");
}
parent.job_options.document.tourOptions.jobList.value=
tmpJobListJoin.join("¹");
jobListIsDefined=1;
for(j=0;j<(maxTour+1);j++) {
setJobList(j,jl_hide_tr_remark,"true");
    setJobList(j, jl_tr_photo, "false");
    setJobList(j, jl_ad_country, "DE");
}
}
function getJobList(tourNo,fldNo)
{
var tmpJobList=new Array(maxTour+1);
var tmpJobListJoin=
parent.job_options.document.tourOptions.jobList.value.split("¹");
tmpJobList[tourNo]=tmpJobListJoin[tourNo].split("²");
return tmpJobList[tourNo][fldNo];
}
function setJobList(tourNo,fldNo,newVal)
{
var tmpJobList=new Array(maxTour+1);
var tmpJobListJoin=
parent.job_options.document.tourOptions.jobList.value.split("¹");
tmpJobList[tourNo]=tmpJobListJoin[tourNo].split("²");
tmpJobList[tourNo][fldNo]=newVal;
tmpJobListJoin[tourNo]=tmpJobList[tourNo].join("²");
parent.job_options.document.tourOptions.jobList.value=
tmpJobListJoin.join("¹");
}
function delJobList(tourNo,doMove)
{
var tmpJobListJoin=
parent.job_options.document.tourOptions.jobList.value.split("¹");
var tmpJobList=new Array(tmpJobListJoin.length);
var delTourNo=tourNo+1;
if((tourNo<tmpJobList.length-1)&&doMove)
tmpJobListJoin[tourNo]=tmpJobListJoin[tourNo+1];
else
delTourNo=tourNo;
tmpJobList[delTourNo]=tmpJobListJoin[delTourNo].split("²");
for(var j=0;j<tmpJobList[delTourNo].length;j++)
tmpJobList[delTourNo][j]="";
tmpJobListJoin[delTourNo]=tmpJobList[delTourNo].join("²");
parent.job_options.document.tourOptions.jobList.value=
tmpJobListJoin.join("¹");
}
function switchJobList()
{
var tourNo=getCurTourNo();
var tmpJobListJoin=
parent.job_options.document.tourOptions.jobList.value.split("¹");
var tmpJob=tmpJobListJoin[tourNo];
tmpJobListJoin[tourNo]=tmpJobListJoin[tourNo+1];
tmpJobListJoin[tourNo+1]=tmpJob;
parent.job_options.document.tourOptions.jobList.value=
tmpJobListJoin.join("¹");
refreshFormFields();
}
function getCurTourNo()
{
return(parseInt(
parent.job_tour.document.tourNoForm.tourNoVal.value,
10)-1);
}
function setCurTourNo(curTourNo)
{
parent.job_tour.document.tourNoForm.tourNoVal.value=
(curTourNo+1).toString(10);
if(curTourNo==0)
{
parent.job_tour.document.tourForm.prevButton.disabled=true;
parent.job_tour.document.prev_gif.src="../images/prev_dis.gif";
    parent.job_tour.document.getElementById('tr_tracking_von').style.visibility = 'collapse';
}else{
parent.job_tour.document.tourForm.elements.prevButton.disabled=false;
parent.job_tour.document.prev_gif.src="../images/prev.gif";
    if (get_cs_tracking(curCsc_id_payer) == 1)
        parent.job_tour.document.getElementById('tr_tracking_von').style.visibility = 'visible';
}
if(curTourNo==maxTour-1)
{
parent.job_tour.document.tourForm.nextButton.disabled=true;
parent.job_tour.document.next_gif.src="../images/next_dis.gif";
}else{
parent.job_tour.document.tourForm.nextButton.disabled=false;
parent.job_tour.document.next_gif.src="../images/next.gif";
}
refreshFormFields();
}
function saveFormFields()
{
var curTourNo=getCurTourNo();
  if (trim(parent.job_tour.document.tourForm.elements[von_fields[jl_tr_tracking]].value) != "") {
    if (!validateEmail(parent.job_tour.document.tourForm.elements[von_fields[jl_tr_tracking]].value)) {
      alert('"' + parent.job_tour.document.tourForm.elements[von_fields[jl_tr_tracking]].value + '" ist keine gültige Mail-Adresse!');
      parent.job_tour.document.tourForm.elements[von_fields[jl_tr_tracking]].value = "";
    }
  }

  if (trim(parent.job_tour.document.tourForm.elements[nach_fields[jl_tr_tracking]].value) != "") {
    if (!validateEmail(parent.job_tour.document.tourForm.elements[nach_fields[jl_tr_tracking]].value)) {
      alert('"' + parent.job_tour.document.tourForm.elements[nach_fields[jl_tr_tracking]].value + '" ist keine gültige Mail-Adresse!');
      parent.job_tour.document.tourForm.elements[nach_fields[jl_tr_tracking]].value = "";
    }
  }
for(var i=1;i<(von_fields.length-4);i++)
{
  	if (von_fields[i] != -1) {
setJobList(curTourNo,i,
parent.job_tour.document.tourForm.elements[von_fields[i]].value);
    }
  	if (nach_fields[i] != -1) {
setJobList(curTourNo+1,i,
parent.job_tour.document.tourForm.elements[nach_fields[i]].value);
    }
}
setJobList(curTourNo,jl_hide_tr_remark,
parent.job_tour.document.tourForm.elements[von_fields[jl_hide_tr_remark]].checked);
if(parent.job_tour.document.tourForm.elements[von_fields[jl_hide_tr_remark]].checked)
parent.job_tour.document.tourForm.elements[von_fields[jl_tr_remark]].disabled=false;
else parent.job_tour.document.tourForm.elements[von_fields[jl_tr_remark]].disabled=true;
setJobList(curTourNo+1,jl_hide_tr_remark,
parent.job_tour.document.tourForm.elements[nach_fields[jl_hide_tr_remark]].checked);
if(parent.job_tour.document.tourForm.elements[nach_fields[jl_hide_tr_remark]].checked)
parent.job_tour.document.tourForm.elements[nach_fields[jl_tr_remark]].disabled=false;
else parent.job_tour.document.tourForm.elements[nach_fields[jl_tr_remark]].disabled=true;
setJobList(curTourNo,jl_tr_ware_from,
parent.job_tour.document.tourForm.elements[von_fields[jl_tr_ware_from]].checked);
setJobList(curTourNo,jl_tr_ware_to,
parent.job_tour.document.tourForm.elements[von_fields[jl_tr_ware_to]].checked);
setJobList(curTourNo+1,jl_tr_ware_from,
parent.job_tour.document.tourForm.elements[nach_fields[jl_tr_ware_from]].checked);
setJobList(curTourNo+1,jl_tr_ware_to,
parent.job_tour.document.tourForm.elements[nach_fields[jl_tr_ware_to]].checked);
if(typeof(parent.job_tour.document.tourForm.jb_costsplit)!='undefined'){
if(parent.job_tour.document.tourForm.elements[von_fields[jl_csc_id_payer]].checked||
parent.job_tour.document.tourForm.elements[nach_fields[jl_csc_id_payer]].checked
)
{
if((!parent.job_tour.document.tourForm.jb_costsplit.checked&&!parent.job_tour.document.tourForm.jb_cash.checked)||cash_payer_select=="1")
{
for(var i=0;i<(maxTour+1);i++)
setJobList(i,jl_csc_id_payer,"false");
setJobList(curTourNo,jl_csc_id_payer,
parent.job_tour.document.tourForm.elements[von_fields[jl_csc_id_payer]].checked);
setJobList(curTourNo+1,jl_csc_id_payer,
parent.job_tour.document.tourForm.elements[nach_fields[jl_csc_id_payer]].checked);
setCsc_id_payer("","");
}
}
}
writeJob();
}
function validateEmail(email) 
{
  var re = /^(?:[a-z0-9!#$%&amp;'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&amp;'*+/=?^_`{|}~-]+)*|"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])*")@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\[(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?|[a-z0-9-]*[a-z0-9]:(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])+)\])$/;

  return re.test(email);
}
function checkJb_sales_tax_rate_sign()
{
var curSelectedVal=getSelectedVal("job_options","tourOptions","jb_sales_tax_rate_sign");
for(i=0;i<sales_tax_rate_sign_list.length;i++)
{
if(sales_tax_rate_sign_list[i][0]==curSelectedVal)
{
parent.job_options.document.tourOptions.jb_sales_tax_rate.value=
parseInt(sales_tax_rate_sign_list[i][1],10);
return;
}
}
}
/*
 * checkCs_filter
 *   params: -
 *   return: -
 *   global: cfl, jb_cr_filter, jb_cr_filter_opt
 *
 */

function checkCs_filter(cs_filter) {

// ACHTUNG: DER FALL, WENN EIN VOREINGESTELLTER KUNDENFILTER ABGEWÄHLT WURDE, IST NOCH NICHT BERÜCKSICHTIGT!
// BEIM LADEN EINES SOLCHEN GESPEICHERTEN JOBS WIRD DIESER FILTER WIEDER AUTOMATISCH GESETZT!!! (ähnliches Problem wie beim Kundenrabatt)
// AUCH FILTER MIT NUR EINEM BUCHSTABEN SIND GEFÄHRLICH WG. ERKENNUNG (Bsp.: "E" ->"EP")

  // wenn cs_filter leer, dann gibts nix zu tun...
  if (cs_filter.replace(/\s/,"").length == 0)
    return;

//  // beim Kunden voreingestellte Filter haben immer ein Komma am Anfang, das eliminiert werden muss
//  if (cs_filter.substr(0, 1) == ",")
//    cs_filter = cs_filter.substr(1, cs_filter.length - 1);

  var jb_cr_filter = parent.job_options.document.tourOptions.jb_cr_filter.value;
  if (jb_cr_filter != "")
    jb_cr_filter = "," + jb_cr_filter;
  var jb_cr_filter_opt = parent.job_options.document.tourOptions.jb_cr_filter_opt.value;
  if (jb_cr_filter_opt != "")
    jb_cr_filter_opt = "," + jb_cr_filter_opt;

  for (var i = 0; i < cfl.length; i++)
  {
    if (cs_filter.indexOf("," + cfl[i][0] + ",") > -1) // wenn aktueller Filter in cs_filter vorhanden, dann setzen
    {
      cfl[i][3] = 1; // Filter als gesetzt markieren ...
      // ... und in entsprechender Variable abspeichern, wenn nicht schon vorhanden
      if (cfl[i][2] == 1) // 0 = Info, 1 = Sperre, 2 = Warnung
      {
        if (jb_cr_filter.indexOf(cfl[i][0]) == -1)
          jb_cr_filter = jb_cr_filter + "," + cfl[i][0];
      } else {
        if (jb_cr_filter_opt.indexOf(cfl[i][0]) == -1)
          jb_cr_filter_opt = jb_cr_filter_opt + "," + cfl[i][0];
      }
    }
  }
  
  parent.job_options.document.tourOptions.jb_cr_filter.value = jb_cr_filter.substr(1, jb_cr_filter.length - 1);
  parent.job_options.document.tourOptions.jb_cr_filter_opt.value = jb_cr_filter_opt.substr(1, jb_cr_filter_opt.length - 1);
//  parent.job_options.document.tourOptions.jb_cr_filterButton.value = "Filter*";
}
function checkJb_permanent()
{
if(typeof(parent.job_options.document.tourOptions.jb_permanent)=='undefined')
return;
if(getSelectedVal("job_options","tourOptions","jb_permanent")==""
||getSelectedVal("job_options","tourOptions","jb_permanent")>3
||parent.job_options.document.tourOptions.jb_permanent.disabled==true){
parent.job_options.document.tourOptions.jb_permanent2_0.checked=false;
parent.job_options.document.tourOptions.jb_permanent2_1.checked=false;
parent.job_options.document.tourOptions.jb_permanent2_2.checked=false;
parent.job_options.document.tourOptions.jb_permanent2_3.checked=false;
parent.job_options.document.tourOptions.jb_permanent2_4.checked=false;
parent.job_options.document.tourOptions.jb_permanent2_5.checked=false;
parent.job_options.document.tourOptions.jb_permanent2_6.checked=false;
parent.job_options.document.tourOptions.jb_permanent2_0.disabled=true;
parent.job_options.document.tourOptions.jb_permanent2_1.disabled=true;
parent.job_options.document.tourOptions.jb_permanent2_2.disabled=true;
parent.job_options.document.tourOptions.jb_permanent2_3.disabled=true;
parent.job_options.document.tourOptions.jb_permanent2_4.disabled=true;
parent.job_options.document.tourOptions.jb_permanent2_5.disabled=true;
parent.job_options.document.tourOptions.jb_permanent2_6.disabled=true;
}else{
parent.job_options.document.tourOptions.jb_permanent2_0.disabled=false;
parent.job_options.document.tourOptions.jb_permanent2_1.disabled=false;
parent.job_options.document.tourOptions.jb_permanent2_2.disabled=false;
parent.job_options.document.tourOptions.jb_permanent2_3.disabled=false;
parent.job_options.document.tourOptions.jb_permanent2_4.disabled=false;
parent.job_options.document.tourOptions.jb_permanent2_5.disabled=false;
parent.job_options.document.tourOptions.jb_permanent2_6.disabled=false;
if(getSelectedVal("job_options","tourOptions","jb_permanent")==1){
parent.job_options.document.tourOptions.jb_permanent2_0.checked=true;
parent.job_options.document.tourOptions.jb_permanent2_1.checked=true;
parent.job_options.document.tourOptions.jb_permanent2_2.checked=true;
parent.job_options.document.tourOptions.jb_permanent2_3.checked=true;
parent.job_options.document.tourOptions.jb_permanent2_4.checked=true;
parent.job_options.document.tourOptions.jb_permanent2_5.checked=false;
parent.job_options.document.tourOptions.jb_permanent2_6.checked=false;
}
if(getSelectedVal("job_options","tourOptions","jb_permanent")==2){
parent.job_options.document.tourOptions.jb_permanent2_0.checked=true;
parent.job_options.document.tourOptions.jb_permanent2_1.checked=true;
parent.job_options.document.tourOptions.jb_permanent2_2.checked=true;
parent.job_options.document.tourOptions.jb_permanent2_3.checked=true;
parent.job_options.document.tourOptions.jb_permanent2_4.checked=true;
parent.job_options.document.tourOptions.jb_permanent2_5.checked=true;
parent.job_options.document.tourOptions.jb_permanent2_6.checked=false;
}
if(getSelectedVal("job_options","tourOptions","jb_permanent")==3){
parent.job_options.document.tourOptions.jb_permanent2_0.checked=true;
parent.job_options.document.tourOptions.jb_permanent2_1.checked=true;
parent.job_options.document.tourOptions.jb_permanent2_2.checked=true;
parent.job_options.document.tourOptions.jb_permanent2_3.checked=true;
parent.job_options.document.tourOptions.jb_permanent2_4.checked=true;
parent.job_options.document.tourOptions.jb_permanent2_5.checked=true;
parent.job_options.document.tourOptions.jb_permanent2_6.checked=true;
}
}
checkJb_permanent2();
}
function checkJb_permanent2()
{
var jb_permanent2_0="0";
var jb_permanent2_1="0";
var jb_permanent2_2="0";
var jb_permanent2_3="0";
var jb_permanent2_4="0";
var jb_permanent2_5="0";
var jb_permanent2_6="0";
if(typeof(parent.job_options.document.tourOptions.jb_permanent)=='undefined')
return;
if(getSelectedVal("job_options","tourOptions","jb_permanent")==""
||getSelectedVal("job_options","tourOptions","jb_permanent")>3
||parent.job_options.document.tourOptions.jb_permanent.disabled==true){
}else{
parent.job_options.document.tourOptions.jb_permanent2_0.disabled=false;
parent.job_options.document.tourOptions.jb_permanent2_1.disabled=false;
parent.job_options.document.tourOptions.jb_permanent2_2.disabled=false;
parent.job_options.document.tourOptions.jb_permanent2_3.disabled=false;
parent.job_options.document.tourOptions.jb_permanent2_4.disabled=false;
parent.job_options.document.tourOptions.jb_permanent2_5.disabled=false;
parent.job_options.document.tourOptions.jb_permanent2_6.disabled=false;
}
if(parent.job_options.document.tourOptions.jb_permanent2_0.checked)
jb_permanent2_0="1";
if(parent.job_options.document.tourOptions.jb_permanent2_1.checked)
jb_permanent2_1="1";
if(parent.job_options.document.tourOptions.jb_permanent2_2.checked)
jb_permanent2_2="1";
if(parent.job_options.document.tourOptions.jb_permanent2_3.checked)
jb_permanent2_3="1";
if(parent.job_options.document.tourOptions.jb_permanent2_4.checked)
jb_permanent2_4="1";
if(parent.job_options.document.tourOptions.jb_permanent2_5.checked)
jb_permanent2_5="1";
if(parent.job_options.document.tourOptions.jb_permanent2_6.checked)
jb_permanent2_6="1";
parent.job_options.document.tourOptions.jb_permanent2_hidden.value=
jb_permanent2_0+jb_permanent2_1+jb_permanent2_2+jb_permanent2_3
+jb_permanent2_4+jb_permanent2_5+jb_permanent2_6;
}
function checkPayer(side)
{
if(typeof(parent.job_tour.document.tourForm.jb_costsplit)=='undefined')
return;
if(side!=0)
if(cash_payer_select!="1"||side==1)
parent.job_tour.document.tourForm.elements[von_fields[jl_csc_id_payer]].checked=false;
if(side!=1)
if(cash_payer_select!="1"||side==0)
parent.job_tour.document.tourForm.elements[nach_fields[jl_csc_id_payer]].checked=false;
if(side==0||side==1)
{
if(cash_payer_select!="1"){
parent.job_tour.document.tourForm.jb_cash.checked=false;
parent.job_tour.document.tourForm.jb_costsplit.checked=false;
}
saveFormFields();
}
if(side!=2)
{
if(cash_payer_select!="1"||side==3){
parent.job_tour.document.tourForm.jb_cash.checked=false;
checkCash(false);
}
}
if(side!=3)
{
if(cash_payer_select!="1"||side==2){
parent.job_tour.document.tourForm.jb_costsplit.checked=false;
checkCostsplit(false);
}
}
refreshFormFields();
}
function checkCash(doRefresh)
{
if(!parent.job_tour.document.tourForm.jb_cash.checked)
{
parent.job_options.document.tourOptions.jb_cash_hidden.value="false";
}else{
checkPayer(2);
if(cash_payer_select!="1")
{
for(var i=0;i<(maxTour+1);i++)
setJobList(i,jl_csc_id_payer,"false");
parent.job_tour.document.tourForm.elements[von_fields[jl_csc_id_payer]].checked=
false;
parent.job_tour.document.tourForm.elements[nach_fields[jl_csc_id_payer]].checked=
false;
}
if(parent.job_tour.is_customer)
csc_id_payer_val_save = curCsc_id_payer;
if(setCsc_id_payer("",""))
parent.job_options.document.tourOptions.jb_cash_hidden.value="true";
}
if(doRefresh)
refreshFormFields();
}
function checkCostsplit(doRefresh)
{
if(!parent.job_tour.document.tourForm.jb_costsplit.checked)
{
parent.job_options.document.tourOptions.jb_costsplit_hidden.value="false";
}else{
checkPayer(3);
if(cash_payer_select!="1")
{
for(var i=0;i<(maxTour+1);i++)
setJobList(i,jl_csc_id_payer,"false");
parent.job_tour.document.tourForm.elements[von_fields[jl_csc_id_payer]].checked=
false;
parent.job_tour.document.tourForm.elements[nach_fields[jl_csc_id_payer]].checked=
false;
}
if(setCsc_id_payer("donotdeleteifcash_payer_select",""))
parent.job_options.document.tourOptions.jb_costsplit_hidden.value="true";
if(parent.job_tour.is_customer)
setCsc_id_payer(csc_id_payer_val_save,get_comp(csc_id_payer_val_save));
}
if(doRefresh)
refreshFormFields();
}
function setCsc_id_payer(csc_id_payer_val,comp_payer_val)
{
if(parent.job_options.document.tourOptions.payer_is_default.value=="true" && ask_defaultpayer_change == "1"
&&((parent.job_options.document.tourOptions.csc_id_payer.value!=csc_id_payer_val)||(csc_id_payer_val==""&&ask_defaultpayer_change=="1"))
&&csc_id_payer_val!="donotdeleteifcash_payer_select"
&&((csc_id_payer_val!=csc_id_payer_cash)||ask_defaultpayer_change=="1"))
if(!confirm("Wollen Sie den voreingestellten Bezahler wirklich ändern?" + ask_defaultpayer_change))
{
for(var i=0;i<(maxTour+1);i++)
setJobList(i,jl_csc_id_payer,"false");
parent.job_tour.document.tourForm.elements[von_fields[jl_csc_id_payer]].checked=false;
parent.job_tour.document.tourForm.elements[nach_fields[jl_csc_id_payer]].checked=false;
if(parent.job_options.document.tourOptions.csc_id_payer.value!=""){
parent.job_options.document.tourOptions.jb_cash_hidden.value="false";
parent.job_tour.document.tourForm.jb_cash.checked=false;
}else{
parent.job_options.document.tourOptions.jb_cash_hidden.value="true";
parent.job_tour.document.tourForm.jb_cash.checked=true;
refreshformfields();
}
parent.job_options.document.tourOptions.jb_costsplit_hidden.value="false";
parent.job_tour.document.tourForm.jb_costsplit.checked=false;
return false;
}
if(csc_id_payer_val!="donotdeleteifcash_payer_select")
{
parent.job_options.document.tourOptions.csc_id_payer.value=csc_id_payer_val;
parent.job_options.document.tourOptions.comp_payer.value=comp_payer_val;
parent.job_options.document.tourOptions.payer_is_default.value="";
if(csc_id_payer_val!="")
{
for(var i=0;i<(maxTour+1);i++)
setJobList(i,jl_csc_id_payer,"false");
checkPayer(4);
}
}
return true;
}

function refreshFormFields()
{
var curTourNo=getCurTourNo();
writeJob();
for(var i=1;i<(von_fields.length-3);i++)
{
  	if (von_fields[i] != -1) {
parent.job_tour.document.tourForm.elements[von_fields[i]].value=
getJobList(curTourNo,i);
    }
  	if (nach_fields[i] != -1) {
parent.job_tour.document.tourForm.elements[nach_fields[i]].value=
getJobList(curTourNo+1,i);
    }
}
parent.job_tour.document.tourForm.elements[von_fields[jl_tr_ware_from]].checked=
(getJobList(curTourNo,jl_tr_ware_from)=="true"?true:false);
parent.job_tour.document.tourForm.elements[von_fields[jl_tr_ware_to]].checked=
(getJobList(curTourNo,jl_tr_ware_to)=="true"?true:false);
parent.job_tour.document.tourForm.elements[nach_fields[jl_tr_ware_from]].checked=
(getJobList(curTourNo+1,jl_tr_ware_from)=="true"?true:false);
parent.job_tour.document.tourForm.elements[nach_fields[jl_tr_ware_to]].checked=
(getJobList(curTourNo+1,jl_tr_ware_to)=="true"?true:false);
parent.job_tour.document.tourForm.elements[von_fields[jl_hide_tr_remark]].checked=
(getJobList(curTourNo,jl_hide_tr_remark)=="true"?true:false);
parent.job_tour.document.tourForm.elements[von_fields[jl_tr_remark]].disabled=
(getJobList(curTourNo,jl_hide_tr_remark)=="false"?true:false);
parent.job_tour.document.tourForm.elements[nach_fields[jl_hide_tr_remark]].checked=
(getJobList(curTourNo+1,jl_hide_tr_remark)=="true"?true:false);
parent.job_tour.document.tourForm.elements[nach_fields[jl_tr_remark]].disabled=
(getJobList(curTourNo+1,jl_hide_tr_remark)=="false"?true:false);
if(typeof(parent.job_tour.document.tourForm.jb_costsplit)!='undefined'){
parent.job_tour.document.tourForm.elements[von_fields[jl_csc_id_payer]].disabled=
(getJobList(curTourNo,jl_csc_id_payer)=="disabled"&&(cash_payer_select!="1"||parent.job_tour.document.tourForm.jb_costsplit.checked)?true:false);
parent.job_tour.document.tourForm.elements[von_fields[jl_csc_id_payer]].checked=
(getJobList(curTourNo,jl_csc_id_payer)=="true"?true:false);
parent.job_tour.document.tourForm.elements[nach_fields[jl_csc_id_payer]].disabled=
(getJobList(curTourNo+1,jl_csc_id_payer)=="disabled"&&(cash_payer_select!="1"||parent.job_tour.document.tourForm.jb_costsplit.checked)?true:false);
parent.job_tour.document.tourForm.elements[nach_fields[jl_csc_id_payer]].checked=
(getJobList(curTourNo+1,jl_csc_id_payer)=="true"?true:false);
}
//parent.job_tour.document.tourForm.von_tr_commission_noButton.value=
//(getJobList(curTourNo,jl_tr_commission_no)==""?"Ko.-Nr.":"Ko.-Nr.*");
//parent.job_tour.document.tourForm.nach_tr_commission_noButton.value=
//(getJobList(curTourNo+1,jl_tr_commission_no)==""?"Ko.-Nr.":"Ko.-Nr.*");
//if(typeof(parent.job_tour.document.tourForm.von_cmp_remarkButton)!='undefined'){
if(get_cmp_remark(getJobList(curTourNo,jl_csc_id))!="" && get_cs_eid(getJobList(curTourNo,jl_csc_id)) == get_cs_eid(curCsc_id_payer))
{
      parent.job_tour.document.getElementById("von_cmp_remark_div").innerHTML = 'Bemerkung links<br><textarea class="input ' + parent.job_tour.cmp_remark_style + '" disabled>' + get_cmp_remark(getJobList(curTourNo, jl_csc_id)) + '</textarea>';
//parent.job_tour.document.tourForm.von_cmp_remarkButton.disabled=false;
//parent.job_tour.document.tourForm.von_cmp_remarkButton.className="commission_no_enabled";
}else{
      parent.job_tour.document.getElementById("von_cmp_remark_div").innerHTML = '&nbsp;';
//parent.job_tour.document.tourForm.von_cmp_remarkButton.disabled=true;
//parent.job_tour.document.tourForm.von_cmp_remarkButton.className="commission_no_disabled";
}
//}
//if(typeof(parent.job_tour.document.tourForm.nach_cmp_remarkButton)!='undefined'){
if(get_cmp_remark(getJobList(curTourNo+1,jl_csc_id))!="" && get_cs_eid(getJobList(curTourNo+1,jl_csc_id)) == get_cs_eid(curCsc_id_payer))
{
      parent.job_tour.document.getElementById("nach_cmp_remark_div").innerHTML = 'Bemerkung rechts<br><textarea class="input ' + parent.job_tour.cmp_remark_style + '" disabled>' + get_cmp_remark(getJobList(curTourNo + 1, jl_csc_id)) + '</textarea>';
//parent.job_tour.document.tourForm.nach_cmp_remarkButton.disabled=false;
//parent.job_tour.document.tourForm.nach_cmp_remarkButton.className="commission_no_enabled";
}else{
      parent.job_tour.document.getElementById("nach_cmp_remark_div").innerHTML = '&nbsp;';
//parent.job_tour.document.tourForm.nach_cmp_remarkButton.disabled=true;
//parent.job_tour.document.tourForm.nach_cmp_remarkButton.className="commission_no_disabled";
}
//}
}
function check_tr_mediationarea_id()
{
var curTourNo=getCurTourNo();
if(typeof(parent.job_tour.document.tourForm.von_tr_mediationarea_id_Button)!='undefined'){
parent.job_tour.document.tourForm.von_tr_mediationarea_id_Button.value=
((getJobList(curTourNo,jl_tr_mediationarea_id)==""||getJobList(curTourNo,jl_tr_mediationarea_id)==0)?"Rg.-Plz":"Rg.-Plz*");
parent.job_tour.document.tourForm.nach_tr_mediationarea_id_Button.value=
((getJobList(curTourNo+1,jl_tr_mediationarea_id)==""||getJobList(curTourNo+1,jl_tr_mediationarea_id)==0)?"Rg.-Plz":"Rg.-Plz*");
parent.job_tour.document.tourForm.von_tr_mediationarea_id_Button.disabled=true;
}
for(i=0;i<fz.length;i++)
{
if(fz[i][0]==getJobList(curTourNo,jl_ad_zipcode))
{
if(typeof(parent.job_tour.document.tourForm.von_tr_mediationarea_id_Button)!='undefined')
  parent.job_tour.document.tourForm.von_tr_mediationarea_id_Button.disabled=false;
if(getJobList(curTourNo,jl_tr_mediationarea_id)==0)
{
        setJobList(curTourNo, jl_tr_mediationarea_id, -1);
//        setJobList(curTourNo, jl_tr_mediationarea_id, fz[i][2]);
//        mk_tr_mediationarea_id(0);
}
break;
}
}
if(typeof(parent.job_tour.document.tourForm.nach_tr_mediationarea_id_Button)!='undefined')
  parent.job_tour.document.tourForm.nach_tr_mediationarea_id_Button.disabled=true;
for(i=0;i<fz.length;i++)
{
if(fz[i][0]==getJobList(curTourNo+1,jl_ad_zipcode))
{
if(typeof(parent.job_tour.document.tourForm.nach_tr_mediationarea_id_Button)!='undefined')
  parent.job_tour.document.tourForm.nach_tr_mediationarea_id_Button.disabled=false;
if(getJobList(curTourNo+1,jl_tr_mediationarea_id)==0)
{
        setJobList(curTourNo + 1, jl_tr_mediationarea_id, -1);
//        setJobList(curTourNo + 1, jl_tr_mediationarea_id, fz[i][2]);
//        mk_tr_mediationarea_id(1);
}
break;
}
}
}
function checkTourDirty(i)
{
var retVal=false;
var tourIsNotEmpty=false;
var tourNo=getCurTourNo();
if(!(((getJobList(i,jl_tr_comp)).replace(/\s/,"").length==0)&&
((getJobList(i,jl_ad_street)).replace(/\s/,"").length==0)&&
((getJobList(i,jl_tr_hsno)).replace(/\s/,"").length==0)&&
((getJobList(i,jl_ad_zipcode)).replace(/\s/,"").length==0)&&
((getJobList(i,jl_ad_city)).replace(/\s/,"").length==0)))
tourIsNotEmpty=true;
if((getJobList(i,jl_tr_comp)).replace(/\s/,"").length==0)
{
if(i==tourNo&&tourIsNotEmpty)
parent.job_tour.document.tourForm.elements[von_fields[jl_tr_comp]].className="inputRed";
if(i==tourNo+1&&tourIsNotEmpty)
parent.job_tour.document.tourForm.elements[nach_fields[jl_tr_comp]].className="inputRed";
if(tourIsNotEmpty)
retVal=true;
}else{
if(i==tourNo)
parent.job_tour.document.tourForm.elements[von_fields[jl_tr_comp]].className="input";
if(i==tourNo+1)
parent.job_tour.document.tourForm.elements[nach_fields[jl_tr_comp]].className="input";
}
if((getJobList(i,jl_ad_street)).replace(/\s/,"").length==0&&tourIsNotEmpty)
{
if(i==tourNo&&tourIsNotEmpty)
parent.job_tour.document.tourForm.elements[von_fields[jl_ad_street]].className="inputRed";
if(i==tourNo+1&&tourIsNotEmpty)
parent.job_tour.document.tourForm.elements[nach_fields[jl_ad_street]].className="inputRed";
if(tourIsNotEmpty)
retVal=true;
}else{
if(i==tourNo)
parent.job_tour.document.tourForm.elements[von_fields[jl_ad_street]].className="input";
if(i==tourNo)
parent.job_tour.document.tourForm.elements[nach_fields[jl_ad_street]].className="input";
}
if((getJobList(i,jl_tr_hsno)).replace(/\s/,"").length==0&&tourIsNotEmpty)
{
if(i==tourNo&&tourIsNotEmpty)
parent.job_tour.document.tourForm.elements[von_fields[jl_tr_hsno]].className="inputRed";
if(i==tourNo+1&&tourIsNotEmpty)
parent.job_tour.document.tourForm.elements[nach_fields[jl_tr_hsno]].className="inputRed";
if(tourIsNotEmpty)
retVal=true;
}else{
if(i==tourNo)
parent.job_tour.document.tourForm.elements[von_fields[jl_tr_hsno]].className="input";
if(i==tourNo+1)
parent.job_tour.document.tourForm.elements[nach_fields[jl_tr_hsno]].className="input";
}
if((getJobList(i,jl_ad_zipcode)).replace(/\s/,"").length==0&&tourIsNotEmpty)
{
if(i==tourNo&&tourIsNotEmpty)
parent.job_tour.document.tourForm.elements[von_fields[jl_ad_zipcode]].className="inputRed";
if(i==tourNo+1&&tourIsNotEmpty)
parent.job_tour.document.tourForm.elements[nach_fields[jl_ad_zipcode]].className="inputRed";
if(tourIsNotEmpty)
retVal=true;
}else{
if(i==tourNo)
parent.job_tour.document.tourForm.elements[von_fields[jl_ad_zipcode]].className="input";
if(i==tourNo+1)
parent.job_tour.document.tourForm.elements[nach_fields[jl_ad_zipcode]].className="input";
}
if((getJobList(i,jl_ad_city)).replace(/\s/,"").length==0&&tourIsNotEmpty)
{
if(i==tourNo&&tourIsNotEmpty)
parent.job_tour.document.tourForm.elements[von_fields[jl_ad_city]].className="inputRed";
if(i==tourNo+1&&tourIsNotEmpty)
parent.job_tour.document.tourForm.elements[nach_fields[jl_ad_city]].className="inputRed";
if(tourIsNotEmpty)
retVal=true;
}else{
if(i==tourNo)
parent.job_tour.document.tourForm.elements[von_fields[jl_ad_city]].className="input";
if(i==tourNo+1)
parent.job_tour.document.tourForm.elements[nach_fields[jl_ad_city]].className="input";
}

  // Durch den Wegfall des Ko.-Nr. Buttons muss die Farbgebung des neuen Ko.-Nr.-Feldes überprüft werden, damit das konsistent ist
  // Es ist zwar ein wenig ineffizient, das hier jedes Mal zu machen, aber frisst ja kein Brot...
  var tr_commission_no_needed = false;
  if (is_commission_no(curCsc_id_payer))
  {
    tr_commission_no_needed = true;
    for (var j = 0; j < (maxTour + 1); j++)
    {
       if ((getJobList(j, jl_tr_commission_no)).replace(/\s/,"").length != 0) {
         tr_commission_no_needed = false;
         break;
      }
    }
    parent.job_tour.document.getElementById("div_jb_commission_no").style.display = "inline";
  } else {
    parent.job_tour.document.getElementById("div_jb_commission_no").style.display = "none";
  }
//  if ((getJobList(i, jl_tr_commission_no)).replace(/\s/,"").length == 0 && tr_commission_no_needed && tourIsNotEmpty)
//  {
//    if (i == tourNo && tourIsNotEmpty)
//      parent.job_tour.document.tourForm.elements[von_fields[jl_tr_commission_no]].className = "inputRed";
//    if (i == tourNo + 1 && tourIsNotEmpty)
//      parent.job_tour.document.tourForm.elements[nach_fields[jl_tr_commission_no]].className = "inputRed";
////    // Trotz fehlender Ko.-Nr. soll die Tour sendbar bleiben (nur wenn Parameter MASK_COMMISSION_NO_MANDATORY nicht auf "1" gesetzt ist)
////    if (tourIsNotEmpty && MASK_COMMISSION_NO_MANDATORY == "1")
////      retVal = true; 
//  } else {
//    if (i == tourNo)
//      parent.job_tour.document.tourForm.elements[von_fields[jl_tr_commission_no]].className = "input";
//    if (i == tourNo + 1)
//      parent.job_tour.document.tourForm.elements[nach_fields[jl_tr_commission_no]].className = "input";
//  }

return retVal;
}
function prevTour()
{
if(getCurTourNo()>0)setCurTourNo(getCurTourNo()-1);
}
function nextTour()
{
if(getCurTourNo()<maxTour-1)setCurTourNo(getCurTourNo()+1);
}
function moveToTour(toTourNo)
{
var curTourNo=getCurTourNo();
var tempWin;
if(parent.job_options.isCurrentlySubmitting)
return;
while(curTourNo>toTourNo)
{
prevTour();
curTourNo=getCurTourNo();
}
while(curTourNo<toTourNo)
{
nextTour();
curTourNo=getCurTourNo();
}
if(((getJobList(curTourNo,jl_csc_id)).replace(/\s/,"").length==0)&&
((getJobList(curTourNo+1,jl_csc_id)).replace(/\s/,"").length==0))
return;
tempWin=mkPopupWin(
"function startReload()\n"+
"{\n"+
"  checkDone();\n"+
"  self.location.href=\"../jobs/get_address.php"
+"?csc_id1="+getJobList(curTourNo,jl_csc_id)
+"&csc_id2="+getJobList(curTourNo+1,jl_csc_id)+"\";\n"+
"}\n"+
"\n"+
"//--"+">\n"+
"<\/script>\n"+
"<\/head>\n"+
"<body onLoad=\"startReload()\"\n>"+
"  <table border=0 align=center height=100% cellspacing=0 cellpadding=0 vspace=0 hspace=0>\n"+
"    <tr>\n"+
"      <td align=center valign=center>\n"+
"        <b>Hole Daten...</b>\n"+
"      <\/td>\n"+
"    <\/tr>\n"+
"  <\/table>\n"+
"<\/body>\n"+
"<\/html>\n",0,0);
}
function delTour(side)
{
var curTourNo=getCurTourNo();
var delTourNo=curTourNo+side;
while(delTourNo<maxTour+1)
delJobList(delTourNo++,true);
refreshFormFields();
}
function csc_idChange(side)
{
var curTourNo=getCurTourNo();
var delTourNo=curTourNo+side;
delJobList(delTourNo,false);
setJobList(curTourNo,jl_csc_id,getSelectedVal("job_tour","tourForm",von_fields[jl_csc_id]));
setJobList(curTourNo+1,jl_csc_id,getSelectedVal("job_tour","tourForm",nach_fields[jl_csc_id]));
if(parent.job_tour.document.tourForm.jb_costsplit.checked||parent.job_tour.document.tourForm.jb_cash.checked||
parent.job_options.document.tourOptions.csc_id_payer.value!="")
{
setJobList(curTourNo,jl_csc_id_payer,"disabled");
setJobList(curTourNo+1,jl_csc_id_payer,"disabled");
}
refreshFormFields();
}
function get_cs_eid(csc_id)
{
  if (csc_id.replace(/\s/,"").length == 0)
    return "";
  for (var i = 0; i < cs_eid_list.length; i++)
    if (cs_eid_list[i][0] == csc_id)
      return cs_eid_list[i][1];
  return "";
}
function is_Extern(csc_id)
{
if(cash_payer_select=="1"&&parent.job_tour.document.tourForm.jb_costsplit.checked)
if(is_cashpayer_only(csc_id)||parent.job_tour.is_customer)
return true;
if(csc_id.replace(/\s/,"").length==0)
return true;
for(var i=0;i<cs_eid_list.length;i++)
if(cs_eid_list[i][0]==csc_id)
if(cs_eid_list[i][1]!=""&&cs_eid_list[i][1]!=0)
return false;
return true;
}
function is_commission_no(csc_id)
{
if(csc_id.replace(/\s/,"").length==0)
return false;
for(var i=0;i<cs_eid_list.length;i++)
if(cs_eid_list[i][0]==csc_id)
if(cs_eid_list[i][2]==1)
return true;
return false;
}
function is_cashpayer_only(csc_id)
{
if(csc_id.replace(/\s/,"").length==0)
return false;
for(var i=0;i<cs_eid_list.length;i++)
if(cs_eid_list[i][0]==csc_id)
if(cs_eid_list[i][4]==0)
return true;
return false;
}
function get_comp(csc_id)
{
if(csc_id.replace(/\s/,"").length==0)
return "";
for(var i=0;i<cs_eid_list.length;i++)
if(cs_eid_list[i][0]==csc_id)
return cs_eid_list[i][3];
return "";
}
function get_cmp_remark(csc_id)
{
if(csc_id.replace(/\s/,"").length==0)
return "";
for(var i=0;i<cs_eid_list.length;i++)
if(cs_eid_list[i][0]==csc_id)
return cs_eid_list[i][5];
return "";
}
function get_cs_jobbatch(csc_id)
{
if(csc_id.replace(/\s/,"").length==0)
return "";
for(var i=0;i<cs_eid_list.length;i++)
if(cs_eid_list[i][0]==csc_id)
return cs_eid_list[i][6];
return "";
}
function get_cs_discount(csc_id)
{
if(csc_id.replace(/\s/,"").length==0)
return "";
for(var i=0;i<cs_eid_list.length;i++)
if(cs_eid_list[i][0]==csc_id)
return cs_eid_list[i][7];
return "";
}
function get_cs_filter(csc_id)
{
  // leere csc_id hat keine Filter
  if (csc_id.replace(/\s/,"").length == 0)
    return "";
  for (var i = 0; i < cs_eid_list.length; i++)
    if (cs_eid_list[i][0] == csc_id)
      return cs_eid_list[i][8];
  return "";
}
function get_cs_id(csc_id)
{
  // leere csc_id hat keine cs_id
  if (csc_id.replace(/\s/,"").length == 0)
    return 0;
  for (var i = 0; i < cs_eid_list.length; i++)
    if (cs_eid_list[i][0] == csc_id)
      return cs_eid_list[i][12];
  return 0;
}
function get_cs_fixprice_discount(csc_id)
{
  // leere csc_id hat kein cs_fixprice_discount
  if (csc_id.replace(/\s/,"").length == 0)
    return 0;
  for (var i = 0; i < cs_eid_list.length; i++)
    if (cs_eid_list[i][0] == csc_id)
      return cs_eid_list[i][13];
  return 0;
}
function get_cs_jb_jam_waittime(csc_id)
{
  // leere csc_id hat kein cs_comm_prefix
  if (csc_id.replace(/\s/,"").length == 0)
    return "";
  for (var i = 0; i < cs_eid_list.length; i++)
    if (cs_eid_list[i][0] == csc_id && cs_eid_list[i][19] != '') {
      return cs_eid_list[i][19];
  }
  return "";
}

function get_cs_tracking(csc_id)
{
  // leere csc_id hat kein tracking
  if (csc_id.replace(/\s/,"").length == 0)
    return 0;
  for (var i = 0; i < cs_eid_list.length; i++)
    if (cs_eid_list[i][0] == csc_id && cs_eid_list[i][20] != '') {
      return cs_eid_list[i][20];
  }
  return 0;
}
function get_cs_invmode(csc_id)
{
  // leere csc_id hat keine comp
  if (csc_id.replace(/\s/,"").length == 0)
    return "";
  for (var i = 0; i < cs_eid_list.length; i++)
    if (cs_eid_list[i][0] == csc_id)
      return cs_eid_list[i][24];
  return "";
}

function add_cs_eid(csc_id, cs_eid, cs_commission_no, comp, cmp_authenticated, cmp_remark, cs_jobbatch, cs_discount, cs_filter, tx_id, name, is_extern, cs_id, cs_fixprice_discount, cs_prov, cmp_stax_idno, comm_prefix, cs_jb_jam_waittime, cs_tracking, cs_invmail, cs_jb_incomplete, cs_invmode)
{
var i=cs_eid_list.length;
cs_eid_list[i]=new Array();
cs_eid_list[i][0]=csc_id;
cs_eid_list[i][1]=cs_eid;
cs_eid_list[i][2]=cs_commission_no;
cs_eid_list[i][3]=comp;
cs_eid_list[i][4]=cmp_authenticated;
cs_eid_list[i][5]=cmp_remark;
cs_eid_list[i][6]=cs_jobbatch;
cs_eid_list[i][7]=cs_discount;
cs_eid_list[i][8]=cs_filter;
  cs_eid_list[i][9] = tx_id;
  cs_eid_list[i][10] = name;
  cs_eid_list[i][11] = is_extern;
  cs_eid_list[i][12] = cs_id;
  cs_eid_list[i][13] = cs_fixprice_discount;
  cs_eid_list[i][14] = cs_prov;
  cs_eid_list[i][15] = cmp_stax_idno;
  cs_eid_list[i][16] = new Array();

//  ajaxRequestGet('../include/ajaxReqJob.php', 'cs_id=' + cs_id);
//  if (retValue.length != 0) {
//    for (var j = 0; j < retValue.length; j++) {
//      cs_eid_list[i][16][j] = retValue[j];
//    }
//  }
  cs_eid_list[i][17] = comm_prefix;
  
//  ajaxRequestGet('../include/ajaxReqJob.php', 'csc_id=' + csc_id);
//  cs_eid_list[i][18] = retValue;

  cs_eid_list[i][19] = cs_jb_jam_waittime;
  cs_eid_list[i][20] = cs_tracking;
  cs_eid_list[i][21] = cs_invmail;
  cs_eid_list[i][22] = cs_jb_incomplete;

//  ajaxRequestGet('../include/ajaxReqJob.php', 'csc_id_ask_mail=' + csc_id + "&cs_id_ask_mail=" + cs_id + "&hq_id=" + hq_id + "&vht_id=" + parent.job_options.document.tourOptions.vht_id.value + "&csc_id_payer_cash=" + csc_id_payer_cash);
//  cs_eid_list[i][23] = retValue;
  cs_eid_list[i][24] = cs_invmode;
}
function mkFieldsReloadPrice()
{
var mkFieldsReloadPriceVal="";
for(var i=0;i<parent.job_options.document.tourOptions.elements.length;i++)
{
mkFieldsReloadPriceVal+=
"<input type=\"hidden\" name=\""+
parent.job_options.document.tourOptions.elements[i].name+"\" value=\""+
parent.job_options.document.tourOptions.elements[i].value.replace(/"/,"\\\"")+"\">\n";
}
return mkFieldsReloadPriceVal;
}
function resetSignificantPriceValues()
{
significantPriceValues="";
}
function writeJob()
{
var tourlink;
checkSendTour();
var detailLink="";
if(jb_id!=""){
detailLink="<a href=\"javascript:popupWindow('../admin/jb_detail.php?job_id="+jb_id+"','Auftrag','scrollbars=yes,width=800,height=500');\">Auftragsdetails</a>";
if(parent.job_options.document.tourOptions.csc_id_orderer.value!=""&&parent.job_options.document.tourOptions.csc_id_orderer.value!=0)
detailLink="<a href=\"javascript:popupWindow('../customer/jb_detail.php?job_id="+jb_id+"','Auftrag','scrollbars=yes,width=800,height=500');\">Auftragsdetails</a>";
}
var listLink="";
if(empModeLaterJob=="1")
listLink="<a href=\"../jobs/jb_edit_batch.php\" target=\"_parent\">Listenerfassung</a>";
var curSignificantPriceValues=parent.job_options.document.tourOptions.vht_id.value.toString()+""+curCsc_id_payer;
var j=0;
while((getJobList(j,jl_csc_id)!=""||checkTourComplete(j)))
{
curSignificantPriceValues+=getJobList(j,jl_ad_street)+getJobList(j,jl_tr_hsno)+getJobList(j,jl_ad_zipcode)+getJobList(j,jl_ad_city);
if(++j>=maxTour)
break;
}
var onLoadFunc="";
if(significantPriceValues!=curSignificantPriceValues&&parent.job_tour.document.tourForm.nameOfPayer.value!="")
{
significantPriceValues=curSignificantPriceValues;
    onLoadFunc = "reloadPrice();\n";
}
var i_payer=-1;
if(typeof(parent.job_tour.document.tourForm.jb_costsplit)!='undefined'){
if(((!parent.job_tour.document.tourForm.jb_costsplit.checked&&
!parent.job_tour.document.tourForm.jb_cash.checked)||(cash_payer_select=="1"))&&
(parent.job_options.document.tourOptions.csc_id_payer.value==""||parent.job_tour.is_customer))
{
var payer_selected=false;
for(i=0;i<=j;i++)
{
if(getJobList(i,jl_csc_id_payer)=="disabled")
{
if(!is_Extern(getJobList(i,jl_csc_id)))
setJobList(i,jl_csc_id_payer,"false");
}else{
if(getJobList(i,jl_csc_id_payer)=="true")
{
payer_selected=true;
i_payer=i;
}
if(is_Extern(getJobList(i,jl_csc_id)))
{
if(cash_payer_select!="1"||parent.job_tour.document.tourForm.jb_costsplit.checked)
setJobList(i,jl_csc_id_payer,"disabled");
}
}
}
//// <--- honk --->
//// <--- honk --->
}
}
var oldCurCsc_id_payer=curCsc_id_payer;
if(parent.job_options.document.tourOptions.csc_id_payer.value!=""
&&parent.job_options.document.tourOptions.csc_id_payer.value!=csc_id_payer_cash)
{
parent.job_tour.document.tourForm.nameOfPayer.value=
parent.job_options.document.tourOptions.comp_payer.value;
curCsc_id_payer=parent.job_options.document.tourOptions.csc_id_payer.value;
checkCs_filter(get_cs_filter(curCsc_id_payer));
}else{
if(i_payer>-1&&!parent.job_tour.document.tourForm.jb_cash.checked){
curCsc_id_payer=getJobList(i_payer,jl_csc_id);
parent.job_tour.document.tourForm.nameOfPayer.value=
get_comp(curCsc_id_payer);
}
else{
if(typeof(parent.job_tour.document.tourForm.jb_cash)!='undefined')
{
if(parent.job_tour.document.tourForm.jb_cash.checked
||parent.job_options.document.tourOptions.csc_id_payer.value==csc_id_payer_cash){
parent.job_tour.document.tourForm.nameOfPayer.value=
"*** Barzahlung ***";
if(parent.job_options.document.tourOptions.csc_id_payer.value==csc_id_payer_cash)
{
parent.job_tour.document.tourForm.jb_cash.checked=true;
parent.job_tour.document.tourForm.jb_costsplit.checked=false;
if(setCsc_id_payer("",""))
parent.job_options.document.tourOptions.jb_cash_hidden.value="true";
parent.job_options.document.tourOptions.payer_is_default.value="";
}
if(cash_payer_select!="1")
{
curCsc_id_payer="-1";
if(csc_id_payer_cash!=""){
curCsc_id_payer=csc_id_payer_cash;
}
}else{
if(i_payer>-1)
curCsc_id_payer=getJobList(i_payer,jl_csc_id);
}
}else{
parent.job_tour.document.tourForm.nameOfPayer.value="";
if(parent.job_tour.document.tourForm.jb_costsplit.checked){
parent.job_tour.document.tourForm.nameOfPayer.value=
(cash_payer_select!="1"?"*** Kostenteilung ***":"*** Bezahler wählen ***");
curCsc_id_payer="0";
}
}
}
}
}
if(get_cs_jobbatch(curCsc_id_payer)==1)
parent.job_tour.document.tourForm.nameOfPayer.value=
"*** Listenkunde ***";
checkDiscount();
var curTourNo=getCurTourNo();
check_tr_mediationarea_id();
if(is_commission_no(curCsc_id_payer))
{
//    parent.job_tour.document.tourForm.von_tr_commission_noButton.disabled = false;
//    parent.job_tour.document.tourForm.von_tr_commission_noButton.className = "commission_no_enabled";
//    parent.job_tour.document.tourForm.nach_tr_commission_noButton.disabled = false;
//    parent.job_tour.document.tourForm.nach_tr_commission_noButton.className = "commission_no_enabled";
//      parent.job_tour.document.tourForm.von_tr_commission_no.className = "inputRed";
//      parent.job_tour.document.tourForm.von_tr_commission_no.disabled = false;
//      parent.job_tour.document.tourForm.nach_tr_commission_no.className = "inputRed";
//      parent.job_tour.document.tourForm.nach_tr_commission_no.disabled = false;
      parent.job_tour.document.tourForm.jb_commission_no.className = "inputRed";
      parent.job_tour.document.tourForm.jb_commission_no.disabled = false;
}else{
//    parent.job_tour.document.tourForm.von_tr_commission_noButton.disabled = true;
//    parent.job_tour.document.tourForm.von_tr_commission_noButton.className = "commission_no_disabled";
//    parent.job_tour.document.tourForm.nach_tr_commission_noButton.disabled = true;
//    parent.job_tour.document.tourForm.nach_tr_commission_noButton.className = "commission_no_disabled";
//      parent.job_tour.document.tourForm.von_tr_commission_no.className = "input";
//      parent.job_tour.document.tourForm.von_tr_commission_no.disabled = true;
//      parent.job_tour.document.tourForm.nach_tr_commission_no.className = "input";
//      parent.job_tour.document.tourForm.nach_tr_commission_no.disabled = true;
      parent.job_tour.document.tourForm.jb_commission_no.className = "input";
      parent.job_tour.document.tourForm.jb_commission_no.disabled = true;
}
  if (trim(parent.job_tour.document.tourForm.jb_commission_no.value) != "" || !is_commission_no(curCsc_id_payer)) {
    parent.job_tour.document.tourForm.jb_commission_no.className = "input";
  } else {
    parent.job_tour.document.tourForm.jb_commission_no.className = "inputRed";
  }
//  if (typeof(parent.job_tour.document.tourForm.dritt_cmp_remarkButton) != 'undefined') {
    if (get_cmp_remark(curCsc_id_payer) != ""
      && get_cmp_remark(getJobList(curTourNo, jl_csc_id)) != get_cmp_remark(curCsc_id_payer) && get_cmp_remark(getJobList(curTourNo + 1, jl_csc_id)) != get_cmp_remark(curCsc_id_payer)
    ) {
      parent.job_tour.document.getElementById("dritt_cmp_remark_div").innerHTML = 'Bemerkung Zahler' + (i_payer == -1 ? '&nbsp;3' : '') + '<br><textarea class="input ' + parent.job_tour.cmp_remark_payer_style + '" disabled">' + get_cmp_remark(curCsc_id_payer) + '</textarea>';
//      parent.job_tour.document.tourForm.dritt_cmp_remarkButton.disabled = false;
//      parent.job_tour.document.tourForm.dritt_cmp_remarkButton.className = "commission_no_enabled";
    } else {
      parent.job_tour.document.getElementById("dritt_cmp_remark_div").innerHTML = '&nbsp;';
//      parent.job_tour.document.tourForm.dritt_cmp_remarkButton.disabled = true;
//      parent.job_tour.document.tourForm.dritt_cmp_remarkButton.className = "button_disabled";
    }
//  }

if(getJobList(curTourNo,jl_tr_commission_no)!=""||empModeLaterJob=="1"||commission_no_on=="1")
  {
//    parent.job_tour.document.tourForm.von_tr_commission_noButton.disabled = false;
////    parent.job_tour.document.tourForm.von_tr_commission_noButton.className = "button_enabled";
    parent.job_tour.document.tourForm.von_tr_commission_no.disabled = false;
  }
if(getJobList(curTourNo+1,jl_tr_commission_no)!=""||empModeLaterJob=="1"||commission_no_on=="1")
  {
//    parent.job_tour.document.tourForm.nach_tr_commission_noButton.disabled = false;
////    parent.job_tour.document.tourForm.nach_tr_commission_noButton.className = "button_enabled";
    parent.job_tour.document.tourForm.nach_tr_commission_no.disabled = false;
  }
for(j=j+1;j<(maxTour+1);j++)
setJobList(j,jl_csc_id_payer,"disabled");
if(oldCurCsc_id_payer!=curCsc_id_payer)
{
checkJb_tourname();

    if (get_cs_tracking(curCsc_id_payer) == 1) {
      parent.job_tour.document.getElementById('tr_tracking_row').style.visibility = 'visible';
	  if (curTourNo > 0) {
        parent.job_tour.document.getElementById('tr_tracking_von').style.visibility = 'visible';
      } else {
        parent.job_tour.document.getElementById('tr_tracking_von').style.visibility = 'collapse';
      }
      parent.job_tour.document.getElementById('tr_tracking_nach').style.visibility = 'visible';
    } else {
      parent.job_tour.document.getElementById('tr_tracking_row').style.visibility = 'collapse';
      parent.job_tour.document.getElementById('tr_tracking_nach').style.visibility = 'collapse';
      parent.job_tour.document.getElementById('tr_tracking_von').style.visibility = 'collapse';
    }
}
    parent.job_options.document.tourOptions.jb_jam_waittime.value = get_cs_jb_jam_waittime(curCsc_id_payer);
    if (parent.job_options.document.tourOptions.jb_jam_waittime.value == "0")
      parent.job_options.document.tourOptions.jb_jam_waittime.value = "";
checkTourDirty(getCurTourNo());
checkTourDirty(getCurTourNo()+1);
var locationdata=
"<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">\n"+
"<html lang=\"de\">\n"+
"<head>\n"+
"<title>votian: Auftragserfassung - Tourendaten<\/title>\n"+
"<link rel=\"stylesheet\" type=\"text/css\" href=\"../css/phoenix.css\">\n"+
"<script type=\"text/javascript\">\n"+
"<!"+"--\n"+
"\n"+
"// Opens a new (popup-)window with specified parameters\n"+
"function popupWindow(url,title,config) {\n"+
"  popup = window.open(url,title,config);\n"+
"}"+
"\n"+
"function reloadPrice()\n"+
"{\n"+
"  self.setTimeout('document.reloadPrice.submit()',100);\n"+
"}\n"+
"\n"+
"//--"+">\n"+
"<\/script>\n"+
"<\/head>\n"+
"<body>\n"+
"  <form name=\"reloadPrice\" action=\"../jobs2/job_options.php\" method=\"post\">\n"+
mkFieldsReloadPrice()+
"    <input type=\"hidden\" name=\"getPriceOnly\" value=\"1\">\n"+
"  <\/form>\n"+
"  <table border=0 width=100% align=center cellspacing=0 cellpadding=0 vspace=0 hspace=0>\n"+
"    <tr>\n"+
"      <td colspan=3>\n"+
"        <hr noshade size=\"1\">\n"+
"      <\/td>\n"+
"    <\/tr>\n"+
"    <tr>\n"+
"      <td width=20%>\n"+
listLink+
"        &nbsp;\n"+
"      <\/td>\n"+
"      <td width=60% align=center valign=top>\n"+
"        <div class=headline2>\n"+
"          Tourendaten (Etappen)\n"+
"        <\/div>\n"+
"      <\/td>\n"+
"      <td width=20%>\n"+
detailLink+
"        &nbsp;\n"+
"      <\/td>\n"+
"    <\/tr>\n"+
"    <tr>\n"+
"      <td>\n"+
"        &nbsp;\n"+
"      <\/td>\n"+
"      <td align=center>\n";
var tourname1="";
var tourname2="";
var j=0;
while((getJobList(j,jl_csc_id)!=""||checkTourComplete(j))&&
(getJobList(j+1,jl_csc_id)!=""||checkTourComplete(j+1)))
{
tourname1=getOptionTextByVal("job_tour","tourForm","von_csc_id",getJobList(j,jl_csc_id));
if(tourname1=="")tourname1=getJobList(j,jl_tr_comp);
tourname2=getOptionTextByVal("job_tour","tourForm","nach_csc_id",getJobList(j+1,jl_csc_id));
if(tourname2=="")tourname2=getJobList(j+1,jl_tr_comp);
tourLink="<a href=javascript:parent.job_options.moveToTour("+j+")><b>"+
tourname1+
"<\/b>&nbsp;&nbsp;<img src=\"../images/next1.gif\" border=0>&nbsp;&nbsp;<b>"+
tourname2+
"<\/b><\/a><br>";
locationdata += tourLink;
if(++j>=maxTour)
break;
}
locationdata +=
"      <\/td>\n"+
"      <td>\n"+
"        &nbsp;\n"+
"      <\/td>\n"+
"    <\/tr>\n"+
"    <tr>\n"+
"      <td colspan=3>\n"+
"        <img src=\"../images/empty.gif\" border=0 height=2>\n"+
"      <\/td>\n"+
"    <\/tr>\n"+
"  <\/table>\n"+
"<\/body>\n"+
    "<\/html>\n" +
    "<script type=\"text/javascript\">\n" +
    "<!" + "--\n" +
    onLoadFunc +
    "//--" + ">\n" +
    "<\/script>\n";
//if (navigator.userAgent.indexOf("Firefox") == -1) {
  parent.job_tour_list.document.open();
  parent.job_tour_list.document.write(locationdata);
  parent.job_tour_list.document.close();
//} else {
//  var url = "javascript:(function(){var html = '" + btoa(locationdata)
//               +"';document.open();document.write(atob(html));document.close();})();";
//  parent.job_tour_list.location.href=url;
//}
checkSendTour();
}
function checkTourComplete(i)
{
if((getJobList(i,jl_tr_comp)).replace(/\s/,"").length==0)return false;
if((getJobList(i,jl_ad_street)).replace(/\s/,"").length==0)return false;
if((getJobList(i,jl_tr_hsno)).replace(/\s/,"").length==0)return false;
if((getJobList(i,jl_ad_zipcode)).replace(/\s/,"").length==0)return false;
if((getJobList(i,jl_ad_city)).replace(/\s/,"").length==0)return false;
return true;
}
function checkSendTour()
{
var newCsc=Array(true,true);
var payer_selected=false;
var afterwards_ok=true;

if(is_exported&&jb_id!="")
{
parent.job_options.document.tourOptions.toursubmit.disabled=true;
parent.job_options.document.tourOptions.tourOptions_submit_disabled.value = parent.job_options.document.tourOptions.toursubmit.disabled;
// 2016-03-04: Das Problem mit dem Blockieren der "Senden"-Taste beim Kunden
// STB976835 kann nicht reproduiziert werden. Deshalb darf dieser Kunde immer senden.
if (cs_id=="839286")
  parent.job_options.document.tourOptions.toursubmit.disabled=false;
return;
}
for(var i=0;i<(maxTour+1);i++)
{
if(checkTourDirty(i))
{
parent.job_options.document.tourOptions.toursubmit.disabled=true;
parent.job_options.document.tourOptions.tourOptions_submit_disabled.value = parent.job_options.document.tourOptions.toursubmit.disabled;
// 2016-03-04: Das Problem mit dem Blockieren der "Senden"-Taste beim Kunden
// STB976835 kann nicht reproduiziert werden. Deshalb darf dieser Kunde immer senden.
if (cs_id=="839286")
  parent.job_options.document.tourOptions.toursubmit.disabled=false;
return;
}
}
for(var i=0;i<2;i++)
{
newCsc[i]=checkTourComplete(i);
}
if(typeof(parent.job_tour.document.tourForm.jb_cash)!='undefined'){
if(((newCsc[0])&&
(newCsc[1]))
||((newCsc[0])&&
(parent.job_options.document.tourOptions.vht_id.value==7||
parent.job_tour.document.tourForm.jb_cash.checked||
parent.job_options.document.tourOptions.csc_id_payer.value!=""||
getJobList(0,jl_csc_id_payer)=="true"
))){
parent.job_options.document.tourOptions.toursubmit.disabled=false;
}else{
parent.job_options.document.tourOptions.toursubmit.disabled=true;
}
}else{
if(((newCsc[0])&&
(newCsc[1]))
||((newCsc[0])&&
(parent.job_options.document.tourOptions.vht_id.value==7||
parent.job_options.document.tourOptions.csc_id_payer.value!=""||
getJobList(0,jl_csc_id_payer)=="true"
))){
parent.job_options.document.tourOptions.toursubmit.disabled=false;
}else{
parent.job_options.document.tourOptions.toursubmit.disabled=true;
}
}
for(i=0;i<(maxTour+1);i++)
if(getJobList(i,jl_csc_id_payer)=="true")
payer_selected=true;
if(typeof(parent.job_options.document.tourOptions.afterwards)!='undefined')
if(parent.job_options.document.tourOptions.afterwards.checked)
if(parent.job_options.document.tourOptions.cr_id_order.value=="")
afterwards_ok=false;
if(typeof(parent.job_tour.document.tourForm.jb_costsplit)!='undefined'){
if(!payer_selected&&!parent.job_tour.document.tourForm.jb_costsplit.checked&&
(!parent.job_tour.document.tourForm.jb_cash.checked&&parent.job_options.document.tourOptions.csc_id_payer.value=="")
||!afterwards_ok
||(cash_payer_select=="1"&&(!payer_selected&&parent.job_options.document.tourOptions.csc_id_payer.value==""))){
parent.job_options.document.tourOptions.toursubmit.disabled=true;
}
}
parent.job_options.document.tourOptions.tourOptions_submit_disabled.value = parent.job_options.document.tourOptions.toursubmit.disabled;
// 2016-03-04: Das Problem mit dem Blockieren der "Senden"-Taste beim Kunden
// STB976835 kann nicht reproduiziert werden. Deshalb darf dieser Kunde immer senden.
if (cs_id=="839286")
  parent.job_options.document.tourOptions.toursubmit.disabled=false;
//alert(cs_id);
}
function checkCr_id_order()
{
var found=false;
if(parent.job_options.document.tourOptions.cr_id_order.value!=""&&cr_id_order_list.length!=0)
{
for(var i=0;i<cr_id_order_list.length;i++)
{
if(getCr_id(cr_id_order_list,i)==
parent.job_options.document.tourOptions.cr_id_order.value)
{
if(jb_id=="")
parent.job_options.document.tourOptions.jb_waitstorno.disabled=false;
found=true;
break;
}
}
if(!found)
{
alert("Die Kuriernummer '"+parent.job_options.document.tourOptions.cr_id_order.value+"' ist ungültig!");
parent.job_options.document.tourOptions.cr_id_order.value="";
}
}
if(parent.job_options.document.tourOptions.cr_id_order.value=="")
{
if(typeof(parent.job_options.document.tourOptions.jb_waitstorno)!='undefined')
{
parent.job_options.document.tourOptions.jb_waitstorno.checked=false;
parent.job_options.document.tourOptions.jb_waitstorno.disabled=true;
}
}
checkSendTour();
}
function checkWeight(source)
{
//alert ("Filter: " + parent.job_options.document.tourOptions.jb_cr_filter.value);
  if (source == 1)
  {
    var indexOfBI = 0;
    for (var i = 0; i < cfl.length; i++)
    {
      if (cfl[i][0] == "BI")
      {
      	indexOfBI = i;
        break;
      }
    }

    if (parent.job_options.document.tourOptions.vht_id.value == 1 && cfl[indexOfBI][3] == 0 && indexOfBI > 0)
    {
      // Wenn Fahrrad gewählt ist, dann den entsprechenden Filter setzen
      cfl[indexOfBI][3] = 1;
      if (parent.job_options.document.tourOptions.jb_cr_filter.value != "")
        parent.job_options.document.tourOptions.jb_cr_filter.value = parent.job_options.document.tourOptions.jb_cr_filter.value + ",";
      parent.job_options.document.tourOptions.jb_cr_filter.value = parent.job_options.document.tourOptions.jb_cr_filter.value + "BI";
//alert ("Filter set: " + parent.job_options.document.tourOptions.jb_cr_filter.value);
    }
    if (parent.job_options.document.tourOptions.vht_id.value != 1 && cfl[indexOfBI][3] == 1 && indexOfBI > 0)
    {
      // Wenn Fahrrad nicht gewählt ist, dann den entsprechenden Filter löschen
      cfl[indexOfBI][3] = 0;
      parent.job_options.document.tourOptions.jb_cr_filter.value = parent.job_options.document.tourOptions.jb_cr_filter.value.replace(",BI","").replace("BI,","").replace("BI","");
//alert ("Filter unset: " + parent.job_options.document.tourOptions.jb_cr_filter.value);
    }
    if (typeof(parent.job_options.document.tourOptions.jb_cr_filterButton) != 'undefined') {
      if (parent.job_options.document.tourOptions.jb_cr_filter.value == "" &&
          parent.job_options.document.tourOptions.jb_cr_filter_opt.value == "")
        parent.job_options.document.tourOptions.jb_cr_filterButton.value = "Filter";
      else
        parent.job_options.document.tourOptions.jb_cr_filterButton.value = "Filter*";
    }
  }
checkSendTour();
writeJob();
}
/*
 * Quelle: http://www.evocomp.de/beispiele/javascript/trim.html
 */
// Führende und Abschließende Whitespaces (Leerzeichen, Tabulatoren, ...)
// aus der übergebenen Zeichenkette entfernen.
function trim (zeichenkette) {
  // Erst führende, dann Abschließende Whitespaces entfernen
  // und das Ergebnis dieser Operationen zurückliefern
  return zeichenkette.replace (/^\s+/, '').replace (/\s+$/, '');
}

/*
 * checkDimensions
 *   params: -
 *   return: -
 *   global: job_options, tourOptions, cr_id_order
 *
 * Diese Funktion stellt sicher, dass in jb_crvh_length, jb_crvh_width, jb_crvh_height
 * und jb_crvh_position nur gültige Werte stehen können.
 */

function checkDimensions(source)
{
  var val = "";

  if (source == 0)
    val = parent.job_options.document.tourOptions.jb_crvh_length.value;
  if (source == 1)
    val = parent.job_options.document.tourOptions.jb_crvh_width.value;
  if (source == 2)
    val = parent.job_options.document.tourOptions.jb_crvh_height.value;
  if (source == 3)
    val = parent.job_options.document.tourOptions.jb_crvh_position.value;
  if (trim(val) == "")
  {
    alertIsOpen = true;
    alert("Bitte eine ganze Zahl angeben" +
      " (wenn unerheblich, dann \"0\" eintragen)!");
    alertIsOpen = false;
    val = "0";
  }
  if (isNaN(val))
  {
    alertIsOpen = true;
    alert("An dieser Stelle sind nur ganze Zahlen zulässig.");
    alertIsOpen = false;
    val = "0";
  }
  if (parseFloat(val) != parseInt(val))
  {
    alertIsOpen = true;
    alert("An dieser Stelle sind nur ganze Zahlen zulässig.");
    alertIsOpen = false;
    val = "0";
  }
  
  if (source == 0) {
    parent.job_options.document.tourOptions.jb_crvh_length.value = val;
    parent.job_options.document.tourOptions.jb_crvh_length.focus();
  }
  if (source == 1) {
    parent.job_options.document.tourOptions.jb_crvh_width.value = val;
    parent.job_options.document.tourOptions.jb_crvh_width.focus();
  }
  if (source == 2) {
    parent.job_options.document.tourOptions.jb_crvh_height.value = val;
    parent.job_options.document.tourOptions.jb_crvh_height.focus();
  }
  if (source == 3) {
    parent.job_options.document.tourOptions.jb_crvh_position.value = val;
    parent.job_options.document.tourOptions.jb_crvh_position.focus();
  }
  checkSendTour();
  writeJob();
}
function check_jb_commission_no() {
  parent.job_options.document.tourOptions.jb_commission_no_hidden.value = trim(parent.job_tour.document.tourForm.jb_commission_no.value);
  if (trim(parent.job_tour.document.tourForm.jb_commission_no.value) != "" || !is_commission_no(curCsc_id_payer)) {
    parent.job_tour.document.tourForm.jb_commission_no.className = "input";
  } else {
    parent.job_tour.document.tourForm.jb_commission_no.className = "inputRed";
  }
}
function formatPrice(aStr)
{
var partsSum=aStr.split(",");
if(partsSum.length>1){
if(partsSum[1].length<1){
aStr=aStr+"00";
}else{
if(partsSum[1].length<2)
aStr=aStr+"0";
}
}else{
if(partsSum[0].length>0)
aStr=aStr+",00";
}
return aStr;
}
function checkFixprice()
{
if((parent.job_options.document.tourOptions.jb_fixprice.value!="")&&
isNaN(parent.job_options.document.tourOptions.jb_fixprice.value.replace(/,/,".")))
{
alert("Festpreis bitte in der Form '999999,99' eingeben.");
parent.job_options.document.tourOptions.jb_fixprice.value="";
parent.job_options.document.tourOptions.jb_fixprice.focus();
}
var parts=parent.job_options.document.tourOptions.jb_fixprice.value.replace(/,/,".").split(".");
if(parts.length>1)
{
if(parts[1].length>2)
{
alert("Festpreis bitte in der Form '999999,99' eingeben.");
parent.job_options.document.tourOptions.jb_fixprice.value="";
parent.job_options.document.tourOptions.jb_fixprice.focus();
}
}
checkDiscount();
}
function checkServiceprice()
{
if((parent.job_options.document.tourOptions.jb_serviceprice.value!="")&&
isNaN(parent.job_options.document.tourOptions.jb_serviceprice.value.replace(/,/,".")))
{
alert("Servicepreis bitte in der Form '999999,99' eingeben.");
parent.job_options.document.tourOptions.jb_serviceprice.value="";
parent.job_options.document.tourOptions.jb_serviceprice.focus();
}
var parts=parent.job_options.document.tourOptions.jb_serviceprice.value.replace(/,/,".").split(".");
if(parts.length>1)
{
if(parts[1].length>2)
{
alert("Servicepreis bitte in der Form '999999,99' eingeben.");
parent.job_options.document.tourOptions.jb_serviceprice.value="";
parent.job_options.document.tourOptions.jb_serviceprice.focus();
}
}
checkDiscount();
}
function checkDiscount()
{
if(typeof(parent.job_options.document.tourOptions.jb_discount)=='undefined')
return;
if(get_cs_discount(curCsc_id_payer)>0&&((parent.job_options.document.tourOptions.jb_fixprice.value!=""
&&parent.job_options.document.tourOptions.jb_fixprice.value!="0,00"&&parent.job_options.document.tourOptions.jb_fixprice.value!="0,0"
&&parent.job_options.document.tourOptions.jb_fixprice.value!="0,"&&parent.job_options.document.tourOptions.jb_fixprice.value!="0")
||(parent.job_options.document.tourOptions.jb_serviceprice.value!=""
&&parent.job_options.document.tourOptions.jb_serviceprice.value!="0,00"&&parent.job_options.document.tourOptions.jb_serviceprice.value!="0,0"
&&parent.job_options.document.tourOptions.jb_serviceprice.value!="0,"&&parent.job_options.document.tourOptions.jb_serviceprice.value!="0"))){
if(parent.job_options.document.tourOptions.jb_discount.disabled){
parent.job_options.document.tourOptions.jb_discount.disabled=false;
if(discount_default)
parent.job_options.document.tourOptions.jb_discount.checked=true;
}
parent.job_options.document.tourOptions.jb_discount_rate_text.value="("+get_cs_discount(curCsc_id_payer)+"%)";
parent.job_options.document.tourOptions.jb_discount_rate.value=get_cs_discount(curCsc_id_payer);
}else{
if(!parent.job_options.document.tourOptions.jb_discount.disabled){
parent.job_options.document.tourOptions.jb_discount.disabled=true;
if(callerID!="writeJob")
parent.job_options.document.tourOptions.jb_discount.checked=false;
}
parent.job_options.document.tourOptions.jb_discount_rate_text.value="";
parent.job_options.document.tourOptions.jb_discount_rate.value="0";
}
}
function mkCscList(side)
{
var customerId=parent.job_options.cs_id_ec;
var cscIdRoot=csc_id_orderer_root_ec;
var cscIdActual=csc_id_orderer_ec;
var f_comp;
var f_person;
var f_street;
var f_hsno;
var f_zipcode;
var f_city;
var f_country;
var f_remark;
if(side==0)
{
f_comp=parent.job_tour.document.tourForm.elements[von_fields[jl_tr_comp]].value;
f_person=parent.job_tour.document.tourForm.elements[von_fields[jl_tr_person]].value;
f_street=parent.job_tour.document.tourForm.elements[von_fields[jl_ad_street]].value;
f_hsno=parent.job_tour.document.tourForm.elements[von_fields[jl_tr_hsno]].value;
f_zipcode=parent.job_tour.document.tourForm.elements[von_fields[jl_ad_zipcode]].value;
f_city=parent.job_tour.document.tourForm.elements[von_fields[jl_ad_city]].value;
f_country="D";
f_remark=parent.job_tour.document.tourForm.elements[von_fields[jl_tr_remark]].value;
}
if(side==1)
{
f_comp=parent.job_tour.document.tourForm.elements[nach_fields[jl_tr_comp]].value;
f_person=parent.job_tour.document.tourForm.elements[nach_fields[jl_tr_person]].value;
f_street=parent.job_tour.document.tourForm.elements[nach_fields[jl_ad_street]].value;
f_hsno=parent.job_tour.document.tourForm.elements[nach_fields[jl_tr_hsno]].value;
f_zipcode=parent.job_tour.document.tourForm.elements[nach_fields[jl_ad_zipcode]].value;
f_city=parent.job_tour.document.tourForm.elements[nach_fields[jl_ad_city]].value;
f_country="D";
f_remark=parent.job_tour.document.tourForm.elements[nach_fields[jl_tr_remark]].value;
}
tempWin=mkPopupWin(
"function startReload()\n"+
"{\n"+
"  checkDone();\n"+
"  self.location.href=\"csc_list.php"+
"?customerId="+customerId+
"&cscIdRoot="+cscIdRoot+
"&cscIdActual="+cscIdActual+
"&f_comp="+f_comp+
"&f_person="+f_person+
"&f_street="+f_street+
"&f_hsno="+f_hsno+
"&f_zipcode="+f_zipcode+
"&f_city="+f_city+
"&f_country="+f_country+
"&f_remark="+f_remark+
"&tourNo="+(getCurTourNo()+side)+
"&f_act=search"+"\";\n"+
"}\n"+
"\n"+
"//--"+">\n"+
"<\/script>\n"+
"<\/head>\n"+
"<body onLoad=\"startReload()\"\n>"+
"  <table border=0 align=center height=100% cellspacing=0 cellpadding=0 vspace=0 hspace=0>\n"+
"    <tr>\n"+
"      <td align=center valign=center>\n"+
"        <b>Hole Daten...</b>\n"+
"      <\/td>\n"+
"    <\/tr>\n"+
"  <\/table>\n"+
"<\/body>\n"+
"<\/html>\n",1000,480);
}
function searchCsCsc(side){
var f_comp;
var f_act='search';
var tourno=(getCurTourNo()+side);
if(side==0)
{
f_comp=parent.job_tour.document.tourForm.elements[von_fields[jl_tr_comp]].value;
}
if(side==1)
{
f_comp=parent.job_tour.document.tourForm.elements[nach_fields[jl_tr_comp]].value;
}
if(side==2)
{
f_comp=parent.job_options.document.tourOptions.comp_payer.value;
tourno=-1;
}
var widthPopupWin=950;
var heightPopupWin=600;
var leftPopupWin=(screen.width / 2)-(widthPopupWin / 2)-12;
var topPopupWin=(screen.height / 2)-(heightPopupWin / 2)-50;
var popupWin;
if(parent.job_options.document.tourOptions.csc_id_orderer.value!=""&&parent.job_options.document.tourOptions.csc_id_orderer.value!=0){
var customerId=parent.job_options.cs_id_ec;
var cscIdRoot=csc_id_orderer_root_ec;
var cscIdActual=csc_id_orderer_ec;
popupWin=window.open("../customer/csc_list.php?"+
"customerId="+customerId+"&cscIdRoot="+cscIdRoot+"&cscIdActual="+cscIdActual+
"&f_act="+f_act+
"&f_cmp_comp="+myEncodeURI(f_comp)+"&f_cmp_authenticated="+1+
"&tourno="+tourno+"&csc_id="+curCsc_id_payer,
"","dependent=yes,width="+widthPopupWin+",height="+
heightPopupWin+",left="+leftPopupWin+",top="+topPopupWin+
",scrollbars=yes,resizable=yes,staus=no");
}else{
popupWin=window.open("../admin/cs_csc_list.php?f_act="+f_act+
"&f_cmp_comp="+myEncodeURI(f_comp)+"&f_cmp_authenticated="+1+
"&tourno="+tourno,
"","dependent=yes,width="+widthPopupWin+",height="+
heightPopupWin+",left="+leftPopupWin+",top="+topPopupWin+
",scrollbars=yes,resizable=yes,staus=no");
}
};
function searchJbList(){
var leftFields=parent.job_tour.document.tourForm;
var f_act='search';
var tourno=(getCurTourNo());
var customerId=parent.job_options.cs_id_ec;
var cscIdRoot=csc_id_orderer_root_ec;
var cscIdActual=csc_id_orderer_ec;
var f_cmp_comp=leftFields.elements[von_fields[jl_tr_comp]].value;
var f_person=leftFields.elements[von_fields[jl_tr_person]].value;
var f_street=leftFields.elements[von_fields[jl_ad_street]].value;
var f_hsno=leftFields.elements[von_fields[jl_tr_hsno]].value;
var f_zipcode=leftFields.elements[von_fields[jl_ad_zipcode]].value;
var f_city=leftFields.elements[von_fields[jl_ad_city]].value;
var f_remark=leftFields.elements[von_fields[jl_tr_remark]].value;
var widthPopupWin=950;
var heightPopupWin=600;
var leftPopupWin=(screen.width / 2)-(widthPopupWin / 2)-12;
var topPopupWin=(screen.height / 2)-(heightPopupWin / 2)-50;
var popupWin;
popupWin=window.open("../jobs/jb_search_list.php"+
"?customerId="+customerId+
"&cscIdRoot="+cscIdRoot+
"&cscIdActual="+cscIdActual+
"&f_act="+f_act+
"&f_cmp_comp="+myEncodeURI(f_cmp_comp)+
"&f_person="+myEncodeURI(f_person)+"&f_street="+myEncodeURI(f_street)+"&f_hsno="+ myEncodeURI(f_hsno)+
"&f_zipcode="+myEncodeURI(f_zipcode)+"&f_city="+myEncodeURI(f_city)+"&f_remark="+myEncodeURI(f_remark)+
"&tourno="+tourno,
"","dependent=yes,width="+widthPopupWin+",height="+
heightPopupWin+",left="+leftPopupWin+",top="+topPopupWin+
",scrollbars=yes,resizable=yes,status=no");
};
function duplicateJob(){
if(confirm("Wollen Sie wirklich einen neuen Auftrag erzeugen?"))
{
parent.job_options.document.tourOptions.jb_id_org.value=jb_id;
jb_id="";
parent.job_options.document.tourOptions.jb_id.value="";
parent.job_tour.document.tourForm.duplicateJobButton.disabled=true;
if(empModeCopyJob!="1"){
if(typeof(parent.job_options.document.tourOptions.cr_id_order)!='undefined')
parent.job_options.document.tourOptions.cr_id_order.value="";
if(typeof(parent.job_options.document.tourOptions.jb_permanent)!='undefined'){
setDateTimeFields("job_options","tourOptions","","","","","","tag","monat","jahr","stunde","minute","jb_permanent");
checkJb_permanent();
}else{
setDateTimeFields("job_options","tourOptions","","","","","","tag","monat","jahr","stunde","minute","");
}
if(typeof(parent.job_options.document.tourOptions.endetag)!='undefined')
setDateTimeFields("job_options","tourOptions","","","","","","endetag","endemonat","endejahr","","","");
if(typeof(parent.job_options.document.tourOptions.afterwards)!='undefined')
parent.job_options.document.tourOptions.afterwards.disabled=false;
if(manual_disposition=="1"&&typeof(parent.job_options.document.tourOptions.jb_status_manual)!='undefined'){
parent.job_options.document.tourOptions.jb_status_manual.disabled=false;
parent.job_options.document.tourOptions.jb_status_manual.checked=true;
}
}else{
if(typeof(parent.job_options.document.tourOptions.afterwards)!='undefined'){
parent.job_options.document.tourOptions.afterwards.disabled=false;
parent.job_options.document.tourOptions.afterwards.checked=true;
}
if(typeof(parent.job_options.document.tourOptions.jb_globaljob)!='undefined'){
parent.job_options.document.tourOptions.jb_globaljob.disabled=true;
parent.job_options.document.tourOptions.jb_globaljob.checked=false;
}
checkAfterwards();
}
if(typeof(parent.job_options.document.tourOptions.jb_waitstorno)!='undefined')
parent.job_options.document.tourOptions.jb_waitstorno.disabled=false;
if(typeof(parent.job_options.document.tourOptions.crSidList)!='undefined')
parent.job_options.document.tourOptions.crSidList.disabled=false;
if(typeof(parent.job_options.document.tourOptions.cr_id_order)!='undefined')
parent.job_options.document.tourOptions.cr_id_order.disabled=false;
if(typeof(parent.job_options.document.tourOptions.jb_tourname)!='undefined')
parent.job_options.document.tourOptions.jb_tourname.value="";
significantPriceValues="";
writeJob();
parent.frames[0].location.href="job_header.php?csc_id_orderer="+csc_id_orderer_ec+"&what_is_this=Auftragserfassung";
    if (fixprice_was_zone) {
      parent.job_options.document.tourOptions.jb_fixprice.value = "";
      parent.job_options.document.tourOptions.jb_cr_price.value = "";
    }
if(empModeCopyJob=="1")
{
}
}
};
function getLastJob(){
if(prev_jb_id!="")
parent.frames[0].location.href="job_header.php?csc_id_orderer="+csc_id_orderer_ec+"&what_is_this=Auftrags&auml;nderung (Nr. "+prev_jb_id+")";
parent.job_options.document.tourOptions.jb_id.value=prev_jb_id;
self.setTimeout('getSavedTour('+prev_jb_id+','+'true'+')',100);
return;
}
function mk_tr_remark_Text(side){
var widthPopupWin=520;
var heightPopupWin=200;
var leftPopupWin=(screen.width / 2)-(widthPopupWin / 2)-12;
var topPopupWin=(screen.height / 2)-(heightPopupWin / 2)-50;
var popupWin;
var tr_remark="";
if(side==0)
tr_remark=parent.job_tour.document.tourForm.von_tr_remark.value;
if(side==1)
tr_remark=parent.job_tour.document.tourForm.nach_tr_remark.value;
var popupdata =
"<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">\n"+
"<html lang=\"de\">\n"+
"<head>\n"+
"<title>votian: Freitexteingabe<\/title>\n"+
"<link rel=\"stylesheet\" type=\"text/css\" href=\"../css/phoenix.css\">\n"+
"<script type=\"text/javascript\">\n"+
"<!"+"--\n"+
"\n"+
"var side = "+side+";\n"+
"\n"+
"function doFocus(){\n"+
"  document.forms[0].tr_remark.focus();"+
"}\n"+
"\n"+
"function doDelete(){\n"+
"  document.forms[0].tr_remark.value = '';"+
"  document.forms[0].tr_remark.focus();"+
"}\n"+
"\n"+
"function doSave(){\n"+
"  if (side == 0)"+
"    opener.parent.job_tour.document.tourForm.von_tr_remark.value = document.forms[0].tr_remark.value;"+
"  if (side == 1)"+
"    opener.parent.job_tour.document.tourForm.nach_tr_remark.value = document.forms[0].tr_remark.value;"+
"  opener.saveFormFields();\n"+
"  self.close();\n"+
"}\n"+
"\n"+
"// Quelle: http://www.nak-webmaster.de/modules.php?name=News&file=article&sid=71\n"+
"function countDigits(){\n"+
"  var maxDigits = 400;\n"+
"  var areaString = document.forms[0].tr_remark.value;\n"+
"  var currLength = areaString.length + 1;\n"+
"  var restLength = maxDigits - currLength +1;\n"+
"  if ( restLength <  0 ) {\n"+
"    restLength = 0;\n"+
"  }\n"+
"\n"+
"//  document.forms[0].counter.value = restLength;\n"+
"  if (areaString.length  > maxDigits-1) {\n"+
"    //die folgende Zeile entfernt alle Zeichen die  > maxDigits sind\n"+
"    document.forms[0].tr_remark.value = document.forms[0].tr_remark.value.substring(0, maxDigits);\n"+
"  }\n"+
"}\n"+
"\n"+
"//--"+">\n"+
"<\/script>\n"+
"<\/head>\n"+
"<body onload=\"doFocus()\"\n>"+
"  <table border=0 align=center height=100% cellspacing=0 cellpadding=0 vspace=0 hspace=0>\n"+
"    <tr>\n"+
"      <td align=center valign=top>\n"+
"<form>"+
"<textarea name=\"tr_remark\" cols=\"60\" rows=\"8\" onKeyUp=\"countDigits()\" onClick=\"countDigits()\">"
+tr_remark+"</textarea>"+
"</form>"+
"<input type=\"button\" value=\"Abbrechen\" onClick=\"self.close()\" accesskey=\"a\">&nbsp;"+
"<input type=\"button\" value=\"Löschen\" onClick=\"doDelete()\" accesskey=\"l\">&nbsp;"+
"<input type=\"button\" value=\"Speichern\" onClick=\"doSave()\" accesskey=\"s\">&nbsp;"+
"      <\/td>\n"+
"    <\/tr>\n"+
"  <\/table>\n"+
"<\/body>\n"+
"<\/html>\n";
popupWin=window.open("about:blank",
"","dependent=yes,width="+widthPopupWin+",height="+heightPopupWin+
",left="+leftPopupWin+",top="+topPopupWin);
if (navigator.userAgent.indexOf("Firefox") == -1) {
  popupWin.document.open();
  popupWin.document.write(popupdata);
  popupWin.document.close();
} else {
  var url = "javascript:(function(){var html = '" + btoa(popupdata)
               +"';document.open();document.write(atob(html));document.close();})();";
  popupWin.location.href=url;
}
};
function mkRechnungsText(side){
var widthPopupWin=520;
var heightPopupWin=200;
var leftPopupWin=(screen.width / 2)-(widthPopupWin / 2)-12;
var topPopupWin=(screen.height / 2)-(heightPopupWin / 2)-50;
var popupWin;
var tr_remark="";
if(side==0)
tr_remark=parent.job_tour.document.tourForm.von_tr_remark.value;
if(side==1)
tr_remark=parent.job_tour.document.tourForm.nach_tr_remark.value;
if(parent.job_options.document.tourOptions.jb_freetext_1.value!=""&&tr_remark!="")
tr_remark="\n"+tr_remark;
var popupdata =
"<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">\n"+
"<html lang=\"de\">\n"+
"<head>\n"+
"<title>votian: Freitexteingabe<\/title>\n"+
"<link rel=\"stylesheet\" type=\"text/css\" href=\"../css/phoenix.css\">\n"+
"<script type=\"text/javascript\">\n"+
"<!"+"--\n"+
"\n"+
"function doFocus(){\n"+
"  document.forms[0].jb_freetext_1.focus();"+
"}\n"+
"\n"+
"function doDelete(){\n"+
"  document.forms[0].jb_freetext_1.value = '';"+
"  document.forms[0].jb_freetext_1.focus();"+
"}\n"+
"\n"+
"function doSave(){\n"+
"  opener.parent.job_options.document.tourOptions.jb_freetext_1.value = document.forms[0].jb_freetext_1.value;\n"+
"  if (document.forms[0].jb_freetext_1.value == \"\")\n"+
"    opener.parent.job_tour.document.tourForm.jb_freetextButton.value = \"Text\";\n"+
"  else\n"+
"    opener.parent.job_tour.document.tourForm.jb_freetextButton.value = \"Text*\";\n"+
"  self.close();\n"+
"}\n"+
"\n"+
"// Quelle: http://www.nak-webmaster.de/modules.php?name=News&file=article&sid=71\n"+
"function countDigits(){\n"+
"  var maxDigits = 400;   //maximale Zeichenanzahl\n"+
"  var areaString = document.forms[0].jb_freetext_1.value;\n"+
"  var currLength = areaString.length + 1;\n"+
"  var restLength = maxDigits - currLength +1;\n"+
"  if ( restLength <  0 ) {\n"+
"    restLength = 0;\n"+
"  }\n"+
"\n"+
"//  document.forms[0].counter.value = restLength;\n"+
"  if (areaString.length  > maxDigits-1) {\n"+
"    //die folgende Zeile entfernt alle Zeichen die  > maxDigits sind\n"+
"    document.forms[0].jb_freetext_1.value = document.forms[0].jb_freetext_1.value.substring(0, maxDigits);\n"+
"  }\n"+
"}\n"+
"\n"+
"//--"+">\n"+
"<\/script>\n"+
"<\/head>\n"+
"<body onload=\"doFocus()\"\n>"+
"  <table border=0 align=center height=100% cellspacing=0 cellpadding=0 vspace=0 hspace=0>\n"+
"    <tr>\n"+
"      <td align=center valign=top>\n"+
"<form>"+
"<textarea name=\"jb_freetext_1\" cols=\"60\" rows=\"8\" onKeyUp=\"countDigits()\" onClick=\"countDigits()\">"
+parent.job_options.document.tourOptions.jb_freetext_1.value+tr_remark+"</textarea>"+
"</form>"+
"<input type=\"button\" value=\"Abbrechen\" onClick=\"self.close()\" accesskey=\"a\">&nbsp;"+
"<input type=\"button\" value=\"Löschen\" onClick=\"doDelete()\" accesskey=\"l\">&nbsp;"+
"<input type=\"button\" value=\"Speichern\" onClick=\"doSave()\" accesskey=\"s\">&nbsp;"+
"      <\/td>\n"+
"    <\/tr>\n"+
"  <\/table>\n"+
"<\/body>\n"+
"<\/html>\n";
popupWin=window.open("about:blank",
"","dependent=yes,width="+widthPopupWin+",height="+heightPopupWin+
",left="+leftPopupWin+",top="+topPopupWin);
if (navigator.userAgent.indexOf("Firefox") == -1) {
  popupWin.document.open();
  popupWin.document.write(popupdata);
  popupWin.document.close();
} else {
  var url = "javascript:(function(){var html = '" + btoa(popupdata)
               +"';document.open();document.write(atob(html));document.close();})();";
  popupWin.location.href=url;
}
};

function mkDispoInfo() {
  var widthPopupWin = 400;
  var heightPopupWin = 140;
  var leftPopupWin = (screen.width / 2) - (widthPopupWin / 2) - 12;
  var topPopupWin = (screen.height / 2) - (heightPopupWin / 2) - 50;
  var popupWin;

  var jb_dispoinfo = parent.job_options.document.tourOptions.jb_dispoinfo.value;
  var jb_warnjahr =  parent.job_options.document.tourOptions.jb_warnjahr.value;
  var jb_warnmonat =  parent.job_options.document.tourOptions.jb_warnmonat.value;  
  var jb_warntag =  parent.job_options.document.tourOptions.jb_warntag.value;
  var jb_warnstunde =  parent.job_options.document.tourOptions.jb_warnstunde.value;
  var jb_warnminute =  parent.job_options.document.tourOptions.jb_warnminute.value; 
//isCurrentlySubmitting = false;
  var popupdata =
    "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">\n" +
    "<html lang=\"de\">\n" +
    "<head>\n" +
    "<title>votian: Eingabe der Dispo-Info<\/title>\n" +
    "<link rel=\"stylesheet\" type=\"text/css\" href=\"../css/phoenix.css.php\">\n" +
    "<script src=\"../include/lib_global.js\" type=\"text/javascript\"></script>\n" +
    "<script type=\"text/javascript\">\n" +
    "<!" + "--\n" +
    "\n" +
    "function doFocus(){\n" +
    "  document.forms[0].jb_dispoinfo.focus();" +
    "}\n" +
    "\n" +
    "function doDelete(){\n" +
    "  document.forms[0].jb_dispoinfo.value = '';" +
    "  document.forms[0].jb_warnjahr.value = '';" +
    "  document.forms[0].jb_warnmonat.value = '';" +
    "  document.forms[0].jb_warntag.value = '';" +
    "  document.forms[0].jb_warnstunde.value = '';" +
    "  document.forms[0].jb_warnminute.value = '';" +
    "  document.forms[0].jb_dispoinfo.focus();" +
    "}\n" +
    "\n" +
    "function doSave(){\n" +
    "  opener.parent.job_options.document.tourOptions.jb_dispoinfo.value = document.forms[0].jb_dispoinfo.value;\n" +
    "  opener.parent.job_options.document.tourOptions.jb_warnjahr.value = document.forms[0].jb_warnjahr.value;\n" +
    "  opener.parent.job_options.document.tourOptions.jb_warnmonat.value = document.forms[0].jb_warnmonat.value;\n" +
    "  opener.parent.job_options.document.tourOptions.jb_warntag.value = document.forms[0].jb_warntag.value;\n" +
    "  opener.parent.job_options.document.tourOptions.jb_warnstunde.value = document.forms[0].jb_warnstunde.value;\n" +
    "  opener.parent.job_options.document.tourOptions.jb_warnminute.value = document.forms[0].jb_warnminute.value;\n" +
    "  if (document.forms[0].jb_dispoinfo.value == \"\" &&\n" +
    "    document.forms[0].jb_warnjahr.value == \"\" && document.forms[0].jb_warnmonat.value == \"\" && document.forms[0].jb_warntag.value == \"\" &&" +
    "    document.forms[0].jb_warnstunde.value == \"\" && document.forms[0].jb_warnminute.value == \"\")" +
    "    opener.parent.job_tour.document.tourForm.jb_dispoInfoButton.value = \"Dispo Info\";\n" +
    "  else\n" +
    "    opener.parent.job_tour.document.tourForm.jb_dispoInfoButton.value = \"Dispo Info*\";\n" +
    "  opener.saveFormFields();\n" +
    "  opener.refreshFormFields();\n" +
    "  self.close();\n" +
    "}\n" +
    "\n" +
    "//--" + ">\n" +
    "<\/script>\n" +
    "<\/head>\n" +
    "<body onload=\"doFocus()\"\n>" +
    "  <table border=0 align=center height=100% cellspacing=0 cellpadding=0 vspace=0 hspace=0>\n" +
    "<form name=\"jb_dispoinfo_form\">\n" +
    "    <tr>\n" +
    "      <td align=left valign=top>\n" +
    "<b>Dispo Info:</b><br>\n" +
    "<input name=\"jb_dispoinfo\" type=\"text\" value=\"" + jb_dispoinfo + "\" size=\"30\" maxlength=\"30\" class=\"input\">\n" +
    "      <\/td>\n" +
    "    <\/tr>\n" +
    "    <tr>\n" +
    "      <td align=left valign=top>\n" +
    "<b>Enddatum/-uhrzeit:</b><br>\n" +
    "<input name=\"jb_warntag\" type=\"text\" size=\"2\" maxlength=\"2\" class=\"input\" value=\"" + jb_warntag + "\"\n" +
    "onchange=\"fillDateFields(0, '', 'jb_dispoinfo_form', 'jb_warntag', 'jb_warntag', 'jb_warnmonat', 'jb_warnjahr', 'jb_warnstunde', 'jb_warnminute', '')\">\n" +
    "<input name=\"jb_warnmonat\" type=\"text\" size=\"2\" maxlength=\"2\" class=\"input\" value=\"" + jb_warnmonat + "\"\n" +
    "onchange=\"fillDateFields(0, '', 'jb_dispoinfo_form', 'jb_warnmonat', 'jb_warntag', 'jb_warnmonat', 'jb_warnjahr', 'jb_warnstunde', 'jb_warnminute', '')\">\n" +
    "<input name=\"jb_warnjahr\" type=\"text\" size=\"4\" maxlength=\"4\" class=\"input\" value=\"" + jb_warnjahr + "\"\n" +
    "onchange=\"fillDateFields(0, '', 'jb_dispoinfo_form', 'jb_warnjahr', 'jb_warntag', 'jb_warnmonat', 'jb_warnjahr', 'jb_warnstunde', 'jb_warnminute', '')\">\n&nbsp;&nbsp;" +
    "<input name=\"jb_warnstunde\" type=\"text\" size=\"2\" maxlength=\"2\" class=\"input\" value=\"" + jb_warnstunde + "\"\n" +
    "onchange=\"fillDateFields(0, '', 'jb_dispoinfo_form', 'jb_warnstunde', 'jb_warntag', 'jb_warnmonat', 'jb_warnjahr', 'jb_warnstunde', 'jb_warnminute', '')\">\n" +
    "<input name=\"jb_warnminute\" type=\"text\" size=\"2\" maxlength=\"2\" class=\"input\" value=\"" + jb_warnminute + "\"\n" +
    "onchange=\"fillDateFields(0, '', 'jb_dispoinfo_form', 'jb_warnminute', 'jb_warntag', 'jb_warnmonat', 'jb_warnjahr', 'jb_warnstunde', 'jb_warnminute', '')\">\n" +
    "</form>" +
    "      <\/td>\n" +
    "    <\/tr>\n" +
    "    <tr>\n" +
    "      <td align=center valign=top>\n" +
    "<input type=\"button\" class=\"button_enabled\" value=\"Abbrechen\" onClick=\"self.close()\" accesskey=\"a\">&nbsp;" +
    "<input type=\"button\" class=\"button_enabled\" value=\"Löschen\" onClick=\"doDelete()\" accesskey=\"l\">&nbsp;" +
    "<input type=\"button\" class=\"button_enabled\" value=\"Speichern\" onClick=\"doSave()\" accesskey=\"s\">&nbsp;" +
    "      <\/td>\n" +
    "    <\/tr>\n" +
    "  <\/table>\n" +
    "<\/body>\n" +
    "<\/html>\n";
  popupWin1(widthPopupWin, heightPopupWin, leftPopupWin, topPopupWin, popupdata);
};

/*
function mk_tr_commission_no(side){
var widthPopupWin=400;
var heightPopupWin=100;
var leftPopupWin=(screen.width / 2)-(widthPopupWin / 2)-12;
var topPopupWin=(screen.height / 2)-(heightPopupWin / 2)-50;
var popupWin;
var tr_commission_no="";
if(side==0)
tr_commission_no=parent.job_tour.document.tourForm.von_tr_commission_no.value;
if(side==1)
tr_commission_no=parent.job_tour.document.tourForm.nach_tr_commission_no.value;
var popupdata =
"<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">\n"+
"<html lang=\"de\">\n"+
"<head>\n"+
"<title>votian: Eingabe der Kommissionsnummer<\/title>\n"+
"<link rel=\"stylesheet\" type=\"text/css\" href=\"../css/phoenix.css\">\n"+
"<script type=\"text/javascript\">\n"+
"<!"+"--\n"+
"\n"+
"var side = "+side+";\n"+
"\n"+
"function doFocus(){\n"+
"  document.forms[0].tr_commission_no.focus();"+
"}\n"+
"\n"+
"function doDelete(){\n"+
"  document.forms[0].tr_commission_no.value = '';"+
"  document.forms[0].tr_commission_no.focus();"+
"}\n"+
"\n"+
"function doSave(){\n"+
"  if (side == 0)"+
"    opener.parent.job_tour.document.tourForm.von_tr_commission_no.value = document.forms[0].tr_commission_no.value;"+
"  if (side == 1)"+
"    opener.parent.job_tour.document.tourForm.nach_tr_commission_no.value = document.forms[0].tr_commission_no.value;"+
"  opener.saveFormFields();\n"+
"  opener.refreshFormFields();\n"+
"  self.close();\n"+
"}\n"+
"\n"+
"//--"+">\n"+
"<\/script>\n"+
"<\/head>\n"+
"<body onload=\"doFocus()\"\n>"+
"  <table border=0 align=center height=100% cellspacing=0 cellpadding=0 vspace=0 hspace=0>\n"+
"    <tr>\n"+
"      <td align=center valign=top>\n"+
"<form>"+
"<input name=\"tr_commission_no\" type=\"text\" value=\""+tr_commission_no+"\" size=\"30\" maxlength=\"30\" class=\"input\">"+
"</form>"+
"<input type=\"button\" value=\"Abbrechen\" onClick=\"self.close()\" accesskey=\"a\">&nbsp;"+
"<input type=\"button\" value=\"Löschen\" onClick=\"doDelete()\" accesskey=\"l\">&nbsp;"+
"<input type=\"button\" value=\"Speichern\" onClick=\"doSave()\" accesskey=\"s\">&nbsp;"+
"      <\/td>\n"+
"    <\/tr>\n"+
"  <\/table>\n"+
"<\/body>\n"+
"<\/html>\n";
popupWin=window.open("about:blank",
"","dependent=yes,width="+widthPopupWin+",height="+heightPopupWin+
",left="+leftPopupWin+",top="+topPopupWin);
if (navigator.userAgent.indexOf("Firefox") == -1) {
  popupWin.document.open();
  popupWin.document.write(popupdata);
  popupWin.document.close();
} else {
  var url = "javascript:(function(){var html = '" + btoa(popupdata)
               +"';document.open();document.write(atob(html));document.close();})();";
  popupWin.location.href=url;
}
};

function mk_cmp_remark(side){
var widthPopupWin=520;
var heightPopupWin=200;
var leftPopupWin=(screen.width / 2)-(widthPopupWin / 2)-12;
var topPopupWin=(screen.height / 2)-(heightPopupWin / 2)-50;
var popupWin;
var curTourNo=(getCurTourNo());
var cmp_remark=get_cmp_remark(getJobList(curTourNo+side,jl_csc_id));
var comp=get_comp(getJobList(curTourNo+side,jl_csc_id));
var popupdata =
"<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">\n"+
"<html lang=\"de\">\n"+
"<head>\n"+
"<title>votian: Bemerkung zu Kunde "+comp+"<\/title>\n"+
"<link rel=\"stylesheet\" type=\"text/css\" href=\"../css/phoenix.css\">\n"+
"<script type=\"text/javascript\">\n"+
"<!"+"--\n"+
"\n"+
"function doFocus(){\n"+
"  document.forms[0].ok_button.focus();"+
"}\n"+
"\n"+
"//--"+">\n"+
"<\/script>\n"+
"<\/head>\n"+
"<body onload=\"doFocus()\"\n>"+
"<\/head>\n"+
"<body>\n"+
"  <table border=0 align=center height=100% cellspacing=0 cellpadding=0 vspace=0 hspace=0>\n"+
"    <tr>\n"+
"      <td align=center valign=top>\n"+
"<form>"+
"<textarea name=\"cmp_remark\" cols=\"60\" rows=\"8\" readonly>"
+cmp_remark+"</textarea>"+
"<br><input type=\"button\" name=\"ok_button\" value=\"OK\" onClick=\"self.close()\" accesskey=\"o\">&nbsp;"+
"</form>"+
"      <\/td>\n"+
"    <\/tr>\n"+
"  <\/table>\n"+
"<\/body>\n"+
"<\/html>\n";
popupWin=window.open("about:blank",
"","dependent=yes,width="+widthPopupWin+",height="+heightPopupWin+
",left="+leftPopupWin+",top="+topPopupWin);
if (navigator.userAgent.indexOf("Firefox") == -1) {
  popupWin.document.open();
  popupWin.document.write(popupdata);
  popupWin.document.close();
} else {
  var url = "javascript:(function(){var html = '" + btoa(popupdata)
               +"';document.open();document.write(atob(html));document.close();})();";
  popupWin.location.href=url;
}
};
*/
function is_in_customer_filters(crf_short)
{
if(crf_short.replace(/\s/,"").length==0)
return false;
for(var i=0;i<cs_filter_list_customer.length;i++){
if(cs_filter_list_customer[i]==crf_short){
return true;
}
}
return false;
}
function mkJb_cr_filter(){
var widthPopupWin=900;
var heightPopupWin=575;
var leftPopupWin=(screen.width / 2)-(widthPopupWin / 2)-12;
var topPopupWin=(screen.height / 2)-(heightPopupWin / 2)-50;
var popupWin;
var content="<tr>\n";
var jb_cr_filter_checked;
var savefunction="";
var j=0;
for(var i=0;i<cfl.length;i++)
{
if(cs_jbedit_cs_filter==""||is_in_customer_filters(cfl[i][0])){
if(j++%4==0)
content=content+"</tr>\n<tr>";
jb_cr_filter_checked="";
jb_cr_filter_musthave="";
jb_cr_filter_savefield="jb_cr_filter_opt";
if(cfl[i][2]==1)
{
jb_cr_filter_savefield="jb_cr_filter";
jb_cr_filter_musthave="*";
}
if(cfl[i][3]==1)
jb_cr_filter_checked="checked";
if(cfl[i][0]=="&nbsp;")
{
content=content+"<td align=left>"
+cfl[i][0]+jb_cr_filter_musthave+"</td><td align=left valign=center>&nbsp;&nbsp;&nbsp;"+cfl[i][1]+"</td>\n";
}else{
content=content+"<td align=left>"+
"<input type=\"checkbox\" name=\"jb_cr_filter_list"+i+"\" value=\"1\""+jb_cr_filter_checked+">"
+cfl[i][0]+jb_cr_filter_musthave+"</td><td align=left valign=center>&nbsp;&nbsp;&nbsp;"+cfl[i][1]+"</td>\n";
savefunction=savefunction+
"  if (document.jb_cr_filter_list.jb_cr_filter_list"+i+".checked)\n"+
"  { opener.cfl["+i+"][3] = 1;\n"+
"    "+jb_cr_filter_savefield+" = "+jb_cr_filter_savefield+" + \",\" + \""+cfl[i][0]+"\";}\n"+
"  else { opener.cfl["+i+"][3] = 0 };\n";
}
}
}
content=content+"</tr>\n";
var popupdata =
"<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">\n"+
"<html lang=\"de\">\n"+
"<head>\n"+
"<title>votian: Eingabe der Kurierfilter<\/title>\n"+
"<link rel=\"stylesheet\" type=\"text/css\" href=\"../css/phoenix.css\">\n"+
"<script type=\"text/javascript\">\n"+
"<!"+"--\n"+
"\n"+
"var jb_cr_filter = \"\";\n"+
"var jb_cr_filter_opt = \"\";\n"+
"\n"+
"function doSave(){\n"+
savefunction+
"  opener.parent.job_options.document.tourOptions.jb_cr_filter.value = jb_cr_filter.substr(1, jb_cr_filter.length - 1);\n"+
"  opener.parent.job_options.document.tourOptions.jb_cr_filter_opt.value = jb_cr_filter_opt.substr(1, jb_cr_filter_opt.length - 1);\n"+
"  if (opener.parent.job_options.document.tourOptions.jb_cr_filter.value == \"\" &&\n"+
"      opener.parent.job_options.document.tourOptions.jb_cr_filter_opt.value == \"\")\n"+
"    opener.parent.job_options.document.tourOptions.jb_cr_filterButton.value = \"Filter\";\n"+
"  else\n"+
"    opener.parent.job_options.document.tourOptions.jb_cr_filterButton.value = \"Filter*\";\n"+
"  self.close();\n"+
"}\n"+
"\n"+
"//--"+">\n"+
"<\/script>\n"+
"<\/head>\n"+
"<body>"+
"<table border=0 align=center width=100% height=90% cellspacing=0 cellpadding=0 vspace=0 hspace=0>\n"+
"<tr><td>"+
"  <table border=1 align=center width=100% cellspacing=0 cellpadding=0 vspace=0 hspace=0>\n"+
"<form name=\"jb_cr_filter_list\">"+
content+
"</form>"+
"  <\/table>\n"+
"</td><t/r>"+
"  <\/table>\n<br><center>"+
"<input type=\"button\" value=\"Abbrechen\" onClick=\"self.close()\" accesskey=\"a\">&nbsp;"+
"<input type=\"button\" value=\"Speichern\" onClick=\"doSave()\" accesskey=\"s\">&nbsp;"+
"<\/center><\/body>\n"+
"<\/html>\n";
popupWin=window.open("about:blank",
"","dependent=yes,width="+widthPopupWin+",height="+heightPopupWin+
",left="+leftPopupWin+",top="+topPopupWin);
if (navigator.userAgent.indexOf("Firefox") == -1) {
  popupWin.document.open();
  popupWin.document.write(popupdata);
  popupWin.document.close();
} else {
  var url = "javascript:(function(){var html = '" + btoa(popupdata)
               +"';document.open();document.write(atob(html));document.close();})();";
  popupWin.location.href=url;
}
};
function searchAddress(side){
var customerId=parent.job_options.cs_id_ec;
var cscIdRoot=csc_id_orderer_root_ec;
var cscIdActual=csc_id_orderer_ec;
var f_street;
var f_hsno;
var f_zipcode;
var f_city;
var f_act='search';
if(side==0)
{
f_street=parent.job_tour.document.tourForm.elements[von_fields[jl_ad_street]].value;
f_hsno=parent.job_tour.document.tourForm.elements[von_fields[jl_tr_hsno]].value;
f_zipcode=parent.job_tour.document.tourForm.elements[von_fields[jl_ad_zipcode]].value;
f_city=parent.job_tour.document.tourForm.elements[von_fields[jl_ad_city]].value;
}
if(side==1)
{
f_street=parent.job_tour.document.tourForm.elements[nach_fields[jl_ad_street]].value;
f_hsno=parent.job_tour.document.tourForm.elements[nach_fields[jl_tr_hsno]].value;
f_zipcode=parent.job_tour.document.tourForm.elements[nach_fields[jl_ad_zipcode]].value;
f_city=parent.job_tour.document.tourForm.elements[nach_fields[jl_ad_city]].value;
}
var widthPopupWin=800;
var heightPopupWin=600;
var leftPopupWin=(screen.width / 2)-(widthPopupWin / 2)-12;
var topPopupWin=(screen.height / 2)-(heightPopupWin / 2)-50;
var popupWin;
popupWin=window.open("../admin/ad_list.php?"+"customerId="+customerId+"&cscIdRoot="+cscIdRoot+"&cscIdActual="+cscIdActual+"&f_act="+f_act+"&f_street="+myEncodeURI(f_street)+"&f_hsno="+myEncodeURI(f_hsno)+"&f_zipcode="+myEncodeURI(f_zipcode)+"&f_city="+myEncodeURI(f_city)+"&tourno="+(getCurTourNo()+side),"","dependent=yes,width="+widthPopupWin+",height="+heightPopupWin+",left="+leftPopupWin+",top="+topPopupWin+",scrollbars=yes,resizable=yes,status=no");
};

function myEncodeURI(aString) {
  var aStringNew = "";
  for (i = 0; i < aString.length; i++) {
    aStringNew = aStringNew + '%' + aString.charCodeAt(i).toString(16);
  }
  return aStringNew;
};

function mk_tr_mediationarea_id(side){
var widthPopupWin=400;
var heightPopupWin=75;
var leftPopupWin=(screen.width / 2)-(widthPopupWin / 2)-12;
var topPopupWin=(screen.height / 2)-(heightPopupWin / 2)-50;
var popupWin;
var curTourNo=getCurTourNo();
var tr_mediationarea_id=getJobList(curTourNo+side,jl_tr_mediationarea_id);
var tr_mediationarea_id_options="";
for(i=0;i<fz.length;i++)
{
if(fz[i][0]==getJobList(curTourNo+side,jl_ad_zipcode))
{
tr_mediationarea_id_options+="<option ";
if(tr_mediationarea_id==fz[i][2])
tr_mediationarea_id_options+="selected ";
tr_mediationarea_id_options+=" value=\""+fz[i][2]+"\">"+fz[i][1]+" ("+fz[i][3]+")</option>\n";
}
}
var popupdata =
"<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">\n"+
"<html lang=\"de\">\n"+
"<head>\n"+
"<title>votian: Eingabe der Abrechnungs-PLZ<\/title>\n"+
"<link rel=\"stylesheet\" type=\"text/css\" href=\"../css/phoenix.css\">\n"+
"<script type=\"text/javascript\">\n"+
"<!"+"--\n"+
"\n"+
"var side = "+side+";\n"+
"\n"+
"function doFocus(){\n"+
"  document.forms[0].tr_mediationarea_id.focus();"+
"}\n"+
"\n"+
"function doDelete(){\n"+
"  document.forms[0].tr_mediationarea_id.value = '';"+
"  document.forms[0].tr_mediationarea_id.focus();"+
"}\n"+
"\n"+
"function doSave(){\n"+
"  opener.setJobList("+curTourNo+" + "+side+", opener.jl_tr_mediationarea_id, document.forms[0].tr_mediationarea_id.value);\n"+
"  opener.saveFormFields();\n"+
"  opener.resetSignificantPriceValues();\n"+
"  opener.refreshFormFields();\n"+
"  self.close();\n"+
"}\n"+
"\n"+
"//--"+">\n"+
"<\/script>\n"+
"<\/head>\n"+
"<body onload=\"doFocus()\"\n>"+
"  <table border=0 align=center height=100% cellspacing=0 cellpadding=0 vspace=0 hspace=0>\n"+
"    <tr>\n"+
"      <td align=center valign=top>\n"+
"<form>"+
"<select name=\"tr_mediationarea_id\" class=\"input\">"+
tr_mediationarea_id_options+
"</select>"+
"</form>"+
"<input type=\"button\" value=\"Abbrechen\" onClick=\"self.close()\" accesskey=\"a\">&nbsp;"+
"<input type=\"button\" value=\"Löschen\" onClick=\"doDelete()\" accesskey=\"l\">&nbsp;"+
"<input type=\"button\" value=\"Speichern\" onClick=\"doSave()\" accesskey=\"s\">&nbsp;"+
"      <\/td>\n"+
"    <\/tr>\n"+
"  <\/table>\n"+
"<\/body>\n"+
"<\/html>\n";
popupWin=window.open("about:blank",
"","dependent=yes,width="+widthPopupWin+",height="+heightPopupWin+
",left="+leftPopupWin+",top="+topPopupWin);
if (navigator.userAgent.indexOf("Firefox") == -1) {
  popupWin.document.open();
  popupWin.document.write(popupdata);
  popupWin.document.close();
} else {
  var url = "javascript:(function(){var html = '" + btoa(popupdata)
               +"';document.open();document.write(atob(html));document.close();})();";
  popupWin.location.href=url;
}
};
function mkPriceQuery(){
var widthPopupWin=420;
var heightPopupWin=320;
var leftPopupWin=(screen.width / 2)-(widthPopupWin / 2)-12;
var topPopupWin=(screen.height / 2)-(heightPopupWin / 2)-50;
var popupWin;
var curTourNo=(getCurTourNo());
var tr_mediationarea_id;
var zipcodes=[
getJobList(0,jl_ad_zipcode),
getJobList(1,jl_ad_zipcode),
getJobList(2,jl_ad_zipcode),
getJobList(3,jl_ad_zipcode),
getJobList(4,jl_ad_zipcode),
getJobList(5,jl_ad_zipcode)];
for(j=0;j<6;j++)
{
tr_mediationarea_id=getJobList(j,jl_tr_mediationarea_id);
if(tr_mediationarea_id!=0)
{
for(i=0;i<fz.length;i++)
{
if(fz[i][0]==zipcodes[j])
{
if(tr_mediationarea_id==fz[i][2])
zipcodes[j]=fz[i][1];
}
}
}
}
popupWin=window.open("../jobs/price_query.php?zipcode1="+zipcodes[0]+
"&zipcode2="+zipcodes[1]+"&zipcode3="+zipcodes[2]+"&zipcode4="+zipcodes[3]+"&zipcode5="+zipcodes[4]+
"&zipcode6="+zipcodes[5]+"&vht_id="+parent.job_options.document.tourOptions.vht_id.value,
"","dependent=yes,width="+widthPopupWin+",height="+
heightPopupWin+",left="+leftPopupWin+",top="+topPopupWin);
};
function checkAccept_all_addresses()
{
if(parent.job_tour.document.tourForm.accept_all_addresses.checked)
{
parent.job_options.document.tourOptions.accept_all_addresses.value="1";
}else{
parent.job_options.document.tourOptions.accept_all_addresses.value="";
}
}
function checkJb_globaljob()
{
if(parent.job_options.document.tourOptions.jb_globaljob.checked)
{
parent.job_options.document.tourOptions.crSidList.disabled=true;
parent.job_options.document.tourOptions.cr_id_order.disabled=true;
parent.job_options.document.tourOptions.cr_id_order.value="";
parent.job_options.document.tourOptions.jb_waitstorno.disabled=true;
parent.job_options.document.tourOptions.jb_waitstorno.checked=false;
parent.job_options.document.tourOptions.afterwards.checked=false;
parent.job_options.document.tourOptions.afterwards.disabled=true;
}else{
if(jb_id==""){
parent.job_options.document.tourOptions.jb_waitstorno.disabled=false;
parent.job_options.document.tourOptions.crSidList.disabled=false;
parent.job_options.document.tourOptions.cr_id_order.disabled=false;
parent.job_options.document.tourOptions.afterwards.disabled=false;
}
}
checkSendTour();
}
function checkAfterwards()
{
if(typeof(parent.job_options.document.tourOptions.afterwards)=='undefined')
return;
if(parent.job_options.document.tourOptions.jb_id.value!=""&&parent.job_options.document.tourOptions.jb_id.value!="____")
parent.job_options.document.tourOptions.afterwards.checked=false;
if(parent.job_options.document.tourOptions.afterwards.checked)
{
var now=new Date();
setDateTimeFields("job_options","tourOptions",now.getDate(),(now.getMonth()+1),now.getFullYear(),now.getHours(),now.getMinutes(),"tag","monat","jahr","stunde","minute","jb_permanent");
is_afterwards=true;
parent.job_options.document.tourOptions.jb_permanent.disabled=true;
setDateTimeFields("job_options","tourOptions","","","","","","endetag","endemonat","endejahr","","","");
if(empModeLaterJob=="1")
setDateTimeFields("job_options","tourOptions","","","","","","tag","monat","jahr","stunde","minute","jb_permanent");
parent.job_options.document.tourOptions.endetag.disabled=true;
parent.job_options.document.tourOptions.endemonat.disabled=true;
parent.job_options.document.tourOptions.endejahr.disabled=true;
checkJb_permanent();
parent.job_options.document.tourOptions.jb_globaljob.disabled=true;
if(jb_id=="")
parent.job_options.document.tourOptions.jb_waitstorno.disabled=true;
parent.job_options.document.tourOptions.jb_status_manual.disabled=true;
parent.job_options.document.tourOptions.jb_status_manual.checked=false;
}else{
is_afterwards=false;
parent.job_options.document.tourOptions.jb_permanent.disabled=false;
parent.job_options.document.tourOptions.endetag.disabled=false;
parent.job_options.document.tourOptions.endemonat.disabled=false;
parent.job_options.document.tourOptions.endejahr.disabled=false;
checkJb_permanent();
if(jb_id=="")
parent.job_options.document.tourOptions.jb_waitstorno.disabled=false;
if(parent.job_options.document.tourOptions.jb_id.value!=""&&parent.job_options.document.tourOptions.jb_id.value!="____")
{
parent.job_options.document.tourOptions.afterwards.disabled=true;
}
else
{
parent.job_options.document.tourOptions.afterwards.disabled=false;
}
}
checkSendTour();
}
function checkJb_tourname()
{
var tempWin;
var csc_id_payer="";
while(parent.job_options.document.tourOptions.savedTour.length>1)
{
parent.job_options.document.tourOptions.savedTour.options[
parent.job_options.document.tourOptions.savedTour.length-1]=null;
};
if(curCsc_id_payer!="")
{
tempWin=mkPopupWin(
"function startReload()\n"+
"{\n"+
"  checkDone();\n"+
"  self.location.href=\"../jobs/get_tournames.php?csc_id="+
curCsc_id_payer+"\";\n"+
"}\n"+
"\n"+
"//--"+">\n"+
"<\/script>\n"+
"<\/head>\n"+
"<body onLoad=\"startReload()\">\n"+
"  <table border=0 align=center height=100% cellspacing=0 cellpadding=0 vspace=0 hspace=0>\n"+
"    <tr>\n"+
"      <td align=center valign=center>\n"+
"        <b>Hole Daten...</b>\n"+
"      <\/td>\n"+
"    <\/tr>\n"+
"  <\/table>\n"+
"<\/body>\n"+
"<\/html>\n",0,0);
}
}
var savedTour_options;
function checkJb_tourname_workaround()
{
var savedTour_options_arr=savedTour_options.split("\t");
var numIdx=getNumIndex("job_options","tourOptions","savedTour");
var j=0;
for(var i=0;i<savedTour_options_arr.length;i+=2)
{
parent.frames[numIdx[0]].document.forms[numIdx[1]].elements[numIdx[2]].options[j+++1]=
new Option(savedTour_options_arr[i],savedTour_options_arr[i+1],false,false);
}
savedTour_options="";
}
var setDistancepriceSubmit = false;
function checkJob()
{
var curTourNo=getCurTourNo();
var tempWin;
if(parent.job_options.isCurrentlySubmitting)
return false;
  if (get_cs_invmode(curCsc_id_payer) == 0 && trim(parent.job_options.document.tourOptions.jb_fixprice.value) == "") {
    openDistanceprice("zone");
    const myDiv = parent.job_tour.document.getElementById('div_zoneprice');
    const link = myDiv.querySelector('a');
    setDistancepriceSubmit = true;
    link.click();
    return false;
  }

if(optionTextExists("job_options","tourOptions","savedTour",
parent.job_options.document.tourOptions.jb_tourname.value)&&
parent.job_options.document.tourOptions.jb_tourname.value!="")
if(!confirm("Wollen Sie den gespeicherten Auftrag wirklich überschreiben?\n"+
"\n(Wenn nein, dann ändern Sie bitte vor dem nächsten \n"+
"Senden den Wert \""+
parent.job_options.document.tourOptions.jb_tourname.value+
"\" im Feld \"Tourname\"!)"))
return false;
tempWin=mkPopupWin(
"//--"+">\n"+
"<\/script>\n"+
"<\/head>\n"+
"<body onLoad=\"self.setTimeout('checkDone()',100)\">\n"+
"  <table border=0 align=center height=100% cellspacing=0 cellpadding=0 vspace=0 hspace=0>\n"+
"    <tr>\n"+
"      <td align=center valign=center>\n"+
"        <b>Sende Auftrag...</b>\n"+
"      <\/td>\n"+
"    <\/tr>\n"+
"  <\/table>\n"+
"<\/body>\n"+
"<\/html>\n",0,0);
return true;
}
function getSavedTour(jb_id,jb_copy,no_dates)
{
var tempWin;
var cr_sid_none="";
if(jb_copy=="")
jb_copy=false;
if(jb_id==0)
{
if(parent.job_options.isCurrentlySubmitting)
return;
if(typeof(parent.job_header.job_header_isLoading)=='undefined'||parent.job_header.job_header_isLoading==true||
typeof(parent.job_tour.job_tour_isLoading)=='undefined'||parent.job_tour.job_tour_isLoading==true||
typeof(parent.job_options.job_options_isLoading)=='undefined'||parent.job_options.job_options_isLoading==true)
{
self.setTimeout('getSavedTour('+jb_id+','+jb_copy+')',100);
return;
}
if(getSelectedVal("job_options","tourOptions","savedTour")==0)
return;
if(getJobList(0,jl_csc_id)!="")
{
if(confirm(
"Beim Laden einer gespeicherten Tour werden die bereits\n"+
"erfassten Daten gelöscht. Wollen Sie das wirklich?")==false)
{
parent.job_options.document.tourOptions.savedTour.value="";
return;
}
parent.job_options.document.tourOptions.jb_id_org.value = getSelectedVal("job_options", "tourOptions", "savedTour");
}
jb_id=getSelectedVal("job_options","tourOptions","savedTour");
cr_sid_none="&cr_sid=none&consider_manual_disp=1";
}
tempWin=mkPopupWin(
"function startReload()\n"+
"{\n"+
"  checkDone();\n"+
"  self.location.href=\"get_saved_tour.php?jb_id="+
jb_id+cr_sid_none+"&jb_copy="+jb_copy+"&no_dates="+no_dates+"\";\n"+
"}\n"+
"\n"+
"//--"+">\n"+
"<\/script>\n"+
"<\/head>\n"+
"<body onLoad=\"startReload()\">\n"+
"  <table border=0 align=center height=100% cellspacing=0 cellpadding=0 vspace=0 hspace=0>\n"+
"    <tr>\n"+
"      <td align=center valign=center>\n"+
"        <b>Hole Daten...</b>\n"+
"      <\/td>\n"+
"    <\/tr>\n"+
"  <\/table>\n"+
"<\/body>\n"+
"<\/html>\n",0,0);
}
function getStartAddress(csc_id_start)
{
var tempWin;
if(parent.job_options.isCurrentlySubmitting)
return;
if(typeof(parent.job_header.job_header_isLoading)=='undefined'||parent.job_header.job_header_isLoading==true||
typeof(parent.job_tour.job_tour_isLoading)=='undefined'||parent.job_tour.job_tour_isLoading==true||
typeof(parent.job_options.job_options_isLoading)=='undefined'||parent.job_options.job_options_isLoading==true)
{
self.setTimeout('getStartAdress('+csc_id_start+')',100);
return;
}
tempWin=mkPopupWin(
"function startReload()\n"+
"{\n"+
"  checkDone();\n"+
"  self.location.href=\"../admin/cs_csc_list.php?csc_id_start="+csc_id_start+"\";\n"+
"}\n"+
"\n"+
"//--"+">\n"+
"<\/script>\n"+
"<\/head>\n"+
"<body onLoad=\"startReload()\">\n"+
"  <table border=0 align=center height=100% cellspacing=0 cellpadding=0 vspace=0 hspace=0>\n"+
"    <tr>\n"+
"      <td align=center valign=center>\n"+
"        <b>Hole Daten...</b>\n"+
"      <\/td>\n"+
"    <\/tr>\n"+
"  <\/table>\n"+
"<\/body>\n"+
"<\/html>\n",0,0);
}

function popupWin1(widthPopupWin, heightPopupWin, leftPopupWin, topPopupWin, popupdata)
{
  popupWin=window.open("about:blank", "",
    "dependent=yes,width=" + widthPopupWin + ",height=" + heightPopupWin +
    ",left=" + leftPopupWin + ",top=" + topPopupWin);
  if (navigator.userAgent.indexOf("Firefox") == -1) {
    popupWin.document.open();
    popupWin.document.write(popupdata);
    popupWin.document.close();
  } else {
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Base64_encoding_and_decoding#Solution_.232_.E2.80.93_rewriting_atob%28%29_and_btoa%28%29_using_TypedArrays_and_UTF-8
    var url = "javascript:(function(){var html = '" + btoa(encodeURIComponent( escape( popupdata )))
                 +"';document.open();document.write(unescape(decodeURIComponent(window.atob( html ))));document.close();})();";
    popupWin.location.href=url;
  }
}

function openDistanceprice(m) {
  if (typeof (m) != 'undefined' && m == "zone") {
    parent.job_tour.$('#div_zoneprice').hide();
    parent.job_tour.$('#div_zoneprice').html("&nbsp;Strecke wird ermittelt...");
    parent.job_tour.$('#div_zoneprice').show();
  } else {
    parent.job_tour.$('#div_distanceprice').html("&nbsp;Entfernung wird ermittelt...");
  }
  setTimeout(openDistancepriceDoit(m), 0);
}

var priceStrFull = "";
var priceStrDiscount = "";
// https://stackoverflow.com/questions/13484496/how-can-i-get-an-elements-innerhtml-to-update-immediately
function openDistancepriceDoit(m) {

  var mode = "km";
  var div_name = '#div_distanceprice';

  if (typeof (m) != 'undefined' && m == "zone") {
    mode = "zone";
    div_name = '#div_zoneprice';
  }

  var ajaxParms = "";

  var cur_jb_markup = parseFloat(parent.job_options.document.tourOptions.jb_markup.value.replace(/,/,"."));
  if (MASK_CR_PRICE_MODE == "1") {
    if (typeof (parent.job_options.document.tourOptions.currentTSZ) != 'undefined')
      cur_jb_markup = parseFloat(parent.job_options.document.tourOptions.currentTSZ.value.substr(0, parent.job_options.document.tourOptions.currentTSZ.value.length - 2).replace(/,/,"."));
    else
      cur_jb_markup = parent.job_options.document.tourOptions.jb_markup.value;
    if (trim(parent.job_options.document.tourOptions.jb_markup.value) != "")
      cur_jb_markup = parseFloat(parent.job_options.document.tourOptions.jb_markup.value.replace(/,/,"."));
//    var cur_jb_cr_markup = parseFloat(parent.job_options.document.tourOptions.currentCrTSZ.value.substr(0, parent.job_options.document.tourOptions.currentCrTSZ.value.length - 2).replace(/,/,"."));
//    if (trim(parent.job_options.document.tourOptions.jb_cr_markup.value) != "")
//      cur_jb_cr_markup = parseFloat(parent.job_options.document.tourOptions.jb_cr_markup.value.replace(/,/,"."));
  }

  var i = 0;
  while (checkTourComplete(i))
  {
    if (ajaxParms != "")
      ajaxParms += "|";
    ajaxParms += getJobList(i, jl_ad_street) + ";" + getJobList(i, jl_tr_hsno) + ";" + getJobList(i, jl_ad_zipcode) + ";" + getJobList(i, jl_ad_city) + ";" + getJobList(i, jl_ad_country);    
    if (i++ >= maxTour)
      break;
  }
  
  var jb_ordertime = "";
  if (trim(parent.job_options.document.tourOptions.tag.value) != "")
//  if(!isNaN(new Date(parent.job_options.document.tourOptions.jahr.value, parent.job_options.document.tourOptions.monat.value - 1, parent.job_options.document.tourOptions.tag.value,
//    parent.job_options.document.tourOptions.stunde.value, parent.job_options.document.tourOptions.minute.value)))
    jb_ordertime = parent.job_options.document.tourOptions.jahr.value.toString() + "-" + parent.job_options.document.tourOptions.monat.value.toString() + "-" + parent.job_options.document.tourOptions.tag.value.toString()
       + "%2000:00:00";
//      + "%20" + parent.job_options.document.tourOptions.stunde.value.toString() + ":" + parent.job_options.document.tourOptions.minute.value.toString() + ":00";
//alert(isNaN(new Date(parent.job_options.document.tourOptions.jahr.value, parent.job_options.document.tourOptions.monat.value - 1, parent.job_options.document.tourOptions.tag.value,
//    parent.job_options.document.tourOptions.stunde.value, parent.job_options.document.tourOptions.minute.value)) + "|" +
//jb_ordertime);
  ajaxParms = "hq_id=" + hq_id + '&cs_id=' + get_cs_id(curCsc_id_payer) + "&vht_id=" + parent.job_options.document.tourOptions.vht_id.value +
    "&jb_markup=" + cur_jb_markup + '&jb_ordertime=' + jb_ordertime + "&mode=" + mode + "&a=" + ajaxParms;
//alert(ajaxParms);
  ajaxRequestGet('../include/ajaxReqKmPrice.php', ajaxParms);

//alert(retValue);
//alert(retValue[1]);
//alert(decodeURIComponent(retValue[1]));
  if (retValue[0] != "ERROR") {
//console.log("1." + retValue[0] + " " + retValue[4] + " " + retValue[5] + " " + retValue[6]);
//self_service_discount = 0;
    if ((get_cs_fixprice_discount(curCsc_id_payer) == 1 && get_cs_discount(curCsc_id_payer) != 0 || self_service_discount > 0) && parseFloat(retValue[5].replace(/,/,".")) != 0) {
      let discounted_price = Math.round(parseFloat(retValue[5].replace(/,/,".")) * (100 - get_cs_discount(curCsc_id_payer) - self_service_discount)) / 100;
//      retValue[0] = (retValue[5] * (100 + parseFloat(retValue[4].substr(retValue[4].indexOf("+") + 1, retValue[4].indexOf("%") - retValue[4].indexOf("+") - 1).replace(/,/,"."))) / 100).toString().replace(/\./,",") + " " + String.fromCodePoint(0x404);
//      retValue[6] = (Math.round(parseFloat(retValue[6].replace(/,/,".")) * (100 - get_cs_discount(curCsc_id_payer))) / 100).toString().replace(/\./,",");
      retValue[0] = (Math.round(discounted_price * (100 + parseFloat(retValue[4].substr(retValue[4].indexOf("+") + 1, retValue[4].indexOf("%") - retValue[4].indexOf("+") - 1).replace(/,/,".")))) / 100).toString().replace(/\./,",") + " \u20AC";
      discounted_price = discounted_price.toString().replace(/\./,",");
      retValue[4] = retValue[4].replace(retValue[5], discounted_price);
      priceStrDiscount = " (" + retValue[5] + " \u20AC" + " abzgl. " + (parseFloat(get_cs_discount(curCsc_id_payer)) + self_service_discount).toString().replace(/\./,",") + " % Rabatt = ";
    }
//console.log("2." + retValue[0] + " " + retValue[4] + " " + retValue[5] + " " + retValue[6] + " ");
    parent.job_tour.$(div_name).html("&nbsp;" + 
     "<a href=\"javascript:parent.job_options.setDistanceprice('" + retValue[5] + "', '" + retValue[6] + "', '" + retValue[2] + "|" + retValue[3] + "|" + retValue[4] + "|" + retValue[7] + "|" + retValue[8] + "|" + retValue[10] + "')\">" + retValue[0] + "<\/a>" +
     " (<a href=\"" + (mode != "zone" ? "https://www.google.de/maps/dir" + unescape(retValue[1]) : "../locating/map_pzm.php?p=" + encodeURI(retValue[1])) +
       "\" target=\"_blank\">" + retValue[2] + "</a> " + (mode != "zone" ? "* " : "") + retValue[3] + retValue[4] + ")");
    // retValue[2] = $total_km, retValue[3] = $price_per_km, retValue[4] = $basic_price
    if (typeof (MASK_HIDE_STANDARD_PRICE_IF_KM_PRICE) != 'undefined' && MASK_HIDE_STANDARD_PRICE_IF_KM_PRICE == "1") {
      parent.job_tour.document.tourForm.currentPrice.style.visibility = "hidden";
      parent.job_tour.document.tourForm.currentCrPrice.style.visibility = "hidden";
    }
    priceStrFull = retValue[0];
  } else {
    parent.job_tour.$(div_name).html("&nbsp;" + retValue[1]);
  }
}

function setDistanceprice(priceStr, crPriceStr, km_price_params) {
//  var addConfirmStr = "";
//  if (setDistancepriceSubmit)
//    addConfirmStr = " und Auftrag absenden";
//addConfirmStr = "cs_fixprice_discount = " + get_cs_fixprice_discount(curCsc_id_payer) + ", cs_discount = " + get_cs_discount(curCsc_id_payer) + ", priceStr = " + priceStr + ", crPriceStr = " + crPriceStr;

  let km_price_paramsArr = km_price_params.split("|");

  if (confirm("Der Preis für diesen Auftrag beträgt " + priceStrFull + (priceStrDiscount != "" ? priceStrDiscount : " (") +
    km_price_paramsArr[2].replace(/ = /, "") /* + " " + String.fromCodePoint(0x404)*/ + ")."  +
    "\n\nMöchten Sie den Auftrag absenden und damit kostenpflichtig bestellen" + /*addConfirmStr +*/ "?\n" /*+ km_price_params*/)) {
    parent.job_options.document.tourOptions.jb_fixprice.value = priceStr;
    if (MASK_CR_PRICE_MODE == "1")
      parent.job_options.document.tourOptions.jb_cr_price.value = crPriceStr;
    if (get_cs_fixprice_discount(curCsc_id_payer) == 1 && get_cs_discount(curCsc_id_payer) != 0 && parseFloat(priceStr.replace(/,/,".")) != 0) {
      parent.job_options.document.tourOptions.jb_discount.value = 1;
      parent.job_options.document.tourOptions.jb_discount_rate = get_cs_discount(curCsc_id_payer);
    }
    parent.job_options.document.tourOptions.km_price_params.value = km_price_params;
    checkFixprice(1);
    if (setDistancepriceSubmit)
      parent.job_options.document.tourOptions.toursubmit.click();
  }
  priceStrFull = "";
  priceStrDiscount = "";
  setDistancepriceSubmit = false;
}
