function showReserveMark(id) {
      if (id == 1) {
        
        $('infoMark').addClassName('reserveMarkActive');
        $('infoMark').removeClassName('reserveMarkUnactive');
        $('calcMark').addClassName('reserveMarkUnactive');
        $('calcMark').removeClassName('reserveMarkActive');
        $('helpMark').addClassName('reserveMarkUnactive');
        $('helpMark').removeClassName('reserveMarkActive');
        
        $('info').show();
        $('calc').hide();
        $('help').hide();
        
      } else if (id == 2) {
        
        $('infoMark').addClassName('reserveMarkUnactive');
        $('infoMark').removeClassName('reserveMarkActive');
        $('calcMark').addClassName('reserveMarkActive');
        $('calcMark').removeClassName('reserveMarkUnactive');
        $('helpMark').addClassName('reserveMarkUnactive');
        $('helpMark').removeClassName('reserveMarkActive');
        
        $('info').hide();
        $('calc').show();
        $('help').hide();
        
      } else if (id == 3) {
        
        $('infoMark').addClassName('reserveMarkUnactive');
        $('infoMark').removeClassName('reserveMarkActive');
        $('calcMark').addClassName('reserveMarkUnactive');
        $('calcMark').removeClassName('reserveMarkActive');
        $('helpMark').addClassName('reserveMarkActive');
        $('helpMark').removeClassName('reserveMarkUnactive');
        
        $('info').hide();
        $('calc').hide();
        $('help').show();
        
      }    
    
    }
    
    function showPersons() {
      count = parseInt($F('personCount'));
      for (i=1; i<=6; i++) {
        if (count == 0) {
          $('person'+i).hide();
        } else {
          if (i<=count) $('person'+i).show();
          else $('person'+i).hide();
        }
      }
      onePrice = parseInt($F('price'));
      //$('priceAll').value = (count+1)*$F('price');
      
      surchargesSum = calcDiscounts();
      
      $('priceAll').value = onePrice + (count * onePrice) + surchargesSum;
    }
    
    function calcDiscounts() {
      
      discountsCount = parseInt($F('surchargesCount'));
      personsCount = (parseInt($F('personCount')) + 1);
      surcharchesSum = 0;
      alertTxtMax = '';
      alertTxtMin = '';
      for (i=1; i<=discountsCount; i++) {
        eval('currentCurrencyType = parseInt($F(\'currencyType'+i+'\'))');
        eval('currentSurchargeAmount = parseInt($F(\'surchargeAmount'+i+'\'))');
        eval('currentSurchargePrice = parseInt($F(\'surchargePrice'+i+'\'))');
        
        
        if (currentSurchargeAmount > personsCount) {
          
          alertTxtMax = 'Uwaga!\n\nIlość zniżek lub dopłat nie może przekraczać ilości osób wyjeżdżających.\nIlość zniżek lub dopłat została zmniejszona.';
          eval('$(\'surchargeAmount'+i+'\').value = personsCount');
          currentSurchargeAmount = personsCount;
        } 
        if (currentSurchargeAmount < 0) {
          alertTxtMin = 'Uwaga!\nIlość zniżek nie może być liczbą ujemną';
          eval('$(\'surchargeAmount'+i+'\').value = 0');
          currentSurchargeAmount = 0;
        } 
        
        
        if (currentCurrencyType == 1) {
          
          surcharchesSum = surcharchesSum + (currentSurchargeAmount * currentSurchargePrice);
          
        } else if (currentCurrencyType == 2) { 
        
          currentPercent = parseInt($F('price'))/100;
          surcharchesSum = surcharchesSum  + Math.ceil((currentSurchargePrice * currentPercent) * currentSurchargeAmount);
        }
      }
      if (alertTxtMax != '') alert(alertTxtMax);  
      if (alertTxtMin != '') alert(alertTxtMin);
      return surcharchesSum;  
    }
    
    
    function minusSurcharge(id) {
      eval('$(\'surchargeAmount'+id+'\').value  = parseInt($F(\'surchargeAmount'+id+'\')) - 1');
      showPersons();
    }
    
    function plusSurcharge(id) {
      eval('$(\'surchargeAmount'+id+'\').value = parseInt($F(\'surchargeAmount'+id+'\')) + 1');
      showPersons();
    }
    
    function checkConfirmReservation() {
      if ($('confirmReg')) {
        if ($('confirmData').checked && $('confirmReg').checked) {
          
          reservation.submit();
        } else {
          alert('Wymagane jest wyrażenie zgody na przetwarzanie danych osobowych\n oraz akceptacja regulaminu.');
        
        }
      
      } else {
        if ($('confirmData').checked) reservation.submit();
        else alert('Wymagane jest wyrażenie zgody na przetwarzanie danych osobowych.');
      } 
    }
    
    function checkReservationForm() {
      
      
      error = false;
      errorMsg = "Uwaga!\n";
      
      
      if (!$('firstName').present() || !$('lastName').present()) {
        error = true;
        errorMsg += "Nie podano imienia lub nazwiska.\n";
      } 
      
      
      
      if (!$('day').present() || !$('month').present() || !$('year').present()) {
        error = true;
        errorMsg += "Nie podano daty urodzenia.\n";
        
      }
      
      if ($('year').present() && $('month').present() && $('day').present()) {
        today = new Date();
        todayMinus18 = new Date(today.getFullYear()-18, today.getMonth()+1, today.getDate());
        
        bornDate = new Date(parseInt($F('year')), parseInt($F('month')), parseInt($F('day')));
        
        if (todayMinus18 < bornDate) {
          error = true;
          errorMsg += "Osoba rezerwująca wyjazd powinna być pełnoletnia.\n";
        }
      }
      
      if (!$('cityPlace').present()) {
        error = true;
        errorMsg += "Nie podano miasta zamieszkania.\n";
      }
      if (!$('street').present()) {
        error = true;
        errorMsg += "Nie podano adresu zamieszkania.\n";
      }
      
      if (!$('postCode').present() || !is_numeric($F('postCode'))) {
        error = true;
        errorMsg += "Nie podano lub błędny kod pocztowy.\n";
      }
      if (!$('mail').present() || !is_valid_email($F('mail'))) {
        error = true;
        errorMsg += "Nie podano lub błędny adres email.\n";
      }
      /*
      if (!$('phone').present() || !is_numeric($F('phone'))) {
        error = true;
        errorMsg += "Nie podano lub błędny nr telefonu.\n";
      }

      */
      
      
      
      
      personCount = parseInt($F('personCount'));
      
      
      for (i = 1; i <= personCount; i++) {
        
        //alert(i);
        
        if (!$('firstName'+i).present() || !$('lastName'+i).present()) {
          error = true;
          errorMsg += "Nie podano imienia lub nazwiska osoby towarzyszącej nr "+i+".\n";
        } 
        if (!$('day'+i).present() || !$('month'+i).present() || !$('year'+i).present()) {
          error = true;
          errorMsg += "Nie podano daty urodzenia osoby towarzyszącej nr "+i+".\n";
        } 
        
        
      }
            
      
      if (error) {
        alert(errorMsg);
      } else {
        reservation.submit();
      }
    }
    
    
    
