/*
** Magic-Tours search_formular_generation-script
** (c) by Johanner Ernesti 2007
*/

// how many day in the future may the daparture/coming back
var MAX_FUTURE_DAYS = 300;

var flyConstants = [
    {key : "W", title : "&lt;West&gt;"},
    {key : "O", title : "&lt;Ost&gt;"},
    {key : "S", title : "&lt;S&uuml;d&gt;"},
    {key : "N", title : "&lt;Nord&gt;"},
    {key : "M", title : "&lt;Mitte&gt;"},
    {key : "AMS", title : "Amsterdam (NL)"},
    {key : "AGB", title : "Augsburg"},
    {key : "BSL", title : "Basel (CH)"},
    {key : "TXL", title : "Berlin Tegel"},
    {key : "SXF", title : "Berlin Sch&ouml;nefeld"},
    {key : "THF", title : "Berlin Tempelhof"},
    {key : "BRE", title : "Bremen"},
    {key : "BRU", title : "Br&uuml;ssel (B)"},
    {key : "BUD", title : "Budapest (H)"},
    {key : "DTM", title : "Dortmund"},
    {key : "DRS", title : "Dresden"},
    {key : "DUS", title : "D&uuml;sseldorf"},
    {key : "EIN", title : "Eindhoven (NL)"},
    {key : "ENS", title : "Enschede (NL)"},
    {key : "ERF", title : "Erfurt"},
    {key : "FRA", title : "Frankfurt/Main"},
    {key : "FDH", title : "Friedrichshafen"},
    {key : "GVA", title : "Genf (CH)"},
    {key : "GRZ", title : "Graz (A)"},
    {key : "GRQ", title : "Groningen (NL)"},
    {key : "HHN", title : "Hahn"},
    {key : "HAM", title : "Hamburg"},
    {key : "HAJ", title : "Hannover"},
    {key : "HOQ", title : "Hof"},
    {key : "INN", title : "Innsbruck (A)"},
    {key : "FKB", title : "Karlsruhe"},
    {key : "KSF", title : "Kassel"},
    {key : "KLU", title : "Klagenfurth (A)"},
    {key : "CGN", title : "K&ouml;ln/Bonn"},
    {key : "LEJ", title : "Leipzig"},
    {key : "LNZ", title : "Linz (A)"},
    {key : "LBC", title : "L&uuml;beck"},
    {key : "LGG", title : "L&uuml;ttich (B)"},
    {key : "LUX", title : "Luxemburg (L)"},
    {key : "MST", title : "Maastricht (NL)"},
    {key : "MLH", title : "M&uuml;lhausen/Basel"},
    {key : "MUC", title : "M&uuml;nchen"},
    {key : "FMO", title : "M&uuml;nster"},
    {key : "NRN", title : "Niederrhein/Weeze"},
    {key : "NUE", title : "N&uuml;rnberg"},
    {key : "PAD", title : "Paderborn"},
    {key : "RLG", title : "Rostock"},
    {key : "RTM", title : "Rotterdam (NL)"},
    {key : "SCN", title : "Saarbr&uuml;cken"},
    {key : "SZG", title : "Salzburg (A)"},
    {key : "SXB", title : "Strassbourg (F)"},
    {key : "STR", title : "Stuttgart"},
    {key : "WAW", title : "Warschau (PL)"},
    {key : "VIE", title : "Wien (A)"},
    {key : "ZRH", title : "Z&uuml;rich (CH)"}
];

var destinationConstants = [
    {key : "B", title : "Balearen"},
    {key : "PMI", title : " &nbsp; Mallorca"},
    {key : "IBZ", title : " &nbsp; Ibiza"},
    {key : "MAH", title : " &nbsp; Menorca"},
    {key : "C", title : "Kanaren"},
    {key : "FUE", title : " &nbsp; Fuerteventura"},
    {key : "LPA", title : " &nbsp; Gran Canaria"},
    {key : "ACE", title : " &nbsp; Lanzarote"},
    {key : "TFS", title : " &nbsp; Teneriffa S&uuml;d"},
    {key : "TFN", title : " &nbsp; Teneriffa Nord"},
    {key : "SPC", title : " &nbsp; La Palma"},
    {key : "E", title : "Spanisches Festland"},
    {key : "D", title : "Portugal/Madeira"},
    {key : "FAO", title : " &nbsp; Faro"},
    {key : "FNC", title : " &nbsp; Madeira"},
    {key : "F", title : "T&uuml;rkei/Zypern"},
    {key : "AYT", title : " &nbsp; Antalya (T&uuml;rkei)"},
    {key : "DLM", title : " &nbsp; Dalaman (T&uuml;rkei)"},
    {key : "LCA", title : " &nbsp; Larnaca (Zypern)"},
    {key : "G", title : "Griechische Inseln"},
    {key : "HER", title : " &nbsp; Kreta"},
    {key : "RHO", title : " &nbsp; Rhodos"},
    {key : "KGS", title : " &nbsp; Kos"},
    {key : "CFU", title : " &nbsp; Korfu"},
    {key : "SMI", title : " &nbsp; Samos"},
    {key : "J", title : "Tunesien/Marokko"},
    {key : "AGA", title : " &nbsp; Agadir (Marokko)"},
    {key : "DJE", title : " &nbsp; Djerba (Tunesien)"},
    {key : "MIR", title : " &nbsp; Monastir (Tunesien)"},
    {key : "I", title : "Italien/Malta"},
    {key : "M", title : "&Auml;gypten/Israel/V.A.E."},
    {key : "P", title : "Dom. Republik"},
    {key : "O", title : "Kuba"},
    {key : "Q", title : "Karibik"},
    {key : "S", title : "Mexiko/S&uuml;damerika"},
    {key : "T", title : "Asien/S&uuml;dsee"},
    {key : "MRU", title : " &nbsp; Mauritius"},
    {key : "MLE", title : " &nbsp; Malediven"},
    {key : "BKK", title : " &nbsp; Thailand"}
];

var days = new Array("Sonntag", "Montag", "Dienstag", "Mittwoch", "Donnerstag", "Freitag", "Samstag", "Fehler");


function writeSelectChild(name)
    {
    document.write('<select name="' + name + '">');
    document.write('<option value="18" selected="selected">&lt;ohne&gt;</option>');
    document.write('<option value="1">unter 2</option>');

    for(var i = 2; i <= 14; i++)
        document.write('<option value="' + i + '">' + i + ' Jahre</option>');

    document.write('</select>');
    }


function writeSelectFlies(name)
    {
    document.write('<select name="' + name + '" size="1">');
    document.write('<option value="-" selected="selected">&lt; keine Auswahl &gt;</option>"');

    for(var i = 0; i < flyConstants.length; i++)
        document.write('<option value="' + flyConstants[i].key + '">' + flyConstants[i].title + '</option>');

    document.write('</select>');
    }


function writeSelectDate(name, start)
    {
    if(name == "VON")
        document.write('<select name="' + name + '" size="1" id="' + name + '" onchange="document.getElementById(\'BIS\').value = 1*this.value + 3;">');
    else
        document.write('<select name="' + name + '" id="' + name + '" size="1">');

    var selected = 'selected="selected"',
        now = new Date(),
        ms = now.getTime();

    for(var i = start; i < start + MAX_FUTURE_DAYS; i++)
        {
        if(i == start + 1)
            selected = "";

        var then = new Date(ms + i * 24 * 3600 * 1000),
            day = then.getDate() < 10 ? "0" + then.getDate() : then.getDate(),
            month = (then.getMonth() + 1) < 10 ? "0" + (then.getMonth() + 1) : (then.getMonth() + 1),
            year = "" + then.getFullYear();

        document.write('<option value="' + i + '"' + selected + '>' + day + "." + month + "." + year.substr(2, 2) + " - " + days[then.getDay()] + '</option>"');
        }

    document.write('</select>');
    }

function writeSelectDestination(name)
    {
    document.write('<select name="' + name + '" size="1">');
    document.write('<option value="-" selected="selected">&lt; Alle Ziele &gt;</option>"');

    for(var i = 0; i < destinationConstants.length; i++)
        document.write('<option value="' + destinationConstants[i].key + '">' + destinationConstants[i].title + '</option>');

    document.write('</select>');
    }


function writeSelectDuration(name)
    {
    document.write('<select name="' + name + '" id="' + name + '" size="1" onchange="durationSelectionChanged(\'' + name + '\')">');
    document.write('<option value="00-28" selected="selected">egal</option>"');
    document.write('<option value="06-08">1 Woche</option>"');
    document.write('<option value="12-15">2 Wochen</option>"');
    document.write('<option value="19-22">3 Wochen</option>"');
    document.write('<option value="03-05">3 bis 5 Tage</option>"');
    document.write('<option value="08-13">8 bis 13 Tage</option>"');
    document.write('<option value="15-31">&uuml;ber 14 Tage</option>"');
    document.write('</select>');
    }


function writeSelectFood(name)
    {
    document.write('<select size="1" name="' + name + '">');
    document.write('<option value="0" selected="selected">&lt;Keine Auswahl&gt;</option>');
    document.write('<option value="2">ohne</option>');
    document.write('<option value="3">Frühst&uuml;ck</option>');
    document.write('<option value="1">Halbpension</option>');
    document.write('<option value="4">Vollpension</option>');
    document.write('<option value="6">All Inclusive</option>');
    document.write('</select>');
    }


function writeSelectStars(name)
    {
    document.write('<select size="1" name="' + name + '">');
    document.write('<option value="0" selected="selected">&lt;Keine Auswahl&gt;</option>');

    for(var i = 2; i < 6; i++)
        document.write('<option value="' + i + '">' + i + ' Sterne</option>');

    document.write('</select>');
    }


function durationSelectionChanged(_id)
    {
    var v = document.getElementById(_id).value;
    var tmp = v.split("-");

    document.getElementById("LMIN").value = tmp[0];
    document.getElementById("LMAX").value = tmp[1];
    document.getElementById("xL").value = v;
    }

