function dni_mies(month, year){
    var m = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
    if (month != 2) 
        return m[month - 1];
    if (year % 4 != 0) 
        return m[1];
    if (year % 100 == 0 && year % 400 != 0) 
        return m[1];
    return m[1] + 1;
}

function dzien_tyg_nr(month, year){
    var temp = new Date(year, month - 1, 1);
    var temp2 = temp.getDay() % 7;
    if (temp2 == 0) 
        temp2 = 7;
    
    return temp2;
}

function dzien_tyg(day, month, year){
    var dni = new Array("Poniedziałek", "Wtorek", "Środa", "Czwartek", "Piątek", "Sobota", "Niedziela");
    return dni[dzien_tyg_nr(day, month, year) - 1];
}

function miesiac_pl(mies){
    var mies_pl = Array("", "Stycznia", "Lutego", "Marca", "Kwietnia", "Maja", "Czerwca", "Lipca", "Sierpnia", "Września", "Października", "Listopada", "Grudnia");
    return mies_pl[mies];
}

function mktime(){
    var d = new Date(), r = arguments, i = 0, e = ['Hours', 'Minutes', 'Seconds', 'Month', 'Date', 'FullYear'];
    for (i = 0; i < e.length; i++) {
        if (typeof r[i] === 'undefined') {
            r[i] = d['get' + e[i]]();
            r[i] += (i === 3); // +1 to fix JS months.
        }
        else {
            r[i] = parseInt(r[i], 10);
            if (isNaN(r[i])) {
                return false;
            }
        }
    }
    r[5] += (r[5] >= 0 ? (r[5] <= 69 ? 2e3 : (r[5] <= 100 ? 1900 : 0)) : 0);
    d.setFullYear(r[5], r[3] - 1, r[4]);
    d.setHours(r[0], r[1], r[2]);
    return (d.getTime() / 1e3 >> 0) - (d.getTime() < 0);
}

function gmmktime(){
    var d = new Date(), r = arguments, i = 0, e = ['Hours', 'Minutes', 'Seconds', 'Month', 'Date', 'FullYear'];
    for (i = 0; i < e.length; i++) {
        if (typeof r[i] === 'undefined') {
            r[i] = d['getUTC' + e[i]]();
            r[i] += (i === 3); // +1 to fix JS months.
        }
        else {
            r[i] = parseInt(r[i], 10);
            if (isNaN(r[i])) 
                return false;
        }
    }
    r[5] += (r[5] >= 0 ? (r[5] <= 69 ? 2e3 : (r[5] <= 100 ? 1900 : 0)) : 0);
    d.setUTCFullYear(r[5], r[3] - 1, r[4]);
    d.setUTCHours(r[0], r[1], r[2]);
    return (d.getTime() / 1e3 >> 0) - (d.getTime() < 0);
}

function date(format, timestamp){
    var that = this, jsdate, f, formatChr = /\\?([a-z])/gi, formatChrCb, _pad = function(n, c){
        if ((n = n + "").length < c) {
            return new Array((++c) - n.length).join("0") + n;
        }
        else {
            return n;
        }
    }, txt_words = ["Sun", "Mon", "Tues", "Wednes", "Thurs", "Fri", "Satur", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"], txt_ordin = {
        1: "st",
        2: "nd",
        3: "rd",
        21: "st",
        22: "nd",
        23: "rd",
        31: "st"
    };
    formatChrCb = function(t, s){
        return f[t] ? f[t]() : s;
    };
    f = {
        d: function(){
            return _pad(f.j(), 2);
        },
        D: function(){
            return f.l().slice(0, 3);
        },
        j: function(){
            return jsdate.getDate();
        },
        l: function(){
            return txt_words[f.w()] + 'day';
        },
        N: function(){
            return f.w() || 7;
        },
        S: function(){
            return txt_ordin[f.j()] || 'th';
        },
        w: function(){
            return jsdate.getDay();
        },
        z: function(){
            var a = new Date(f.Y(), f.n() - 1, f.j()), b = new Date(f.Y(), 0, 1);
            return Math.round((a - b) / 864e5) + 1;
        },
        W: function(){
            var a = new Date(f.Y(), f.n() - 1, f.j() - f.N() + 3), b = new Date(a.getFullYear(), 0, 4);
            return 1 + Math.round((a - b) / 864e5 / 7);
        },
        F: function(){
            return txt_words[6 + f.n()];
        },
        m: function(){
            return _pad(f.n(), 2);
        },
        M: function(){
            return f.F().slice(0, 3);
        },
        n: function(){
            return jsdate.getMonth() + 1;
        },
        t: function(){
            return (new Date(f.Y(), f.n(), 0)).getDate();
        },
        L: function(){
            var y = f.Y(), a = y & 3, b = y % 4e2, c = y % 1e2;
            return 0 + (!a && (c || !b));
        },
        o: function(){
            var n = f.n(), W = f.W(), Y = f.Y();
            return Y + (n === 12 && W < 9 ? -1 : n === 1 && W > 9);
        },
        Y: function(){
            return jsdate.getFullYear();
        },
        y: function(){
            return (f.Y() + "").slice(-2);
        },
        a: function(){
            return jsdate.getHours() > 11 ? "pm" : "am";
        },
        A: function(){
            return f.a().toUpperCase();
        },
        B: function(){
            var H = jsdate.getUTCHours() * 36e2, i = jsdate.getUTCMinutes() * 60, s = jsdate.getUTCSeconds();
            return _pad(Math.floor((H + i + s + 36e2) / 86.4) % 1e3, 3);
        },
        g: function(){
            return f.G() % 12 || 12;
        },
        G: function(){
            return jsdate.getHours();
        },
        h: function(){
            return _pad(f.g(), 2);
        },
        H: function(){
            return _pad(f.G(), 2);
        },
        i: function(){
            return _pad(jsdate.getMinutes(), 2);
        },
        s: function(){
            return _pad(jsdate.getSeconds(), 2);
        },
        u: function(){
            return _pad(jsdate.getMilliseconds() * 1000, 6);
        },
        e: function(){
        
            return 'UTC';
        },
        I: function(){
            var a = new Date(f.Y(), 0), c = Date.UTC(f.Y(), 0), b = new Date(f.Y(), 6), d = Date.UTC(f.Y(), 6);
            return 0 + ((a - c) !== (b - d));
        },
        O: function(){
            var a = jsdate.getTimezoneOffset();
            return (a > 0 ? "-" : "+") + _pad(Math.abs(a / 60 * 100), 4);
        },
        P: function(){
            var O = f.O();
            return (O.substr(0, 3) + ":" + O.substr(3, 2));
        },
        T: function(){
        
            return 'UTC';
        },
        Z: function(){
            return -jsdate.getTimezoneOffset() * 60;
        },
        c: function(){
            return 'Y-m-d\\Th:i:sP'.replace(formatChr, formatChrCb);
        },
        r: function(){
            return 'D, d M Y H:i:s O'.replace(formatChr, formatChrCb);
        },
        U: function(){
            return jsdate.getTime() / 1000 | 0;
        }
    };
    this.date = function(format, timestamp){
        that = this;
        jsdate = ((typeof timestamp === 'undefined') ? new Date() : (timestamp instanceof Date) ? new Date(timestamp) : new Date(timestamp * 1000));
        return format.replace(formatChr, formatChrCb);
    };
    return this.date(format, timestamp);
}

function strlen(string){
    // http://kevin.vanzonneveld.net
    // +   original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +   improved by: Sakimori
    // +      input by: Kirk Strobeck
    // +   improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +   bugfixed by: Onno Marsman
    // +    revised by: Brett Zamir (http://brett-zamir.me)
    // %        note 1: May look like overkill, but in order to be truly faithful to handling all Unicode
    // %        note 1: characters and to this function in PHP which does not count the number of bytes
    // %        note 1: but counts the number of characters, something like this is really necessary.
    // *     example 1: strlen('Kevin van Zonneveld');
    // *     returns 1: 19
    // *     example 2: strlen('A\ud87e\udc04Z');
    // *     returns 2: 3
    
    var str = string + '';
    var i = 0, chr = '', lgth = 0;
    
    if (!this.php_js || !this.php_js.ini || !this.php_js.ini['unicode.semantics'] ||
    this.php_js.ini['unicode.semantics'].local_value.toLowerCase() !== 'on') {
        return string.length;
    }
    
    var getWholeChar = function(str, i){
        var code = str.charCodeAt(i);
        var next = '', prev = '';
        if (0xD800 <= code && code <= 0xDBFF) { // High surrogate (could change last hex to 0xDB7F to treat high private surrogates as single characters)
            if (str.length <= (i + 1)) {
                throw 'High surrogate without following low surrogate';
            }
            next = str.charCodeAt(i + 1);
            if (0xDC00 > next || next > 0xDFFF) {
                throw 'High surrogate without following low surrogate';
            }
            return str.charAt(i) + str.charAt(i + 1);
        }
        else 
            if (0xDC00 <= code && code <= 0xDFFF) { // Low surrogate
                if (i === 0) {
                    throw 'Low surrogate without preceding high surrogate';
                }
                prev = str.charCodeAt(i - 1);
                if (0xD800 > prev || prev > 0xDBFF) { //(could change last hex to 0xDB7F to treat high private surrogates as single characters)
                    throw 'Low surrogate without preceding high surrogate';
                }
                return false; // We can pass over low surrogates now as the second component in a pair which we have already processed
            }
        return str.charAt(i);
    };
    
    for (i = 0, lgth = 0; i < str.length; i++) {
        if ((chr = getWholeChar(str, i)) === false) {
            continue;
        } // Adapt this line at the top of any loop, passing in the whole string and the current iteration and returning a variable to represent the individual character; purpose is to treat the first part of a surrogate pair as the whole character and then ignore the second part
        lgth++;
    }
    return lgth;
}

function getLiczba(str){
    if (str == "01") 
        return 1;
    if (str == "02") 
        return 2;
    if (str == "03") 
        return 3;
    if (str == "04") 
        return 4;
    if (str == "05") 
        return 5;
    if (str == "06") 
        return 6;
    if (str == "07") 
        return 7;
    if (str == "08") 
        return 8;
    if (str == "09") 
        return 9;
    return str;
}

function getLiczbaRev(str){
    if (str == "1") 
        return "01";
    if (str == "2") 
        return "02";
    if (str == "3") 
        return "03";
    if (str == "4") 
        return "04";
    if (str == "5") 
        return "05";
    if (str == "6") 
        return "06";
    if (str == "7") 
        return "07";
    if (str == "8") 
        return "08";
    if (str == "9") 
        return "09";
    return str;
}

///////////////////////////////////////////////////////////////////////////////////////
//        ZMIENNE  
///////////////////////////////////////////////////////////////////////////////////////
var cal_display = 'all';
var cal_today = new Date();
var cal_dep_date_temp = mktime(0, 0, 0, date('m'), parseInt(date('d')) + 3, date('Y'));
var cal_ar_date_temp = mktime(0, 0, 0, date('m'), parseInt(date('d')) + 10, date('Y'));
var cal_dep_date = date("d.m.Y", cal_dep_date_temp);
var cal_ar_date = date("d.m.Y", cal_ar_date_temp);

function kalendarz(dane, type){
    //alert(type+" "+dane);
    var out = '';
    var info = '' // zmienna wywala wszystko w alercie
    var temp, cal_dep, a, dep_day_in_month;
    var cal_dep_day, cal_dep_month, cal_dep_year;
    var cal_ar_day, cal_ar_month, cal_ar_year;
    
    var dep_day_start;
    if (type == "dep") 
        cal_dep_date = dane;
    if (type == "ar") 
        cal_ar_date = dane;
    if (type == "display") 
        cal_display = dane;
    // okreslanie daty wylotu
    cal_dep_temp = cal_dep_date.split(".");
    cal_dep_day = getLiczba(cal_dep_temp[0]);
    cal_dep_month = getLiczba(cal_dep_temp[1]);
    //alert(cal_dep_month+ " " +getLiczba(cal_dep_temp[1])+ " "+strlen(cal_dep_temp[1]));
    
    cal_dep_year = cal_dep_temp[2];
    // okreslanie daty przylotu
    cal_ar_temp = cal_ar_date.split(".");
    cal_ar_day = getLiczba(cal_ar_temp[0]);
    cal_ar_month = getLiczba(cal_ar_temp[1]);
    cal_ar_year = cal_ar_temp[2];
    dep_day_in_month = dni_mies(cal_dep_month, cal_dep_year);
    dep_day_start = (cal_dep_month != date('n')) ? 1 : date('d');
    out = out + '<div style="float:left;width:247px;"><div><div class="calendar_date_line select"><span style="float:left;"><select name="dep_day" onchange="kalendarz(this.value,\'dep\');">';
    for (a = dep_day_start; a <= dep_day_in_month; a++) {
        out = out + '<option value="' + a + '.' + cal_dep_month + '.' + cal_dep_year + '"  ';
        if (a == cal_dep_day) 
            out = out + 'selected="selected" ';
        out = out + '>' + a + '</option>';
    }
    out = out + '</select></span><span style="padding-left:12px;float:left;"><select name="dep_date" onchange="kalendarz(this.value,\'dep\')">';
    //alert(parseInt(date('n')));
    for (a = 0; a <= 11; a++) {
        temp = mktime(0, 0, 0, parseInt(date('n')) + a, 1, date('Y'));
        out = out + '<option value="' + cal_dep_day + '.' + date('m.Y', temp) + '"  ';
        if (getLiczbaRev(cal_dep_month) + '.' + cal_dep_year == date('m.Y', temp)) 
            out = out + ' selected="selected" ';
        out = out + '> ';
        out = out + miesiac_pl(date('n', temp)) + ' ' + date('y', temp);
        out = out + '</option>';
    }
    out = out + '</select></span></div><div class="calendar_date_line icon"></div><div class="calendar_date_line show"></div><div class="clear"><!-- --></div><div class="nl"><!-- --></div><div class="kalendarz"><!-- --><div class="calendar_line_el name"><div class="calendar_line_el_content">Pn</div></div><div class="calendar_line_el name"><div class="calendar_line_el_content">Wt</div></div><div class="calendar_line_el name"><div class="calendar_line_el_content">Śr</div></div><div class="calendar_line_el name"><div class="calendar_line_el_content">Cz</div></div><div class="calendar_line_el name"><div class="calendar_line_el_content">Pt</div></div><div class="calendar_line_el name"><div class="calendar_line_el_content">So</div></div><div class="calendar_line_el name"><div class="calendar_line_el_content">Nd</div></div>';
    var dni_w_miesiacu = date('t', mktime(0, 0, 0, cal_dep_month, 1, cal_dep_year))
    var numer_dnia_tygodnia = dzien_tyg_nr(cal_dep_month, cal_dep_year);
    var odejmij = numer_dnia_tygodnia - 1;
    var count = parseInt(dni_w_miesiacu) + parseInt(odejmij);
    for (a = 1; a <= count; a++) {
        if (a < numer_dnia_tygodnia) 
            out = out + '<span class="calendar_line_el unactive"><!-- --><span class="calendar_line_eu_content"></span></span>';
        else {
            var b = a - odejmij;
            var b2 = (b < 10) ? '0' + b : b;
            if (date('m') == cal_dep_month && b < date('d')) 
                out = out + '<span class="calendar_line_el unactive" ><!-- --><span class="calendar_line_el_content" >' + b2 + '</span></span>';
            else {
                if (b == cal_dep_day) 
                    out = out + '<span class="calendar_line_el select" ><!-- --><span class="calendar_line_el_content"><span onclick="kalendarz(\'' + getLiczbaRev(b) + '.' + getLiczbaRev(cal_dep_month) + '.' + cal_dep_year + '\',\'dep\');" class="onmouseover" style="color:#ffffff;">' + b2 + '</span></span></span>';
                else 
                    out = out + '<span class="calendar_line_el active" ><!-- --><span class="calendar_line_el_content"><span onclick="kalendarz(\'' + getLiczbaRev(b) + '.' + getLiczbaRev(cal_dep_month) + '.' + cal_dep_year + '\',\'dep\');" class="onmouseover">' + b2 + '</span></span></span>';
            }
        }
    }
    out = out + '<div class="calendar_line"><!-- --></div></div><div class="nl"><!-- --></div></div></div>';
    if (cal_display == "all") {
        out = out + '<div style="float:left;width:247px;" id="cal_powrot">';
        if (mktime(0, 0, 0, cal_dep_month, cal_dep_day, cal_dep_year) > mktime(0, 0, 0, cal_ar_month, cal_ar_day, cal_ar_year)) {
            cal_ar_day = cal_dep_day;
            cal_ar_date = date("d.m.Y", mktime(0, 0, 0, cal_dep_month, cal_ar_day, cal_dep_year));
            cal_ar_temp = cal_ar_date.split(".");
            cal_ar_day = cal_ar_temp[0];
            cal_ar_month = cal_ar_temp[1];
            cal_ar_year = cal_ar_temp[2];
        }
        
        var ar_day_in_month = dni_mies(cal_ar_month, cal_ar_year);
        
        var ar_day_start = (cal_dep_month != cal_ar_month) ? 1 : cal_dep_day;
        
        out = out + '<div id="ar_container"><div><div class="calendar_date_line select"><div style="float:left;"><select name="ar_day" onchange="kalendarz(this.value,\'ar\');">';
        for (a = ar_day_start; a <= ar_day_in_month; a++) {
            out = out + '<option value="' + a + '.' + cal_ar_month + '.' + cal_ar_year + '" ';
            if (cal_ar_day == a) 
                out = out + 'selected="selected" ';
            out = out + '>' + a + '</option>';
        }
        out = out + '</select></div><div style="padding-left:12px;float:left;"><select name="ar_date" onchange="kalendarz(this.value,\'ar\');">';
        
        for (a = 1; a <= 12; a++) {
            if (date("m", mktime(0, 0, 0, cal_dep_month, (parseInt(cal_dep_day) + 1), cal_dep_year)) != cal_dep_month && a == 0) 
                var dep_month2 = dep_month2 + 1;
            temp = mktime(0, 0, 0, parseInt(cal_dep_month) + a, 0, cal_dep_year);
            
            if (mktime(0, 0, 0, parseInt(cal_dep_month) + a, 0, cal_dep_year) > mktime(0, 0, 0, parseInt(date('n')) + 12, date("d"), date("y"))) 
                break;
            out = out + '<option value="' + cal_ar_day + '.' + date("m.Y", temp) + '"  ';
            if (getLiczbaRev(cal_ar_month) + '.' + cal_ar_year == date("m.Y", temp)) 
                out = out + ' selected="selected" ';
            out = out + '> ';
            out = out + miesiac_pl(date("n", temp)) + ' ' + date("y", temp) + '</option>';
        }
        out = out + '</select></div></div><div class="calendar_date_line icon"></div><div class="calendar_date_line show"></div></div><div class="clear"><!-- --></div><div id="dep_container_calendar" ><div class="nl"><!-- --></div><div class="kalendarz"><!-- -->';
        temp = mktime(0, 0, 0, cal_ar_month, cal_ar_day, cal_ar_year);
        out = out + '<span class="calendar_line_el name"><span class="calendar_line_el_content">Pn</span></span><span class="calendar_line_el name"><span class="calendar_line_el_content">Wt</span></span><span class="calendar_line_el name"><span class="calendar_line_el_content">Śr</span></span><span class="calendar_line_el name"><span class="calendar_line_el_content">Cz</span></span><span class="calendar_line_el name"><span class="calendar_line_el_content">Pt</span></span><span class="calendar_line_el name"><span class="calendar_line_el_content">So</span></span><span class="calendar_line_el name"><span class="calendar_line_el_content">Nd</span></span>';
        dni_w_miesiacu = date('t', temp);
        numer_dnia_tygodnia = dzien_tyg_nr(cal_ar_month, cal_ar_year);
        odejmij = parseInt(numer_dnia_tygodnia) - 1;
        count = parseInt(dni_w_miesiacu) + parseInt(odejmij);
        for (a = 1; a <= count; a++) {
            if (a < numer_dnia_tygodnia) 
                out = out + '<span class="calendar_line_el unactive"><!-- --><span class="calendar_line_el_content"></span></span>';
            else {
                b = parseInt(a) - parseInt(odejmij);
                b2 = (b < 10) ? "0" + b : b;
                
                if (cal_dep_month == cal_ar_month && b < cal_dep_day) 
                    out = out + '<span class="calendar_line_el unactive"><!-- --><span class="calendar_line_el_content">' + b2 + '</span></span>';
                else {
                    if (parseInt(b) == cal_ar_day) 
                        out = out + '<span class="calendar_line_el select"><!-- --><span class="calendar_line_el_content">' + b2 + '</span></span>';
                    else 
                        out = out + '<span class="calendar_line_el active"><!-- --><span class="calendar_line_el_content"><span onclick="kalendarz(\'' + getLiczbaRev(b) + '.' + getLiczbaRev(cal_ar_month) + '.' + cal_ar_year + '\',\'ar\');" class="onmouseover" style="color:#ff6600;" >' + b2 + '</span></span></span>';
                }
            }
        }
    }
    document.getElementById('calendar').innerHTML = out;
    var req = mint.Request();
    req.AddParam(type, dane);
    req.Send('_inc/calendar.php', null);
}


//var cal_disp_var = '';
var XMLHttpRequestObject = false;
if (window.XMLHttpRequest) {
    XMLHttpRequestObject = new XMLHttpRequest();
}
else 
    if (window.ActiveXObject) {
        XMLHttpRequestObject = new ActiveXObject("Microsoft.XMLHTTP");
    }

function kalendarz_(){
    var req = mint.Request();
    req.Send("_inc/search_panel/calendar.php?calendar_display=all", "calendar");
}

function kalendarz_small(dane, typ){
    if (XMLHttpRequestObject) {
        var dest = "calendar_small";
        var div = document.getElementById(dest);
        if (typ == "dep") {
            var url = "_inc/calendar_small.php?dep_date=" + dane;
        }
        if (typ == "ar") {
            var url = "_inc/calendar_small.php?ar_date=" + dane;
        }
        if (typ == "dep_calendar_display") {
            var url = "_inc/calendar_small.php?dep_calendar_display=" + dane;
        }
        if (typ == "ar_calendar_display") {
            alert('a');
            var url = "_inc/calendar_small.php?ar_calendar_display=" + dane;
        }
        if (typ == "display") 
            var url = "_inc/calendar_small.php?display=" + dane;
        
        XMLHttpRequestObject.open("GET", url);
        XMLHttpRequestObject.onreadystatechange = function(){
            if (XMLHttpRequestObject.readyState == 4 &&
            XMLHttpRequestObject.status == 200) {
                var str = "";
                str += XMLHttpRequestObject.responseText;
                div.innerHTML = str;
            }
        }
        XMLHttpRequestObject.send(null);
    }
}

function cursor_default(id){
    document.getElementById(id).style.cursor = "default";
}

function cursor_pointer(id){
    document.getElementById(id).style.cursor = "pointer";
}

function go_to(str){
    location.href = str;
}

function search_engine(name){
    var req = mint.Request();
    
    kalendarz('all', 'display');
    document.getElementById('se_lotnicze_btn').src = 'grafika/se/bilety_lotnicze_btn1.gif';
    document.getElementById('se_hotele_btn').src = 'grafika/se/hotele_btn1.gif';
    document.getElementById('se_car_btn').src = 'grafika/se/wynajem_aut_btn1.gif';
    document.getElementById('se_all_btn').src = 'grafika/se/fly_stay_btn1.gif';
    if (name == "hotele") {
        //alert('s');
        document.getElementById('se_content').style.backgroundImage = "url('grafika/se/hotele_bg.jpg')";
    }
    else 
        document.getElementById('se_content').style.backgroundImage = "url('grafika/se/main_bg.jpg')";
    switch (name) {
        case 'lotnicze':
            document.getElementById('se_lotnicze_btn').src = 'grafika/se/bilety_lotnicze_btn2.gif';
            req.Send("_inc/se_lotnicze.php", "se_content");
            break;
        case 'hotele':
            document.getElementById('se_hotele_btn').src = 'grafika/se/hotele_btn2.gif';
            req.Send("_inc/se_hotele.php", "se_content");
            break;
        case 'car':
            document.getElementById('se_car_btn').src = 'grafika/se/wynajem_aut_btn2.gif';
            req.Send("_inc/se_car.php", "se_content");
            break;
        case 'all':
            document.getElementById('se_all_btn').src = 'grafika/se/fly_stay_btn2.gif';
            req.Send("_inc/se_all.php", "se_content");
            break;
    }
}

ac = new Array(2);
ac['dep'] = 0;
ac['ar'] = 0;
suggest = new Array();
function temppp(){
    return;
}

function autocom(id, val, target, se_type){
    if (target == "dep_autocomplete") {
        var t = 'dep';
    }
    else {
        var t = 'ar';
    }
    if (val.length > 2) {
        var req = mint.Request();
        req.AddParam('q', val);
        req.AddParam('target', t);
        req.AddParam('se_type', se_type);
        req.Send("_inc/search_for_airport.php");
        req.OnSuccess = function(){
            mint.fx.Size(target, null, '180', 1, 500);
            document.getElementById(target).innerHTML = this.responseText;
        }
        if (suggest[suggest.length - 1] != undefined) 
            document.getElementById('temp').innerHTML = suggest[suggest.length - 1];
    }
    else 
        mint.fx.Size(target, null, 0, 1, 500);
}

function getSearch_for_airport(val, se_type, target){
    var req = mint.Request();
    req.Send("_inc/search_for_airport.php?q=" + val + "&target=" + target +
    "&se_type=" +
    se_type, target);
}

function close_autocomplete(){
    mint.fx.Size('ar_autocomplete', null, 0, 1, 100);
    mint.fx.Size('dep_autocomplete', null, 0, 1, 100);
}

function openWindow(href, name, width, height){
    window.open(href, name, "height=" +
    height +
    ", width=" +
    width +
    ", status=no, scrollbars=yes, toolbar=no, menubar=no, location=no, resizable=no");
    return false;
}

function subskrypcja(){
    var email = document.getElementById('email').value;
    var req = mint.Request();
    req.AddParam('email', email);
    req.Send("widget.php?action=subscribe", 'resp');
    document.getElementById('email').value = "";
    alert("Adres " + email + " zapisany do subskrypcji");
}

var prom_dep = "";
var prom_ar = "";
var prom_airline = "";
var prom_airline = "";
function promotions_low_cost(type, val, page){
    var req = mint.Request();
    if (type == "ar") 
        prom_ar = val;
    if (type == "dep") 
        prom_dep = val;
    if (page == undefined) 
        page = 1;
    if (type == "airline_code") 
        prom_airline = val;
    req.AddParam("dep_code", prom_dep);
    req.AddParam("ar_code", prom_ar);
    req.AddParam("airline_code", prom_airline);
    req.AddParam("page", page);
    req.Send("widget.php?action=promotion_low_cost", "promotions_details");
}

function promotions_regular(type, val, page){
    var req = mint.Request();
    if (type == "ar") 
        prom_ar = val;
    if (type == "dep") 
        prom_dep = val;
    if (type == "airline") 
        prom_airline = val;
    if (page == undefined) 
        page = 1;
    req.AddParam("dep_code", prom_dep);
    req.AddParam("ar_code", prom_ar);
    req.AddParam("airline", prom_airline);
    req.AddParam("page", page);
    req.Send("widget.php?action=promotion_regular", "promotions_details");
}

function new_chat(){
    openWindow('/chat', 'chat', '504', '550');
}

function check_my_trip(){
    /*openWindow(
     'https://www.checkmytrip.com/plnext/XCMTXITN/CleanUpSessionPui.action?SITE=XCMTXITN&LANGUAGE=PL',
     'checmytrip', '1000', '680');
     */
    if ((document.getElementById('cmt_code').value == '') || (document.getElementById('cmt_name').value == '')) 
        alert('Prosimy podać numer rezerwacji oraz nazwisko pasażera.');
    else {
        openWindow('https://www.checkmytrip.com/cmtservlet?R=' + document.getElementById('cmt_code').value + '&L=PL&N=' + document.getElementById('cmt_name').value, 'checmytrip', '1000', '680');
    }
}

function pausecomp(millis){
    var date = new Date();
    var curDate = null;
    do {
        curDate = new Date();
    }
    while (curDate - date < millis);
}

var poradnik_podroznika_array = new Array();
function poradnik_podroznika(header, delay){
    if (delay > 0) {
        pausecomp(delay);
    }
    var req = mint.Request();
    req.AddParam('action', 'poradnik_podroznika');
    req.AddParam('header', header);
    if ((poradnik_podroznika_array[header] == undefined) ||
    (poradnik_podroznika_array[header] == "close")) {
        req.Send("widget.php?action=poradnik_podroznika", header);
        poradnik_podroznika_array[header] = "open";
    }
    else {
        document.getElementById(header).innerHTML = '';
        poradnik_podroznika_array[header] = "close";
    }
}

function wiele_polaczen(){
    window.location.href = "https://www.biletybilety.pl/wiele-polaczen";
}

function slike() {
	document.getElementById('se_lot_form').submit();
}


function submit_form(id){
	var sub = true;
	var adult = document.getElementById('adult').value;
	var young = document.getElementById('young').value;
    
	if (id == 'se_lotnicze_form') {
		if (adult == 0 && young > 0) {
			//alert('komunikat informacyjny');
			sub = false;
			//$('#young_lay').click(function () {
			//$('#young_lay').show("slow");
			$('#young_lay').slideDown("slow");
			//});
		}
    }
	
	if (sub) {
		document.getElementById(id).submit();
	}
}


function submit_hotele_form(){
    //go_to('http://www.booking.com/index.html?aid=335691');
    //alert('s');
    window.open("", "myNewWin", "width=" + screen.width + ",height=" + screen.height + ",status=yes, scrollbars=yes, toolbar=yes, menubar=yes, location=yes, resizable=yes");
    var a = window.setTimeout("document.se_hotele_form.submit();", 500);
}

function atlas(type){
    if (type == "dep") {
        openWindow('/mapa.php?type=dep_airport', 'mapa', 730, 550);
    }
    if (type == "ar") {
        openWindow('/mapa.php?type=ar_airport', 'mapa', 730, 550);
    }
}

function getKraje(id, ref_id, all){
    var req = mint.Request();
    var req2 = mint.Request();
    req.Send("_inc/atlas_content.php?kontynent_id=" + id, 'kraje');
    req2.Send("_inc/atlas_content.php", "lotniska");
    for (a = 1; a <= all; a++) {
        document.getElementById('kontynenty' + a).style.backgroundColor = "";
        document.getElementById('kontynenty' + a).style.color = "";
        document.getElementById('kontynenty' + a).style.fontWeight = "";
    }
    document.getElementById('' + ref_id + '').style.backgroundColor = "gray";
    document.getElementById('' + ref_id + '').style.color = "white";
    document.getElementById('' + ref_id + '').style.fontWeight = "bold";
}

function getLotniska(id, ref_id, all){
    var req = mint.Request();
    req.Send("_inc/atlas_content.php?kraj_id=" + id, 'lotniska');
    for (a = 1; a <= all; a++) {
        document.getElementById('kraj' + a).style.backgroundColor = "";
        document.getElementById('kraj' + a).style.color = "";
        document.getElementById('kraj' + a).style.fontWeight = "";
    }
    document.getElementById('' + ref_id + '').style.backgroundColor = "gray";
    document.getElementById('' + ref_id + '').style.color = "white";
    document.getElementById('' + ref_id + '').style.fontWeight = "bold";
}

function mapa(name, id){
    var req = mint.Request();
    if (name == "kontynent") {
        req.Send("mapa.php?sub=1&kontynent_id=" + id, "kraje");
        document.getElementById('lotniska').innerHTML = "";
    }
    if (name == "kraj") {
        req.Send("mapa.php?sub=1&kraj_id=" + id, "kraje");
    }
}

function chooseAirport(airport, field){
    window.opener.document.getElementById(field).value = airport;
    window.close();
    return false;
}

function switch_img(id, type){
    if (type == "on") {
        document.getElementById(id).src = "grafika/btn/" + id + "2.gif";
    }
    if (type == "out") {
        document.getElementById(id).src = "grafika/btn/" + id + ".gif";
    }
}

function pasangers(){
    var a = Number(document.getElementById('adult').value);
    if (document.getElementById('teenager')) 
        var b = Number(document.getElementById('teenager').value);
    else 
        var b = Number(0);
    var c = Number(document.getElementById('young').value);
    var d = Number(document.getElementById('inf').value);
    var summa = a + b + c + d;
    if (summa > 9) {
        if (confirm('Rezerwacje indywidualne są mozliwe tylko do 9 osób w tym dzieci.\n\n W przypadku potrzeby zarezerwowania wiÄ�kszej liczby miejsc prosimy o kontakt z naszym Call Center po numerem telefonu \n\n 800 000 185 \n\n lub skorzystał z formularz rezerwacji grupowych. Czy wyświetlić formularz rezerwacji grupowych? ')) {
            go_to('/rezerwacje-grupowe');
        }
        else {
            document.getElementById('teenager').value = 0;
            document.getElementById('young').value = 0;
            document.getElementById('inf').value = 0;
        }
    }
    if (document.getElementById('adult').value == "<9") {
        go_to('/rezerwacje-grupowe');
    }
}

function homepage(){
    go_to('http://www.biletybilety.pl/');
}

function twoDaysFrame(){
    document.getElementById('se_frame_layer').style.width = "100%";
    document.getElementById('se_frame_layer').style.height = "100%";
    alert("UWAGA! Mniej niż 3 dni do wylotu.\n\nRezerwacja biletu na tą datę jest możliwa tylko poprzez kontakt z naszym Call Center\n\n801 000 185\n\nZespół BiletyBilety.pl");
}

function mini_one_way(){
    mint.fx.Size("ar_date_box", 120, 0, 20, 250);
}

function mini_two_way(){
    mint.fx.Size("ar_date_box", 120, 42, 20, 250);
}

function small_one_way(){
    kalendarz_small('half', 'display');
}

function small_two_way(){
    kalendarz_small('all', 'display');
}

function mini_se_display(){
    document.getElementById('se_mini').style.display = '';
    document.getElementById('dep_cal').style.display = '';
    document.getElementById('ar_cal').style.display = '';
    document.getElementById('dep_airport_ico').style.display = '';
    document.getElementById('ar_airport_ico').style.display = '';
    mint.fx.Fade("se_mini", 100, 20, 500);
}

function close_info_box(){
    mint.fx.Fade("info_box", 0, 100, 10000);
}

function vDymek(ev, name){


    var IE = document.all ? true : false;
    if (IE) {
        tempX = event.clientX + document.body.scrollLeft;
        tempY = event.clientY + document.body.scrollTop;
    }
    else {
        tempX = ev.pageX;
        tempY = ev.pageY;
    }
    if (tempX < 0) {
        tempX = 0
    };
    if (tempY < 0) {
        tempY = 0
    };
    var div = document.getElementById('dymek');
    var div_top, div_content, div_bottom;
    div.style.display = 'block';
    div.style.top = tempY + 'px';
    div.style.left = tempX + 'px';
    div_top = '<div id="dymek2" style="padding:10px;border-color:#999;border-style:solid;border-width:1px;background-color:#ffff99;font-size:10px;font-family:arial;font-color:#000000;width:250px;">';
    if (name == 'mix_lot') 
        div_content = '<div style="text-align:justify;">opcja <strong style="text-decoration:underline;">mix lot</strong> umożliwia wyszukanie połączeń do tego samego portu lotniczego lub w obrębie tej samej destynacji <strong style="text-decoration:underline;">tanimi liniami</strong> jak również liniami <strong style="text-decoration:underline;">regularnymi</strong>. Przykładowy lot z Warszawy do Londynu może być liniami LOT lub British Airways na lotnisko Londyn Heathrow, a powrót w ramach tej samej rezerwacji tanią linią Wizziar lub Ryanair z portów Londyn Stansted, lub Londyn Luton. Ponadto możesz sam skomponować swoją podróż wybierając na liście wyników opcje <strong style="text-decoration:underline;">połącz sam</strong>.</div>';
    if (name == 'direct') 
        div_content = 'ogranicz wyszukiwanie połączeń tylko do lotów bezpośrednich';
    if (name == "plus_minus") 
        div_content = 'wyszukaj najtańsze połączenia na przestrzeni kilku dni';
    div_bottom = '</div>';
    
    div.innerHTML = div_top + div_content + div_bottom;
    //mint.fx.Round("dymek", "all", "small");
    //mint.fx.Round("dymek2", "all", "small");
}

function hDymek(){
    var div = document.getElementById('dymek');
    div.style.display = 'none';
}

function nakladka(){
    //mint.fx.Fade("nakladka", 0, 20, 500);
    document.getElementById('nakladka').style.visibility = 'hidden';
    //#document.getElementById('nakladka').style.width = '1px';
    //#document.getElementById('nakladka').style.height = '1px';
}




function get_help_content(id){

    if (id.length > 0) {
    
        document.getElementById('help_content').innerHTML = "Ładowanie...";
        var req = mint.Request();
        req.AddParam("action", "get_help_content");
        req.AddParam("subheader_id", id);
        req.Send("widget.php", "help_content");
    }
    return;
}

function buy_ub(name){
    /*	document.getElementById('box_europejskie').innerHTML='';
     document.getElementById('box_signaliduna').innerHTML='';
     document.getElementById('box_warta').innerHTML='';
     document.getElementById('signaliduna_desc').style.visibility = "hidden";
     document.getElementById('europejskie_desc').style.visibility = "hidden";
     document.getElementById('warta_desc').style.visibility = "hidden";
     document.getElementById('signaliduna').style.visibility = "hidden";
     document.getElementById('europejskie').style.visibility = "hidden";
     document.getElementById('warta').style.visibility = "hidden";
     
     
     document.getElementById(name).style.visibility = 'visible';
     */
    var req = mint.Request();
    req.AddParam("action", "show_iframe");
    req.AddParam("name", name);
    //req.Send("widget_ubezpieczenia.php", "box_" + name);
    req.Send("widget_ubezpieczenia.php", "response");
}

function help_score(type, id, id2){
    var req = mint.Request();
    req.AddParam("action", "help_score");
    req.AddParam("type", type);
    req.AddParam("subheader_id", id);
    req.AddParam("header_id", id2);
    
    req.Send("widget.php", null);
    alert("Dziękujemy za ocenę.");
}

function get_mapa(){
    alert('pobieranie mapy');
    var req = mint.Request();
    req.AddParam("action", "get_mapa");
    
    req.Send("widget.php", "mapka");
    
}

