/**
 * This file handles the JS functions, definitions for the searchbox. 
 * Based on the TT Showroom. 
 *
 * @copyright 2010 Traveltainment
 * @version 2.4.3
 * 
 * @link X:\documentation\docs_fuer_IBE-Kunden\Deeplink_Schnellsuche\Deeplink Dokumentation Deutsch\TT-Doku_deeplinks.pdf
 * 
 * @todo consider case toRegion < 10000 f.i. if Cost Rica has been selected via QSM country selectbox with topRegion = 68
 * only the region selctbox will set correctly but not the country selectbox due to the change request concerning the QSM country selectbox 
 * (see description in method getCountryOptionsLamiPlus)!
 * 
 * modified 30.03.2010 by Willi Man <wman@traveltainment.de>
 * modified 12.05.2010
 * workarounds for browser chrome, safari, opera
 * change request 06.05.2010
 * we must now handle the leftside QSM and a different pricegrid QSM.
 * The two quicksearch modules must be synchronized.
 * change request 10.06.2010 
 * The second QSM should not be placed over the pricegrid due to usability issues.
 * Instead it should be diplayed on the left side. Therefore the synchronization 
 * between the two QSM versions must be handled different.
 * change request 11.06.2010 
 * The country options optLaender654 must be expanded.
 * optLaender654LamiPlus will now be used as country options.
 * modified 16.06.2010
 * Fallback solution in case of undefined TTREGS_654.
 * change request 22.06.2010
 * New search option hotel rating and hotel name
 * modified 06.07.2010
 * Remove pricegrid QSM related functionality.
 * modified 15.07.2010
 * Consider IBE param s_ort
 * modified 20.07.2010
 * deactivate the regionGroup case, because if a country|region|flugdauer|topRegion 
 * is defined, we will go to the hotel page directly.
 * Consider IBE params lcfilter, sleistung, zfilter, IFFFilter, topRegionen.
 * If GET param flugdauer or topRegionen isset, redirect to hotel page.
 * modified 21.07.2010
 * Handle IBE params erwachsene, alter1, alter2, alter3.
 * modified 22.07.2010
 * Handle human readable date format in IBE params 
 * &termin=18.07.2010&ruecktermin=09.09.2010 
 * Consider case: GET ruecktermin defined and termin undefined 
 * modified 26.07.2010
 * Changed behavior of deeplink param flugdauer 
 * modified 28.07.2010
 * Bugfix in method initAirportAndTouroperator
 * modified 30.07.2010
 * Unescape get param shotel
 * modified 05.08.2010
 * IE Bugfix: if one jumps into the IBE with a deeplink, the main form "bengine"
 * might be undefined, which causes a lot of problems. Catch this error in method initSearch.
 * modified 06.08.2010
 * unescape GET param s_ort.
 * modified 09.08.2010
 * calling method setRegion with delay necessary.
 * new method getPageScrollTopPosition.
 * changed scrollTo behaviour.
 * modified 18.08.2010
 * added method getDefaultReturnDate.
 * modfied 27.08.2010
 * #0027689: if airport or travelduration is not set via deeplink, do not init the 
 * default values (airport AMS and duration 1 week).
 * bugfix 31.08.2010 
 * #0027468: empty div element in region list causes empty line while sorting the elements.
 */

var qsmDelay = 25;
var qsmFormname = "bengine";

var IBELmpsPlus = new TTIBE("IBELmpsPlus", port, "bengine");
IBELmpsPlus.req = {input_abflughafen:"-1"};

IBELmpsPlus.initOnLoad = function() {
    var bform    = document.forms[this.formname];
    var mustHave = ["TTREGS_"+this.port, "Zielauswahl", "TTAFH"];
    var injObj   = {Zielauswahl:[]};

    for (var i in mustHave) {
        if (typeof(window[mustHave[i]]) == "undefined") {
            window.setTimeout("IBELmpsPlus.initOnLoad()", qsmDelay);
            return;
        }
    }
    this.inject(injObj);
    // set global country list optLaender654LamiPlus based on array optLaender654
    window.setTimeout("setCountryOptionsLamiPlus()", qsmDelay);
};

/*
 * calling the setTimeout method is necessary for browser chrome, safari, opera
 */
var optLaender654LamiPlus;
window.setTimeout("IBELmpsPlus.initOnLoad()", qsmDelay);

var defaultDurationSlider    = 1; // start value slider travel duration
var defaultBudgetValue       = '15_0-10000'; // default range budget slider
var defaultHotelRatingSlider = 4; // start value slider hotel rating
var defaultHotelName         = 'Type hier de naam...';
var defaultDaysReturnDate    = 30;

var isDeeplink = urlHasParameters();

$(document).ready(function() {
    
    var startValue;
	if (typeof getParams.dauer !== 'undefined' && getParams.dauer != '') {
        startValue = getDurationStepByValue(getParams.dauer);
	} else {
        if (isDeeplink) {
            startValue = 0;
        } else {
            startValue = defaultDurationSlider;    
        }
    }
    
    $("#selectedDuration").html(durationValues[startValue][1]);
//    $("#selectedDurationPricegrid").html(durationValues[startValue][1]);
	
	/**
	 * slider travel duration
	 */
	$('#sliderTravelDuration').slider({
		value : startValue,
		min : 0,
		max : 9,
		step : 1,
		slide: function(event, ui) {
			$("#selectedDuration").html(durationValues[ui.value][1]);
//            $("#selectedDurationPricegrid").html(durationValues[ui.value][1]);
//            $('#sliderTravelDurationPricegrid').slider('value', ui.value);
		},
		stop: function(event, ui){
			changeDuration(durationValues[ui.value][0], durationValues[ui.value][2]);
		}
	});	
    
    /**
     * slider travel duration pricegrid
     */
//    $('#sliderTravelDurationPricegrid').slider({
//        value : startValue,
//        min : 0,
//        max : 9,
//        step : 1,
//        slide: function(event, ui) {
//            $("#selectedDuration").html(durationValues[ui.value][1]);
//            $("#selectedDurationPricegrid").html(durationValues[ui.value][1]);
//            $('#sliderTravelDuration').slider('value', ui.value);
//        },
//        stop: function(event, ui){
//            changeDuration(durationValues[ui.value][0], durationValues[ui.value][2]);
//        }
//    }); 
	
	/**
	 * slider rating filter
	 */
	$('#sliderRatingFilter').slider({
		value : 0,
		min : 0,
		max : 4,
		step : 1,
		slide: function(event, ui) {
		},
		stop: function(event, ui){
			VRA.setValue(ui.value);
		}
	});	
    
    /**
     * slider hotel rating
     */
    $('#sliderHotelRating').slider({
        value : defaultHotelRatingSlider,
        min  : 4,
        max  : 10,
        step : 1,
        slide: function(event, ui) {
            
            var sliderHotelRatingLabel = ui.value;
            if (ui.value == '4') {
                $("#searchHotelRatingPlusm").css('display', 'none');
                sliderHotelRatingLabel = 'Alle keuzes';
            } else {
                $("#searchHotelRatingPlusm").css('display', 'block');
            }
            
            $("#searchHotelRatingValue").html(sliderHotelRatingLabel);
        },
        stop: function(event, ui){
            $('#hbfges').val(hotelRatingValues[ui.value]);
            sendSearchForm();
        }
    }); 
    
});

var googleMapOpen = true;
if (getParams.map == '0') {
    googleMapOpen = false;
}  
// Instanzen für Searchdialog Dreamreader: Abflughafen + Reiseziele
var drAfhSd = null;
var drRZSd  = null;

/* Für die Suche */
var vra                  = "";
var dauer                = "";
var kategorie            = "";
var verpflegung          = "";
var zimmer               = "";
var preis                = "";
var personen             = "";
var familie_kinder       = "";
var strand               = "";
var wellness             = "";
var typ                  = "";
var sportmoeglichkeiten  = "";
var marke                = "";
var pCalenderFrom        = null;
var pCalenderTo          = null;
var pSdCalFrom           = null;
var pSdCalTo             = null;
var dauerMin             = null;
var dauerMax             = null;
var dauer_sd             = null;
var dauerMin_sd          = null;
var dauerMax_sd          = null;
var weekNames			 = ['Zo.','Ma.','Di.','Wo.','Do.','Vr.','Za.'];
var monthNames			 = ['jan.', 'feb.', 'maart', 'april', 'mei', 'juni', 'juli', 'aug.', 'sept.', 'okt.', 'nov.', 'dec.'];

/**
 * @link X:\documentation\docs_fuer_IBE-Kunden\Deeplink_Schnellsuche\Deeplink Dokumentation Deutsch\TT-Doku_deeplinks.pdf
 * 
 * In the IBE Deeplink Documentation following values are defined for the travel duration:
 * -1        any duration
 * 9         1 - 4 days
 * 10        5 - 8 days
 * 6_7       1 week
 * 7         9 - 12 days
 * 3         13 - 15 days
 * 6_14      2 weeks
 * 12        16 - 22 days
 * 6_21      3 weeks
 * 13        > 22 days
 * 
 * But it is also possible to define:
 * 6_1-4      1 - 4 days
 * 6_5-8      5 - 8 days
 * 6_7-7      1 week
 * 6_9-12     9 - 12 days
 * 6_13-15    13 - 15 days
 * 6_14-14    2 weeks
 * 6_16-22    16 - 22 days
 * 6_21-21    3 weeks
 * 
 * Note: the values 6_1-23 (any duration) and 6_23-23 (> 22 days) will be replaced in 
 * method sendSearchForm().
 */
var durationValues = [ 
        ['6_1-23',  'Alle keuzes', '23'],
        ['6_7-7',   '1 week', '7'],
        ['6_14-14', '2 weken', '14'],
        ['6_21-21', '3 weken', '21'],
        ['6_1-4',   '1 - 4 Nachten', '4'],
        ['6_5-8',   '5 - 8 Nachten', '8'],
        ['6_9-12',  '9 - 12 Nachten', '12'],
        ['6_13-15', '13 - 15 Nachten', '15'],
        ['6_16-22', '16 - 22 Nachten', '22'],
        ['6_23-23', '&gt; 22 Nachten', '23']
    ];

/**
 * Hotel rating values.
 * Mapping between slider values and IBE values hbfges.
 */
var hotelRatingValues = ['0', '0', '0', '0', '0', '30', '35', '45', '50', '55', '60'];
var defaultHotelRatingValue = hotelRatingValues[defaultHotelRatingSlider]; // start IBE value hotel rating

/**
 * Food mapping.
 * One can call the engine with param "verpflegung" with values:
 * -1 egal
 * 0  nur Uebernachtung  (Logies)
 * 1  Fruehstueck        (Logies met ontbijt)
 * 2  Halbpension        (Halfpension)
 * 3  Vollpension        (Volpension)
 * 4  All Inclusive      (All Inclusive)
 * 5  Vollpension Plus   
 * 6  Halbpension Plus   
 * 7  All Inclusive Plus 
 * Engine returns:
 *  0   Laut Programm
 *  1   nur Uebernachtung
 *  2   Uebernachtung mit Fruehstueck
 *  4   Halbpension
 *  8   Vollpension
 * 16   All Inclusive
 * 32   Vollpension Plus
 * 64   Halbpension Plus
 * 128  All Inclusive Plus
 * Necessary to fit the requirements in ticket 0026646:
 * "show only options (in the QSM selectboxes) which are available for the selected hotel at the offerpage"
 * Remark: Vollpension Plus, Halbpension Plus, All Inclusive Plus not available in TCNL.
 * Will be mapped to Vollpension, Halbpension, All Inclusive.
 */
var foodMapping  = new Array();
foodMapping[0]   = -1;
foodMapping[1]   = 0;
foodMapping[2]   = 1;
foodMapping[4]   = 2;
foodMapping[8]   = 3;
foodMapping[16]  = 4;
foodMapping[32]  = 3;
foodMapping[64]  = 2;
foodMapping[128] = 4;

/**
 * Accommodation mapping 
 * 
 * [zimmer]
 * -1 egal
 * 5  Einzelzimmer          (1 persoonskamer)
 * 6  Doppelzimmer          (2 persoonskamer)
 * 2  Familienzimmer        (Familiekamer)
 * 0  Bungalow              (Bungalow)
 * 7  Apartment             (Appartement)
 * -2 weitere Zimmertypen
 * 
 * [zfilter] 
 * 2     Studio
 * 4     Familienzimmer
 * 8     Bungalow
 * 16    Suite
 * 32    Einzelzimmer
 * 64    Doppelzimmer
 * 128   Appartement
 * 256   Villa
 * 512   Superior
 * 1024  Dreibettzimmer
 * 2048  Duplexzimmer
 * 4096  Mehrbettzimmer
 * 8192  Ferienwohnung
 * 16384 Ferienhaus
 * 32768 Deluxe-Zimmer
 * 
 * [zfilter]               ==> [zimmer]
 * 2     Studio            ==> ?
 * 4     Familienzimmer    ==> 2  Familienzimmer
 * 8     Bungalow          ==> 0  Bungalow 
 * 16    Suite             ==> ?
 * 32    Einzelzimmer      ==> 5  Einzelzimmer 
 * 64    Doppelzimmer      ==> 6  Doppelzimmer
 * 128   Appartement       ==> 7  Apartment
 * 256   Villa             ==> ?
 * 512   Superior          ==> ?
 * 1024  Dreibettzimmer    ==> ?
 * 2048  Duplexzimmer      ==> 2  Familienzimmer
 * 4096  Mehrbettzimmer    ==> ?
 * 8192  Ferienwohnung     ==> ?
 * 16384 Ferienhaus        ==> ?
 * 32768 Deluxe-Zimmer     ==> ?
 * 
 * Necessary to fit the requirements in ticket 0026646:
 * "show only options (in the QSM selectboxes) which are available for the selected hotel"
 */
var accommodationMapping    = new Array();
accommodationMapping[0]     = -1;
accommodationMapping[2]     = -1;
accommodationMapping[4]     = 2;
accommodationMapping[8]     = 0;
accommodationMapping[16]    = -1;
accommodationMapping[32]    = 5;
accommodationMapping[64]    = 6;
accommodationMapping[128]   = 7;
accommodationMapping[256]   = -1;
accommodationMapping[512]   = -1;
accommodationMapping[1024]  = -1;
accommodationMapping[2048]  = 2;
accommodationMapping[4096]  = -1;
accommodationMapping[8192]  = -1;
accommodationMapping[16384] = -1;
accommodationMapping[32768] = -1;

/**
 * Write hidden fields
 * @param hf
 */
function writeHiddenFields(hf) {
    for(hfname in hf) {
      document.write('<input id="'+hfname+'" type="hidden" name="'+hfname+'" value="'+hf[hfname]+'">'+"\n");
    }
    
    $('#KID').val(KID);
}

/**
 * Get browser
 */
function getBrowser() {
    var browser = '';
	var vers = '';
	jQuery.each(jQuery.browser, function(i, val) {
	    if (i == 'msie' && val === true) {
	        browser += 'IE';
		} else if (i == 'mozilla' && val === true) {
	        browser += 'MOZ';
		}
		if (i == 'version') {
			vers = val;
			if (vers == '7.0') {
				vers = '7';
			} else if (vers == '6.0') {
				vers = '6';
			}
		}
    });	
	browser += vers;
	return browser;
}
var browser = getBrowser();

/**
 * Events for tooltip temperature (region lister) 
 */
var temperatureOnmouseEnter = function() { $("#tooltipTemperature").fadeIn(600); return false; };
var temperatureOnmouseLeave = function() { $('#tooltipTemperature').hide(); return false; };

var firstInit;
var searchReset = false;
var debug                   = false;
var isUpdateHiddenFields    = false;
var isUpdateRegionen        = false;
var debugSearch             = false;

var defaultAirport  = 'AMS';
var defaultDuration = '6_7-7'; // one week

/**
 * Submit search form.
 * Must be called when the user changes the search criteria.
 * In this case an AJAX request will be transmitted to call the IBE.
 * @param  stat
 * @return void
 */
function sendSearchForm (stat) {
	/**
	 * @link X:\documentation\docs_fuer_IBE-Kunden\Deeplink_Schnellsuche\Deeplink Dokumentation Deutsch\TT-Doku_deeplinks.pdf
	 * 
 	 * In the IBE Deeplink Documentation following values are defined for the travel duration:
	 * -1        any duration
	 * 9         1 - 4 days
	 * 10        5 - 8 days
	 * 6_7       1 week
	 * 7         9 - 12 days
	 * 3         13 - 15 days
	 * 6_14      2 weeks
	 * 12        16 - 22 days
	 * 6_21      3 weeks
	 * 13        > 22 days
	 * 
	 * But it is also possible to define:
	 * 6_1-4      1 - 4 days
	 * 6_5-8      5 - 8 days
	 * 6_7-7      1 week
	 * 6_9-12     9 - 12 days
	 * 6_13-15    13 - 15 days
	 * 6_14-14    2 weeks
	 * 6_16-22    16 - 22 days
	 * 6_21-21    3 weeks
	 * 
	 * In case of 6_1-23 (any duration) and 6_23-23 (> 22 days) one must rewrite 
	 * the duration parameter!
	 */
    
	//console.log('sendSearchForm');
    
	var travelDuration = $('#dauer').val();
	switch (travelDuration) {
	    case '6_1-23':
	    	$('#dauer').val('-1');
	        break;
	    case '6_23-23':
	        $('#dauer').val('13');
	        break;
	}
	
	/* Muss wieder rein */
	TTG.flagCenterMove = true;
    
	// reset the HIB scrollbox
    resetHIBScrollBox();
    
    var tmpStep;
    
    if (pStrecke.config.bestOfferModule) {
        // Angebotsfilter BestOfferModul zurücksetzen
        pBom.emptyFilterCollected();
    }
    
    if (pStrecke.reqSearchForm !== null) {
        pStrecke.reqSearchForm.abort();
    }
    
    tmpStep = pStrecke.step;
    
    if (isUpdateHiddenFields || isUpdateRegionen) {
		tmpStep = $("#detail").val();
	}
    
    var destination = [];
    destination = getAjaxDestination(tmpStep);

//	if (stat != 'oF' && tmpStep == 'hotel') {
//		OF.isClicked = false;
//		$('#s_ort').val('');
//		var tmpOrtsFilterSelectedRow = OF.selectedRow;
//       
//		setTimeout( function() {
//            
//			OF.handleOrtsFilter();
//			$('#s_ort').val(OF.selectedOrt);
//			OF.selectedRow = tmpOrtsFilterSelectedRow;
//			OF.isClicked = true;
//			pStrecke.reqSearchForm = sendPostRequest(destination[0], 'formSearch', null, destination[1], null, null, true);
//		},520);
//	} else {
//		pStrecke.reqSearchForm = sendPostRequest(destination[0], 'formSearch', null, destination[1], null, null, true);
//	}

    pStrecke.reqSearchForm = sendPostRequest(destination[0], 'formSearch', null, destination[1], null, null, true);

    if (debug) {
        debugForm();
    }
}

/**
 * --- InitSearch -----------------------------------------------------------
 * Will be called, when the user loads or reloads the page.
 * If the user jumps into the IBE via Deeplink, the GET parameters will be considered
 * to initialize the search form and parameters.
 * Note: If config value pStrecke.usingUrlSession = true the session params will 
 * be assigned to variable getParams (i.e. getParams = sessionParams).
 * If the search is initialized the global variable firstInit will be set to false.
 */
function initSearch() { 

    // IE Bugfix: check if the main form exist.
    // Might not be defined in case of a deeplink.
    var testForm = document.forms[qsmFormname];
    if (testForm == undefined) {
        return;
    }
    
    // check if deeplink parameter values must be transformed.
    deepLinkMapping();
    
	if (debugSearch && typeof console != 'undefined') {
		console.log('initSearch');
		console.log(getParams);
		console.log(sessionParams);
	}

    firstInit = true;
    
    if (typeof optLaender654LamiPlus == 'undefined') {
        optLaender654LamiPlus = getCountryOptionsLamiPlus();
    }
    
    if (pStrecke.config.bestOfferModule) {
        // BestOfferModul - Filter-Gruppen
        pBom.addFilterGroup('filterRoom', 'Zimmertypen');
        pBom.addFilterGroup('filterBoard', 'Verpflegungsoptionen');
        pBom.addFilterGroup('filterAirport', 'Abflughäfen');    
        pBom.addFilterGroup('filterTransfer', 'Transferoptionen', {
            enabled: ['Transfer']
        });
    }
    
    // init IBE param s_ort
    if (typeof getParams.s_ort != 'undefined' && getParams.s_ort != '') {
        $("#s_ort").val(unescape(getParams.s_ort));
    } 
    
    // init IBE param lcfilter
    if (typeof getParams.lcfilter != 'undefined' && getParams.lcfilter != '') {
        $("#lcfilter").val(getParams.lcfilter);
    } else {
        $("#lcfilter").val(''); 
    }
    
    // init IBE param sleistung
    if (typeof getParams.sleistung != 'undefined' && getParams.sleistung != '') {
        $("#sleistung").val(getParams.sleistung);
    } else {
        $("#sleistung").val(''); 
    }
    
    // init IBE param zfilter
    if (typeof getParams.zfilter != 'undefined' && getParams.zfilter != '') {
        $("#zfilter").val(getParams.zfilter);
    } else {
        $("#zfilter").val(''); 
    }
    
    // init IBE param IFFFilter
    if (typeof getParams.IFFFilter != 'undefined' && getParams.IFFFilter != '') {
        $("#IFFFilter").val(getParams.IFFFilter);
    } else {
        $("#IFFFilter").val(''); 
    }
    
    // init travel duration
    if (typeof getParams.dauer != 'undefined' && getParams.dauer != '') {
        $("#dauer").val(getParams.dauer);
        startValue = getDurationStepByValue(getParams.dauer);
        $('#sliderTravelDuration').slider('value', startValue);
//        $('#sliderTravelDurationPricegrid').slider('value', startValue);
    } else {
        if (isDeeplink) {
            $("#dauer").val('-1');
        } else {
            $("#dauer").val(defaultDuration);
        }
        
    }
    
    // init hotel rating
    if (typeof getParams.hbfges != 'undefined' && getParams.hbfges != '') {
        $("#hbfges").val(getParams.hbfges);
        var startSliderHotelRating = getHotelRatingStepByValue(getParams.hbfges);
        $('#sliderHotelRating').slider('value', startSliderHotelRating);
        var sliderHotelRatingLabel = startSliderHotelRating;
        if (parseInt(startSliderHotelRating) == 0) {
            $("#searchHotelRatingPlusm").css('display', 'none');
            sliderHotelRatingLabel = 'Alle keuzes';
        } else {
            $("#searchHotelRatingPlusm").css('display', 'block');
        }
        $("#searchHotelRatingValue").html(sliderHotelRatingLabel);
    } else {
        $("#hbfges").val(defaultHotelRatingValue);
    }
    
    if ($('#preis').val() == '') {
        if (typeof getParams.preis != 'undefined') {
            $('#preis').val(getParams.preis);
        } else {
            $('#preis').val(defaultBudgetValue);
        }
    }
    
    if ($('#hbfges').val() == '' || $('#hbfges').val() == '0') {
        $('#hbfges').val('');
    }
    
    if ($('#hbfempf').val() == '' || $('#hbfempf').val() == '0') {
        $('#hbfempf').val('');
    }
    
    // init budget slider
    window.setTimeout("initSliderBudget()", qsmDelay);
    
    // if get param flugdauer isset and topRegion is undefined ==> topRegion = flugdauer
    if (typeof getParams.flugdauer != 'undefined' && 
        getParams.flugdauer >= 10000 && 
        typeof getParams.topRegion == 'undefined') {
        getParams.topRegion = getParams.flugdauer;
        $("#topRegion").val(getParams.topRegion); 
    }   
    
    // if get param topRegionen (e.g 10007;10008;568;613) isset 
    // ==> topRegion = first element of topRegionen
    if (typeof getParams.topRegionen != 'undefined' && getParams.topRegionen != '') {
        var topRegionen = getParams.topRegionen.split(';');
        if (topRegionen.length > 0) {
            getParams.topRegion = topRegionen[0];
            $("#topRegion").val(topRegionen[0]);
        }
    } else {
        $("#topRegionen").val(''); 
    }
    
    // init top regions and top regiongroups
    if (typeof getParams.topRegion != 'undefined' && getParams.topRegion != '') {
        // in this case the get param topRegion will be written to the hidden field 
        // topRegion by file /booking/ibe_ajax/inc/init.inc.php 
        var topRegionGroup;
        if (getParams.topRegion < 10000) {
            // in case of a top region
            topRegionGroup = getTopRegionGroupByTopRegion(getParams.topRegion); 
        } else {
            // in case of a top region group
            topRegionGroup = getParams.topRegion;
        }
        
        selectedOption = getCountryOption(topRegionGroup);
        
        var options = $('#tt_countries').find('option');
        $(options).remove();
        
        var countries = document.getElementsByName('tt_countries')[0];
        
        // set default option
        if (countries) {
            countries.options[0] = new Option('Alle keuzes', '-1', true, true);
        }
        
        if (port == 654) {
            fillSelectbox("tt_countries", optLaender654LamiPlus, selectedOption);
        }
        
        try {
            // @see /booking_ml/jslib/formulare/nl/zielauswahl_land.js
            // RZC := ReiseZiel onChange
            if (!jQuery.isFunction(IBELmpsPlus.RZC)) {
                window.setTimeout("IBELmpsPlus.initOnLoad()", qsmDelay);
                window.setTimeout(function() { IBELmpsPlus.RZC(1); }, qsmDelay); // Reiseziel onchange
            } else {  
                window.setTimeout(function() { IBELmpsPlus.RZC(1); }, qsmDelay); // Reiseziel onchange
            }
        }
        catch (e) {
            alert("An error occured (" + e + ")\n\nPlease reload the page.");
        }
        
        if (getParams.topRegion < 10000) {
            window.setTimeout(function() { setRegion(getParams.topRegion); }, qsmDelay);
        } 
    
    } else {
        
        if (port == 654) {
            fillSelectbox("tt_countries", optLaender654LamiPlus);
        }  
        
        /*
         * calling the setTimeout method is necessary for browser chrome, safari, opera
         */
        try {
            // @see /booking_ml/jslib/formulare/nl/zielauswahl_land.js
            if (!jQuery.isFunction(IBELmpsPlus.RZC)) {
                window.setTimeout("IBELmpsPlus.initOnLoad()", qsmDelay);
                window.setTimeout("IBELmpsPlus.RZC()", qsmDelay); // Reiseziel onchange
            } else {
                window.setTimeout("IBELmpsPlus.RZC()", qsmDelay); // Reiseziel onchange
            }
        } catch (e) {
            alert("An error occured (" + e + ")\n\nPlease reload the page."); 
        } 
    }
    
    // init airports and touroperators
    window.setTimeout("initAirportAndTouroperator()", qsmDelay);
    
    if (pStrecke.step != 'termine') {
           $('#hotel_touroperators').val(''); 
           $('#hotel_airports').val(''); 
    } else {
        if (typeof(getParams.hotel_touroperators) != 'undefined' && getParams.hotel_touroperators.length > 0) {
            $('#hotel_touroperators').val(getParams.hotel_touroperators); 
        }
        if (typeof(getParams.hotel_airports) != 'undefined' && getParams.hotel_airports.length > 0) {
            $('#hotel_airports').val(getParams.hotel_airports); 
        }
    }
   
    // init hotel name  
    initHotelName();
    
	PERSONS.ADULTS.deepLinkInit(getParams.personen);
	PERSONS.CHILDS.init();
	PERSONS.CHILDS.deepLinkInit(getParams.personen);
	// hotel rating
	VRA.deepLinkInit(getParams.hbf_detail); 
    // hotel category	
    STARS.deepLinkInit(getParams.kategorie);
    // food
	VERPFL.deepLinkInit(getParams.verpflegung);
    // room type
	ROOM.deepLinkInit(getParams.zimmer);
    // hotel details
	HD.deepLinkInit(getParams.familie_kinder, getParams.strand, getParams.wellness, getParams.typ, getParams.sportmoeglichkeiten);

	// init calendars
	window.setTimeout("initCalendars()", qsmDelay);
//    window.setTimeout("initPricegridCalendar()", qsmDelay);
	// submit search form
	window.setTimeout("sendSearchForm()", qsmDelay);
    window.setTimeout(function() { firstInit = false; }, 600);  
}


/** 
 *  Reset the quicksearch module
 *  Note: searchReset will be set to true, to avoid calling method
 *  TTMainCustomer::resetAirportAndTouroperator()
 */
function resetSearch() {
	
    if (typeof optLaender654LamiPlus == 'undefined') {
        optLaender654LamiPlus = getCountryOptionsLamiPlus();
    }
    
    $("#dauer").val(defaultDuration);
    $('#sliderTravelDuration').slider('value', defaultDurationSlider);
    $("#selectedDuration").html(durationValues[defaultDurationSlider][1]);
    // reset QSM pricegrid
//    $('#sliderTravelDurationPricegrid').slider('value', defaultDurationSlider);
//    $("#selectedDurationPricegrid").html(durationValues[defaultDurationSlider][1]);
    
    $('#termin').val('');
    $('#ruecktermin').val('');
    $('#position').val('-1');
    
    $("#zgk").val('');
    $("#flugdauer").val('');
    $("#topRegion").val('');
    $("#topRegionen").val(''); 
   
    $('#abflughafen').val(defaultAirport);
    $('#input_abflughafen').find('option').remove();
    var input_abflughafen = document.getElementById('input_abflughafen');
    var defaultOption = new Option('Alle keuzes', '-1', true, true);
    if (input_abflughafen) {
        input_abflughafen.options[0] = defaultOption;
    }
    
    $('#preis').val(defaultBudgetValue);
    $("#sliderBudget").slider( "destroy" );
    
    $('#hbfges').val('');
    $('#hbfempf').val('');
    $('#hbfanzf').val('');
    $('#hbf_detail').val('');
    
    $('#sportangebot').val('-1');
    $('#marke').val('');
    $('#zimmer').val('');
    $('#verpflegung').val('');
    $('#kategorie').val('');
    $("#lcfilter").val('');
    $("#sleistung").val(''); 
    $("#zfilter").val('');
    $("#IFFFilter").val(''); 
    
    $('#tt_countries').find('option').remove();
    var tt_countries = document.getElementById('tt_countries');
    var defaultOption = new Option('Alle keuzes', '-1', true, true);
    if (tt_countries) {
        tt_countries.options[0] = defaultOption;
    }
    
    $('#tt_region').find('option').remove();
    var tt_region = document.getElementById('tt_region');
    var defaultOption = new Option('Alle keuzes', '-1', true, true);
    if (tt_region) {
        tt_region.options[0] = defaultOption;
    }
    
    $('#foodSelect').find('option').remove();
    $('#roomSelect').find('option').remove();
    $('#operatorSelect').find('option').remove();
    var operatorSelect = document.getElementById('operatorSelect');
    var defaultOption = new Option('Alle keuzes', '-1', true, true);
    if (operatorSelect) {
        operatorSelect.options[0] = defaultOption;
    }
    
    // init budget slider
    initSliderBudget();
    
    try {
	    fillSelectbox("input_abflughafen", TTAFH, defaultAirport);
	    if (port == 654) {
		    fillSelectbox("tt_countries", optLaender654LamiPlus);
		    fillSelectbox("input_marke", arrMarke_654);
	    } 
        if (!jQuery.isFunction(IBELmpsPlus.RZC)) {
            window.setTimeout("IBELmpsPlus.initOnLoad()", qsmDelay);
            window.setTimeout("IBELmpsPlus.RZC()", qsmDelay); // Reiseziel onchange
        } else {
            // @see /booking_ml/jslib/formulare/nl/zielauswahl_land.js
            window.setTimeout("IBELmpsPlus.RZC()", qsmDelay); // Reiseziel onchange
        } 
    } catch (e) {
    	alert("An error occured (" + e + ")\n\nPlease reload the page."); 
    }

    $('#personen').val('25;25');
    PERSONS.ADULTS.changeCss('inactive', 1);
    PERSONS.ADULTS.changeCss('active', 2);
    PERSONS.ADULTS.changeCss('inactive', 3);
    PERSONS.ADULTS.changeCss('inactive', 4);
	$('.amountAdultsValue').text(2);
	PERSONS.CHILDS.setSelectbox(null, null, null, null, 'childCombo');
//	PERSONS.CHILDS.setSelectbox(null, null, null, null, 'childComboPricegrid');
	PERSONS.CHILDS.changeTxt();      

	// reset rating filter
	VRA.setValue(0, false);
	$('#sliderRatingFilter').slider('value', 0);
	
    // reset hotel rating
    $("#hbfges").val(defaultHotelRatingValue);
    $('#sliderHotelRating').slider('value', defaultHotelRatingSlider);
    $("#searchHotelRatingValue").html('Alle keuzes');
    $("#searchHotelRatingPlusm").css('display', 'none');
    
    // reset hotel name
    $('#shotel').val('');
    $('#input_shotel').val(defaultHotelName);
    
    // reset location filter
    $("#s_ort").val('');
    
    // reset category
    for (var i = 1; i <= 5; i++) {
        $('#stars_' + i).attr('class', 'searchStarsUnchecked');
    } 
    $('#stars_1').attr('class', 'searchStarsChecked');
    $("#kategorie").val('-1');
    
    // reset QSM pricegrid
//    $('#roomSelectPricegrid').find('option').remove();
//    $('#foodSelectPricegrid').find('option').remove();
	VERPFL.deepLinkInit();
	ROOM.deepLinkInit();
 	
	$('#familie_kinder').val('');
	$('#strand').val('');
	$('#wellness').val('');
	$('#typ').val('');
	$('#sportmoeglichkeiten').val('');
	
	$('#hotelDetailsCheck0').attr('checked', false);
	$('#hotelDetailsCheck1').attr('checked', false);
	$('#hotelDetailsCheck2').attr('checked', false);
	$('#hotelDetailsCheck3').attr('checked', false);
    
	// reset calendar
    window.setTimeout("resetCalendars()", qsmDelay);
    TTG.initializeGoogleMap();
    
    var pageScrollPosition = getPageScrollTopPosition();
    if (pStrecke.step != 'region') {
        $("#detail").val('region');
        try {
            terminHin = termin_min_654;
            terminRueck = getDefaultReturnDate();   
            
            $('#termin').val(terminHin);
            $('#ruecktermin').val(terminRueck);
            
        } catch (e) {
            alert("An error occured (" + e + ")\n\nPlease reload the page."); 
        }

        pStrecke.goToRegions(false, null, false);
       
        if (pageScrollPosition > 160) {
            // scroll to top of list
            scrollTo(0, 160);
        }
        
        return;
    }
    
    searchReset = true;
    // submit search form
    window.setTimeout("sendSearchForm()", qsmDelay);
    
    if (pageScrollPosition > 160) {
        // scroll to top of list
        scrollTo(0, 160);
    }
      
}

/**
 * Reset the HIB scrollbox
 */
function resetHIBScrollBox() {
    
    if (typeof ttScrollBox !== undefined) {
        ttScrollBox.actBoxId      = '';
        ttScrollBox.newBoxId      = '';
        ttScrollBox.actScrollType = '';
        ttScrollBox.newScrollType = '';
        ttScrollBox.livingBoxes   = new Array();
        ttScrollBox.actPort       = '';
        ttScrollBox.actSourceElem = null;
        ttScrollBox.actRefBox     = null;
        ttScrollBox.box           = null;
    }
}

/** 
 *  Check deeplink paramater values - which could be generated with a deeplink 
 *  generator - if they must be transformed to new values according to the 
 *  expected IBE Ajax quicksearch paramter values.
 */
function deepLinkMapping() {
    
    //console.log('deepLinkMapping');
    
    if (typeof getParams.dauer != 'undefined' && getParams.dauer != '' && getParams.dauer != '-1') {
        getParams.dauer = checkDauerParamater(getParams.dauer);
    }
    
    if (typeof getParams.hbfilter != 'undefined' && getParams.hbfilter != '') {
        // @todo check if there is something todo
        //pStrecke.setHbDetail
    }
    
    if (typeof getParams.IFF != 'undefined' && getParams.IFF != '') {
        // in this case the get param IFF will be written to the hidden field 
        // IFF by file /booking/ibe_ajax/inc/init.inc.php
        if (typeof getParams.topRegion != 'undefined' && getParams.topRegion != '') {
            // @todo check the difference between topRegion, zgk (zielgebietskenner) and flugdauer
            // check if this is necessary
            //$('#zgk').val(getParams.topRegion);
        }
    }
    
    if (typeof getParams.preis != 'undefined' && getParams.preis != '') {
        
        switch (getParams.preis) {
            // whatever
            case "-1":
                $('#preis').val('15_0-10000');
                break;
            // up to 300 EUR
            case "1":
                $('#preis').val('15_0-300');
                break;
            // up to 500 EUR    
            case "2":
                $('#preis').val('15_0-500');
                break;
            // up to 750 EUR   
            case "3":
                $('#preis').val('15_0-750');
                break;
            // up to 1000 EUR      
            case "4":
                $('#preis').val('15_0-1000');
                break;  
            // fallback (whatever)  
            default:
                var regexp = /(15_[\d]+-[\d]+)/;
                regexp.exec(getParams.preis);
                var priceVal = RegExp.$1;
                if (priceVal.length == 0) {
                    $('#preis').val('15_0-10000');
                }
                break;         
        } 
    }
    
    if (typeof getParams.erwachsene != 'undefined' && getParams.erwachsene != '') {
        var persons = unescape(getParams.erwachsene);
        var aPersons = new Array();
        if (persons.length > 0) {
            aPersons = persons.split(';');
            if (typeof getParams.alter1 != 'undefined' && getParams.alter1.length > 0 && 
                getParams.alter1 != '-1' && parseInt(getParams.alter1) > 0) {
                aPersons.push(getParams.alter1);
            }
            if (typeof getParams.alter2 != 'undefined' && getParams.alter2.length > 0 && 
                getParams.alter2 != '-1' && parseInt(getParams.alter2) > 0) {
                aPersons.push(getParams.alter2);
            }
            if (typeof getParams.alter3 != 'undefined' && getParams.alter3.length > 0 && 
                getParams.alter3 != '-1' && parseInt(getParams.alter3) > 0) {
                aPersons.push(getParams.alter3);
            }
        }
        
        if (aPersons.length > 0) {
            getParams.personen = aPersons.join(';');
        }
    }
    
}

/**
 * @todo description
 * @param string tmpStep
 */
function getAjaxDestination (tmpStep) {
    
    //console.log('getAjaxDestination');

    var destination = new Array();
    
    /* call via deeplink */
    if (getParams.detail !== undefined) {
        tmpStep = getParams.detail;
    }
    
    switch(tmpStep) {
        case "region": 
            if (typeof getParams.flugdauer !== 'undefined') {
                getParams.flugdauer = '';
            }
            destination[0] = pathDevAbsolute + "booking/ibe_ajax/inc/getRegionData.script.php?";
            destination[1] = "pRegionen.showList(null)"; 
            break; 
//        case "regionGroup":  
        case "zielgebiet":  
            // if flugdauer or topregion is defined, we will go to the hotel page directly.
            if (getParams.flugdauer === undefined) {
                if (getParams.topRegion !== undefined) {
                    getParams.flugdauer = '';
                    destination[0] = pathDevAbsolute + "booking/ibe_ajax/inc/getHotelData.script.php?";
                    destination[1] = "pHotels.showList()";  
                } else {
                    destination[0] = pathDevAbsolute + "booking/ibe_ajax/inc/getRegionData.script.php?";
                    destination[1] = "pRegionen.showList(null)";  
                }
            } else if (getParams.flugdauer >= 10000) {
                if (getParams.topRegion === undefined) {
                    getParams.topRegion = getParams.flugdauer;
                }
                destination[0] = pathDevAbsolute + "booking/ibe_ajax/inc/getHotelData.script.php?";
                destination[1] = "pHotels.showList()"; 
            } else {
                destination[0] = pathDevAbsolute + "booking/ibe_ajax/inc/getRegionData.script.php?";
                destination[1] = "pRegionen.showList(null)";  
            }
            
            if (typeof getParams.topRegionen != 'undefined' && getParams.topRegionen != '') {
                var topRegionen = getParams.topRegionen.split(';');
                if (topRegionen.length > 0) {
                    destination[0] = pathDevAbsolute + "booking/ibe_ajax/inc/getHotelData.script.php?";
                    destination[1] = "pHotels.showList()"; 
                }
            }
            
// if pStrecke.isSingleRegionView = true ==> will cause the regionGroup case, which we do not want here
// because if a country|region|flugdauer|topRegion is defined, we will go to the hotel page directly. 
//                if (getParams.flugdauer >= 10000) {
//                    pStrecke.isSingleRegionView = true;   
//                }
                    
          break;
        case "hotel":   
            destination[0] = pathDevAbsolute + "booking/ibe_ajax/inc/getHotelData.script.php?";
            destination[1] = "pHotels.showList()"; 
          break; 
        case "termine": 
            if (pStrecke.config.bestOfferModule) {
                $('#bomType').val('');
                destination[0] = pathDevAbsolute + "booking/ibe_ajax/inc/getBomData.script.php?";
                destination[1] = "pTermine.responseBom()";                                     
            } else {
                destination[0] = pathDevAbsolute + "booking/ibe_ajax/inc/getTerminData.script.php?";
                destination[1] = "pTermine.showList()";
            }
          break;
        default:        
            destination[0] = pathDevAbsolute + "booking/ibe_ajax/inc/getRegionData.script.php?";
            destination[1] = "pRegionen.showList(null)";   
          break;
    }
    return destination;
}

/* --- searchCallback ------------------------------------------------------- */
function searchCallback (step) {
    
    //console.log('searchCallback');
    
    $("#detail").val(step);
    
    if (step == 'region') {
        $('#s_ort').val('');
//        OF.selectedRow = 0;
//        OF.selectedOrt = '';
//        OF.isClicked   = false;
//        OF.handleOrtsFilter();
    }

    if (step == 'hotel') {
//        OF.handleOrtsFilter();
    }

    if (step == 'termine') {
        STARS.disable(1);
        HD.disable(1);
        $('#vraDisabled').css({'display':'block'});
    } else {
        STARS.disable(0);
        HD.disable(0);
        $('#vraDisabled').css({'display':'none'});
    }
}

/* --- Formular Ausgabe / Debug --------------------------------------------- */
function debugForm() {
    var debugStr = $("#formSearch").serialize();
    
    debugStr = debugStr.replace(/=/g, ':</b> ');
    debugStr = debugStr.replace(/&/g, '<br><b>');
    debugStr = '<b>' + debugStr;
    //alert(debugStr);
    $("#debugContent").html(unescape(debugStr));
}

/**
 * fill select-box with options
 * @param string selname
 * @param array  arrdata
 * @param string selected 
 */
function fillSelectbox(selname, arrdata, selected) {
    
    var sb = document.getElementsByName(selname)[0] || 0;
    if (!sb || sb.type != 'select-one') { 
        return;
    }
    var sel = selected != 'undefined' ? selected : '';
    if (typeof arrdata !== 'undefined') {
        for (var i = 0; i < arrdata.length; i++) {
            var lbl = arrdata[i].split(';')[0];
            var val = arrdata[i].split(';')[1];
            
            sb.options[sb.options.length] = new Option(lbl, val);
            
            if (val == sel) {
                sb.options[sb.options.length-1].selected = true;
            }
        } 
    } else {
        return;
    }
}

/**
 * Init airport and touroperator selectboxes
 * Note: searchReset will be set to true, to avoid calling method
 * TTMainCustomer::resetAirportAndTouroperator()
 */
function initAirportAndTouroperator() { 
    
    //console.log('initAirportAndTouroperator')
    
    if (typeof(getParams.abflughafen) != 'undefined' && getParams.abflughafen != '') {
        $('#abflughafen').val(getParams.abflughafen);
        var input_abflughafen = document.getElementById('input_abflughafen');
        var options = $(input_abflughafen).find('option');
        $(options).remove();
        if (input_abflughafen) {
            input_abflughafen.options[0] = new Option('Alle keuzes', '-1', true, true);
        }
        fillSelectbox('input_abflughafen', TTAFH, getParams.abflughafen);
    } else {
        if (isDeeplink) {
            $('#abflughafen').val('-1');
            fillSelectbox("input_abflughafen", TTAFH);
        } else {
            $('#abflughafen').val(defaultAirport);
            fillSelectbox("input_abflughafen", TTAFH, defaultAirport);
        }
    }
    
    if (typeof(getParams.marke) != 'undefined' && getParams.marke != '') {
        $('#marke').val(getParams.marke);
        var operatorSelect = document.getElementById('operatorSelect');
        var options = $(operatorSelect).find('option');
        $(options).remove();
        if (operatorSelect) {
            operatorSelect.options[0] = new Option('Alle keuzes', '-1', true, true);
        }
        if (port == 654) {
            fillSelectbox("input_marke", arrMarke_654, getParams.marke);
        }  
    } else {
        if (port == 654) {
            fillSelectbox("input_marke", arrMarke_654);
        }  
    }
    searchReset = true; 
}

/**
 * Search hotel name.
 */
function searchHotelName() {
    
    //console.log('searchHotelName');
    var hotelName = $('#input_shotel').val();
    if (hotelName != defaultHotelName) {
        $('#shotel').val(hotelName);
        sendSearchForm();
    }
}

/**
 * Init input field for hotel name search.
 */
function initHotelName () {
    
    if (typeof(getParams.shotel) != 'undefined' && getParams.shotel != '') {
         $('#shotel').val(getParams.shotel);
         $('#input_shotel').val(unescape(getParams.shotel));
    } else {
         $('#input_shotel').val(defaultHotelName);
    }
    
    $('#input_shotel').bind('focus', function(event) {
        if ($('#input_shotel').val() == defaultHotelName) {
             $('#input_shotel').val('');
        }
    });    
    
    $('#input_shotel').bind('change', function(event) {
        searchHotelName();
    });  
    
}

/**
 * Reset the country and region selectbox, if user jumps back to the first step or
 * selects a region from the region list.
 * @param zgKenner Zielgebietskenner = topRegion group
 */
function initCountry (zgKenner) {
    
    //console.log('initCountry');
    
    if (typeof optLaender654LamiPlus == 'undefined') {
        optLaender654LamiPlus = getCountryOptionsLamiPlus();
    }
    
    TTRegionListCustomer.init();
    
    var selectedOption = '-1';
    if (zgKenner > 0) {
        selectedOption = getCountryOption(zgKenner);
    }
    
    var countries = document.getElementsByName('tt_countries')[0];
    var options = $(countries).find('option');
    $(options).remove();
    // set default option
    if (countries) {
        countries.options[0] = new Option('Alle keuzes', '-1');
    }
    if (port == 654) {
        fillSelectbox("tt_countries", optLaender654LamiPlus, selectedOption);
    }
    
    try {
        // @see /booking_ml/jslib/formulare/nl/zielauswahl_land.js
        // RZC := ReiseZiel onChange
        window.setTimeout(function() { IBELmpsPlus.RZC(1); }, qsmDelay);
    }
    catch (e) {
        alert("An error occured (" + e + ")\n\nPlease reload the page.");
    }
    
}

/**
 * Set the region and country selectbox, if user selects a region from the region list.
 * @param topRegion 
 * @param topRegionGroup 
 */
function initRegion (topRegion, topRegionGroup) {
    
    initCountry(topRegionGroup);
    var regions = document.getElementsByName('tt_region')[0];
    var options = $(regions).find('option');
    $(options).remove();
    
    for (var i = 0; i < options.length; i++) {
        
        var splittedOption = options[i].value.split("|");
        
        if (splittedOption[2] && splittedOption[2] == topRegion) {
            options[i].selected = true;
        } else {
            options[i].selected = false;
        }
        $(regions).append(options[i]);
    }
}

/**
 * Set the region selectbox.
 * @param topRegion
 */
function setRegion(topRegion) {
    
    var regions = document.getElementsByName('tt_region')[0];
    var options = $(regions).find('option');
    $(options).remove();
    
    for (var i = 0; i < options.length; i++) {
        var splittedOption = options[i].value.split("|");
        if (splittedOption[2] && splittedOption[2] == topRegion) {
            options[i].selected = true;
        } else {
            options[i].selected = false;
        }
        $(regions).append(options[i]);
    }
}

/**
 * Reset calendars
 */
function resetCalendars() {
    initCalendars(true);
//    initPricegridCalendar(true);
}

/**
 * Init calendars
 * @param bool reset
 */
function initCalendars(reset) {

    var oDate = new Date();
    var test;

    if (!reset) {
        if (typeof getParams.termin != 'undefined' && getParams.termin != '') { 
            terminHin = checkDateFormat(getParams.termin);
        }
        if (typeof getParams.ruecktermin != 'undefined' && getParams.ruecktermin != '') {
            terminRueck = checkDateFormat(getParams.ruecktermin);
        }
    } else {
        terminHin = ''; 
        terminRueck = '';
    }

//    var travelDuration = $('#dauer').val();
//
//    switch (travelDuration) {
//        case '-1':
//            var days = 23;
//            break;
//        case '13':
//            var days = 23;
//            break;
//        default:
//            var days = travelDuration.split('_')[1].split('-')[1];;
//            break;
//    }
    
    /*
     * Some browser (chrome, safari) do have problems with the dynamically included file termine_654.js,
     * where the variables termin_min_654 and termin_max_654 are defined.
     */
    try {
        test = termin_min_654;
    }  catch (e) {
        //alert("error (" + e + ")");
        termin_min_654 = parseInt(oDate.getTime() / 1000) + (86400 * 2);
        termin_max_654 = getDefaultReturnDate();
    }
    
    try {
        if (terminHin == '') {
            terminHin = parseInt(termin_min_654);
        }
        if (terminRueck == '') {
            terminRueck = getDefaultReturnDate();   
        }
        
        // Such-Parameter initialisieren
        $('#termin').val(terminHin);
        $('#ruecktermin').val(terminRueck);
        
        pCalenderFrom = new TTCalendar({
            idFrom: 'idCalFrom',
            curDate: terminHin,
            callback: 'cbCalendarDay',
            dateFromMin: termin_min_654 
        });    
        pCalenderFrom.setFormat('dd.mm.yy');
        pCalenderFrom.setWeekNames(weekNames);
        pCalenderFrom.setMonthNames(monthNames);
        pCalenderFrom.show();
        
        pCalenderTo = new TTCalendar({
            idFrom: 'idCalTo',
            curDate: terminRueck,
            callback: 'cbCalendarReturnDate',
            dateFromMax: termin_max_654 
        }); 
        pCalenderTo.setFormat('dd.mm.yy');  
        pCalenderTo.setWeekNames(weekNames);
        pCalenderTo.setMonthNames(monthNames);
        pCalenderTo.show();   
        
    } catch (e) {
        alert("An error occured (" + e + ")\n\nPlease reload the page."); 
    }
}

/**
 * Init pricegrid calendar 
 * Note: not requested anymore.
 * @deprecated since version 2.2.0
 */
function initPricegridCalendar(reset) {

    if (!reset) {
        if (typeof getParams.termin != 'undefined' && getParams.termin != '') {
            terminHin = getParams.termin;
        }
        if (typeof getParams.ruecktermin != 'undefined' && getParams.ruecktermin != '') {
            terminRueck = getParams.ruecktermin;
        }
    } else {
        terminHin = ''; 
        terminRueck = '';
    }
    
    var oDate = new Date();
//    var travelDuration = $('#dauer').val();
//    
//    switch (travelDuration) {
//        case '-1':
//            var days = 23;
//            break;
//        case '13':
//            var days = 23;
//            break;
//        default:
//            var days = travelDuration.split('_')[1].split('-')[1];;
//            break;
//    }
    
    try {
        if (terminHin == '' && terminRueck == '') {
            terminHin = termin_min_654;
            terminRueck = getDefaultReturnDate();   
        }
        
        // Such-Parameter initialisieren
        $('#termin').val(terminHin);
        $('#ruecktermin').val(terminRueck);

        pCalenderFromPricegrid = new TTCalendar({
            idFrom: 'idCalFromPricegrid',
            curDate: terminHin,
            callback: 'cbCalendarDepartureDatePricegrid',
            dateFromMin: termin_min_654 
        });    
        pCalenderFromPricegrid.setFormat('dd.mm.yy');
        pCalenderFromPricegrid.setWeekNames(weekNames);
        pCalenderFromPricegrid.setMonthNames(monthNames);
        pCalenderFromPricegrid.show();
        
        pCalenderToPricegrid = new TTCalendar({
            idFrom: 'idCalToPricegrid',
            curDate: terminRueck,
            callback: 'cbCalendarReturnDatePricegrid',
            dateFromMax: termin_max_654 
        }); 
        pCalenderToPricegrid.setFormat('dd.mm.yy');  
        pCalenderToPricegrid.setWeekNames(weekNames);
        pCalenderToPricegrid.setMonthNames(monthNames);
        pCalenderToPricegrid.show();   
        
    } catch (e) {
        alert("An error occured (" + e + ")\n\nPlease reload the page."); 
    }
}

/**
 * Callback function if startdate will be changed.
 * 
 * @param object date
 * @param string id
 */ 
function cbCalendarDay(date, id) {  
    
    var aDate = date.split('-');
    var oDate = new Date(aDate[0], parseFloat(aDate[1]) - 1, aDate[2]);
    
    var previousDepartureDate = $('#termin').val(); 
    var newDepartureDate      = oDate.getTime() / 1000;   
    var change                = newDepartureDate - previousDepartureDate;
    var numSecondsADay        = 86400;
    var numSecondsAMonth      = numSecondsADay * 30;  
    var changeDays = Math.round(change / numSecondsADay);  
    change = changeDays * numSecondsADay; // change in seconds

    // change return date only if the change is smaller than one month
    // otherwise change return date to one month later
    var greaterOneMonth = false; 
    if ((change > 0 && change > numSecondsAMonth) || (change < 0 && change < -numSecondsAMonth)) {
        change = numSecondsAMonth;
        greaterOneMonth = true;
    }

    $('#termin').val(newDepartureDate);
    // trigger pricegrid calendar
//    pCalenderFromPricegrid.setDate(newDepartureDate);
    
    // set the new date in the return date calendar depending on the change of 
    // the departure date
    var currentReturnDate = $('#idCalTo').attr('date');  
    var aReturnDate = currentReturnDate.split('-');
    var oReturnDate = new Date(aReturnDate[0], parseFloat(aReturnDate[1]) - 1, aReturnDate[2]);
    var newReturnDateCalendar;
    if (greaterOneMonth) {
        newReturnDateCalendar = parseInt(newDepartureDate) + change + (numSecondsADay / 2);
    } else {
        newReturnDateCalendar = parseInt(oReturnDate.getTime() / 1000) + change + (numSecondsADay / 2);
    }
    
    // set global values
    terminHin = newDepartureDate;
    terminRueck = newReturnDateCalendar;    

    $('#ruecktermin').val(newReturnDateCalendar);
    
    pCalenderTo.setDate(newReturnDateCalendar);
    // trigger calendar
//    pCalenderToPricegrid.setDate(newReturnDateCalendar);
   
    sendSearchForm();
}

/**
 * Callback function, if return date will be changed.
 * 
 * @param object date
 * @param string id
 */ 
function cbCalendarReturnDate(date, id) {  
    
    var aDate = date.split('-');
    var oDate = new Date(aDate[0], parseFloat(aDate[1]) - 1, aDate[2]);
    var newReturnDate = oDate.getTime() / 1000;
    $('#ruecktermin').val(newReturnDate);
    
    // trigger pricegrid calendar
//    pCalenderToPricegrid.setDate(newReturnDate);
    
    // set global value
    terminRueck = newReturnDate;   
    
    sendSearchForm();
}

/**
 * Callback function, if departure date in QSM pricegrid will be changed.
 * Note: not requested anymore.
 * @param object date
 * @param string id
 * @deprecated since version 2.2.0
 */ 
function cbCalendarDepartureDatePricegrid(date, id) {  
    
    var aDate = date.split('-');
    var oDate = new Date(aDate[0], parseFloat(aDate[1]) - 1, aDate[2]);
    
    var previousDepartureDate = $('#termin').val();
    var newDepartureDate      = oDate.getTime() / 1000;
    var change                = newDepartureDate - previousDepartureDate;

    // change (in seconds) must at least be one day
    if (change > 0 && change < 86400) {
        change = 86400; 
    }
    if (change < 0 && change > -86400) {
        change = -86400; 
    }

    $('#termin').val(newDepartureDate);
    pCalenderFrom.setDate(newDepartureDate);
    
    /*
    // Rücktermin (berechnet sich aus der Dauer)
    var travelDuration = $('#dauer').val();
    switch (travelDuration) {
        case '-1':
            var days = 23;
            break;
        case '13':
            var days = 23;
            break;
        default:
            var days = travelDuration.split('_')[1].split('-')[1];;
            break;
    }
    
    // return date as timestamp
    var returnDate = parseInt($('#termin').val()) + (86400 * days);
    $('#ruecktermin').val(returnDate);
    */
    
    // set the new date in the return date calendar depending on the change of 
    // the departure date
    var currentReturnDate = $('#idCalToPricegrid').attr('date');
    var aReturnDate = currentReturnDate.split('-');
    var oReturnDate = new Date(aReturnDate[0], parseFloat(aReturnDate[1]) - 1, aReturnDate[2]);
    var newReturnDateCalendar = parseInt(oReturnDate.getTime() / 1000) + change;
    $('#ruecktermin').val(newReturnDateCalendar);
    // set global values
    terminHin = newDepartureDate;
    terminRueck = newReturnDateCalendar;    
     
    pCalenderToPricegrid.setDate(newReturnDateCalendar);
    // trigger calendar
    pCalenderTo.setDate(newReturnDateCalendar);
    
    // submit search form
    window.setTimeout("sendSearchForm()", qsmDelay);
}

/**
 * Callback function, if return date in QSM pricegrid will be changed.
 * 
 * @param object date
 * @param string id
 * @deprecated since version 2.2.0
 */ 
function cbCalendarReturnDatePricegrid(date, id) {  
    
    var aDate = date.split('-');
    var oDate = new Date(aDate[0], parseFloat(aDate[1]) - 1, aDate[2]);
    var newReturnDate = oDate.getTime() / 1000;
    $('#ruecktermin').val(newReturnDate);
    
    // trigger calendar
    pCalenderTo.setDate(newReturnDate);
    
    // set global value
    terminRueck = newReturnDate;   
    
    sendSearchForm();
}

/**
 * Get country option by selected topRegion group from optLaender654LamiPlus array.
 * @param  zgKenner topRegion group
 * @return string
 */
function getCountryOption (zgKenner) {
    
    var option = '-1';
    
    if (typeof optLaender654LamiPlus == 'undefined') {
        optLaender654LamiPlus = getCountryOptionsLamiPlus();
    }
    var optLaender = optLaender654LamiPlus;
    
    if (optLaender) {
        for (var i = 0; i < optLaender.length; i++) {
            
            if (optLaender[i].indexOf(zgKenner) >= 0) {
                var option = optLaender[i].split(';')[1];
                break;
            }
        }
    } else {
        alert("Country options are not available.");
    }
    
    return option;
}

/**
 * Get the topRegion group by selected topRegion based on array TTREGS_654.
 * @param  topRegion 
 * @return string    The topRegion group
 */
function getTopRegionGroupByTopRegion (topRegion) {
    
    // bruteforce fallback solution for chrome, safari, opera.
    if (typeof TTREGS_654 == 'undefined') {
        TTREGS_654 = TTREGS_654_Fallback;
    }
    
    var topRegionGroup = '-1';
    if (TTREGS_654) {
        for (var i = 0; i < TTREGS_654.length; i++) {
            var regions = TTREGS_654[i].split('|');
            if (regions[3] == topRegion) {
                topRegionGroup = regions[2]; 
                break;
            }
        }
    } else {
        alert("TT regions are not available.");
    }
    
    return topRegionGroup;
}

/**
 * Get the topRegion name by selected topRegion based on array TTREGS_654.
 * @param  topRegion 
 * @return string    The topRegion name
 */
function getTopRegionNameByTopRegion (topRegion) {
    
    // bruteforce fallback solution for chrome, safari, opera.
    if (typeof TTREGS_654 == 'undefined') {
        TTREGS_654 = TTREGS_654_Fallback;
    }
    
    var topRegionName = '';
    if (TTREGS_654) {
        for (var i = 0; i < TTREGS_654.length; i++) {
            var regions = TTREGS_654[i].split('|');
            if (regions[3] == topRegion) {
                topRegionName = regions[0]; 
                break;
            }
        }
    } else {
        alert("TT regions are not available.");
    }
    
    return topRegionName;
}

/**
 * Generate country options for Lami Plus IBE 
 * 
 * The country options will be expanded to fit the new requirements.
 * Example:
 * Spanje;10004,10005,10042,565
 * Will be expanded to
 * Spanje Canarische Eilanden;10005
 * Spanje vasteland;10042
 * rondreis Andalusië;565
 * @return array
 */
function getCountryOptionsLamiPlus () {
    
    var countryOptionsLamiPlus = new Array();
    try {
        if (optLaender654) {
            var counter = 0;
            for (var i = 0; i < optLaender654.length; i++) {
                var countryOptions = optLaender654[i].split(';');
                if (countryOptions.length > 0) {
                    if (countryOptions[1]) {
                        var countryRegions = countryOptions[1].split(',');
                        if (countryRegions.length > 0) {
                            for (var j = 0; j < countryRegions.length; j++) {
                                var topRegionName = getTopRegionNameByTopRegion(countryRegions[j]);
                                if (topRegionName.length > 0) {
                                    var newCountryOptionElem = topRegionName + ';' +countryRegions[j];
                                    countryOptionsLamiPlus[counter] = newCountryOptionElem;
                                    counter++; 
                                }
                            }     
                        }
                    }
                }
            }
        }
    }
    catch (e) {
        alert("An error occured (" + e + ")\n\nPlease reload the page.");
    }
    
    return  countryOptionsLamiPlus;
}

/**
 * Set global country options for Lami Plus IBE 
 */
function setCountryOptionsLamiPlus(){
    optLaender654LamiPlus = getCountryOptionsLamiPlus();
    optLaender654LamiPlus.sort();
}

/**
 * Check date format.
 * Check the given date. If it is a human readable date of form 15.10.2010 return 
 * the date as timestamp.
 * @param date
 * return int Unix timestamp
 */
function checkDateFormat(date){
    
    var newDate = date;
    if (typeof date != 'undefined' && date.length > 0) {
        var aTmpDate = date.split('.');      
        if (aTmpDate.length == 3) {
            var oDate = new Date(aTmpDate[2], aTmpDate[1] - 1, aTmpDate[0]);
            newDate = oDate.getTime() / 1000;
        }
    }
    return newDate;
}

/**
 * @todo description 
 * 
 * @param  elem
 * @param  id
 * @param  key
 * @param  val
 */
function setSelValue(elem, id, key, val) {
    /* Deeplink */
    if (elem == null) {
        var elems = $("input[name='name_" + id + "']");

        for (var i = 0; i < elems.length; i++) {
            if (elems[i].value == key) {
                elem  = $(elems[i].parentNode).next();
            }
        }
    }
    if (id == 'idSearchRooms') {
        $('#zimmer').val(key);
    }
    if (id == 'idSearchBoard') {
        $('#verpflegung').val(key);
    }

    if (id == 'idSearchHolidays') {
        pCalenderFrom.updateHolidays(key);
        pCalenderTo.updateHolidays(key);
    } else {
        /*if (id == 'idSearchRooms') {
            pTracking.track('changedroomtype'+key)
        }
        if (id == 'idSearchBoard') {
            pTracking.track('changedmeals'+key)
        } */
        sendSearchForm();
    }
}

/**
 * @todo description 
 * @param  elem
 */
function showSelBox(elem) {
    $('.searchSelContent').hide();
    $(elem).next().toggle();
}

/**
 * @todo description 
 * @param valDefault
 * @param aItems
 * @param id
 */
function printSelBox(valDefault, aItems, id) {
    var html = '<div class="searchSelBox">';
    var checked, divClose, classValue;

    for (var i = 0; i < aItems.length; i++) {
        if (i == 0) {
            divClose = '<div class="searchSelBoxClose" onClick="$(this).parent().parent().hide();">&nbsp;</div>';
            classValue = 'searchSelValueClose';
        } else {
            divClose = '';
            classValue = 'searchSelValue';
        }

        checked = valDefault == aItems[i].key ? 'checked' : '';
        html +=
            '<div class="searchSelRadio"><input type="radio" name="name_' + id + '" value="' + aItems[i].key + '" onClick="setSelValue(this, \'' + id + '\', \'' + aItems[i].key + '\', \'' + aItems[i].val + '\');" ' + checked + '></div>'
            + '<div class="' + classValue + '" onClick="setSelValue(this, \'' + id + '\', \'' + aItems[i].key + '\', \'' + aItems[i].val + '\');">' + aItems[i].val + '</div>'
            + divClose
            + '<div class="clear"></div>';
    }

    html += '</div>';
    $('#' + id + 'Content').html(html);
}

/**
 * @todo description
 * @param  operator
 */
function getNumStars(operator) {
    var actualNumStars = parseInt($('#kategorie').val()) + 2;

    switch (operator) {
        case 'minus':
            returnNumStars = actualNumStars - 1;
            if (returnNumStars < 1) {
                returnNumStars = 1;
            }
            break;
        case 'plus':
            returnNumStars = actualNumStars + 1;
            if (returnNumStars > 5) {
                returnNumStars = 5;
            }
            break;
    } 
    return returnNumStars;
}

/** Für die Google Map **/
function toggleMap() {
    if ( document.getElementById('idMap').style.display == 'block') {
        $('#idMap').hide();
        $('#headLineMap').html('Landkarte einblenden');
        $('#headLineMap').attr('class','headLineMapIn');
        //pTracking.track('mapcollapsed');
        googleMapOpen = false;         
    } else {
        $('#idMap').show();
        $('#headLineMap').html('Landkarte ausblenden');
        $('#headLineMap').attr('class','headLineMap');
        //pTracking.track('mapexpanded');
        googleMapOpen = true;  
    }
}
/** Google Map Ende **/

function getHrefBreadCrumbLeft() {
    var href = '';
    if (HOTELOPTION.isOpen) {
        href = 'hopt=1';
    }
    if (!GOOGLEMAP.isExpanded) {
        if (href != '') {
            href += '&gmap=1'; 
        } else {
            href += 'gmap=1'; 
        }
    }    
    location.href = typo3SiteUrl + '?' + href;
}

/**
 * Get the duration slider step by given duration value.
 * 
 * Requires global durationValues
 * 
 * @param  duration The selected travel duration 
 * @return integer
 */
function getDurationStepByValue(duration) {
    var step = 0;
    for (var i = 0; i < durationValues.length ; i++) {
        if (durationValues[i][0] == duration) {
            step = i;
            break;
        }
    }
    return step;
}

/**
 * Get the hotel rating slider step by given rating value.
 * Requires global hotelRatingValues.
 * 
 * @param  rating The selected hotel rating 
 * @return integer
 */
function getHotelRatingStepByValue(rating) {
    
    var step = 0;
    for (var i = 0; i < hotelRatingValues.length ; i++) {
        if (hotelRatingValues[i] == rating) {
            step = i;
            break;
        }
    }
    return step;
}

/**
 * Handlers for the onclick events to sort the regions.
 * Necessary to switch the events per bind and unbind.
 */
var handlerCountryAsc       = function() { sortRegions('name', 'asc'); return false; }
var handlerCountryDesc      = function() { sortRegions('name', 'desc'); return false; }
var handlerPriceAsc         = function() { sortRegions('price', 'asc'); return false; }
var handlerPriceDesc        = function() { sortRegions('price', 'desc'); return false; }
var handlerTemperatureAsc   = function() { sortRegions('temperature', 'asc'); return false; }
var handlerTemperatureDesc  = function() { sortRegions('temperature', 'desc'); return false; }

/** 
 *  Sort region lister 
 *  @param string type {name, price, temperature}
 *  @param string order {asc, desc}
 */
function sortRegions(type, order) {
	
	if (typeof console != 'undefined') { 
		//console.log(type + ' ' + order);
	}
	var regionContainer = $("#idListContent");
	var regions = $("#idListContent div[class='listReg']");
    var listEnd = $("#idListContent div[class='listEnd']");
    $(listEnd).remove();
	var countryLink = $('#ttSortCountry')[0];
	var priceLink = $('#ttSortPrice')[0];
	var temperatureLink = $('#ttSortTemperature')[0];
	
	switch (type) {
		case 'name':
			if (order == 'asc') {
				regions.sort(sortRegionsByNameAsc).appendTo(regionContainer);
				$(countryLink).unbind('click', handlerCountryAsc);
				$(countryLink).bind('click', handlerCountryDesc);
				$(countryLink).attr('class', 'desc');
			} else {
				regions.sort(sortRegionsByNameDesc).appendTo(regionContainer);
				$(countryLink).unbind('click', handlerCountryDesc);
				$(countryLink).bind('click', handlerCountryAsc);
				$(countryLink).attr('class', 'asc');
			}
	        break;
	    case 'price':
	    	if (order == 'asc') {
	    		regions.sort(sortRegionsByPriceAsc).appendTo(regionContainer);
	    		$(priceLink).unbind('click', handlerPriceAsc);
				$(priceLink).bind('click', handlerPriceDesc);
				$(priceLink).attr('class', 'desc');
	    	} else {
	    		regions.sort(sortRegionsByPriceDesc).appendTo(regionContainer);
	    		$(priceLink).unbind('click', handlerPriceDesc);
				$(priceLink).bind('click', handlerPriceAsc);
				$(priceLink).attr('class', 'asc');
			}
	        break;
	    case 'temperature':
	    	if (order == 'asc') {
	    		regions.sort(sortRegionsByTemperatureAsc).appendTo(regionContainer);
	    		$(temperatureLink).unbind('click', handlerTemperatureAsc);
				$(temperatureLink).bind('click', handlerTemperatureDesc);
				$(temperatureLink).attr('class', 'desc');
	    	} else {
	    		regions.sort(sortRegionsByTemperatureDesc).appendTo(regionContainer);
	    		$(temperatureLink).unbind('click', handlerTemperatureDesc);
				$(temperatureLink).bind('click', handlerTemperatureAsc);
				$(temperatureLink).attr('class', 'asc');
			}
	        break;    
	}
    listEnd.appendTo(regionContainer);
}

/** 
 *  Sort regions by price ascending
 *  @param object elem1
 *  @param object elem2
 */
function sortRegionsByPriceAsc(elem1, elem2) {
	return (parseInt($(elem1).attr('minprice')) >= parseInt($(elem2).attr('minprice'))) ? 1 : -1;
}

/** 
 *  Sort regions by name ascending
 *  @param object elem1
 *  @param object elem2
 */
function sortRegionsByNameAsc(elem1, elem2) {
	return ($(elem1).attr('country') >= $(elem2).attr('country')) ? 1 : -1;
}

/** 
 *  Sort regions by country temperature ascending
 *  @param object elem1
 *  @param object elem2
 */
function sortRegionsByTemperatureAsc(elem1, elem2) {
	return (parseInt($(elem1).attr('airTemperatureCountry')) >= parseInt($(elem2).attr('airTemperatureCountry'))) ? 1 : -1;
}

/** 
 *  Sort regions by price descending
 *  @param object elem1
 *  @param object elem2
 */
function sortRegionsByPriceDesc(elem1, elem2) {
	return (parseInt($(elem1).attr('minprice')) <= parseInt($(elem2).attr('minprice'))) ? 1 : -1;
}

/** 
 *  Sort regions by name descending
 *  @param object elem1
 *  @param object elem2
 */
function sortRegionsByNameDesc(elem1, elem2) {
	return ($(elem1).attr('country') <= $(elem2).attr('country')) ? 1 : -1;
}

/** 
 *  Sort regions by country temperature descending
 *  @param object elem1
 *  @param object elem2
 */
function sortRegionsByTemperatureDesc(elem1, elem2) {
	return (parseInt($(elem1).attr('airTemperatureCountry')) <= parseInt($(elem2).attr('airTemperatureCountry'))) ? 1 : -1;
}

/**
 * Check if the IBE parameter dauer must be changed (in case of a deeplink).
 * @param string dauer
 */
function checkDauerParamater(dauer) {
   
    var aTmp = dauer.split('_');
    
    // check values like 3, 7, 9, 10, 6_7, 6_14, 6_21, etc.
    if (aTmp[0] == '6' && aTmp[1].length < 3) {
        aTmp[0] = '';
    }
    
    if (aTmp[0] != '6') {
        var newVal = '';
        
        switch (dauer) {
            case '-1':
                newVal = '6_1-23';
                break;
            case '9':
                newVal = '6_1-4';
                break;
            case '10':
                newVal = '6_5-8';
                break;
            case '7':
                newVal = '6_9-12';
                break;
            case '3':
                newVal = '6_13-15';
                break;
            case '12':
                newVal = '6_16-22';
                break;
            case '13':
                newVal = '6_23-23';
                break;
            case '6_7':
                newVal = '6_7-7';
                break;
            case '6_14':
                newVal = '6_14-14';
                break;
            case '6_21':
                newVal = '6_21-21';
                break;
        }
    } else {
        newVal = dauer;
    }
    
    return newVal;   
}   

/**
 * Get page scroll top position
 */
function getPageScrollTopPosition () {
    var browserAgent = navigator.userAgent;
    var pageScrollPosition = 0;
    if (browserAgent.indexOf("MSIE") >= 0 ) {
        if (document.documentElement) {
            pageScrollPosition = document.documentElement.scrollTop;
        }
        else if (document.body) {
            pageScrollPosition = document.body.scrollTop;
        } else {
            pageScrollPosition = 0;
        }
    } else {
        pageScrollPosition = window.pageYOffset;
    }
    return pageScrollPosition;
}

/**
 * Returns default return date as timestamp.
 */
function getDefaultReturnDate () {
    var oDate = new Date();
    var startDate;
    var returnDate;
    if (typeof termin_min_654 != 'undefined') {
        startDate = new Date(termin_min_654 * 1000);
    } else {
        startDate = new Date(((oDate.getTime() / 1000) + (86400 * 3)) * 1000);
    }

    // default return date := start date + 1 month 
    returnDate = new Date(startDate.getFullYear(), parseInt(startDate.getMonth()) + 1, startDate.getDate());
    returnDate = returnDate.getTime() / 1000;
    return returnDate;
}

/* --- MODAL SCROLL + def. POSITION ----------------------------------------- */
var modalTime   = 300;
var divTime     = 400;

/* --- MODAL NO SCROLL + ZENTRIERT ------------------------------------------ */
/*
 * @todo check if we need this 
 */
function modalOpen (elem) {
    
    var modalBox = $('#' + elem);
    var closeDiv = $('#searchCloseButton');
    
    if (isActiveSearchDialog && elem == 'airportAltContainer') {
        var refBox  = $('#idSearch');
        var refPos  = refBox.position();  
        var posTop  = refPos.top - 30;
        var posLeft = refPos.left + 216;
          
    } else {    
        var bW        = $(document).width();
        var elemWidth = modalBox.width();
        var posLeft   = parseInt((bW - elemWidth) / 2);
        
        var scrollY = self.pageYOffset;
        if (scrollY == "" || scrollY == "undefined" || !scrollY) {
            scrollY = document.body.scrollTop;
        }
        if (scrollY == "" || scrollY == "undefined" || !scrollY || scrollY == 0) {
            scrollY = document.documentElement.scrollTop;
        }
        var posTop = 160 + scrollY;
    }
    
    modalBox.css("display", "block");
    modalBox.css("position", "absolute");
    modalBox.css("left", posLeft);
    modalBox.css("top", posTop + "px");     
    if (closeDiv) {
        closeDiv.css("display", "block");
        closeDiv.click(
            function() {
                modalClose(elem);
            }
        );
    } 
}

function modalClose (elem) {  
    $('#' + elem).hide();     
}

/**
 * @deprecated
 * @todo check if we need this 
 */
function cbFooterContentFrom() {
    var str = '';
    str += '<div class="searchLabelHoliDays">Schulferien anzeige f&uuml;r:</div>';
    str += '    <div class="searchBoardHoliDay">';
    str += '        <select id="idSearchHolidays" sType="ferien" class="iepngfix" onchange="pCalenderFrom.updateHolidays(this.options[this.selectedIndex].value);">';
    str += getHolidayOptions();
    str += '        </select>';
    str += '    </div>';
    str += '    <div class="clear"></div>';
    return str;
}

/**
 * @deprecated
 * @todo check if we need this 
 */
function cbFooterContentTo() {
    var str = '';
    str += '<div class="searchLabelHoliDays">Schulferien anzeige f&uuml;r:</div>';
    str += '    <div class="searchBoardHoliDay">';
    str += '        <select id="idSearchHolidays" sType="ferien" class="iepngfix" onchange="pCalenderTo.updateHolidays(this.options[this.selectedIndex].value);">';
    str += getHolidayOptions();
    str += '        </select>';
    str += '    </div>';
    str += '    <div class="clear"></div>';
    return str;
}

/**
 * @deprecated
 * @todo check if we need this 
 */
// Ferien-Funktionen für Search Dialog
function cbFooterContentFromSd() {
    var str = '';
    str += '<div class="searchLabelHoliDays">Schulferien anzeige f&uuml;r:</div>';
    str += '    <div class="searchBoardHoliDay">';
    str += '        <select id="idSearchHolidaysSd" sType="ferien" class="iepngfix" onchange="pSdCalFrom.updateHolidays(this.options[this.selectedIndex].value);">';
    str += getHolidayOptions();
    str += '        </select>';
    str += '    </div>';
    str += '    <div class="clear"></div>';
    return str;
}

/**
 * @deprecated
 * @todo check if we need this 
 */

function cbFooterContentToSd() {
    var str = '';
    str += '<div class="searchLabelHoliDays">Schulferien anzeige f&uuml;r:</div>';
    str += '    <div class="searchBoardHoliDay">';
    str += '        <select id="idSearchHolidaysSd" sType="ferien" class="iepngfix" onchange="pSdCalTo.updateHolidays(this.options[this.selectedIndex].value);">';
    str += getHolidayOptions();
    str += '        </select>';
    str += '    </div>';
    str += '    <div class="clear"></div>';
    return str;
}

/**
 * @deprecated
 * @todo check if we need this 
 */
function getHolidayOptions() {
    var itemsHolidays = [
        {key:'BW', val:'Baden-W&uuml;rttemberg'},
        {key:'BY', val:'Bayern'},
        {key:'BE', val:'Berlin'},
        {key:'BB', val:'Brandenburg'},
        {key:'HB', val:'Bremen'},
        {key:'HE', val:'Hessen'},
        {key:'MV', val:'Mecklenburg-Vorp.'},
        {key:'NDS', val:'Niedersachsen'},
        {key:'NRW', val:'Nordrhein-Westfalen'},
        {key:'RP', val:'Rheinland-Pfalz'},
        {key:'SL', val:'Saarland'},
        {key:'SN', val:'Sachsen'},
        {key:'SA', val:'Sachsen-Anhalt'},
        {key:'SH', val:'Schleswig-Holstein'},
        {key:'TH', val:'Thüringen'}];
    str = ''; 
    for (var i = 0; i < itemsHolidays.length; i++) {
        if (g_strFerienSelect == itemsHolidays[i].key) {
            str += '<option value="'+itemsHolidays[i].key+'" selected="selected">'+itemsHolidays[i].val+'</option>';
        } else {
            str += '<option value="'+itemsHolidays[i].key+'">'+itemsHolidays[i].val+'</option>';
        }
    }
    return str;
}

/**
 * Toggled im Filter die Daten zum Ein- und Ausklappen
 * @param {Object} elem
 */
function toggleSearchHl(elem) {
    if ($(elem).attr('class') == 'searchFilterHlImgUp') {
        $(elem).attr('class', 'searchFilterHlImgDown');
        $(elem).parent().next().hide();                
    } else {
        $(elem).attr('class', 'searchFilterHlImgUp');
        $(elem).parent().next().show();                
    }        
}

function setRadioTravelTarget(elem) {
    if ($(elem).attr('class') == 'searchRadioTravelTargetActive') {
        $(elem).attr('class', 'searchRadioTravelTarget');
        $('#sportangebot').val(''); 
    } else {
        $('.searchRadioTravelTargetActive').attr('class', 'searchRadioTravelTarget');
        $(elem).attr('class', 'searchRadioTravelTargetActive');
        $('#sportangebot').val($(elem).attr('type')); 
    }
    
    sendSearchForm();
}

function setFlightTime(elem) {
    $('.searchFilterFlightTime1Active').attr('class', 'searchFilterFlightTime1');
    $('.searchFilterFlightTime2Active').attr('class', 'searchFilterFlightTime2');
    $('.searchFilterFlightTime3Active').attr('class', 'searchFilterFlightTime3');
    
    $('.searchFilterFlightTime' + $(elem).attr('type')).attr('class', 'searchFilterFlightTime' + $(elem).attr('type') + 'Active');
    
    switch ($(elem).attr('type')) {
        case '1':
            $('#flightMinutesFrom').val('0');
            $('#flightMinutesTo').val('120');
            break;
        case '2':
            $('#flightMinutesFrom').val('121');
            $('#flightMinutesTo').val('300');            
            break;
        case '3':
            $('#flightMinutesFrom').val('301');
            $('#flightMinutesTo').val('10000');               
            break;
    }
    
    pRegionen.showList();
}

function initSliderRatingMin() {
    $("#sliderRatingMin").slider(        {
        range: 'min',
        min:    0,
        max:    60,
        step:   1,
        slide: function (event, ui) {
            $(ui.handle).html(number_format(parseInt(ui.value) / 10, 1, '.', ','));
        },
        start: function(event, ui) {
            $("#sliderRatingMin").slider('value' , ui.value - 5);
        },
        stop: function(event, ui) {
            $('#hbfges').val(ui.value);
            sendSearchForm();            
        },
        change: function(event, ui){
            $(event.target).find('a').html(number_format(parseInt(ui.value) / 10, 1, '.', ','));
        }});
        
    if ($('#hbfges').val() == '' || $('#hbfges').val() == '0') {
        $("#sliderRatingMin").slider('value' , 0);
    } else {
        $("#sliderRatingMin").slider('value' , $('#hbfges').val());
    }
}

function initSliderRecommendation() {
    $("#sliderRecommendation").slider({
        range: 'min',
        min:    0,
        max:    100,
        step:   1,
        slide: function (event, ui) {
            $(ui.handle).html(ui.value + '%');
        },
        start: function(event, ui) {
            $("#sliderRecommendation").slider('value' , ui.value - 8);
        },        
        stop: function(event, ui) {
            $('#hbfempf').val(ui.value * 10);
            sendSearchForm();            
        },
        change: function(event, ui){
            $(event.target).find('a').html(ui.value + '%');
        }});
        
    if ($('#hbfempf').val() == '' || $('#hbfempf').val() == '0') {
        $("#sliderRecommendation").slider('value' , 0);
    } else {
        $("#sliderRecommendation").slider('value' , parseInt($('#hbfempf').val()) / 10);
    }
}

/**
 * Change duration
 * @param string duration E.g. 6_9-12
 * @param int	 days
 */
function changeDuration(duration, days) {
	
    $('#dauer').val(duration);
    
    // @todo check if we need this here. Maybe needed in showroom but not in 
    // TCNL Relaunch, because we have here a second calendar, for the return date.
    //$('#ruecktermin').val(parseInt($('#termin').val()) + (86400 * days));
    
    sendSearchForm();
}

/**
 * Init the budget slider
 */
function initSliderBudget() {
    
    // IE bugfix: the hidden input field "preis" might be undefined if one jump 
    // into the IBE with a deeplink.
    if ($('#preis').val() == null || $('#preis').val() == undefined) {
        return;
    }
    
    var initPriceFrom;
    var initPriceTo;
    // Slider für das Budget setzen
    if ($('#preis').val() == '' || $('#preis').val() == '-1') {
        initPriceFrom = '0';
        initPriceTo = '1500';
        $('#preis').val(defaultBudgetValue);          
    } else {
        initPriceFrom = $('#preis').val().split('_')[1].split('-')[0];
        initPriceTo = $('#preis').val().split('_')[1].split('-')[1]; 
    }
    
    var priceToLabel;
    if (parseInt(initPriceTo) >= 1500) {
        priceToLabel = 'alle';
    } else {
        priceToLabel = initPriceTo;
    }
    
    $('.searchTravelTargetBudgetValue').html('&euro; '  + initPriceFrom + '-' + priceToLabel);
    $("#sliderBudget").slider(
        {
            range: true,
            min:    0,
            max:    1500,
            step:   150,
            values: [initPriceFrom, initPriceTo],
            slide: function (event, ui) {
                if (ui.values[1] >= 1500) {
                    priceToLabel = 'alle';
                } else {
                    priceToLabel = ui.values[1]; 
                }
                $('.searchTravelTargetBudgetValue').html('&euro; '  + ui.values[0] + '-' + priceToLabel);
            },
            stop: function (event, ui) {
                var priceToValue;
                if (parseInt($("#sliderBudget").slider('values')[1]) >= 1500) {
                    priceToValue = '10000';
                } else {
                    priceToValue = $("#sliderBudget").slider('values')[1];
                } 
                
                $('#preis').val('15_' + $("#sliderBudget").slider('values')[0] + '-' + priceToValue);
                sendSearchForm();
            }
        }
    ); 
}

/* --- TTAFH DLC ------------------------------------------------------------ */  
var TTAFHDLC = new Array (
"Nord;NORTH",
"S\xFCd;SOUTH",
"West;WEST",
"Ost;EAST",
"Altenburg-Nobitz;AOC",
"Amsterdam (NL);AMS",
"Basel-Mulhouse (CH);MLH",
"Berlin-Sch\xF6nefeld;SXF",
"Berlin-Tegel;TXL",
"Billund (DK);BLL",
"Bremen;BRE",
"Br\xFCssel (B);BRU",
"Dortmund;DTM",
"Dresden;DRS",
"D\xFCsseldorf;DUS",
"Eindhoven (NL);EIN",
"Enschede (NL);ENS",
"Erfurt;ERF",
"Frankfurt;FRA",
"Frankfurt-Hahn;HHN",
"Friedrichshafen;FDH",
"Genf (CH);GVA",
"Graz (A);GRZ",
"Groningen (NL);GRQ",
"Hamburg;HAM",
"Hannover;HAJ",
"Innsbruck (A);INN",
"Karlsruhe;FKB",
"Klagenfurt (A);KLU",
"K\xF6ln-Bonn;CGN",
"Leipzig/Halle;LEJ",
"Linz (A);LNZ",
"L\xFCbeck;LBC",
"L\xFCttich (B);LGG",
"Luxemburg;LUX",
"Maastricht-Aachen (NL);MST",
"Memmingen;FMM",
"M\xFCnchen;MUC",
"M\xFCnster-Osnabr\xFCck;FMO",
"Niederrhein (Weeze);NRN",
"N\xFCrnberg;NUE",
"Paderborn;PAD",
"Rostock;RLG",
"Saarbr\xFCcken;SCN",
"Salzburg (A);SZG",
"Schwerin;SZW",
"Strasbourg (F);SXB",
"Stuttgart;STR",
"Warschau (PL);WAW",
"Wien (A);VIE",
"Z\xFCrich (CH);ZRH",
"Zweibr\xFCcken;ZQW"
);  
// deutsche
var TTAFHDLC_GER = new Array (
"Altenburg-Nobitz;AOC",
"Berlin-Sch\xF6nefeld;SXF",
"Berlin-Tegel;TXL",
"Bremen;BRE",
"Dortmund;DTM",
"Dresden;DRS",
"D\xFCsseldorf;DUS",
"Erfurt;ERF",
"Frankfurt;FRA",
"Frankfurt-Hahn;HHN",
"Friedrichshafen;FDH",
"Hamburg;HAM",
"Hannover;HAJ",
"Karlsruhe;FKB",
"K\xF6ln-Bonn;CGN",
"Leipzig/Halle;LEJ",
"L\xFCbeck;LBC",
"Memmingen;FMM",
"M\xFCnchen;MUC",
"M\xFCnster-Osnabr\xFCck;FMO",
"Niederrhein (Weeze);NRN",
"N\xFCrnberg;NUE",
"Paderborn;PAD",
"Rostock;RLG",
"Saarbr\xFCcken;SCN",
"Schwerin;SZW",
"Stuttgart;STR",
"Zweibr\xFCcken;ZQW"
);
TTAFHDLC_GER.sort();
//ausländische
var TTAFHDLC_FOR = new Array (
"Amsterdam (NL);AMS",
"Basel-Mulhouse (CH);MLH",
"Billund (DK);BLL",
"Br\xFCssel (B);BRU",
"Eindhoven (NL);EIN",
"Enschede (NL);ENS",
"Genf (CH);GVA",
"Graz (A);GRZ",
"Groningen (NL);GRQ",
"Innsbruck (A);INN",
"Klagenfurt (A);KLU",
"Linz (A);LNZ",
"L\xFCttich (B);LGG",
"Luxemburg (L);LUX",
"Maastricht-Aachen (NL);MST",
"Salzburg (A);SZG",
"Strasbourg (F);SXB",
"Warschau (PL);WAW",
"Wien (A);VIE",
"Z\xFCrich (CH);ZRH"
);
TTAFHDLC_FOR.sort();
// Gruppen
var TTAFHDLC_GROUP = [
{"id":"NORTH","dlc":"BRE,HAM,LBC,BLL,RLG,SZW,HAJ,GRQ"},
{"id":"SOUTH","dlc":"MUC,STR,LNZ,FKB,FDH,MLH,SZG,NUE,ZRH,INN,SXB,FMM"},
{"id":"WEST","dlc":"DUS,CGN,DTM,MST,FMO,PAD,FRA,HHN,ZQW,SCN,NRN,ENS,LUX"},
{"id":"EAST","dlc":"TXL,DRS,SXF,RLG,SZW,LEJ,AOC,ERF"}
];

/**
 * Fallback regions in case of undefined TTREGS_654.
 * This will be used as bruteforce fallback solution for chrome, safari, opera.
 * TTREGS_654 is normally defined in JS cache file, which will be updated once a day.
 * So this list will not be updated and must be updated manually, if the geo tree is modified.
 * Note: TTREGS_654_Fallback should normally not be used!
 */
var TTREGS_654_Fallback = [
"Marokko|10000|10000|10000",
"Marokko noorden|404|10000|405",
"Casablanca / El Jadida|747|10000|748",
"Marrakech|208|10000|209",
"Essaouira|756|10000|757",
"Agadir|6|10000|7",
"Ouarzazate en omstreken|758|10000|759",
"Tunesi\xEB|10001|10001|10001",
"Tunesi\xEB noorden|246|10001|247",
"oase Zarzis|254|10001|255",
"schiereiland Djerba|133|10001|134",
"Monastir|221|10001|222",
"Hammamet|115|10001|116",
"Dominicaanse Republiek  (Cara\xEFben, Antillen)|10002|10002|10002",
"Punta Cana (oosten)|401|10002|402",
"Puerto Plata & Samana (noorden)|400|10002|401",
"Santo Domingo (zuiden)|75|10002|76",
"Mexico|10003|10003|10003",
"Yucatan / Cancun|386|10003|387",
"Spanje Eilanden Balearen (Mallorca, etc.)|10004|10004|10004",
"Ibiza|123|10004|124",
"Menorca|214|10004|215",
"Formentera|93|10004|94",
"Mallorca|205|10004|206",
"Spanje Canarische Eilanden|10005|10005|10005",
"Tenerife|351|10005|352",
"Lanzarote|185|10005|186",
"Gran Canaria|106|10005|107",
"El Hierro|81|10005|82",
"Fuerteventura|96|10005|97",
"La Palma|182|10005|183",
"La Gomera|181|10005|182",
"Egypte|10006|10006|10006",
"Rode Zee - Marsa Alam & Quseir|287|10006|288",
"Rode Zee - Sharm el-Sheikh / Nuweiba|327|10006|328",
"Ca\xEFro & Gizeh & Memphis|158|10006|159",
"Rode Zee - Hurghada & Safaga|121|10006|122",
"Luxor & Assuan|198|10006|199",
"Griekse eilanden (Kreta, Rhodos, etc.)|10007|10007|10007",
"Kefalonia|167|10007|168",
"Patmos|270|10007|271",
"Ios (Cycladen)|145|10007|146",
"Paros (Cycladen)|269|10007|270",
"Santorini (Cycladen)|310|10007|311",
"Poros|280|10007|281",
"Rhodos|295|10007|296",
"Aegina|5|10007|6",
"Karpathos|164|10007|165",
"Naxos (Cycladen)|230|10007|231",
"Chios|56|10007|57",
"Skiathos & Skopelos|331|10007|332",
"Leros|188|10007|189",
"Thassos|357|10007|358",
"Euboea (Cycladen)|672|10007|673",
"Lesbos|189|10007|190",
"Alonissos|14|10007|15",
"Kreta|175|10007|176",
"Lefkas|187|10007|188",
"Samos|308|10007|309",
"Kos|174|10007|175",
"Corfu|172|10007|173",
"Mikonos (Cycladen)|228|10007|229",
"Zakynthos|387|10007|388",
"Kalymnos|161|10007|162",
"Griekenland|10008|10008|10008",
"Epiros|87|10008|88",
"Peloponnesos|271|10008|272",
"Athene en omstreken|23|10008|24",
"Olympische Rivi\xE8ra (vasteland)|673|10008|674",
"Chalkidiki|54|10008|55",
"Turkije|10009|10009|10009",
"Antalya & Belek|17|10009|18",
"Kemer & Beldibi|168|10009|169",
"schiereiland Bodrum|112|10009|113",
"Lyci\xEB - Dalaman Turkije|70|10009|71",
"Ayvalik, Cesme & Izmir|53|10009|54",
"Marmaris en omstreken|207|10009|208",
"Istanbul & omgeving|150|10009|151",
"Kusadasi & Didyma|178|10009|179",
"Side & Alanya|324|10009|325",
"Cyprus|10010|10010|10010",
"Cyprus zuiden|390|10010|391",
"Kroati\xEB|10011|10011|10011",
"Midden-Dalmati\xEB|218|10011|219",
"Zuid-Dalmati\xEB|339|10011|340",
"Kroatische eilanden|177|10011|178",
"eiland Brac|132|10011|133",
"Noord-Dalmati\xEB|244|10011|245",
"Bulgarije|10012|10012|10012",
"Goudstrand|103|10012|104",
"Zonnestrand|333|10012|334",
"Cuba  (Cara\xEFben, Antillen)|10013|10013|10013",
"Holgu\xEDn|118|10013|119",
"Varadero en Havana|373|10013|374",
"overige aanbiedingen Cuba|422|10013|423",
"Jamaica (Cara\xEFben, Antillen)|10016|10016|10016",
"Jamaica|153|10016|154",
"Cara\xEFben, Antillen|10017|10017|10017",
"Aruba|768|10017|769",
"Saint-Martin (fr.) & Sint Maarten (nl.)|761|10017|762",
"Bonaire, Curaçao, Saba, Sint Eustatius, Sint Maarten|240|10017|241",
"Kenia|10018|10018|10018",
"Mombasa zuid|342|10018|343",
"Mombasa noord of Malindi|248|10018|249",
"Kaapverdi\xEB|10020|10020|10020",
"Sal|305|10020|306",
"Boa Vista|40|10020|41",
"Afrika|10021|10021|10021",
"Johannesburg en omstreken|156|10021|157",
"Kaapstad en omstreken|163|10021|164",
"Gambia|99|10021|100",
"Malediven (Indische Oceaan)|10022|10022|10022",
"Malediven|204|10022|205",
"Zanzibar (Indische Oceaan)|10026|10026|10026",
"Zanzibar (Tanzania)|349|10026|350",
"Midden-Amerika|10028|10028|10028",
"Panama|267|10028|268",
"Costa Rica|67|10028|68",
"Verenigde Staten van Amerika (VS)|10029|10029|10029",
"Orlando (Florida)|260|10029|261",
"New York|237|10029|238",
"New Jersey|235|10029|236",
"Brazili\xEB|10030|10030|10030",
"Brazili\xEB|660|10030|661",
"Verenigde Arabische Emiraten (Duba\xEF, Oman, etc,)|10032|10032|10032",
"Ras Al-Khaimah|288|10032|289",
"Dubai|76|10032|77",
"Fujairah|97|10032|98",
"Oman|258|10032|259",
"Abu Dhabi|1|10032|2",
"Midden-Oosten  (Isra\xEBl, Saoedi-Arabi\xEB, etc.)|10033|10033|10033",
"Jordani\xEB|157|10033|158",
"Thailand|10034|10034|10034",
"Bangkok en omstreken|30|10034|31",
"eiland Ko Samui|136|10034|137",
"eiland Phuket|142|10034|143",
"Thailand|356|10034|357",
"Thaise eilanden|355|10034|356",
"Khao Lak|169|10034|170",
"Azi\xEB (Rusland, China, Vietnam, etc.)|10035|10035|10035",
"Sri Lanka|334|10035|335",
"China|55|10035|56",
"Bali|29|10035|30",
"Sint Petersburg en omstreken|499|10035|500",
"Maleisi\xEB|203|10035|204",
"Moskou en omstreken|225|10035|226",
"Tokio & Osaka|364|10035|365",
"Nepal|232|10035|233",
"Hongkong en omstreken|119|10035|120",
"Goa|102|10035|103",
"Canada|10037|10037|10037",
"Ontario|259|10037|260",
"Alberta|10|10037|11",
"British Columbia|46|10037|47",
"Itali\xEB|10039|10039|10039",
"Marken|685|10039|686",
"Calabri\xEB|159|10039|160",
"Friuli-Julisch Veneti\xEB|686|10039|687",
"Emilia Romagna|85|10039|86",
"Valle d'Aosta & Piemont & Lombardije|276|10039|277",
"Ischia|147|10039|148",
"Veneti\xEB|374|10039|375",
"Sicili\xEB|330|10039|331",
"Latium (Rome en omstreken)|299|10039|300",
"Napels en omstreken|231|10039|232",
"Toscane|365|10039|366",
"Sardini\xEB|311|10039|312",
"Frankrijk|10040|10040|10040",
"Franse Alpen|95|10040|96",
"Corsica|173|10040|174",
"Rh\xF4ne (Regio Rh\xF4ne / Alpen)|681|10040|682",
"Ile-de-France|268|10040|269",
"C\xF4te d'Aquitaine (Gironde, Landes)|24|10040|25",
"Portugal|10041|10041|10041",
"Porto|281|10041|282",
"Costa de Prata|63|10041|64",
"Madeira|201|10041|202",
"Lissabon en omstreken|194|10041|195",
"Costa do Estoril|65|10041|66",
"Costa da Caparica|61|10041|62",
"Costa Verde|68|10041|69",
"Azoren|25|10041|26",
"Algarve|12|10041|13",
"Vasteland|89|10041|90",
"Spanje vasteland|10042|10042|10042",
"Costa Brava (Cataloni\xEB)|60|10042|61",
"Costa Blanca|59|10042|60",
"Costa de Almer\xEDa (Andalusi\xEB)|104|10042|105",
"Costa del Sol (Andalusi\xEB)|64|10042|65",
"Madrid en omstreken|202|10042|203",
"Costa de la Luz - Andalusi\xEB (Cadiz, Huelva, Islantilla etc.)|62|10042|63",
"Centraal-Spanje|388|10042|389",
"Catalaanse kust|165|10042|166",
"Costa Azahar|58|10042|59",
"Barcelona & Costa del Maresme (Cataloni\xEB)|32|10042|33",
"Malta|10044|10044|10044",
"Malta|206|10044|207",
"Zwitserland|10045|10045|10045",
"Z\xFCrich|394|10045|395",
"Oostenrijk|10046|10046|10046",
"Tirol|408|10046|409",
"Seefeld|320|10046|321",
"Wenen en omstreken|395|10046|396",
"Westtirol en Oetztal|266|10046|267",
"Zillertal|389|10046|390",
"Salzburgerland|306|10046|307",
"Duitsland|10047|10047|10047",
"Berlijn|37|10047|38",
"M\xFCnchen|656|10047|657",
"Groot-Brittanni\xEB|10048|10048|10048",
"Londen & Zuid-Engeland|391|10048|392",
"Midden- en Noord-Engeland|498|10048|499",
"Verenigd Koninkrijk (Schotland, Wales, etc.)|10051|10051|10051",
"Noord-Ierland|508|10051|509",
"Ierland|146|10051|147",
"Schotland|315|10051|316",
"Polen|10052|10052|10052",
"Polen|278|10052|279",
"Oost-Europa|10053|10053|10053",
"Krim (Jalta)|176|10053|177",
"Tsjechi\xEB|367|10053|368",
"Litouwen|377|10053|378",
"Estland|348|10053|349",
"Riga|297|10053|298",
"Hongarije|370|10053|371",
"Noord-Europa|10054|10054|10054",
"Lapland|690|10054|691",
"Denemarken|72|10054|73",
"Zweden|456|10054|457",
"Finland|91|10054|92",
"Noorwegen|251|10054|252",
"IJsland|149|10054|150",
"op goed geluk hotel|10055|10055|10055",
"op goed geluk hotel aan de Spaanse kust - binnenland|560|10055|561",
"op goed geluk hotel in Dominicaanse Republiek|423|10055|424",
"op goed geluk hotel in Cuba|419|10055|420",
"op goed geluk hotel in Sardini\xEB|619|10055|620",
"op goed geluk hotel in Sicili\xEB|624|10055|625",
"Rondreis|10056|10056|10056",
"rondreis Bulgarije|631|10056|632",
"rondreis Cuba|413|10056|414",
"rondreis Marokko|642|10056|643",
"rondreis Mexico|629|10056|630",
"rondreis Sardini\xEB|617|10056|618",
"rondreis Sicili\xEB|615|10056|616",
"rondreis Griekenland|612|10056|613",
"rondreis Thailand|588|10056|589",
"rondreis Jordani\xEB|587|10056|588",
"rondreis Tanzania|586|10056|587",
"rondreis Kenia|585|10056|586",
"rondreis Kreta|567|10056|568",
"rondreis arabische schiereiland|430|10056|431",
"rondreis Sri Lanka|453|10056|454",
"rondreis Portugal|412|10056|413",
"rondreis Egypte|540|10056|541",
"rondreis Tunesi\xEB|542|10056|543",
"rondreis Andalusi\xEB|564|10056|565",
"Kruisvaarte|10057|10057|10057",
"cruise Turkije|544|10057|545",
"nijlcruises|539|10057|540",
"Fly & Drive|10058|10058|10058",
"Fly & Drive Lissabon & omstreken|710|10058|711"];
TTREGS_654_Fallback.sort();


