function startList(){
    if (document.all&&document.getElementById) {
        var navRoot = document.getElementById("nav_menu");
        for (i=0; i<navRoot.childNodes.length; i++) {
               var node = navRoot.childNodes[i];
               if (node.nodeName=="LI") {
                  node.onmouseover=function() {
                       this.className+=" over";
                    }
                  node.onmouseout=function() {
                       this.className=this.className.replace(" over", "");
                    }
                }
        }
    }
 }

 function toggleCompanyData(){
     var company_wraper = document.getElementById('dane_firmy');
     if(company_wraper.style.display == 'none'){
         company_wraper.style.display = 'block';
         addCompanyValidationRules();
     }else{
         company_wraper.style.display = 'none';
         removeCompanyValidationRules();
     }
 }

/*function addCompanyValidationRules(){
    $("#firma").rules("add", {
        required: true,
        messages: {
            required: "Podaj nazwę firmy",
        }
    });

   $("#firma_ulica").rules("add", {
        required: true,
        messages: {
            required: "Podaj ulicę",
        }
    });

    $("#firma_kod_pocztowy").rules("add", {
        required: true,
        messages: {
            required: "Podaj kod pocztowy",
        }
    });

    $("#firma_miejscowosc").rules("add", {
        required: true,
        messages: {
            required: "Podaj miejscowość",
        }
    });

    $("#firma_nip").rules("add", {
        required: true,
        messages: {
            required: "Podaj NIP",
        }
    });

}*/

 function removeCompanyValidationRules(){
     $("#firma").rules("remove");
     $("#firma_ulica").rules("remove");
     $("#firma_kod_pocztowy").rules("remove");
     $("#firma_miejscowosc").rules("remove");
     $("#firma_nip").rules("remove");
 }

 function setReservationValidators(form_id){
     $(document).ready(function(){
        $('#' + form_id).validate({
            rules:{
                email:{
                    required: true,
                    email: true
                },
                data_przyjazdu:{
                    required: true,
                    datePL: true
                },
                ilosc_osob:{
                    required:true,
                    max:4
                },
                ilosc_dzieci:{
                    required:true,
                    max:3
                }
            },
            messages:{
                imie_nazwisko:'Podaj imię i nazwisko',
                ulica:'Podaj ulicę z numerem',
                kod_pocztowy:'Podaj kod pocztowy',
                miejscowosc:'Podaj miejscowość',
                kraj:'Podaj kraj',
                telefon:'Podaj numer telefonu',
                numer_dokumentu:'Podaj numer dokumentu',
                regulamin:'To pole musi być zaznaczone',
                ilosc_osob: 'Nie wiecej niż 4',
                ilosc_dzieci: 'Nie wiecej niż 4',
                email:{
                    required: "Podaj email",
                    email: "Podaj poprawna wartość email"
                }
            }
        });
    });
 }

 function dateFormat(){
    return "dd-mm-yy";
 }

 function dayNames(){
     return ['Niedziela', 'Poniedziałek', 'Wtorek', 'Środa', 'Czwartek', 'Piątek', 'Sobota'];
 }
function dayNamesMin(){
     return  ['Nie', 'Pon', 'Wto', 'Śro', 'Czw', 'Pią', 'Sob'];
}
function monthNames(){
    return ['Styczeń','Luty','Marzec', 'Kwiecień','Maj','Czerwiec','Lipiec','Sierpień', 'Wrzesień','Październik','Listopad','Grudzień'];
}

    function setEndReservation(input){
        var dateStr = input.value.split('-',3);
        var date = new Date(dateStr[2],dateStr[1] - 1, dateStr[0]);
        date.setDate(date.getDate() + 7);
        var day = date.getDate();
        var month = date.getMonth();
        month = month + 1;
        if(month < 10){
            month = '0' +month;
        }

        if(day < 10){
            day = '0' +day;
        }
        $("#dateout").val( day+ '-' + month + '-' + date.getFullYear() );
    }
