  ////////////////////////////////
 //  © 2007 Traveltainment AG  //
///////////////////////////////

//___Kundendaten____________________
var split_cus = TTCustomer.split("|");
var ordner_name = split_cus[0];
var KID = split_cus[1];
var jsq_quick = split_cus[2]; //Sprung ohne Schnellsuche == 0 | Sprung mit Schnellsuche == 1
var jsq_popup = split_cus[3]; //target -> self == 0 |target -> blank == 1
var frameurl = split_cus[4]; //Strecke in frame -> nein == 0 | ja == 1
var searchurl = split_cus[5];

//Hauptpfade (default)
var cacheurl = "http://images.traveltainment.de/";
var main_url = "http://www2.vidado.com/";

//Wurden zuvor andere Pfade definiert?
if (typeof(TTMainUrl) != 'undefined' && TTMainUrl != ''){
    main_url = TTMainUrl;
}
if (typeof(TTCacheUrl) != 'undefined' && TTCacheUrl != ''){
    cacheurl = TTCacheUrl;
}

//Default-Variablen checken
if (typeof(TTAddVal) == 'undefined'){
    var TTAddVal = '';
}
if (typeof(TTImgUrl) == 'undefined'){
    var TTImgUrl = 'http://www2.vidado.com/kunden_parameter/';
}

//DIV Container (wird in jsqs_x.js gefüllt)
document.write('<div id="tt_jsq_div">&nbsp;loading...</div>');

//__Welche Strecken?___________
var split_lines = TTLines.split("|");
if (typeof(TTJumpMarks) != 'undefined' && TTJumpMarks != ''){
    var split_jumper = TTJumpMarks.split("|");
}

//___Globals für Ausgabe_________________
var jsq_jump = 'IBE_lami'; //Default aktive Strecke; meist IBE_lami (port 654)
var tmpx_split_lines = split_lines[0].split(",");
var splitx_lines_type = tmpx_split_lines[0].split("#");
if(splitx_lines_type[0] == '654'){
    if (typeof(splitx_lines_type[1]) != 'undefined' && splitx_lines_type[1] == '1'){
        jsq_jump = 'IBE_lamipa';
    }
}
else if(splitx_lines_type[0] == '651'){
    jsq_jump = 'IBE_pauschal';
}
else if(splitx_lines_type[0] == '652'){
    jsq_jump = 'IBE_flug';
}
else if(splitx_lines_type[0] == '653'){
    jsq_jump = 'IBE_erde';
}
else if(splitx_lines_type[0] == '655'){
    jsq_jump = 'IBE_fewo';
}
var IBE_typ = jsq_jump;
var jsq_art = '';

//Externe Javascript Dateien preloaden
var jsFiles = [main_url+'booking/js/ttafh.js',
               main_url+'booking/js/ttfdrz.js',
               main_url+'booking/jslib/core/datehelper.js',
               main_url+'booking/jslib/core/zeitraum.js',
               main_url+'booking/jslib/core/reisende.js',
               main_url+'booking/jslib/formulare/terminauswahl.js',
               main_url+'booking/jslib/formulare/formbase.js',
               url+'booking/'+ordner_name+'/js/jsqs.js'];

var defPersOptTxt = {
  erw:["Erwachsener","Erwachsene"],  // "normal"
  erw_short:["Erwachsener","Erwachsene"], // Formular 2 / Nur Flug
  pers:["Person","Personen"],        // Fewo
  kinder:["Jah.","Jahre"]
};

//IBE Instanzen erstellen
var setJSFiles = '0';

for(var p=0;p<split_lines.length;p++){
    var tmp_split_lines = split_lines[p].split(",");
    var split_lines_type = tmp_split_lines[0].split("#");

    if(split_lines_type[0] == '654'){
        if (typeof(split_lines_type[1]) != 'undefined' && split_lines_type[1] == '1'){
            var IBE_lamipa = new TTIBE("IBE_lamipa",654,"bengine");
            var req =  {flugdauer:'',zielgebiets_kenner:'',topRegion:'','nurflug':'','formular':'4',termin:'',ruecktermin:'',personen:'25;25'};
            IBE_lamipa.lineName = 'lamipa';
            IBE_lamipa.jumper = '';
            if(frameurl == 1 && typeof(split_jumper) != 'undefined' && split_jumper[p] != ''){
                IBE_lamipa.jumper = split_jumper[p];
            }
            IBE_lamipa.req = req;
            IBE_lamipa.req['engine'] = 'pauschal';
            if(tmp_split_lines[2] != '0'){
                IBE_lamipa.req['kategorie'] = '-1';
            }
            if(tmp_split_lines[3] != '0'){
                IBE_lamipa.req['verpflegung'] = '-1';
            }
            if(tmp_split_lines[4] != '0'){
                IBE_lamipa.req['zimmer'] = '-1';
            }
            if(tmp_split_lines[5] != '0'){
                IBE_lamipa.req['marke'] = '';
            }
            if(tmp_split_lines[6] != '0'){
                IBE_lamipa.req['shotel'] = '';
            }
            if(tmp_split_lines[7] != '0'){
                IBE_lamipa.req['preis'] = '';
            }
            if (setJSFiles == '1'){
                IBE_lamipa.jsFiles = [];
            }
            else{
                IBE_lamipa.jsFiles = jsFiles;
                setJSFiles = '1';
            }
        }
        else {
            var IBE_lami = new TTIBE("IBE_lami",654,"bengine");
            var req =  {flugdauer:'',zielgebiets_kenner:'',topRegion:'','nurflug':'','formular':'4',termin:'',ruecktermin:'',personen:'25;25'};
            IBE_lami.lineName = 'lami';
            IBE_lami.jumper = '';
            if(frameurl == 1 && typeof(split_jumper) != 'undefined' && split_jumper[p] != ''){
                IBE_lami.jumper = split_jumper[p];
            }
            IBE_lami.req = req;
            IBE_lami.req['engine'] = '';
            if(tmp_split_lines[2] != '0'){
                IBE_lami.req['kategorie'] = '-1';
            }
            if(tmp_split_lines[3] != '0'){
                IBE_lami.req['verpflegung'] = '-1';
            }
            if(tmp_split_lines[4] != '0'){
                IBE_lami.req['zimmer'] = '-1';
            }
            if(tmp_split_lines[5] != '0'){
                IBE_lami.req['marke'] = '';
            }
            if(tmp_split_lines[6] != '0'){
                IBE_lami.req['shotel'] = '';
            }
            if(tmp_split_lines[7] != '0'){
                IBE_lami.req['preis'] = '';
            }
            if (setJSFiles == '1'){
                IBE_lami.jsFiles = [];
            }
            else{
                IBE_lami.jsFiles = jsFiles;
                setJSFiles = '1';
            }
        }
    }
    if(split_lines_type[0] == '651'){
        var IBE_pauschal = new TTIBE("IBE_pauschal",651,"bengine");
        var req_pa =  {flugdauer:'',zielgebiets_kenner:'',topRegion:'','nurflug':'','formular':'4','engine':'pauschal',termin:'',ruecktermin:'',personen:'25;25'};
        IBE_pauschal.lineName = 'pauschal';
        IBE_pauschal.jumper = '';
        if(frameurl == 1 && typeof(split_jumper) != 'undefined' && split_jumper[p] != ''){
            IBE_pauschal.jumper = split_jumper[p];
        }
        IBE_pauschal.req = req_pa;
        if(tmp_split_lines[2] != '0'){
            IBE_pauschal.req['kategorie'] = '-1';
        }
        if(tmp_split_lines[3] != '0'){
            IBE_pauschal.req['verpflegung'] = '-1';
        }
        if(tmp_split_lines[4] != '0'){
            IBE_pauschal.req['zimmer'] = '-1';
        }
        if(tmp_split_lines[5] != '0'){
            IBE_pauschal.req['marke'] = '';
        }
        if(tmp_split_lines[6] != '0'){
            IBE_pauschal.req['shotel'] = '';
        }
        if(tmp_split_lines[7] != '0'){
            IBE_pauschal.req['preis'] = '';
        }
        if (setJSFiles == '1'){
            IBE_pauschal.jsFiles = [];
        }
        else{
            IBE_pauschal.jsFiles = jsFiles;
            setJSFiles = '1';
        }
    }
    if(split_lines_type[0] == '652'){
        var IBE_flug = new TTIBE("IBE_flug",652,"bengine");
        var req_fl =  {flugdauer:'',zielgebiets_kenner:'',topRegion:'','nurflug':'1','formular':'3','engine':'',termin:'',ruecktermin:'',personen:'25;25',dauer:'-1'};
        IBE_flug.lineName = 'flug';
        IBE_flug.jumper = '';
        if(frameurl == 1 && typeof(split_jumper) != 'undefined' && split_jumper[p] != ''){
            IBE_flug.jumper = split_jumper[p];
        }
        IBE_flug.req = req_fl;
        if(tmp_split_lines[5] != '0'){
            IBE_flug.req['marke'] = '';
        }
        if(tmp_split_lines[7] != '0'){
            IBE_flug.req['preis'] = '';
        }
        if (setJSFiles == '1'){
            IBE_flug.jsFiles = [];
        }
        else{
            IBE_flug.jsFiles = jsFiles;
            setJSFiles = '1';
        }
    }
    if(split_lines_type[0] == '653'){
        var IBE_erde = new TTIBE("IBE_erde",653,"bengine");
        var req_er =  {flugdauer:'',zielgebiets_kenner:'',topRegion:'','nurflug':'','formular':'4','engine':'erde',termin:'',ruecktermin:'',personen:'25;25',dauer:'-1'};
        IBE_erde.lineName = 'erde';
        IBE_erde.jumper = '';
        if(frameurl == 1 && typeof(split_jumper) != 'undefined' && split_jumper[p] != ''){
            IBE_erde.jumper = split_jumper[p];
        }
        IBE_erde.req = req_er;
        if(tmp_split_lines[2] != '0'){
            IBE_erde.req['kategorie'] = '-1';
        }
        if(tmp_split_lines[3] != '0'){
            IBE_erde.req['verpflegung'] = '-1';
        }
        if(tmp_split_lines[4] != '0'){
            IBE_erde.req['zimmer'] = '-1';
        }
        if(tmp_split_lines[5] != '0'){
            IBE_erde.req['marke'] = '';
        }
        if(tmp_split_lines[6] != '0'){
            IBE_erde.req['shotel'] = '';
        }
        if(tmp_split_lines[7] != '0'){
            IBE_erde.req['preis'] = '';
        }
        if (setJSFiles == '1'){
            IBE_erde.jsFiles = [];
        }
        else{
            IBE_erde.jsFiles = jsFiles;
            setJSFiles = '1';
        }
    }
    if(split_lines_type[0] == '655'){
        var IBE_fewo = new TTIBE("IBE_fewo",655,"bengine");
        var req_fw =  {flugdauer:'',zielgebiets_kenner:'',topRegion:'','nurflug':'','formular':'4','engine':'fewo',termin:'',ruecktermin:'',personen:'25;25;25;25'};
        IBE_fewo.lineName = 'fewo';
        IBE_fewo.jumper = '';
        if(frameurl == 1 && typeof(split_jumper) != 'undefined' && split_jumper[p] != ''){
            IBE_fewo.jumper = split_jumper[p];
        }
        IBE_fewo.req = req_fw;
        if(tmp_split_lines[4] != '0'){
            IBE_fewo.req['zimmer'] = '-1';
        }
        if(tmp_split_lines[5] != '0'){
            IBE_fewo.req['marke'] = '';
        }
        if(tmp_split_lines[6] != '0'){
            IBE_fewo.req['shotel'] = '';
        }
        if(tmp_split_lines[7] != '0'){
            IBE_fewo.req['preis'] = '';
        }
        if (setJSFiles == '1'){
            IBE_fewo.jsFiles = [];
        }
        else{
            IBE_fewo.jsFiles = jsFiles;
            setJSFiles = '1';
        }
    }

}

// Default-Werte für Formularfelder
var showReiseziel = '0';
var showKategorie = '0';
var showVerpflegung = '0';
var showZimmer = '0';
var showMarke = '0';
var showShotel = '0';
var showPreis = '0';

//Dynamisches Einbinden der Daten
function initOnLoad(){
    for(var p=0;p<split_lines.length;p++){
        var tmp_split_lines = split_lines[p].split(",");
        var split_lines_type = tmp_split_lines[0].split("#");

        if (split_lines_type[0] == this.port){
            showReiseziel = tmp_split_lines[1];
            showKategorie = tmp_split_lines[2];
            showVerpflegung = tmp_split_lines[3];
            showZimmer = tmp_split_lines[4];
            showMarke = tmp_split_lines[5];
            showShotel = tmp_split_lines[6];
            showPreis = tmp_split_lines[7];
            p = split_lines.length;
        }
    }

    var mustHave  = ['DateHelperLoaded','termin_min_'+this.port,'termin_max_'+this.port,'Zeitraum','Terminauswahl','Reisende'];
    if(this.port == 651 || this.port == 652 || this.port == 654){
        mustHave.push('TTAFH');
    }
    if (this.port != 652){
        mustHave.push('TTREGS_'+this.port);
    }
    if (this.port == 652){
        mustHave.push('TTFDRZ');
    }
    if (this.port != 652 && this.port != 653){
        mustHave.push('optDauer');
    }
    if (showMarke == '1'){
        mustHave.push('arrMarke_'+this.port);
    }
    var injObj    = {Zeitraum:[],Reisende:[this.req['personen']]};

    for(var i in mustHave){
        if(typeof(window[mustHave[i]])=='undefined'){
             if(this.port == 654){
                if (this.lineName == 'lami'){
                    window.setTimeout("IBE_lami.initOnLoad()",50);
                }
                else if (this.lineName == 'lamipa'){
                    window.setTimeout("IBE_lamipa.initOnLoad()",50);
                }
             }
             else if (this.port == 651){
                window.setTimeout("IBE_pauschal.initOnLoad()",50);
             }
             else if (this.port == 652){
                window.setTimeout("IBE_flug.initOnLoad()",50);
             }
             else if (this.port == 653){
                window.setTimeout("IBE_erde.initOnLoad()",50);
             }
             else if (this.port == 655){
                window.setTimeout("IBE_fewo.initOnLoad()",50);
             }
             return;
        }
    }
    this.inject(injObj);
    this.init();
};

//Regionen ziehen
function RegGruppe(label,zk,fd,tr,port){
   this.label = label;
   this.zielgebiet = zk;
   this.ziel  = fd;
   this.topregion = tr;
   this.regionen  = [];

        for(var x=0;x<window["TTREGS_"+port].length;x++){
                var ttziel=window["TTREGS_"+port][x].split('|');
                if(ttziel[3]!=ttziel[2] && ttziel[2]==this.ziel)
            this.regionen.push(window["TTREGS_"+port][x]);
    }
  this.regionen.sort();
}

//Daten aufbereiten
function fillSelFromArray(selname,arrdata){
  var sb = document.getElementsByName(selname)[0] || 0;
  if(!sb || sb.type!='select-one') return;
  var sel = this.req[selname]!='undefined'?this.req[selname]:'';
  for(var i=0;i<arrdata.length;i++){
    var lbl = arrdata[i].split(';')[0];
    var val = arrdata[i].split(';')[1];
    if(selname=='marke' && val=='VTO') lbl=this.req['klabelmarke'];
    sb.options[sb.options.length] = new Option(lbl,val);
    if(val==sel) sb.options[sb.options.length-1].selected=true;
  }
}

//Options Reiseziele füllen
function fillReiseziele(port){
    var regSelect = document.getElementById('jsq_formula').regionen;
    //NurFlug Options
    if(port==652){
        for(t=0;t<window["TTFDRZ"].length;t++){
            var ttf = window["TTFDRZ"][t].split(';');
            regSelect.options[regSelect.options.length] = new Option(ttf[0],ttf[1]);
        }
    //Sonstige Options
    }
    else
    {
        //Aufteilung in Topregion und zugehörigen Regionen; langsamer
        if (showReiseziel == '1'){
            //Gibts Cache von RegGruppe?
            if (this.port == 654 && typeof(TTREGGROUPS_654) != 'undefined'){
                var TTREGGROUPS = TTREGGROUPS_654;
            }
            else if (this.port == 651 && typeof(TTREGGROUPS_651) != 'undefined'){
                var TTREGGROUPS = TTREGGROUPS_651;
            }
            else if (this.port == 653 && typeof(TTREGGROUPS_653) != 'undefined'){
                var TTREGGROUPS = TTREGGROUPS_653;
            }
            else if (this.port == 655 && typeof(TTREGGROUPS_655) != 'undefined'){
                var TTREGGROUPS = TTREGGROUPS_655;
            }
            else
            {
                var TTREGGROUPS = [];
                    for(var t=0;t<window["TTREGS_"+port].length;t++){
                            var ziel=window["TTREGS_"+port][t].split('|');

                            if(ziel[2]==ziel[3]){
                                    TTREGGROUPS[TTREGGROUPS.length] = new RegGruppe(ziel[0],ziel[1],ziel[2],ziel[3],port);
                    }
                }
                //Array RegGruppe cachen
                if (this.port == 654){
                    var TTREGGROUPS_654 = TTREGGROUPS;
                }
                else if (this.port == 651){
                    var TTREGGROUPS_651 = TTREGGROUPS;
                }
                else if (this.port == 653){
                    var TTREGGROUPS_653 = TTREGGROUPS;
                }
                else if (this.port == 655){
                    var TTREGGROUPS_655 = TTREGGROUPS;
                }
            }

            for(t=0;t<TTREGGROUPS.length;t++){
                        regSelect.options[regSelect.options.length] = new Option(TTREGGROUPS[t].label,TTREGGROUPS[t].zielgebiet+'|'+TTREGGROUPS[t].ziel+'|'+TTREGGROUPS[t].topregion);
                    for(j=0;j<TTREGGROUPS[t].regionen.length;j++){
                    var ziel=TTREGGROUPS[t].regionen[j].split('|');
                    regSelect.options[regSelect.options.length] = new Option(String.fromCharCode(160,160,160)+ziel[0],ziel[1]+'|'+ziel[2]+'|'+ziel[3]);
                }
           }

        }
        //einfache alphab. Sortierung; schneller
        else
        {
            for(var t=0;t<window["TTREGS_"+port].length;t++){
                        var ziel=window["TTREGS_"+port][t].split('|');
                regSelect.options[regSelect.options.length] = new Option(ziel[0],ziel[1]+'|'+ziel[2]+'|'+ziel[3]);
            }
        }
    }
};

// Funktionen zuweisen
for(var p=0;p<split_lines.length;p++){
    var tmp_split_lines = split_lines[p].split(",");
    var split_lines_type = tmp_split_lines[0].split("#");

    if(split_lines_type[0] == '654'){
        if (typeof(split_lines_type[1]) != 'undefined' && split_lines_type[1] == '1'){
            IBE_lamipa.initOnLoad = initOnLoad;
            IBE_lamipa.fillSelFromArray = fillSelFromArray;
            IBE_lamipa.fillReiseziele = fillReiseziele;
        }
        else {
            IBE_lami.initOnLoad = initOnLoad;
            IBE_lami.fillSelFromArray = fillSelFromArray;
            IBE_lami.fillReiseziele = fillReiseziele;
        }
    }
    if(split_lines_type[0] == '653'){
        IBE_erde.initOnLoad = initOnLoad;
        IBE_erde.fillSelFromArray = fillSelFromArray;
        IBE_erde.fillReiseziele = fillReiseziele;
    }
    if(split_lines_type[0] == '652'){
        IBE_flug.initOnLoad = initOnLoad;
        IBE_flug.fillSelFromArray = fillSelFromArray;
        IBE_flug.fillReiseziele = fillReiseziele;
    }
    if(split_lines_type[0] == '651'){
        IBE_pauschal.initOnLoad = initOnLoad;
        IBE_pauschal.fillSelFromArray = fillSelFromArray;
        IBE_pauschal.fillReiseziele = fillReiseziele;
    }
    if(split_lines_type[0] == '655'){
        IBE_fewo.initOnLoad = initOnLoad;
        IBE_fewo.fillSelFromArray = fillSelFromArray;
        IBE_fewo.fillReiseziele = fillReiseziele;
    }
}

//Initialisieren
function init(){
    if (typeof(FormBase) != 'undefined'){
        this.monNames = ["Januar","Februar","März","April","Mai","Juni","Juli","August","September","Oktober","November","Dezember"];
        FormBase.apply(this);
        Terminauswahl.apply(this);
        if (typeof(write_quickSearch) != 'undefined'){
            write_quickSearch(this.port, this.lineName, this.jumper);
        }
        else{
            window.setTimeout(this.name + ".init()",100);
        }

        with(this){

            if(this.port==653 || this.port==652){
                dauert();
            }
            else {
                fillSelFromArray('dauer',optDauer);
            }
            fillSelFromArray('abflughafen',TTAFH);
            fillReiseziele(this.port);
            fillReisende(defPersOptTxt);
            if(showKategorie=='2'){
                setRadios(['kategorie']);
            }
            else if(showKategorie=='1'){
                fillSelFromArray('kategorie',optKategorie);
            }
            if(showVerpflegung=='2'){
                setRadios(['verpflegung']);
            }
            else if(showVerpflegung=='1'){
                fillSelFromArray('verpflegung',optVerpflegung);
            }
            if(showZimmer=='2'){
                setRadios(['zimmer']);
            }
            else if(showZimmer=='1'){
                if(this.port==655){
                    fillSelFromArray('zimmer',optZimmerFW);
                }
                else{
                    fillSelFromArray('zimmer',optZimmer);
                }
            }
            if(showMarke=='1'){
                fillSels({"marke":window["arrMarke_"+this.port]});
            }
            if(showShotel=='1'){
                setTexts(['shotel']);
            }
            if(showPreis=='1'){
                setTexts(['preis']);
            }
            InitDays(1);
            InitMonth(1);
            InitDays(0);
            InitMonth(0);
            UpdateDate('k');
            UpdateDate('rueckk');
        }
    }
    else {
        window.setTimeout(this.name + ".init()",100);
    }
};

//Felder beim Wechsel leeren
function clearSelects(formular,arNamen){
  for(var i=0;i<arNamen.length;i++){
    var selname = arNamen[i];
    var sb = document.getElementById('jsq_formula')[selname] || 0;
   if(!sb || sb.type!='select-one') continue;
    var stop = selname=="regionen"?1:0;
   for(var j=sb.options.length;j>stop;j--){
        sb.options[j-1] = null;
   }
  }
}

//Initialisierung der Daten
var setInitStat = '0';
for(var p=0;p<split_lines.length;p++){
    var tmp_split_lines = split_lines[p].split(",");
    var split_lines_type = tmp_split_lines[0].split("#");

    if(split_lines_type[0] == '654'){
        if (typeof(split_lines_type[1]) != 'undefined' && split_lines_type[1] == '1'){
            IBE_lamipa.init = init;
            IBE_lamipa.includeFiles();
            if (setInitStat == '0'){
                IBE_lamipa.initOnLoad();
                setInitStat = '1';
            }
        }
        else {
            IBE_lami.init = init;
            IBE_lami.includeFiles();
            if (setInitStat == '0'){
                IBE_lami.initOnLoad();
                setInitStat = '1';
            }
        }
    }
    if(split_lines_type[0] == '653'){
        IBE_erde.init = init;
        IBE_erde.includeFiles();
        if (setInitStat == '0'){
            IBE_erde.initOnLoad();
            setInitStat = '1';
        }
    }
    if(split_lines_type[0] == '652'){
        IBE_flug.init = init;
        IBE_flug.includeFiles();
        if (setInitStat == '0'){
            IBE_flug.initOnLoad();
            setInitStat = '1';
        }
    }
    if(split_lines_type[0] == '651'){
        IBE_pauschal.init = init;
        IBE_pauschal.includeFiles();
        if (setInitStat == '0'){
            IBE_pauschal.initOnLoad();
            setInitStat = '1';
        }
    }
    if(split_lines_type[0] == '655'){
        IBE_fewo.init = init;
        IBE_fewo.includeFiles();
        if (setInitStat == '0'){
            IBE_fewo.initOnLoad();
            setInitStat = '1';
        }
    }

}

/*-------------------------------------------------------------------------------
___EOF________________________________________________________________________*/