">
//">
Русский
Habarlaşmak
[month-1]; } } function maxLengthCheck(object) { if (object.value.length > object.maxLength) object.value = object.value.slice(0, object.maxLength) } function passengers_check(){ var uly_n = parseInt($('.uly_n input').val()); var chaga_n = parseInt($('.chaga_n input').val()); var babek_n = parseInt($('.babek_n input').val()); var jemi = uly_n + chaga_n + babek_n; dropbtn.attr('data-live',jemi); if((jemi >= 1 && uly_n === 0) || (chaga_n === 0 || jemi === 1)){ $('.chaga_n > .minus').addClass('disabled'); $('.uly_n > .minus').addClass('disabled'); } if(uly_n > 1){ if(jemi >= 2){ $('.uly_n > .minus').removeClass('disabled'); } if(babek_n < uly_n){ $('.babek_n > .plus').removeClass('disabled'); $('.uly_n > .minus').removeClass('disabled'); } } if(chaga_n >= 1){ if(jemi > 1) { $('.chaga_n > .minus').removeClass('disabled');} if(uly_n >= 1 && uly_n > babek_n){ $('.uly_n > .minus').removeClass('disabled'); } } if(babek_n === uly_n){ $('.babek_n > .plus').addClass('disabled'); $('.uly_n > .minus').addClass('disabled'); } if(babek_n === 0){ $('.babek_n > .minus').addClass('disabled'); $('.babek_n > .plus').removeClass('disabled'); } if(babek_n >= 1){ $('.babek_n > .minus').removeClass('disabled'); } } function passengers_clear(){ var uly = dropbtn.attr('data-uly-n'); var chaga = dropbtn.attr('data-chaga-n'); var babek = dropbtn.attr('data-babek-n'); $('.uly_n input').val(uly); $('.chaga_n input').val(chaga); $('.babek_n input').val(babek); } function passengers_null(){ dropbtn.attr('data-uly-n','1'); dropbtn.attr('data-chaga-n','0'); dropbtn.attr('data-babek-n','0'); dropbtn.attr('data-live','0'); dropbtn.attr('data-total','1'); dropbtn.html('1 '); } function passengers_set(){ var uly = parseInt($('.uly_n > input').val()); var chaga = parseInt($('.chaga_n > input').val()); var babek = parseInt($('.babek_n > input').val()); dropbtn.attr('data-uly-n', uly); dropbtn.attr('data-chaga-n', chaga); dropbtn.attr('data-babek-n', babek); dropbtn.attr('data-live', uly+chaga+babek); dropbtn.attr('data-total',uly+chaga); dropbtn.text(uly+chaga+babek+' '); } function num_pass() { var ajax_p = $('.ajax_p'); dropbtn.text(ajax_p.attr('data-total')+' '); dropbtn.attr('data-uly-n',ajax_p.attr('data-uly')); dropbtn.attr('data-chaga-n',ajax_p.attr('data-chaga')); dropbtn.attr('data-babek-n',ajax_p.attr('data-babek')); dropbtn.attr('data-total',ajax_p.attr('data-total')); $('.uly_n input').val(ajax_p.attr('data-uly')); $('.chaga_n input').val(ajax_p.attr('data-chaga')); $('.babek_n input').val(ajax_p.attr('data-babek')); one_way.val($("#one_way option[data-value='"+ajax_p.attr('data-src')+"']").attr('value')); two_way.val($("#two_way option[data-value='"+ajax_p.attr('data-dest')+"']").attr('value')); $("#two_way option[value='"+one_way.val()+"']").attr('disabled',true); $("#one_way option[value='"+two_way.val()+"']").attr('disabled',true); chosen.trigger('chosen:updated'); search_date.val(getHumanDate(ajax_p.attr('data-tdate'))); search_date.attr('data-value',(ajax_p.attr('data-tdate'))); if(ajax_p.attr('data-odate')!== '0'){ date1.removeClass('hide'); date2.removeClass('hide'); search_date2.attr('data-value',(ajax_p.attr('data-odate'))); search_date2.val(getHumanDate(ajax_p.attr('data-odate'))); } } function ajax_success(result){ $('.slide').empty().append(result); slide.show(); num_pass(); } function d_ajax (data, loading){ var check_datas = true; $.ajax({ url: '/function/ajax.php', type: 'POST', dataType: 'html', data: data, beforeSend:function(){ if(loading){ load.show(); } }, success: function (result) { if(data['url'] !== 'home'){ ajax_success(result); } if(data['url'] === 'inbound'){ $('.note_img').tipTop(); } if( (data['url'] === 'outbound' && $('.ajax_p').attr('data-src') === '') || (data['url'] === 'inbound' && $('.ajax_p').attr('data-odate') === '0') || ($('.ajax_p').attr('data-odate') !== '0' && $('.ajax_p').attr('data-outbound_id') === 'null' && data['url'] === 'inbound') || ($('.ajax_p').attr('data-odate') === '0' && $('.ajax_p').attr('data-outbound_id') === 'null' && data['url'] === 'check') || ($('.ajax_p').attr('data-odate') !== '0' && $('.ajax_p').attr('data-inbound_id') === 'null' && data['url'] === 'check')){ check_datas = false; window.location.href = "/"; } },complete:function () { if(check_datas){ load.delay(1000).fadeOut(); } } }); } function next_date ($this){ var dateStr = $this.parent().parent().find('input'); var result = new Date(new Date(dateStr.attr('data-value')).setDate(new Date(dateStr.attr('data-value')).getDate() + 1)); // disabled 15 day after if(get_date(result) === get_date(next_15)){ dateStr.attr('data-disabled-next','true'); $this.addClass('disabled'); }else { dateStr.attr('data-disabled-next', 'false'); $this.removeClass('disabled'); } $this.parent().find('.last_date').removeClass('disabled'); dateStr.attr('data-disabled-last','false'); dateStr.val(getHumanDate(result.toISOString().slice(0,10))); dateStr.attr('data-value',result.toISOString().slice(0,10)); if(dateStr.attr('id') === 'search_date') { datepicker.data('datepicker').selectDate(new Date(result.toISOString().slice(0,10))); }else{ datepicker2.data('datepicker').selectDate(new Date(result.toISOString().slice(0,10))); } } function last_date ($this){ var dateStr = $this.parent().parent().find('input'); var result = new Date(new Date(dateStr.attr('data-value')).setDate(new Date(dateStr.attr('data-value')).getDate() - 1)); // disabled 15 day after if(get_date(result) === get_date(today)){ dateStr.attr('data-disabled-last','true'); $this.addClass('disabled'); }else{ dateStr.attr('data-disabled-last','false'); $this.removeClass('disabled'); } $this.parent().find('.next_date').removeClass('disabled'); dateStr.attr('data-disabled-next','false'); dateStr.val(getHumanDate(result.toISOString().slice(0,10))); dateStr.attr('data-value',result.toISOString().slice(0,10)); if(dateStr.attr('id') === 'search_date'){ datepicker.data('datepicker').selectDate(new Date(result.toISOString().slice(0,10))); }else{ datepicker2.data('datepicker').selectDate(new Date(result.toISOString().slice(0,10))); } } function owl() { var owl = $(".owl-wagons"); owl.owlCarousel({ items: 1, navigation: true, mouseDrag:false, touchDrag:false, dots: true, nav:true, navText: ['
', '
'] }); } function wagons_each() { $('.owl-item.active > .wagon_seats').each(function(item) { if(!$(this).attr('data-checked')){ var wagon_arr = $(this).data('value-false').split(','); var wagon_num = $(this).data('value'); console.log((item+1)+'.'+wagon_num+' - '+wagon_arr); var wagon_level = $(this).data('value-level').split(','); var wagon_number = $(this).data('value-number').split(','); var seats_id = $(this).data('id').split(','); var i; for (i = 0; i < wagon_level.length-1; i++) { $(this).find('svg').find('.coupe').find('#'+ wagon_number[i]).attr('title',': '+wagon_level[i]); $(this).find('svg').find('.coupe').find('#t'+ wagon_number[i]).attr('title',': '+wagon_level[i]); $(this).find('svg').find('.coupe').find('#'+ wagon_number[i]).attr('data-id',seats_id[i]); $(this).find('svg').find('.coupe').find('#t'+ wagon_number[i]).attr('data-id',seats_id[i]); } for (i = 0; i < wagon_arr.length-1; i++) { $(this).find('svg').find('.coupe').find('#'+ wagon_arr[i]).attr('disabled',true).attr('title',''); $(this).find('svg').find('.coupe').find('#t'+ wagon_arr[i]).attr('disabled',true).attr('title',''); } $(this).attr('data-checked','true'); } }); var wagon_count = $(".seat_p").children().size(); $('.pay_btn').attr('data-wagon-count',wagon_count); } function addhrs(time, toadd) { var hh = parseInt(time.substr(0, 2), 10); //Get the hours var mm = parseInt(time.substr(3, 2), 10); //Get the minutes var ahh = parseInt(toadd.substr(0, 2), 10); //Get the hours to add var amm = parseInt(toadd.substr(3, 2), 10); //Get the minutes to add var minutes = hh*60 + mm; var minutes_to_add = ahh*60 + amm; var result_minutes = (minutes + minutes_to_add) % 1440; //Prevent total number of minutes to exceed the minutes in a day. var result_hours = Math.floor(result_minutes / 60); result_minutes -= result_hours * 60; return ('0'+result_hours).substr(-2) + ":" + ('0'+result_minutes).substr(-2); } function tconvert(num,sagat) { var hours = Math.floor(num / 60); var minutes = num % 60; if (hours < 10) {hours = "0"+hours;} if (minutes < 10) {minutes = "0"+minutes;} if(sagat){ if(hours > 0){ return hours + " " + minutes+' '; }else{ return minutes+' '; } }else{ return hours + ":" + minutes; } } function checkin_time (child,src, time,title, mobile){ setTimeout(function(){ if(mobile){ $('.checkin_ul li:first-child > img').attr('src','/img/checkin/'+src); $('.checkin_ul li:first-child > p').text($('.checkin_ul li:nth-child('+child+') > p').text()); }else{ $('.checkin_ul li:nth-child('+child+') > img').attr('src','/img/checkin/'+src); $('.checkin_ul li:nth-child('+child+')').show(); } if(title){ $('.checkin h4').html($('.checkin_ul li:nth-child('+child+') > p').attr('data-title')); } }, time); } function _calculateAge(birthday) { // birthday is a date var ageDifMs = Date.now() - birthday.getTime(); var ageDate = new Date(ageDifMs); // miliseconds from epoch return Math.abs(ageDate.getUTCFullYear() - 1970); } if (hash === 'outbound'){ data_ajax = {}; data_ajax['url'] = 'outbound'; data_ajax['lang'] = ' '; d_ajax(data_ajax); } if (hash ==='inbound'){ load.show(); data_ajax = {}; data_ajax['lang'] = ' '; data_ajax['url'] = 'inbound'; d_ajax(data_ajax); } if (hash === 'check'){ load.show(); data_ajax = {}; data_ajax['lang'] = ' '; data_ajax['url'] = 'check'; d_ajax(data_ajax); } if (hash === 'seats'){ var check_datas = true; load.show(); window.scrollTo(0,0); $.ajax({ url: '/function/ajax.php', type: 'POST', dataType: 'html', data: { url:'seats', lang: ' ' }, success: function (result) { ajax_success(result); if($('.ajax_p').attr('data-passengers') === 'false'){ check_datas = false; window.location.href = "/"; } var max = $('.ajax_p').attr('data-place'); if(check_datas){ owl(); wagons_each(); $('.coupe-text').tipTop(); $('.element-block').tipTop(); } }, complete:function () { if(check_datas){ load.delay(1000).fadeOut(); } } }); } if(hash === 'outbound' || hash === 'inbound' || hash === 'check' || hash === 'seats'){ third.hide(); nextd.off('click').on('click',function () { next_date($(this)); if(type_btn.attr('data-value') === '1'){ var inbound_date = 0; } else{ inbound_date = search_date2.attr('data-value'); } if($(this).parent().parent().hasClass('date1')){ var outbound_date = search_date.attr('data-value'); if(hash === 'check' || hash === 'inbound' || hash ==='seats' ){ hash = 'outbound'; } } else{ outbound_date = search_date.attr('data-value'); if(hash === 'check' || hash ==='seats'){ hash = 'inbound';} } window.location.hash = hash; data_ajax = {}; data_ajax['url'] = hash; data_ajax['outbound_date'] = outbound_date; data_ajax['inbound_date'] = inbound_date; d_ajax(data_ajax); }); lastd.off('click').on('click',function () { last_date($(this)); if(type_btn.attr('data-value') === '1'){ var inbound_date = 0; } else{ inbound_date = search_date2.attr('data-value'); } if($(this).parent().parent().hasClass('date1')){ var outbound_date = search_date.attr('data-value'); if(hash === 'check' || hash ==='inbound' || hash ==='seats' ){ hash = 'outbound'; } }else{ if(hash === 'check' || hash ==='seats'){ hash = 'inbound'; } outbound_date = search_date.attr('data-value'); } window.location.hash = hash; data_ajax = {}; data_ajax['url'] = hash; data_ajax['outbound_date'] = outbound_date; data_ajax['inbound_date'] = inbound_date; d_ajax(data_ajax); }); passengers_clear(); passengers_check(); drop_set.off('click').on('click',function () { drop_content.hide().addClass('disabled'); var uly_n = parseInt($('.uly_n input').val()); var chaga_n = parseInt($('.chaga_n input').val()); var babek_n = parseInt($('.babek_n input').val()); window.location.hash = 'outbound'; data_ajax = {}; data_ajax['url'] = 'outbound'; data_ajax['uly'] = uly_n; data_ajax['chaga'] = chaga_n; data_ajax['babek'] = babek_n; d_ajax(data_ajax, 'loading'); }); // stations change st_change.off('click').on('click',function () { $(this).toggleClass('rotate'); $("#two_way option").removeAttr('disabled'); $("#one_way option").removeAttr('disabled'); var third = one_way.val(); one_way.val(two_way.val()); two_way.val(third); chosen.trigger('chosen:updated'); window.location.hash = 'outbound'; var first = $("#two_way option[value='"+two_way.val()+"']").attr('data-value'); var second = $("#one_way option[value='"+one_way.val()+"']").attr('data-value'); data_ajax = {}; data_ajax['url'] = 'outbound'; data_ajax['src_id'] = second; data_ajax['dest_id'] = first; d_ajax(data_ajax, 'loading'); }); // tuda or obratno $('.type_down > div').off('click').on('click',function () { var last = type_btn.attr('data-value'); var val = $(this).attr('data-value'); if(last !== val){ var text = $(this).html(); type_btn.attr('data-value',val).text(text); var url; if(val === '1'){ date1.addClass('hide'); date2.addClass('hide'); var inbound_date ='0'; url ='outbound'; } else { date1.removeClass('hide'); date2.removeClass('hide'); inbound_date = search_date2.attr('data-value'); if(hash !== 'outbound'){ url ='inbound'; } else{ url ='outbound'; } } window.location.hash = url; data_ajax = {}; data_ajax['url'] = url; data_ajax['inbound_date'] = inbound_date; d_ajax(data_ajax, 'loading'); } }); // stations one_way.off('change').on('change',function (e) { $("#two_way option").removeAttr('disabled'); window.location.hash = 'outbound'; var val = $("#one_way option[value='"+$(this).val()+"']").attr('data-value'); $("#two_way option[value='"+val+"']").attr('disabled',true); data_ajax = {}; data_ajax['url'] = 'outbound'; data_ajax['src_id'] = val; d_ajax(data_ajax, 'loading'); }); two_way.off('change').on('change',function (e) { $("#one_way option").removeAttr('disabled'); window.location.hash = 'outbound'; var val = $("#two_way option[value='"+$(this).val()+"']").attr('data-value'); $("#one_way option[value='"+val+"']").attr('disabled',true); data_ajax = {}; data_ajax['url'] = 'outbound'; data_ajax['dest_id'] = val; d_ajax(data_ajax, 'loading'); }); // next date on load if(get_date(search_date.attr('data-value')) === get_date(next_15)){ search_date.attr('data-disabled-next','true'); search_date.parent().find('.next_date').addClass('disabled'); search_date.parent().find('.last_date').removeClass('disabled'); }else { search_date.attr('data-disabled-next','false'); search_date.parent().find('.next_date').removeClass('disabled'); } // last date on load if(get_date(search_date.attr('data-value')) === get_date(today)){ search_date.attr('data-disabled-last','true'); search_date.parent().find('.last_date').addClass('disabled'); search_date.parent().find('.next_date').removeClass('disabled'); }else { search_date.attr('data-disabled-last','false'); search_date.parent().find('.last_date').removeClass('disabled'); } } }); $("#two_way option[value='"+one_way.val()+"']").attr('disabled',true); $("#one_way option[value='"+two_way.val()+"']").attr('disabled',true); var last_click = 0; $('.sch_img').on('click',function () { var div = $(this).parent().parent().next('.tr_cl'); var paths = div.attr('data-paths').split(','), travel_time = div.attr('data-travel_time'), distance = div.attr('data-distance').split(','), duration = div.attr('data-duration').split(','), layover = div.attr('data-layover').split(','), time = $(this).attr('data-time'), count = div.attr('data-count'), f_duration = tconvert(duration[0]), data_day = $(this).attr('data-day'), origin = div.attr('data-origin'), destination = div.attr('data-destination'); div.find('.table_day > p:first-child').html(days_ [data_day-1]); div.find('.table_time > p:first-child > span').html(time); div.find('tbody').find('tr:first-child').find('td:nth-child(4)').html(time); div.find('tbody').find('tr:nth-child(2)').find('td:nth-child(2)').html(addhrs(time,tconvert(duration[0]))); for (var x = 0; x <= count; x++) { var plus = x+1; var minus = x-1; // stansiya div.find('tbody').find('tr:nth-child('+plus+')').find('td:first-child').html(paths[x]); // uzynlygy div.find('tbody').find('tr:nth-child('+x+')').find('td:nth-child(5)').html(distance[minus]+' '); // dowamlylygy if(x < count){ div.find('tbody').find('tr:nth-child('+plus+')').find('td:nth-child(6)').html(tconvert(duration[x],'')); } if(x >= 2){ // duryan wagty div.find('tbody').find('tr:nth-child('+x+')').find('td:nth-child(3)').html(layover[minus-1]+' '); // baryan wagty var d_time = div.find('tbody').find('tr:nth-child('+x+')').find('td:nth-child(2)').html(), d_add_time = parseInt(layover[minus-1]) + parseInt(duration[minus]); div.find('tbody').find('tr:nth-child('+plus+')').find('td:nth-child(2)').html(addhrs(d_time,tconvert(d_add_time))); // ugrayan wagty var s_time = addhrs(d_time,tconvert(layover[minus-1])); div.find('tbody').find('tr:nth-child('+x+')').find('td:nth-child(4)').html(s_time); } } // baryan wagty span var baryan_wagty = div.find('tr:last-child').find('td:nth-child(2)').text(); div.find('.table_time > p:last-child > span').html(baryan_wagty); if(!div.hasClass('active') || last_click !== data_day){ div.slideDown().addClass('active'); last_click = data_day; $(this).parent().parent().find('.sch_img').removeClass('active'); $(this).addClass('active'); $(this).parent().parent().find('.downimg').addClass('rotate'); }else{ div.slideUp().removeClass('active'); last_click = 0; $(this).removeClass('active'); $(this).parent().parent().find('.downimg').removeClass('rotate'); } }); $('.logo').parent().attr('href'," //"); ", onSelect: function () { if(search_date.val() === get_date(today)) { search_date.attr('data-disabled-last','true'); search_date.attr('data-disabled-next','false'); search_date.parent().find('.last_date').addClass('disabled'); search_date.parent().find('.next_date').removeClass('disabled'); }else if(search_date.val() === get_date(next_15)){ search_date.attr('data-disabled-last','false'); search_date.attr('data-disabled-next','true'); search_date.parent().find('.next_date').addClass('disabled'); search_date.parent().find('.last_date').removeClass('disabled'); }else{ search_date.attr('data-disabled-last','false'); search_date.attr('data-disabled-next','false'); search_date.parent().find('.last_date').removeClass('disabled'); search_date.parent().find('.next_date').removeClass('disabled'); } search_date.attr('data-value',search_date.val()); search_date.val(getHumanDate(search_date.val())); var hash = window.location.hash.slice(1); if(hash === 'inbound' || hash === 'outbound' || hash === 'check' || hash === 'seats'){ var outbound_date = search_date.attr('data-value'); if(hash = 'check'){ window.location.hash = 'outbound'; hash = 'outbound'; } data_ajax = {}; data_ajax['url'] = hash; data_ajax['outbound_date'] = outbound_date; d_ajax(data_ajax, 'loading'); } } }); var datepicker2 = search_date2.datepicker({ dateFormat: 'yyyy-mm-dd', autoClose: true, toggleSelected: false, minDate: new Date(), maxDate: next_15, language: " ", onSelect: function () { if(search_date2.val() === get_date(today)) { search_date2.attr('data-disabled-last','true'); search_date2.attr('data-disabled-next','false'); search_date2.parent().find('.last_date').addClass('disabled'); search_date2.parent().find('.next_date').removeClass('disabled'); }else if(search_date2.val() === get_date(next_15)){ search_date2.attr('data-disabled-last','false'); search_date2.attr('data-disabled-next','true'); search_date2.parent().find('.next_date').addClass('disabled'); search_date2.parent().find('.last_date').removeClass('disabled'); }else{ search_date2.attr('data-disabled-last','false'); search_date2.attr('data-disabled-next','false'); search_date2.parent().find('.last_date').removeClass('disabled'); search_date2.parent().find('.next_date').removeClass('disabled'); } search_date2.attr('data-value',search_date2.val()); search_date2.val(getHumanDate(search_date2.val())); var hash = window.location.hash.slice(1); if(hash === 'inbound' || hash === 'outbound' || hash === 'check' || hash === 'seats'){ var inbound_date = search_date2.attr('data-value'); if(hash === 'check'){ window.location.hash = 'inbound'; hash = 'inbound'; }else{ window.location.hash = hash; } data_ajax = {}; data_ajax['url'] = hash; data_ajax['inbound_date'] = inbound_date; d_ajax(data_ajax, 'loading'); } } }); // datepicker.data('datepicker').selectDate(new Date(search_date.attr('data-value'))); // datepicker2.data('datepicker').selectDate(new Date(search_date2.attr('data-value'))); $(".p_slide").owlCarousel({ items: 1, navigation: true, dots: true, nav:false, loop:true }); chosen.chosen({ no_results_text: " ", width: "300px" }); $('.minus').click(function () { if(!$(this).hasClass('disabled')){ var input = $(this).parent().find('input'); var count = parseInt(input.val()) - 1; count = count < 0 ? 0 : count; input.attr('data-value',count); input.val(count).change(); passengers_check(); } }); $('.plus').click(function () { var total = dropbtn.attr('data-live'); if(!$(this).hasClass('disabled') && total < 9 ){ var input = $(this).parent().find('input'); input.val(parseInt(input.val()) + 1).change(); passengers_check(); } }); $('.retry').on('click',function () { data_ajax = {}; data_ajax['url'] = 'booking'; data_ajax['retry'] = '1'; d_ajax(data_ajax); }); $('.play').on('click',function () { $('.v_pop').fadeIn(); $('.v_pop video').attr('src','/img/animation.mp4').get(0).play(); }); $('.v_pop button').click(function () { $('.v_pop').fadeOut(); $('.v_pop video ').attr('src','').get(0).pause(); }); $('.logo').parent().attr('href'," //");