jQuery.noConflict();

jQuery.datepicker.regional['cs'] = {
  changeMonth: true,
  changeYear: true,
  duration: 'fast',
  closeText: 'Zavřít',
  prevText: '&#x3c;Dříve',
  nextText: 'Později&#x3e;',
  currentText: 'Nyní',
  monthNamesShort: ['leden', 'únor', 'březen', 'duben', 'květen', 'červen', 'červenec', 'srpen', 'září', 'říjen', 'listopad', 'prosinec'],
  monthNames: ['led', 'úno', 'bre', 'dub', 'kvě', 'čer', 'čvc', 'srp', 'zář', 'říj', 'lis', 'pro'],
  dayNames: ['neděle', 'pondělí', 'úterý', 'středa', 'čtvrtek', 'pátek', 'sobota'],
  dayNamesShort: ['ne', 'po', 'út', 'st', 'čt', 'pá', 'so'],
  dayNamesMin: ['ne', 'po', 'út', 'st', 'čt', 'pá', 'so'],
  dateFormat: 'dd.mm.yy',
  firstDay: 1,
  isRTL: false,
  minDate: 0,
  numberOfMonths: 2
};

var specification = new Array(
  new Array(
    new Array('KOUPÍM SI PNEUMATIKY S DISKY U VÁS', '', '0,-'),
    new Array('MÁM U VÁS USKLADNĚNY - JEN PNEU', '700+300 Kč', '1000,-'),
    new Array('MÁM U VÁS USKLADNĚNY - PNEU I S DISKY', '350+350 Kč', '700,-'),
    new Array('MÁM OBJEDNANÉ PNEUMATIKY PŘES VÁŠ SHOP', '', '700,-'),
    new Array('PŘIVEZU SI SEBOU - PNEUMATIKY I S DISKY', '', '350,-'),
    new Array('PŘIVEZU SI SEBOU - PNEUMATIKY VLASTNÍ', '', '700,-'),
    new Array('PŘIVEZU SI SEBOU NOVÉ PNEUMATIKY KOUPENÉ JINDE', '', '1000,-')
  ),
  new Array(
    new Array('GEOMETRIE PŘEDNÍ NÁPRAVA', '', '600,-'),
    new Array('GEOMETRIE PŘEDNÍ A ZADNÍ NÁPRAVA', '', '800,-')
  )
);

function changeTime(day,selected,url) {
  var request = "";

  if(selected != null)
    request = "getdate="+day;
  else
    request = "getdate="+day;

  jQuery.ajax({
   dataType: "text",
   type: "GET",
   url: url,
   data: request,
   success: function(html){
     jQuery("#arrival-msg").css('display','none');
     jQuery("#arrival-box").html(html);
     jQuery("#arrival-box").css('display','block');
  }

 });


}



jQuery(document).ready(function() {
  if(document.getElementById('#date') != null ) {
    var dily = jQuery('#date').attr('value').split(".");
    changeTime(dily[2]+'-'+dily[1]+'-'+dily[0],null,'http://www.pneu-janda.cz/ajax-reserv.php');
  }
  if(document.getElementById('date-geom') != null ) {
    var dily = jQuery('#date-geom').attr('value').split(".");
    changeTime(dily[2]+'-'+dily[1]+'-'+dily[0],null,'http://www.pneu-janda.cz/ajax-reserv-geom.php');
  }


  jQuery.datepicker.setDefaults(jQuery.datepicker.regional['cs']);
  jQuery('#date').datepicker({
    onSelect: function() {
      var date = jQuery(this).datepicker('getDate');
      var day = date.toGMTString();
      changeTime(day,null,'http://www.pneu-janda.cz/ajax-reserv.php');
    }
  });

  jQuery('#date-geom').datepicker({
    onSelect: function() {
      var date = jQuery(this).datepicker('getDate');
      var day = date.toGMTString();
      changeTime(day,null,'http://www.pneu-janda.cz/ajax-reserv-geom.php');
    }
  });
});