var ie = navigator.appVersion.match(/MSIE/) ? true : false; var ie6 = navigator.appVersion.match(/MSIE 6\.0/) ? true : false; $(document).ready(function(){ $('.hot-offers li:last').addClass('last'); $('.promo .block:last').addClass('last'); $mainheight = $(document).height() - $('.head').height() - $('.foot').height() - 145; $('.main').css({'min-height': $mainheight}); $('.success').hide(); if (ie6) {$('.main').css({height: $mainheight, overflow: 'visible'});} $('select[name$=_order]:not([name=transfer_order])').css({'width': '390px'});//главный селект для оферт // Подсказки для полей формы var autofills = { arrival_flight: 'Номер рейса', arrival_date: 'Дата', departure_flight: 'Номер рейса', departure_date: 'Дата', departure_time_date: 'Дата', returntime_date: 'Дата', checkin: 'Дата', checkout: 'Дата', adress_to: 'Адрес или название отеля', adress_from: 'Адрес или название отеля' }; // доступные поля формы var rows = ['arrival_row', 'adress_to_row', 'adress_from_row', 'returnway_row', 'departure_row', 'baby_seat_row', 'passengers_row', 'contacts_row', 'need_hotel_row', 'hotel_row', 'buttons_row', 'links_row', 'departure_time_row', 'returntime_row', 'checkin_row', 'pick_from_row']; //типы трансферов var types = { to_hotel: { name: 'Заказ трансфера', dont_render_rows: ['adress_from_row', 'departure_time_row', 'returntime_row', 'need_hotel_row', 'checkin_row', 'arrival_row'], form_head: 'transfer_order' }, from_hotel: { name: 'Заказ трансфера', dont_render_rows: ['adress_to_row', 'returnway_row', 'arrival_row', 'hotel_row', 'departure_time_row', 'returntime_row', 'need_hotel_row', 'checkin_row', 'pick_from_row'], form_head: 'transfer_order'}, trip: { name: 'Заказ трансфера', dont_render_rows: ['arrival_row', 'departure_row', 'need_hotel_row', 'checkin_row', 'adress_from_row', 'departure_time_row'], form_head: 'transfer_order' }, excursion: { name: 'Заказ экскурсии', dont_render_rows: ['arrival_row', 'departure_row', 'adress_to_row', 'returnway_row', 'returntime_row', 'need_hotel_row', 'checkin_row', 'pick_from_row'], form_head: 'transfer_order' }, hotel: { name: 'Заказ отеля', dont_render_rows: ['arrival_row', 'adress_to_row', 'adress_from_row', 'returnway_row', 'departure_row', 'baby_seat_row', 'passengers_row', 'need_hotel_row', 'hotel_row', 'departure_time_row', 'returntime_row', 'pick_from_row'], form_head: 'hotel_order' }, fellowtraveller: { name: 'Стать попутчиком', dont_render_rows: ['arrival_row', 'adress_to_row', 'adress_from_row', 'returnway_row', 'departure_row', 'baby_seat_row', 'need_hotel_row', 'hotel_row', 'departure_time_row', 'returntime_row', 'checkin_row', 'pick_from_row'], form_head: 'fellowtraveller_order' } }; //не будет отображается в форме типа var dont_render_rows = {}; for (type in types){ dont_render_rows[type] = types[type].dont_render_rows; } // правила и сообщения валидации формы var validation = { pick_from: {rules: {required: true, no_def_val: true}, messages: 'Где встретить'}, arrival_flight: {rules: {required: true, no_def_val: true}, messages: ''}, arrival_date: {rules: {required: true, no_def_val: true}, messages: ''}, adress_from: {rules: {required: true, no_def_val: true}, messages: ' — Обязательное поле'}, adress_to: {rules: {required: true, no_def_val: true}, messages: ' — Обязательное поле'}, departure_flight: {rules: {required: true, no_def_val: true}, messages: ''}, departure_date: {rules: {required: true, no_def_val: true}, messages: ''}, checkin: {rules: {required: true, no_def_val: true}, messages: ''}, checkout: {rules: {required: true, no_def_val: true}, messages: ''}, departure_time_date: {rules: {required: true, no_def_val: true}, messages: ''}, returntime_date: {rules: {required: true, no_def_val: true}, messages: ''}, passengers: {rules: {required: true, range: [1, 200]}, messages: {required: ' — Обязательное поле', range: ' — Минимум 1, максимум 20 человек'}}, name: {rules: {required: true}, messages: ' — Обязательное поле' }, surname: {rules: {required: true}, messages: ' — Обязательное поле' }, tel: {rules: {required: true}, messages: ' — Обязательное поле' }, email: {rules: {required: true, email: true}, messages: {required: ' — Обязательное поле', email: ' — Формат емайла имя@домен ' } } }; var routes = [{"head": "\u041f\u0440\u0430\u0433\u0430", "price": {"car": 20, "van": 30}, "tail": "\u043e\u0442\u0435\u043b\u044c", "time": null, "type": "to_hotel", "id": 1}, {"head": "\u041f\u0440\u0430\u0433\u0430", "price": {"car": 20, "van": 30}, "tail": "\u0430\u044d\u0440\u043e\u043f\u043e\u0440\u0442", "time": null, "type": "from_hotel", "id": 1}, {"head": "\u041f\u0440\u0430\u0433\u0430", "price": {"car": 20, "van": 30}, "tail": "\u0432\u043e\u043a\u0437\u0430\u043b", "time": null, "type": "from_hotel", "id": 2}, {"head": "\u041f\u0440\u0430\u0433\u0430", "price": {"car": 20, "van": 30}, "tail": "\u0430\u0432\u0442\u043e\u0432\u043e\u043a\u0437\u0430\u043b", "time": null, "type": "from_hotel", "id": 3}, {"head": "\u041f\u0440\u0430\u0433\u0430", "price": {"car": 250, "van": 290}, "tail": "\u0411\u0435\u0440\u043b\u0438\u043d", "time": 0, "type": "trip", "id": 43}, {"head": "\u041f\u0440\u0430\u0433\u0430", "price": {"car": 135, "van": 165}, "tail": "\u0411\u0440\u043d\u043e", "time": 0, "type": "trip", "id": 27}, {"head": "\u041f\u0440\u0430\u0433\u0430", "price": {"car": 290, "van": 330}, "tail": "\u0412\u0435\u043d\u0430", "time": 0, "type": "trip", "id": 75}, {"head": "\u041f\u0440\u0430\u0433\u0430", "price": {"car": 145, "van": 185}, "tail": "\u0414\u0440\u0435\u0437\u0434\u0435\u043d", "time": 0, "type": "trip", "id": 55}, {"head": "\u041f\u0440\u0430\u0433\u0430", "price": {"car": 80, "van": 100}, "tail": "\u041a\u0430\u0440\u043b\u043e\u0432\u044b \u0412\u0430\u0440\u044b", "time": 0, "type": "trip", "id": 57}, {"head": "\u041f\u0440\u0430\u0433\u0430", "price": {"car": 75, "van": 90}, "tail": "\u041a\u043e\u043d\u043e\u043f\u0438\u0448\u0442\u0435", "time": 0, "type": "trip", "id": 8}, {"head": "\u041f\u0440\u0430\u0433\u0430", "price": {"car": 90, "van": 115}, "tail": "\u041a\u0443\u0442\u043d\u0430 \u0413\u043e\u0440\u0430", "time": 0, "type": "trip", "id": 13}, {"head": "\u041f\u0440\u0430\u0433\u0430", "price": {"car": 80, "van": 100}, "tail": "\u041b\u0438\u0431\u0435\u0440\u0435\u0446", "time": 0, "type": "trip", "id": 30}, {"head": "\u041f\u0440\u0430\u0433\u0430", "price": {"car": 105, "van": 125}, "tail": "\u041b\u0438\u0431\u0435\u0440\u0435\u0446 (Aquapark)", "time": 0, "type": "trip", "id": 31}, {"head": "\u041f\u0440\u0430\u0433\u0430", "price": {"car": 135, "van": 180}, "tail": "\u041b\u0438\u043f\u043d\u043e", "time": 0, "type": "trip", "id": 32}, {"head": "\u041f\u0440\u0430\u0433\u0430", "price": {"car": 100, "van": 110}, "tail": "\u041c\u0430\u0440\u0438\u0430\u043d\u0441\u043a\u0438\u0435 \u041b\u0430\u0437\u043d\u0435", "time": 0, "type": "trip", "id": 2}, {"head": "\u041f\u0440\u0430\u0433\u0430", "price": {"car": 75, "van": 95}, "tail": "\u041c\u0430\u0445\u043e\u0432\u043e \u043e\u0437\u0435\u0440\u043e", "time": 0, "type": "trip", "id": 33}, {"head": "\u041f\u0440\u0430\u0433\u0430", "price": {"car": 270, "van": 320}, "tail": "\u041c\u044e\u043d\u0445\u0435\u043d", "time": 0, "type": "trip", "id": 45}, {"head": "\u041f\u0440\u0430\u0433\u0430", "price": {"car": 225, "van": 275}, "tail": "\u041d\u044e\u0440\u043d\u0431\u0435\u0440\u0433", "time": 0, "type": "trip", "id": 44}, {"head": "\u041f\u0440\u0430\u0433\u0430", "price": {"car": 20, "van": 25}, "tail": "\u043e\u0431\u0437\u043e\u0440\u043d\u0430\u044f \u044d\u043a\u0441\u043a\u0443\u0440\u0441\u0438\u044f", "time": 0, "type": "trip", "id": 62}, {"head": "\u041f\u0440\u0430\u0433\u0430", "price": {"car": 270, "van": 320}, "tail": "\u041e\u0441\u0442\u0440\u0430\u0432\u0430", "time": 0, "type": "trip", "id": 41}, {"head": "\u041f\u0440\u0430\u0433\u0430", "price": {"car": 80, "van": 100}, "tail": "\u041f\u0430\u0440\u0434\u0443\u0431\u0438\u0446\u0435", "time": 0, "type": "trip", "id": 3}, {"head": "\u041f\u0440\u0430\u0433\u0430", "price": {"car": 60, "van": 80}, "tail": "\u041f\u043b\u0437\u0435\u043d\u044c", "time": 0, "type": "trip", "id": 34}, {"head": "\u041f\u0440\u0430\u0433\u0430", "price": {"car": 60, "van": 80}, "tail": "\u041f\u043e\u0434\u0435\u0431\u0440\u0430\u0434\u044b", "time": 0, "type": "trip", "id": 37}, {"head": "\u041f\u0440\u0430\u0433\u0430", "price": {"car": 80, "van": 100}, "tail": "\u0422\u0435\u043f\u043b\u0438\u0446\u0435", "time": 0, "type": "trip", "id": 42}, {"head": "\u041f\u0440\u0430\u0433\u0430", "price": {"car": 80, "van": 110}, "tail": "\u0422\u0435\u0440\u0435\u0437\u0438\u043d", "time": 0, "type": "trip", "id": 74}, {"head": "\u041f\u0440\u0430\u0433\u0430", "price": {"car": 350, "van": 415}, "tail": "\u0424\u0440\u0430\u043d\u043a\u0444\u0443\u0440\u0442-\u043d\u0430-\u041c\u0430\u0439\u043d\u0435", "time": 0, "type": "trip", "id": 64}, {"head": "\u041f\u0440\u0430\u0433\u0430", "price": {"car": 370, "van": 450}, "tail": "\u0424\u044e\u0441\u0441\u0435\u043d, \u041b\u0438\u043d\u0434\u0435\u0440\u0445\u043e\u0444, \u041d\u043e\u0439\u0448\u0432\u0430\u043d\u0448\u0442\u0430\u0439\u043d", "time": 0, "type": "trip", "id": 76}, {"head": "\u041f\u0440\u0430\u0433\u0430", "price": {"car": 110, "van": 135}, "tail": "\u0427\u0435\u0448\u0441\u043a\u0438\u0435 \u0411\u0443\u0434\u0435\u0439\u043e\u0432\u0438\u0446\u0435", "time": 0, "type": "trip", "id": 39}, {"head": "\u041f\u0440\u0430\u0433\u0430", "price": {"car": 125, "van": 150}, "tail": "\u0427\u0435\u0448\u0441\u043a\u0438\u0439 \u041a\u0440\u0443\u043c\u043b\u043e\u0432", "time": 0, "type": "trip", "id": 14}, {"head": "\u041f\u0440\u0430\u0433\u0430", "price": {"car": 105, "van": 135}, "tail": "\u0428\u043f\u0438\u043d\u0434\u043b\u0435\u0440\u0443\u0432 \u041c\u043b\u044b\u043d, \u043b\u044b\u0436\u043d\u044b\u0439 \u0430\u0440\u0435\u0430\u043b", "time": 0, "type": "trip", "id": 29}, {"head": "\u041a\u0430\u0440\u043b\u043e\u0432\u044b \u0412\u0430\u0440\u044b", "price": {"car": 18, "van": 25}, "tail": "\u043e\u0442\u0435\u043b\u044c", "time": null, "type": "to_hotel", "id": 2}, {"head": "\u041a\u0430\u0440\u043b\u043e\u0432\u044b \u0412\u0430\u0440\u044b", "price": {"car": 18, "van": 25}, "tail": "\u0430\u044d\u0440\u043e\u043f\u043e\u0440\u0442", "time": null, "type": "from_hotel", "id": 4}, {"head": "\u041a\u0430\u0440\u043b\u043e\u0432\u044b \u0412\u0430\u0440\u044b", "price": {"car": 18, "van": 25}, "tail": "\u0432\u043e\u043a\u0437\u0430\u043b", "time": null, "type": "from_hotel", "id": 5}, {"head": "\u041a\u0430\u0440\u043b\u043e\u0432\u044b \u0412\u0430\u0440\u044b", "price": {"car": 18, "van": 25}, "tail": "\u0430\u0432\u0442\u043e\u0432\u043e\u043a\u0437\u0430\u043b", "time": null, "type": "from_hotel", "id": 6}, {"head": "\u041a\u0430\u0440\u043b\u043e\u0432\u044b \u0412\u0430\u0440\u044b", "price": {"car": 400, "van": 470}, "tail": "\u0411\u0430\u0434\u0435\u043d-\u0411\u0430\u0434\u0435\u043d", "time": 0, "type": "trip", "id": 53}, {"head": "\u041a\u0430\u0440\u043b\u043e\u0432\u044b \u0412\u0430\u0440\u044b", "price": {"car": 330, "van": 390}, "tail": "\u0411\u0435\u0440\u043b\u0438\u043d", "time": 0, "type": "trip", "id": 51}, {"head": "\u041a\u0430\u0440\u043b\u043e\u0432\u044b \u0412\u0430\u0440\u044b", "price": {"car": 390, "van": 450}, "tail": "\u0412\u0435\u043d\u0430", "time": 0, "type": "trip", "id": 52}, {"head": "\u041a\u0430\u0440\u043b\u043e\u0432\u044b \u0412\u0430\u0440\u044b", "price": {"car": 150, "van": 175}, "tail": "\u0414\u0440\u0435\u0437\u0434\u0435\u043d", "time": 0, "type": "trip", "id": 49}, {"head": "\u041a\u0430\u0440\u043b\u043e\u0432\u044b \u0412\u0430\u0440\u044b", "price": {"car": 40, "van": 50}, "tail": "\u041c\u0430\u0440\u0438\u0430\u043d\u0441\u043a\u0438\u0435 \u041b\u0430\u0437\u043d\u0435", "time": 0, "type": "trip", "id": 46}, {"head": "\u041a\u0430\u0440\u043b\u043e\u0432\u044b \u0412\u0430\u0440\u044b", "price": {"car": 295, "van": 350}, "tail": "\u041c\u044e\u043d\u0445\u0435\u043d", "time": 0, "type": "trip", "id": 47}, {"head": "\u041a\u0430\u0440\u043b\u043e\u0432\u044b \u0412\u0430\u0440\u044b", "price": {"car": 220, "van": 260}, "tail": "\u041d\u044e\u0440\u043d\u0431\u0435\u0440\u0433", "time": 0, "type": "trip", "id": 48}, {"head": "\u041a\u0430\u0440\u043b\u043e\u0432\u044b \u0412\u0430\u0440\u044b", "price": {"car": 80, "van": 100}, "tail": "\u041f\u0440\u0430\u0433\u0430", "time": 0, "type": "trip", "id": 54}, {"head": "\u041a\u0430\u0440\u043b\u043e\u0432\u044b \u0412\u0430\u0440\u044b", "price": {"car": 90, "van": 110}, "tail": "\u041f\u0440\u0430\u0433\u0430 \u0432\u043e\u043a\u0437\u0430\u043b/\u0433\u043e\u0440\u043e\u0434", "time": 0, "type": "trip", "id": 68}, {"head": "\u041a\u0430\u0440\u043b\u043e\u0432\u044b \u0412\u0430\u0440\u044b", "price": {"car": 350, "van": 415}, "tail": "\u0424\u0440\u0430\u043d\u043a\u0444\u0443\u0440\u0442-\u043d\u0430-\u041c\u0430\u0439\u043d\u0435", "time": 0, "type": "trip", "id": 50}, {"head": "\u041a\u0430\u0440\u043b\u043e\u0432\u044b \u0412\u0430\u0440\u044b", "price": {"car": 50, "van": 60}, "tail": "\u0424\u0440\u0430\u043d\u0442\u0438\u0448\u043a\u043e\u0432\u044b \u041b\u0430\u0437\u043d\u0435", "time": 0, "type": "trip", "id": 60}, {"head": "\u041a\u0430\u0440\u043b\u043e\u0432\u044b \u0412\u0430\u0440\u044b", "price": {"car": 30, "van": 35}, "tail": "\u042f\u0445\u0438\u043c\u043e\u0432", "time": 0, "type": "trip", "id": 59}]; var route_tails = $('select[name=route_tail]'); var route_heads = $('select[name=route_head]'); // валидатор формы var validator = $('#order-transfer').validate({ submitHandler: function(form) { $(form).ajaxSubmit({dataType: 'script', beforeSerialize: clean, success: success}); } }); // галлерея var gallery = $('.auto a'); // Календарик, надо ставить перед init_autofills а то пропишет сегоднешнею дату $("[name=arrival_date], [name=departure_date], [name=departure_time_date], [name=returntime_date], [name=checkin], [name=checkout]").datepicker(); $("[name=arrival_date], [name=departure_date], [name=departure_time_date], [name=returntime_date], [name=checkin], [name=checkout]").datepicker('option', {dateFormat: "yy-mm-dd"}); function render_rows(){// показываем(разворачиваем)/прячем(сворачиваем) нужные/ненужны поля var $order = $('.order'); var type = $('#transfer_type').val(); // пишем заголовок формы: Заказ трансфера, Заказ отеля, Стать попутчиком $order.find('.title a').html(types[type].name); $order.find('div[id$=_order]').hide(); $order.find('#' + types[type].form_head ).show(); for(var i in rows){//сначала все покажем $('#' + rows[i]).show(); } var dont_render = dont_render_rows[type]; for(var i=0; i').val(routes[i].head).html(routes[i].head)); heads[heads.length] = routes[i].head; } } } function init_route_tails() {//инициализация концов маршрутов var tails = get_tails(route_heads.val()); route_tails.empty(); for(var i=0; i').val(tails[i]).html(tails[i])); } init_hidden(); } function init_hidden() {//инициализация типа трансфера, ИД роута var old_type = $('#transfer_type').val(); if(old_type != get_type()){ reset();//!!! должно быть до установок transfer_type и route_id } $('#transfer_type').val(get_type()); $('#route_id').val(get_route().id); render_rows(); } function set_route(id, type){// устанавливает по ИД и типу for(var i=0; i= 0 && $.inArray('departure_row', dont_render) == -1){//показываем когда from_hotel $('#departure_row').show(); } fit_height(); } function pickfrom(){ // показываем поля где встретить терминал либо отель var $pickfrom = $('[name=pick_from]:checked').val(); var settings = validator.settings; var hide = []; var slide_down = []; if ( $pickfrom == 'hotel' ){ // встретить в отеле slide_down = ['#adress_from_row', '#departure_time_row']; hide = ['#arrival_row']; } else if ($pickfrom && $pickfrom.match(/aero|train|bus/)){ // встретить из терминала slide_down = ['#arrival_row']; hide = ['#departure_time_row', '#adress_from_row']; } for(var i=0; i