jQuery(document).ready(function () { // var aMonth = ['январь','февраль','март','апрель','май','июнь','июль','август','сентябрь','откябрь','ноябрь','декабрь']; var nCurrentMonth = current_month; var nCurrentYear = current_year; jQuery('a.month').click(function () { var months = jQuery(this).next(); if (months.css('display') == 'block') { months.css('display','none'); } else { months.css('display','block'); } return false; }); jQuery('div.mchoose a').click(function () { nCurrentMonth = jQuery(this).prevAll('a').length + 1; reloadCalendar(); jQuery('div.mch').css('display','none'); return false; }); jQuery('a.year').click(function () { var years = jQuery(this).next(); if (years.css('display') == 'block') { years.css('display','none'); } else { years.css('display','block'); } return false; }); jQuery('div.ych a').click(function () { nCurrentYear = parseInt(jQuery(this).html()); reloadCalendar(); jQuery('div.ych').css('display','none'); return false; }); jQuery('a.calendar_left').click(function () { nCurrentMonth--; if (nCurrentMonth < 1) { nCurrentMonth = 12; nCurrentYear--; } reloadCalendar(); return false; }); jQuery('a.calendar_right').click(function () { nCurrentMonth++; if (nCurrentMonth > 12) { nCurrentMonth = 1; nCurrentYear++; } reloadCalendar(); return false; }); function reloadCalendar() { jQuery('a.month').html(aMonth[nCurrentMonth - 1]); jQuery('a.year').html(nCurrentYear); jQuery.get('/get_calendar.php',{ 'date' : nCurrentYear + '-' + (nCurrentMonth < 10 ? ('0' + nCurrentMonth) : nCurrentMonth)+ '-01' },function (szCode) { jQuery('#table_calendar').remove(); $('table.table_god').after(szCode); }); } }); var current_letter = ''; jQuery(document).ready(function () { $('table.table_abv a').click(function () { var self = this; $('div.alph').remove(); $.getJSON('/get_placement.php',{ letter : $(this).attr('rel') },function (aCode) { if (current_letter == $(self).attr('rel')) { return false; } current_letter = $(self).attr('rel'); var szHTML = '
'+ '
'+ '
'+ '
'+ ' '+ '
    '+ '
'+ '
'+ '
'+ '
'+ '
'; $(self).after(szHTML); for (var i =0; i < aCode.length; i++ ) { var li = $('
  • '), a = $(''); a.attr('href',aCode[i]['full_url']); a.html(aCode[i]['name']); li.append(a); $('div.alph div.cont ul').append(li); } }); return false; }); $('a.eventclose').live('click',function () { current_letter = ''; $('div.alph').remove(); return false; }); }); jQuery(document).ready(function () { // Грузим данные jQuery.getJSON('/get_showcase.php',{},function(aData) { // Запускаем таймер var position = 0; window.setInterval(function () { jQuery('div.sr_baner a').fadeOut('slow',function () { position++; if (position >= aData.length) { position = 0; } var link = jQuery(''); link.attr('href',aData[position]['link']); var image = jQuery(''); image.attr('src',aData[position]['image']['_base_src']); image.attr('alt',aData[position]['title']) .appendTo(link); $('div.sr_baner a').remove(); $('div.sr_baner').append(link); }); },5000); }); }); // Логин jQuery(document).ready(function () { // Подключаем ajax на форму отсылки пароля $('div.forgotform form').submit(function () { $.post('/users_forgot.php',{ ajax : 1, email : $('div.forgotform form input[name=email]').val() },function (szResult) { if (szResult == 'Ok') { $('div.forgotform').css('display','none'); $('div.forgotform').after('
    ' +'данные успешно высланы' +'' +'
    '); $('div.sended input[type=image]').click(function () { $('div.top_menu a.li_1').click(); $('div.sended').remove(); return false; }); } else { alert('E-mail не найден'); } }) return false; }); jQuery('div.top_menu a.li_1').click(function () { // Если пользователь авторизирован, то ссылка указывает на профиль // поэтому функция вывода формы логина не нужна if (jQuery(this).attr('href').length > 1) { return true; } var loginForm = jQuery(this).parent().parent().next(); if (jQuery('div.forgotform').css('display') == 'block') { return false; } if (loginForm.css('display') == 'block') { loginForm.css('display','none'); } else { loginForm.css('display','block'); } return false; }); $('div.loginform a').click(function () { jQuery('div.loginform').css('display','none'); jQuery('div.forgotform').css('display','block'); }); $('div.forgotform a').click(function () { jQuery('div.loginform').css('display','block'); jQuery('div.forgotform').css('display','none'); }); }); jQuery(document).ready(function ( ) { var aCheck = { rules :{ email : { required : true, email : true }, agree : { required : 1 }, name : { required : 1 }, surname : { required : 1 }, phone : { required : 1 }, kcaptcha : { required : 1 } }, messages : { confirm_password : { equalTo : 'Пароли не совпадают' }, email : { required : 'Вы не ввели Ваш email', email : 'Неправильный формат ввода email' }, aggree : { required : 'Вы не согласились с условиями регистрации' }, name : { required : 'Вы не ввели Ваше имя' }, surname : { required : 'Вы не ввели Вашу фамилию' }, phone : { required : 'Вы не ввели телефон' }, kcaptcha : { required : 'Вы не ввели код защиты от роботов' } }, errorPlacement : function (error) { error.appendTo('#error-layer'); } }; jQuery('#signup-form').each(function () { aCheck['messages']['login'] = { minlength: 'Минимальная длина 4 символа', required : 'Обязательное поле' }; aCheck['rules']['login'] = { minlength: 4, required : true }; aCheck['messages']['password'] = { minlength: 'Минимальная длина 6 символов', required : 'Вы не ввели пароль' }; aCheck['rules']['password'] = { minlength: 6, required : true }; aCheck['rules']['confirm_password'] = { equalTo : '#signup-form input[name=password]' }; $('#signup-form').validate(aCheck); }); jQuery('#profile-form').each(function () { $('#profile-form').validate(aCheck); aCheck['rules']['confirm_password'] = { equalTo : '#profile-form input[name=password]' }; }); }); $(document).ready(function () { // Проверяем есть ли массив prices? if (window.prices ) { // Скрываем форму выбора билета $('div.shch').css('display','none'); // Объявляем объект работы с билетами ts = { placement_id : 0, date : 0, all_dates : [], all_placements : [], clearTickets: function () { var tblock = $('table.table_for:eq(0);'); tblock.find('tr').remove(); }, // Отображает списки билетов showTickets : function () { var tickets = []; var placement = ts.getPlacement(); var date = ts.getDateByPlacement(placement); // Есть массив билетов? // Да if (date.children) { // Получаем массв на вывод tickets = date.children; } else { // Нет // Значит берем цены у самого первого сеанса tickets = placement.children[0].children; } // Выводим // 1. Сначала киляем все ряды таблицы ts.clearTickets(); var tblock = $('table.table_for'); for (var i =0 ; i < tickets.length ; i++ ) { var row = tickets[i]; var tr = $(''); tr //.append('места') .append('' + row.name + '' + row.price + ' - ' + row.price2 + '') // Подпись к типу билетов !!!!! ОБЪЕДИНИЛ ДВА АППЕНДА!!!!! .append('

    шт.

    ') // Блок количества .appendTo(tblock.find('tbody')); // Добавляем в таблицу последним рядом } // Добавляем кнопку "Заказать" tblock.find('tbody').append( '' +'' +'

    ' +'' +'') // !!!!COLSPAN СДЕЛАЛ 3!!!! }, selectTicket : function () { // Удаляем блоки выбора $('div.shch').remove(); // Добавляем новый $(this.parentNode).after( '
    ' + '
    ' + '
    ' + '
    ' + '
    ' + '0' + '1' + '2' + '3' + '4' + '5' + '6' + '7' + '8' + '9' + '
    ' + '
    ' + '
    ' + '
    ' + '
    ' + '
    ' ); $('div.shch a').click(function () { // Прописываем реакцию на кнопки var nCount = $(this).html(); $('div.shch').prev().children('a').html(nCount + ' шт.'); $('div.shch').remove(); return false; }) return false; }, /** * Проводит реакцию на нажатие кнопки "Заказать". При этом создает форму (
    ) и посылает её на страницу to_basket.php */ orderClick : function () { var bFound = false; // Получаем все билеты, у которых выбрано не 1 $('table.table_for a.shtyka').each(function () { // var nCount = $(this).html().match(/[0-9]+/); var title = $(this).parent().parent().prev().find('span:eq(0)').text(); if (nCount >= 1) { // В форму пихаем szHidden = ''; $('form#tickets_form').append( szHidden ) bFound = true; } }); if (bFound) { $('form#tickets_form').submit(); } else { alert('Вы не выбрали билеты для заказа'); } return false; }, /** * Отображает список площадок или дат, в зависимости от того, куда была нажата кнопка */ clickList: function () { var oldValue = $(this).next().css('display'); $('div.plc').css('display','none'); if (oldValue == 'none') { $(this).next().css('display','block') } else { $(this).next().css('display','none') } return false; }, /** * Обработчик нажатия в списке места и времени, по нажатию, фильтрует другой список */ clickListLink : function ( ) { var link = $(this); var linkValue = link.attr('rel'); var isPlacement = false; // ts.clearTickets(); // Определяем в каком списке мы находимся isPlacement = link.parents('div.plc').nextAll('div.plc').length == 0?true:false; // Пользователь кликнул по отфильтрованной ссылке? if (link.hasClass('other_places')) { // Да // Сбрасываем внутренние значения ts.placement_id = 0; ts.date = 0; $('a.placebg:eq(1)').html('Выберите место'); $('a.placebg:eq(0)').html('Выберите дату'); } // Устанавливаем текущее значение // Сохраняем в объекте ts if (isPlacement) { ts.filterDates(linkValue); ts.placement_id = linkValue; // Сменяем схему зала $('p.img_zal a').attr('href','/files/placements/' + ts.placement_id); initLightbox(); } else { ts.filterPlacements(linkValue); ts.date = linkValue; } // Если оба поля обозначены, то показываем билеты if (ts.date && ts.placement_id) { ts.showTickets(); } // Сохраняем значение link.parents('div.plc').prev().html(link.html()); // Скрываем подменю link.parents('div.plc').css('display','none'); return false; }, /** * Инциализирует списки */ initLists : function () { ts.all_placements = []; ts.all_dates = []; // Фильтруем даты, которые уже прошли // Получаем все площадки, выводим их // Получаем все даты, выводим их $.each(prices,function (key,place) { // if (place.children) { // Проверяем есть ли такая площадка? if ($.inArray(place['value'],ts.all_placements) == -1) { ts.all_placements.push(place['value']); // Флаг, того, что хотя бы одна дата есть для данной площадки, а значит её можно выводить var bAdded = false; $.each(place.children,function (key,date) { // Если дата меньше текущей, то продолжаем if (isLessThanNow(date['value'])) { return ; } bAdded = true; if ($.inArray(date['value'],ts.all_dates) == -1) { // ts.all_dates.push(date['value']); $('a.placebg:eq(0)').next().find('div.pls').append( '' + showDate(date['value']) +'' + '
    ' ); } }); // В первый список добавляем ссылку if (bAdded) { $('a.placebg:eq(1)').next().find('div.pls').append( '' + place['name'] +'' + '
    ' ); } else { // Не выводим prices[key]['deleted'] = 1; } } } }); if ((ts.all_placements.length == 1) && (ts.all_dates.length == 1)) { ts.placement_id = ts.all_placements[0]; ts.date = ts.all_dates[0]; $('a[rel='+ ts.all_placements[0] +']').click(); } else if (ts.all_placements.length == 1) { ts.placement_id = ts.all_placements[0]; $('a[rel='+ ts.all_placements[0] +']').click(); } else if (ts.all_dates.length == 1) { ts.date = ts.all_dates[0]; $('a[rel='+ ts.all_dates[0] +']').click(); } }, responseGet : function () { var match = window.location.toString().match(/placement_id=([0-9]+)/); if (match) { $('div.plc a[rel=' + match[1] +']').click(); } var match = window.location.toString().match(/date=([0-9]+\-[0-9]+\-[0-9]+%20[0-9]+\:[0-9]+)/); if (match) { match[1] = match[1].replace('%20',' '); $('div.plc a[rel=' + match[1] +']').click(); } }, /** * PRIVATE METHODS */ getPlacement : function () { // Отыскиваем типы билетов (по месту и дате) var placement = null; // Отыскиваем площаку $.each(prices,function (i) { if (prices[i]['value'] == ts.placement_id) { placement = prices[i]; return false; } }); if (!placement) { alert('Внутренняя ошибка, площадка не найдена'); } if (!placement.children) { alert('У данной площадки нету сеансов, обратитесь в службу технической поддержки за помощью'); return ; } return placement; }, getDateByPlacement : function (placement) { // Отыскиваем дату var date; $.each(placement.children,function (i,value) { if (placement.children[i]['value'] == ts.date ) { date = placement.children[i]; return false; } }); if (!date) { alert('Внутренняя ошибка, у данной площадки нету сеансов на указанную дату') } return date; }, /** * По площадке фильтрует даты */ filterDates : function (placement_id) { var filter = []; var link = null; var list = $('a.placebg:eq(0)').next().find('div.pls'); list.children('*').remove(); // Получаем площадку var place = ts.getPlaceById(placement_id) if (!place.children) { return false;} // Перебор всех дат в ней $.each(place.children,function (key,date) { // Если дата меньше текущей, то продолжаем if (isLessThanNow(date['value'])) { return ; } // Каждая дата, выводится в основном списке и сохраняется, для последующей фильтрации filter.push(date['value']); ts.createLink(date['value'],showDate(date['name'])).appendTo(list); }); // Если массив выведенных дат отличается от массива всех дат if (filter.length != this.all_dates.length) { list.append('
    Остальные площадки
    '); // То, перебор всех дат $.each(this.all_dates,function (key,date) { // Если дата меньше текущей, то продолжаем if (isLessThanNow(date)) { return ; } // Если дата не в массиве для фильтрации, то выводим её if ($.inArray(date,filter) == -1) { ts.createLink(date,showDate(date),1).appendTo(list); } }); } ts.clickAfterFilter(filter,0); }, /** * По дате фильтрует площадки */ filterPlacements : function (date) { var nDeletedCount = 0; // Кол-во удаленных площадок var link = null; var list = $('a.placebg:eq(1)').next().find('div.pls'); list.children('*').remove(); var filter = []; // Перебор площадок $.each(prices,function (key,place) { if (place.deleted) { // Это удаленная площадка не учитываем её nDeletedCount++; return; } if (place.children) { var bFound = false; $.each(place.children,function (key,places_date) { // Отыскиваем по дате совпадения if (date == places_date['value']) { bFound = true; return false; } }); if (bFound) { // Сохраняем в массив filter.push(place); link = ts.createLink(place['value'],place['name']); list.append(link); } } }); // Если массив сохраненных площадок не равен массиву всех площадок, то if (filter.length < ts.all_placements.length - nDeletedCount) { list.append('
    Остальные площадки
    '); // Приступаем к выводу доп. площадок (не совпадающих по дате) // Перебор всех площадок $.each(ts.all_placements,function (key,value) { // Если площадка не в отфильтрованном массиве, var row = ts.getPlaceById(value); if (row.deleted) { return; } if ($.inArray(row,filter) == -1) { // то выводим её link = ts.createLink(row['value'],row['name'],1); list.append(link); } }); } ts.clickAfterFilter(filter,1); }, clickAfterFilter : function (filter,isPlacement) { // Если ссылка одна, кликаем на неё if (filter.length == 1) { if (isPlacement) { ts.placement_id = filter[0]['value']; $('a.placebg:eq(1)').html(filter[0]['name']); } else { ts.date = filter[0]; $('a.placebg:eq(0)').html(showDate(filter[0])); } } if (ts.placement_id) { // Сменяем схему зала $('p.img_zal a').attr('href','/files/placements/' + ts.placement_id); initLightbox(); } }, /** * Отыскивает площадку по её индексу */ getPlaceById : function (id) { var found = null; $.each(prices,function (key,value) { if (value['value'] == id) { found = value; return false; } }); return found; }, /** * Создает ссылку */ createLink : function (value,title,is_filter) { var link = $(''); link.attr('rel',value); link.html(title); if (is_filter) { link.addClass('other_places'); } link.append('
    '); return link; } } $('table.table_for td a.shtyka').live('click',ts.selectTicket); $('table.table_for input[type=image]').live('click',ts.orderClick); $('a.placebg').click(ts.clickList); $('div.plc a').live('click',ts.clickListLink); ts.initLists(); //ts.clearTickets(); ts.responseGet(); } }); $(document).ready(function () { if ($('#basket-form').length > 0) { $('#basket-form').validate({ rules : { agree : { required : 1 }, name : { required : 1 }, phone : { required : 1 }, email : { required : 1, email : 1 }, metro : { required : 1 } }, messages : { agree : { required : 'Вы не согласились с договором-офертой' }, name : { required : 'Вы не ввели Ваше имя' }, phone : { required : 'Вы не ввели телефон' }, email : { required : 'Вы не ввели Ваш email', email : 'Неправильный формат ввода email' }, metro : { required : 'Вы не ввели телефон' } }, errorPlacement : function (error) { error.appendTo('#error-layer'); } }); } }); /// Закрывался всех выпадающих меню $(document).ready(function () { jQuery('*').live('click',function (event) { if (($(this).get(0).tagName != 'A') && ($(this).get(0).tagName != 'INPUT') && ($(this).get(0).tagName != 'IMG')) { if ($(this).parents('a').length > 0) { return ; } current_letter = ''; event.stopPropagation(); // Скрываем выпадающие списки календаря $('div.mch').css('display','none'); $('div.ych').css('display','none'); $('div.alph').remove(); // Формы логина $('div.forgotform').css('display','none'); $('div.loginform').css('display','none'); // Страницы события $('div.shch').css('display','none'); $('div.plc').css('display','none'); return false; } }); }); function showDate(value) { var aMonth = [ 'января', 'февраля', 'марта', 'апреля', 'мая', 'июня', 'июля', 'августа', 'сентября', 'октября', 'ноября', 'декабря', ]; var aDate = value.split(/[ \:\-]/); // var szResult = aDate[2] + ' ' + aMonth[aDate[1] - 1] + ' ' + aDate[0]; szResult += ' ' + aDate[3] + ':' + aDate[4]; return szResult; } function isLessThanNow(date) { var aDate = date.split(/[ \-\:]/) var now = new Date(); var curr_date = new Date(aDate[0],aDate[1] - 1,aDate[2],aDate[3],aDate[4]); return curr_date < now;