$(function() { $('.external').click(function() { return !ExternalLink(this.href); }); /*-------------- foot -------------*/ $(' #heslo ').val(''); $(' #prihlaseni_s_heslem ').submit(function() { if ( $(' #heslo ').val() == '' ) { alert(' Vyplňte prosím heslo.'); return false; } else return true; }); $(' #heslo ').change(function() { $(' #heslo_hidden ').val( $(this).val() ); }); $(' #prihlaseni_s_heslem ').submit(function() { $(' #heslo_hidden ').val( $(' #heslo ').val() ); }); }); function PrictiDen(dateString) { /* Pricte den dateString - yyyy/mm/dd */ var myDate = new Date(dateString); myDate.setTime(myDate.getTime() + 1 *24*60*60*1000) return myDate; } function DatumZobrazeni(myDate) { return ""+myDate.getDate()+"."+(myDate.getMonth() + 1)+"."+myDate.getFullYear(); } /*--------------- osobni diar ----------------*/ $(document).ready(function() { // alert('ano'); var js_lang = 'cs'; $.datepicker.setDefaults($.datepicker.regional[js_lang]); var datum_aktualni = new Date(); $( "#datepicker_rezervace" ).datepicker({ dateFormat: 'dd.mm.yy', minDate: datum_aktualni, onSelect: function(dateText, inst) { $("#casy_rezervace").html(''); $( "#datepicker_rezervace" ).trigger('change'); } }); $('#typ_prohlidky_rezervace').change(function(e) { $("#casy_rezervace").html(''); }); $('#submit_rezervace').hide(); $('#datepicker_rezervace, #typ_prohlidky_rezervace').change(function(e) { e.preventDefault(); if ( !$( "#datepicker_rezervace" ).val() || !$("#typ_prohlidky_rezervace").val() ) { return false; } var data = { datum : $( "#datepicker_rezervace" ).val(), typ : $("#typ_prohlidky_rezervace").val() } $.ajax({ url: '/diar_vybrat_cas.html?session=', data: data, success: function(data) { $("#casy_rezervace").html( $('#body_ajax', data) ); var pocetRadku = 0; $("#casy_rezervace table tr").each(function() { if ($('.volny' ,$(this)).length == 0) { $(this).hide(); } else { pocetRadku++; } }); if (!pocetRadku) { $("#casy_rezervace").html('Bohužel tento den nejsou k dispozici žádné termíny'); } } }); }); $( "#vybrat_cas td a" ).live('click', function(e) { e.preventDefault(); var data = { datum : $( "#datepicker_rezervace" ).val(), typ : $("#typ_prohlidky_rezervace").val(), cas : $(this).html() } $.ajax({ url: '/diar_uloz_cas.html?session=', type: 'POST', data: data, success: function(data) { var param = ''; if (data == 'error') { param = 'diar_error=1' } else { param = 'diar_add=1' } if (data != 'error') { window.location = '/diar.html?' + param; } else { alert('Na daný typ prohlídky bohužel není dostatečný časový prostor'); } } }); }); $( "#datepicker1" ).datepicker({ dateFormat: 'dd.mm.yy', minDate: datum_aktualni, altFormat: 'yy/mm/dd', altField: '#datepicker1_hidden', onSelect: function(dateText, inst) { if ( $("#datepicker1_hidden").val() >= $("#datepicker2_hidden").val() ) { var myDate = PrictiDen( $("#datepicker1_hidden").val() ); var noveDatum = DatumZobrazeni(myDate); $( "#datepicker2" ).datepicker( "option", "minDate", noveDatum ); $( "#datepicker2" ).datepicker( "setDate" , noveDatum ); } else { var myDate = PrictiDen( $("#datepicker1_hidden").val() ); var noveDatum = DatumZobrazeni(myDate); $( "#datepicker2" ).datepicker( "option", "minDate", noveDatum ); } } }); $(' .pridat_hodiny ').click(function() { var hodnota = $( this ).parent().parent().children().children(' .cas ').val() * 1 + 1; if (hodnota > 24) hodnota = 1; $( this ).parent().parent().children().children(' .cas ').val(hodnota); }); $(' .ubrat_hodiny ').click(function() { var hodnota = $( this ).parent().parent().children().children(' .cas ').val() * 1 - 1; if (hodnota < 1) hodnota = 24; $( this ).parent().parent().children().children(' .cas ').val(hodnota); }); var hodiny_interval = 15; $(' .pridat_minuty ').click(function() { var hodnota = $( this ).parent().parent().children().children(' .cas ').val() * 1 + hodiny_interval; if (hodnota > 59) hodnota = 0; $( this ).parent().parent().children().children(' .cas ').val(hodnota); }); $(' .ubrat_minuty ').click(function() { var hodnota = $( this ).parent().parent().children().children(' .cas ').val() * 1 - hodiny_interval; if (hodnota < 0) hodnota = 60 - hodiny_interval; $( this ).parent().parent().children().children(' input.cas ').val(hodnota); }); $(' #formulare .upozorneni_sms_img, #formulare .upozorneni_email_img ').click(function() { var src = $( this ).attr("src"); var zapnuto = src.substring((src.length - 6) , (src.length - 4) ); if (zapnuto == 'no') { $( this ).attr("src", "/images/diar/check_ok.gif"); if ( $( this ).attr("class").indexOf('sms') > 0 ) $(' .upozorneni_sms_hidden ').val("ano"); if ( $( this ).attr("class").indexOf('email') > 0 ) $(' .upozorneni_email_hidden ').val("ano"); } else { $( this ).attr("src", "/images/diar/check_no.gif"); if ( $( this ).attr("class").indexOf('sms') > 0 ) $(' .upozorneni_sms_hidden ').val("ne"); if ( $( this ).attr("class").indexOf('email') > 0 ) $(' .upozorneni_email_hidden ').val("ne"); } }); $(' #pridat_dalsi_prohlidku ').click(function() { if ( $(' .dalsi_prohlidka ').css("display") == "block" ) $(' .dalsi_prohlidka ').hide('slow'); else $(' .dalsi_prohlidka ').show('slow'); }); $(' #nova_prohlidka ').click(function() { if ( $(' .dalsi_planovana_prohlidka ').css("display") == "block" ) $(' .dalsi_planovana_prohlidka ').hide('slow'); else $(' .dalsi_planovana_prohlidka ').show('slow'); }); /*----------------------- nastaveni --------------------------*/ var dny_interval = 1; var max_predposlat = 30; $(' .pridat_dny ').click(function() { var hodnota = $( this ).parent().parent().children().children(' .cas ').val() * 1 + dny_interval; if (hodnota > max_predposlat) hodnota = 0; $( this ).parent().parent().children().children(' .cas ').val(hodnota); var text = ''; if (hodnota == 1) text = ' den '; else if (hodnota > 1 && hodnota < 5) text = ' dny '; else if (hodnota > 4) text = ' dní '; else text = ' dnů '; text = ' '+text+' '; $( this ).parent().parent().children().children(' span.menici_se_text ').html(text); }); $(' .ubrat_dny ').click(function() { var hodnota = $( this ).parent().parent().children().children(' .cas ').val() * 1 - dny_interval; if (hodnota < 0) hodnota = max_predposlat - dny_interval; $( this ).parent().parent().children().children(' input.cas ').val(hodnota); var text = ''; if (hodnota == 1) text = ' den '; else if (hodnota > 1 && hodnota < 5) text = ' dny '; else if (hodnota > 4) text = ' dní '; else text = ' dnů '; text = ' '+text+' '; $( this ).parent().parent().children().children(' span.menici_se_text ').html(text); }); $(' #nastaveni .upozorneni_sms_img, #nastaveni .upozorneni_email_img ').click(function() { var src = $( this ).attr("src"); var zapnuto = src.substring((src.length - 6) , (src.length - 4) ); if (zapnuto == 'no') { $( this ).attr("src", "/images/diar/check_ok.gif"); if ( $( this ).attr("class").indexOf('sms') > 0 ) $(' .upozorneni_sms_hidden ').val("ano"); if ( $( this ).attr("class").indexOf('email') > 0 ) $( this ).parent().parent().children(' .upozorneni_email_hidden ').val("ano"); $( this ).parent().parent().parent().children(' .dny_obal ').show('slow'); /* $( this ).parent().parent().parent().children(' .ulozit ').show('slow');*/ } else { $( this ).attr("src", "/images/diar/check_no.gif"); if ( $( this ).attr("class").indexOf('sms') > 0 ) $(' .upozorneni_sms_hidden ').val("ne"); if ( $( this ).attr("class").indexOf('email') > 0 ) $( this ).parent().parent().children(' .upozorneni_email_hidden ').val("ne"); $( this ).parent().parent().parent().children(' .dny_obal ').hide('slow'); /* $( this ).parent().parent().parent().children(' .ulozit ').hide('slow'); */ } }); });