﻿function schsch(){
        x = document.forms.bf.ROUNDTRIP[0].checked;
        if (x == true){
                document.getElementById("sch").style.visibility = 'visible';
        }else{
                document.getElementById("sch").style.visibility = 'hidden';
        }
}

function chf(){

        //je to dneska?
        d = new Date();
        if (document.forms.bf.DEPDAY.value == d.getDate() && document.forms.bf.DEPMONTH.value == (d.getMonth()+1)){
                if (!confirm("Pro odlet jste vybrali dnešní den. Dnešní lety jsou nabízeny až do 1 hodiny před plánovaným odletem.\n\nUJISTĚTE SE, PROSÍM, ŽE SE K LETIŠTNÍ ODBAVOVACÍ PŘEPÁŽCE MŮŽETE DOSTAVIT ALESPOŇ 40 MINUT PŘED ODLETEM\n\nChcete-li změnit datum odletu, klikněte na Storno\n\n--------------------------------\n\nYou have choosen Departure date on today. Today flights are offered max. 1 hour before departure time. PLEASE ENSURE YOU WILL BE ON THE DEPARTURE DESK MIN. 40 MINUTES BEFORE DEPARTURE! "))
                        return false;
        }


        //pouze pokud se rovnaji data a jde o zpatecni let
        if (document.forms.bf.ROUNDTRIP[0].checked == true){
                if (document.forms.bf.DEPDAY.value == document.forms.bf.RETDAY.value && document.forms.bf.DEPMONTH.value == document.forms.bf.RETMONTH.value){
                        if (!confirm('Pro let tam a zpět jste vybrali stejný den. Jste si jisti, že jste vybrali spravně?\n\n--------------------------------\n\nDeparture and Return date was set on same day. Do you want to continue?'))
                                return false;
                }
        }

        if (document.forms.bf.ORIGIN.value == 0){
                alert('Vyberte místo odletu / Choose airport of departure');
                return false;
        }
        if (document.forms.bf.DESTINATION.value == 0){
                alert('Vyberte místo příletu / Choose airport of arrival');
                return false;
        }
}

function chfhotel(){
        if (document.forms.hotSearch.city.value == 0){
                alert('Vyberte město / Choose city');
                return false;
        }
}

function chfwheel(){
        if (document.forms.carForm.city.value == 0){
                alert('Vyberte město / Choose city');
                return false;
        }
}

function chfshuttle(){

        if (document.forms.bshuttle.city.value == 0){
                alert('Vyberte město / Choose city');
                return false;
        }
}


function plane() {
        x = document.getElementById('bfmain');
        y = document.getElementById('bfmainhotel');
        z = document.getElementById('bfmainwheel');
        w = document.getElementById('bfmainshuttle');
        x.style.visibility = 'visible';
        y.style.visibility = 'hidden';
        z.style.visibility = 'hidden';
        w.style.visibility = 'hidden';
        x = document.forms.bf.ROUNDTRIP[0].checked;
        if (x == true){
                document.getElementById("sch").style.visibility = 'visible';
        }else{
                document.getElementById("sch").style.visibility = 'hidden';
        }
}

function hotel() {
        x = document.getElementById('bfmain');
        y = document.getElementById('bfmainhotel');
        z = document.getElementById('bfmainwheel');
        w = document.getElementById('bfmainshuttle');
        x.style.visibility = 'hidden';
        y.style.visibility = 'visible';
        z.style.visibility = 'hidden';
        w.style.visibility = 'hidden';
        document.getElementById("sch").style.visibility = 'hidden';
}

function shuttle() {
        x = document.getElementById('bfmain');
        y = document.getElementById('bfmainhotel');
        z = document.getElementById('bfmainwheel');
        w = document.getElementById('bfmainshuttle');
        x.style.visibility = 'hidden';
        y.style.visibility = 'hidden';
        z.style.visibility = 'hidden';
        w.style.visibility = 'visible';
        document.getElementById("sch").style.visibility = 'hidden';
}

function wheel() {
        x = document.getElementById('bfmain');
        y = document.getElementById('bfmainhotel');
        z = document.getElementById('bfmainwheel');
        w = document.getElementById('bfmainshuttle');
        x.style.visibility = 'hidden';
        y.style.visibility = 'hidden';
        z.style.visibility = 'visible';
        w.style.visibility = 'hidden';
        document.getElementById("sch").style.visibility = 'hidden';

        if (vheelpopup == 0){
                vheelpopup = 1;
                window.open("http://www.sixti.cz/pop_up_Sixti.htm","ad","toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=290,height=565");
        }
}

function setCSC(city,state,country) {
    if (city != "") {
        document.forms.hotSearch.city.value=city;
        document.forms.hotSearch.stateProvince.value=state;
        document.forms.hotSearch.country.value=country;
    }
}


function openWindow1() {
window.open("","JSL1",'toolbar=0,location=0,scrollbars=0,width=400,height=200,resizable=0,top=20,left=20');
}

function openWindow2() {
window.open("","JSL2",'toolbar=0,location=0,directories=no,status=no,scrollbars=1,menubar=no,resizable=yes,width=270,height=150,resizable=0,top=20,left=20');
}





//start new script code
    function isBrowserSupp() {
        // Get the version of the browser
        version =  parseFloat( navigator.appVersion );

        if ( ( version >= 2.0 ) && ( version < 2.1 ) && ( navigator.appName.indexOf( "Netscape" ) != -1 ) ) {
            return false;
        } else {
            return true;
        }

        return true;
    }

    function isLeapYear( yrStr ) {
        var leapYear = false;
        var year = parseInt( yrStr, 10 );
        // every fourth year is a leap year
        if ( year % 4 == 0 ) {
            leapYear = true;
            // unless it's a multiple of 100
            if( year % 100 == 0 ) {
                leapYear = false;
                // unless it's a multiple of 400
                if( year % 400 == 0 ) {
                    leapYear=true;
                }
            }
        }
        return leapYear;
    }

    function getDaysInMonth( mthIdx, YrStr ) {
        // all the rest have 31
        var maxDays = 31
        // expect Feb. (of course)
        if( mthIdx == 1 ) {
            if( isLeapYear( YrStr ) ) {
		//tady podtim ma byt 28
                maxDays=31;
            } else {
                maxDays=31;
            }
        }

        // thirty days hath...
        if( mthIdx == 3 || mthIdx == 5 || mthIdx == 8 || mthIdx == 10 ) {
            maxDays=31;
        }
        return maxDays;
    }

    //the function which does some magic to the date fields
    // return non-zero if it is the last day of the month
    function adjustDate( mthIdx, Dt ) {
        var value = 0;

        var today = new Date()
        var theYear = parseInt( today.getYear(), 10 )

        if( mthIdx < today.getMonth() ) {
            theYear = ( parseInt( today.getYear(), 10 ) + 1 )
        }
        if( theYear < 100 ) {
            theYear = "19" + theYear
        } else {
            if( ( theYear - 100 ) < 10 ) {
                theYear = "0" + ( theYear - 100 )
            } else {
                theYear = ( theYear - 100 ) + ""
            }
            theYear = "20" + theYear
        }


        var numDays = getDaysInMonth( mthIdx, theYear );

        if( mthIdx == 1 ) {
            if( Dt.options.selectedIndex + 1 < numDays ) {
                return 0;
            } else {
                Dt.options.selectedIndex=numDays - 1;
                //check for leap year
                if( numDays == 29 ) {
                    return 99;
                } else {
                    return 1;
                }
            }
        }

        if( Dt.options.selectedIndex + 1 < numDays ) {
            value = 0;
        } else {
            if ( Dt.options.selectedIndex + 1 > numDays ) {
                Dt.options.selectedIndex--;
                value = 3;
            } else {
                //index is 31 or 30
                value = 2;
            }
        }
        return value;
    }

    //changes departure month when arrival month is changed
    function amadChange( inM, inD, outM, outD ) {
        if ( !isBrowserSupp() ) {
            return;
        }

        var res = adjustDate( inM.options.selectedIndex, inD );
        if( res != 0 ) {
               outD.options.selectedIndex = 0;
               if ( outM.options.selectedIndex == 11 ) {
                    outM.options.selectedIndex = 0
               } else {
                    outM.options.selectedIndex=inM.options.selectedIndex + 1;
                    outD.options.selectedIndex = 1;
               }
        } else {
            outM.options.selectedIndex = inM.options.selectedIndex;
            if (outD.options.selectedIndex <= inD.options.selectedIndex) {
                outD.options.selectedIndex = inD.options.selectedIndex + 2;
            }
        }
        return;
    }


    function dmddChange( outM, outD ) {
        if ( !isBrowserSupp() ) {
            return;
        }

        adjustDate( outM.options.selectedIndex, outD );
        return;
    }
    function OpenWindow(file, name, width, height) {
        OpenWindow(file, name, width, height, false);
    }

    function OpenWindow(file, name, width, height, showLeftTopScrollbar) {
        var attr = "";
        if(showLeftTopScrollbar) {
            attr += "top=50,left=50,scrollbars=1,";
        }
        attr += "width=" + width + ",height=" + height + ",resizeable=1";
        window.open(file, name, attr);
    }
