· 7 years ago · Feb 19, 2019, 06:08 PM
1var sitename = typeof sitename!= 'undefined' ? sitename : 'https://widget.tiwo.ru',
2 minified_css_timestamp = typeof minified_css_timestamp != 'undefined' ? minified_css_timestamp : Math.random(),
3 minified_js_timestamp = typeof minified_js_timestamp != 'undefined' ? minified_js_timestamp : Math.random(),
4 pathname = '/ticketseller_api/', oldpathname = '/ticketseller_240417/', hash = window.location.hash, payment_finish_event_id = 0, StarsClickId = 0,
5 payment_ok = 0, payment_finish_order_id = 0, payment_finish_secret = 0, infowindow = 0, metaviewport, metaviewport_content = '', speedtestTime = 0,
6 isMobile = false, commission = 0, commission_val = 0, validation = function() {}, data_lang = 'rus', yacode = null, buyClickLoader = true, TIWOexternalYandexCounters = TIWOexternalYandexCounters || [],
7 bsWidgetPopupContent = '', bsCookie = '', bsCookieName = 'bsCookie', event_id = 0, addonLoad = false, speedtestLog = [], valuta = 'Ñ€.', ticketTypes = {}, ticketTribunes = {}, auto_user_refund = 1, tiwo_cart_ttl = 20*60*1000, tiwo_cart_max_tickets = 10,
8 stylesLoaded = false, isTableView = false, request_uri = window.location.href, $insideLoader = null, BS_GTM = '', expired_order = false, TiwoBasket = new TiwoBasketFunc(), TiwoReferrer = new TiwoReferrerFunc(),
9 TiwoWidgetAfterLoadInit = TiwoWidgetAfterLoadInit || function () {}, TiwoWidgetOrderCreateAfter = TiwoWidgetOrderCreateAfter || function () {}, TiwoWidgetBasketItemsChangeAfter = TiwoWidgetBasketItemsChangeAfter || function () {}, TiwoWidgetOnStepOrderFormShown = TiwoWidgetOnStepOrderFormShown || function () {}, TiwoWidgetOnBackToFirstStep = TiwoWidgetOnBackToFirstStep || function () {},
10 TiwoWidgetPromoApplyAfter = TiwoWidgetPromoApplyAfter || function () {}, TiwoWidgetPromoCancelAfter = TiwoWidgetPromoCancelAfter || function () {}, TiwoWidgetSuccessPageShowAfter = TiwoWidgetSuccessPageShowAfter || function () {}, TiwoWidgetUnSuccessPageShowAfter = TiwoWidgetUnSuccessPageShowAfter || function () {},
11 orderPayMethod = 'visa',payMethodInvoice = 6, pdfInvoicesFolder = '/pdf_invoices/files/', pdfInvoicesFileNameTemplate = 'invoice#order#.pdf', invoiceName = null, TiwoTxtMessages = {}, tiwoStartPromocode = false, tiwoPromoBackgroundSend = false, tiwoEventType = 1,
12 data_promo = '', TIWOAnalyticsUser = false, TIWOAnalyticsChain = false, TiwoAfterWidgetLoadGoals = [];
13
14 TiwoTxtMessages.ticketsCountsArray = ['билет', 'билета', 'билетов'];
15 TiwoTxtMessages.ticketsCountsToPay = 'к оплате';
16 TiwoTxtMessages.table = 'Ñтол';
17 TiwoTxtMessages.row = 'Ñ€Ñд';
18 TiwoTxtMessages.place = 'меÑто';
19 TiwoTxtMessages.ShowPlaces = 'Выбрать меÑта';
20 TiwoTxtMessages.HidePlaces = 'Скрыть меÑта';
21 TiwoTxtMessages.ShowSector = 'Показать Ñектор';
22 TiwoTxtMessages.HideSector = 'Скрыть Ñектор';
23 TiwoTxtMessages.WaitingForPSConfirm = 'Подождите, пожалуйÑта, <br>ожидаем Ð¿Ð¾Ð´Ñ‚Ð²ÐµÑ€Ð¶Ð´ÐµÐ½Ð¸Ñ Ð¾Ð¿Ð»Ð°Ñ‚Ñ‹ платежной ÑиÑтемой.';
24 TiwoTxtMessages.WaitingForOrderProcessing = 'Подождите, пожалуйÑта, <br>идет формирование Вашего заказа';
25 TiwoTxtMessages.SecondNameRequired = 'Ð’Ñ‹ указали только имÑ. Ðужно указать еще фамилию';
26 TiwoTxtMessages.RequiredField = 'Ðто поле обÑзательно Ð´Ð»Ñ Ð·Ð°Ð¿Ð¾Ð»Ð½ÐµÐ½Ð¸Ñ';
27 TiwoTxtMessages.InvalidSymbol = 'ÐедопуÑтимый Ñимвол';
28 TiwoTxtMessages.PayButton = 'Оплатить';
29 TiwoTxtMessages.ChooseButton = 'Выбрать';
30 TiwoTxtMessages.CancelButton = 'Отменить';
31 TiwoTxtMessages.Total = 'Ð’Ñего';
32 TiwoTxtMessages.INNValidateError = 'ИÐРдолжен ÑоÑтоÑть из 10 или 12 цифр';
33 TiwoTxtMessages.BIKValidateError = 'БИК должен ÑоÑтоÑть из 9 цифр';
34 TiwoTxtMessages.BillDownload = 'Скачать Ñчет';
35 TiwoTxtMessages.Example = 'Пример';
36 TiwoTxtMessages.Free = 'беÑплатно';
37
38//таймер Ð´Ð»Ñ ÐºÐ¾Ñ€Ð·Ð¸Ð½Ñ‹
39function TiwoBasketFunc() {
40
41 var BASKET_DEFAULT_TTL = 20*60*1000;
42 var self = this;
43 this.timerId = 0;
44 this.basketItems = [];
45 this.sessid = 0;
46 this.eventID = 0;
47
48 function onExpired() {
49 if (self.sessid && self.isActive() && self.basketItems.length && self.eventID) {
50 jQuery(window).one('mouseover',function(){
51 jQuery('#action-loader').show();
52 var query = {sessid: self.sessid, basketItems: self.basketItems, eventID: self.eventID};
53 jQuery.ajax({
54 type: 'post', dataType: 'json', url: sitename+pathname+'ajax/basketDiedRenew.php', data: query,
55 success: function(res) {
56 if (res.success) {
57 //удалоÑÑŒ воÑÑтановить корзину
58 if (!res.newBasket) {
59 jQuery('#action-loader').hide();
60 //корзину не уÑпел почиÑтить Ñкрипт - ничего не делаем
61 }else{
62 jQuery(".ts-bottom-panel .total-summ-old").text("").hide();
63 jQuery(".ts-bottom-panel .total .total-summ").text(res.SUMM);
64 jQuery('#blackstar_form_contact input[name="PROMO"]').val("");
65 jQuery('#blackstar_form_contact input[name="PROMO"]').removeClass("used_promo");
66 jQuery('.activate_promo').show();
67 jQuery('#blackstar_form_contact input[name="PROMO"]').prop("readonly", false);
68 jQuery('#action-loader').hide();
69 self.basketItems = res.TICKETS;
70 }
71 TiwoBasket.prolongate();
72 }else{
73 window.location.hash='#tiwowidget='+self.eventID;
74 window.location.reload();
75 }
76 },
77 error: function() {
78 window.location.hash='#tiwowidget='+self.eventID;
79 window.location.reload();
80 }
81 });
82 });
83 jQuery(window).one('focusin',function(){jQuery(window).trigger('mouseover');});
84 jQuery(window).one('scroll',function(){jQuery(window).trigger('mouseover');});
85 }
86 }
87
88 this.updateTTLforBasket = function () {
89 if (self.sessid && self.isActive()) {
90 var query = {sessid: self.sessid};
91 jQuery.ajax({
92 type: 'post', dataType: 'json', url: sitename+pathname+'ajax/basketTTLprolongation.php', data: query,
93 success: function(res) {
94 if (res.success) {
95 self.prolongate();
96 }
97 }
98 });
99 }
100 }
101
102 this.run = function() {
103 this.timerId = setTimeout(onExpired, tiwo_cart_ttl ? tiwo_cart_ttl : BASKET_DEFAULT_TTL);
104 if (!self.sessid) {
105 self.sessid = jQuery('.blackstar_modal input[name=SESSION_ID]').val();
106 }
107 if (!self.eventID) {
108 self.eventID = jQuery('.blackstar_modal input[name=EVENT_ID]').val();
109 }
110 console.log('Таймер корзины запущен');
111 };
112
113 this.prolongate = function() {
114 //Ñто Ñугубо продление таймаута в Ñкрипте, ТТЛ корзины не увеличивает
115 console.log('Продление таймера корзины');
116 clearTimeout(self.timerId);
117 self.run();
118 }
119
120 this.stop = function () {
121 clearTimeout(self.timerId);
122 self.timerId = 0;
123 self.basketItems = [];
124 console.log('Таймер корзины оÑтановлен');
125 }
126
127 this.isActive = function() {
128 return self.timerId ? true : false;
129 }
130}
131//конец таймера
132
133//таймер Ð´Ð»Ñ ÐºÐ¾Ñ€Ð·Ð¸Ð½Ñ‹
134
135//метод Ð´Ð»Ñ Ñ€Ð°Ð±Ð¾Ñ‚Ñ‹ Ñ Ñ€ÐµÑ„ÐµÑ€Ð°Ð»ÑŒÐ½Ð¾Ð¹ ÑиÑтемой
136function TiwoReferrerFunc() {
137
138 var self = this;
139 this.paramName = 'referrer_id';
140 this.referrer_id = '';
141
142 this.logClickReferralLink = function () {
143 if (this.referrer_id) {
144 jQuery.ajax({url: sitename + '/service/agent_lk/logClick.php',type: 'post', data: {referrer_id: this.referrer_id}});
145 }
146 }
147
148 this.deleteReferrerParameterFromUrl = function () {
149 var res = '';
150 var d = location.href.split("#")[0].split("?");
151 var base = d[0];
152 var query = d[1];
153 if(query) {
154 var params = query.split("&");
155 for(var i = 0; i < params.length; i++) {
156 var keyval = params[i].split("=");
157 if(keyval[0] !== self.paramName) {
158 res += params[i];
159 }
160 }
161 }
162 window.history.replaceState({}, document.title, base + (res.length ? '?' + res : '') + location.hash);
163 }
164
165 this.run = function() {
166 if (getParameterByName(self.paramName)) {
167 self.referrer_id = getParameterByName(self.paramName);
168 setCookie('TIWO_REFFERER_ID', self.referrer_id, { path: '/', expires: 3600 * 24});
169 self.deleteReferrerParameterFromUrl();
170 self.logClickReferralLink();
171 }else if(getCookie_v2('TIWO_REFFERER_ID')) {
172 self.referrer_id = getCookie_v2('TIWO_REFFERER_ID');
173 }
174 };
175}
176
177//Ð¸Ð½Ð¸Ñ†Ð¸Ð°Ð»Ð¸Ð·Ð°Ñ†Ð¸Ñ Ð¾Ð¿Ð»Ð°Ñ‚Ñ‹ ÑÑ€
178var initCPPayment = function (order_id, json) {
179 var cp_description = "Оплата билетов на мероприÑтие";
180 var widget = new cp.CloudPayments();
181 widget.charge({
182 publicId: jQuery('.ts-payment-methods .ts-payment-methods__link.current').data('ps_merchant_id'),
183 description: cp_description, ////!!!!!!
184 amount: json.cart.price,
185 currency: 'RUB',
186 invoiceId: order_id,
187 //accountId: json.mail,
188 //requireEmail: false,
189 data: {}
190 },
191 function (options) { // success
192 CheckPayOrder(order_id, json.secret);
193 },
194 function (reason, options) { // fail
195 CheckPayOrder(order_id, json.secret);
196 });
197}
198
199function CheckPayOrder(order, secret) {
200 if(order && secret) {
201 var isAjaxBusy = false;
202 jQuery.ajax({
203 type: 'post',
204 url: sitename + pathname + 'view/common/step4_pay_end.php',
205 data: {
206 'cloudpay' : "Y",
207 'order': order,
208 'secret': secret
209 },
210 dataType: "html",
211 beforeSend:function(){
212 if(isAjaxBusy){
213 return false;
214 }
215 else
216 {
217 isAjaxBusy = true;
218 }
219 },
220 complete:function(){
221 isAjaxBusy = false;
222 },
223 success: function(msg){
224 jQuery('.step3').hide();
225 jQuery('.step1, .right-col .steps, .vh-align-wait').hide();
226 jQuery('.step4.payment-final').show();
227 jQuery('body').attr('data-step', 4);
228 jQuery('.right-col .step4.payment-final').html(msg);
229 jQuery('#action-loader').hide();
230 jQuery('.have_tickets .bs_tickets_count').empty();
231 }
232 });
233 }
234}
235
236//форма Ð´Ð»Ñ Ð´Ð°Ð½Ð½Ñ‹Ñ… карты в виджете
237function initCPCardForm(order_id, secret, from) {
238 toggleAndSetLoaderDescription(true, 0, '');
239 from = from || '';
240 var ifrm = document.createElement('iframe');
241 ifrm.setAttribute('id', 'cp_iframe');
242 //ifrm.style.cssText = "flex-grow: 1;width:100%;border: none;margin-bottom:20px;";
243 ifrm.setAttribute('src', sitename + pathname + 'frames/cloudpayments/?order_id='+order_id+'&secret='+secret+'&from='+from);
244 jQuery('.blackstar_modal .widget').removeClass('error-pay-page');
245 jQuery('.blackstar_modal .widget-body .right-col > div:not(#action-loader, .steps)').hide();
246 jQuery('.blackstar_modal .widget-body .right-col').css('background-color', '#fff');
247 jQuery('.blackstar_modal .widget-body .left-col .step3').show();
248 jQuery('.blackstar_modal .widget-body .right-col .steps').show().find('em').text('Введите данные карты Ð´Ð»Ñ Ð¾Ð¿Ð»Ð°Ñ‚Ñ‹');;
249 jQuery('.blackstar_modal .widget-body .right-col').addClass('inframe-pay-mode').append(ifrm);
250 window.addEventListener('message', handleTiwoPostMessage, false);
251}
252
253function CheckPayOrderCPForm(order, secret){
254 jQuery('#cp_iframe').remove();
255 jQuery('.blackstar_modal .widget-body .right-col').removeClass('inframe-pay-mode');
256 toggleAndSetLoaderDescription(true, 0, 'Обработка ответа от банка...');
257 if(order && secret){
258 var isAjaxBusy = false;
259 jQuery.ajax({
260 type: 'post',
261 url: sitename + pathname + 'view/common/step4_pay_end.php',
262 data: {
263 'cloudpay' : "Y",
264 'CPInWidget' : 'Y',
265 'order': order,
266 'secret': secret
267 },
268 dataType: "html",
269 beforeSend:function(){
270 if(isAjaxBusy){
271 return false;
272 }else{
273 isAjaxBusy = true;
274 }
275 },
276 complete:function(){
277 isAjaxBusy = false;
278 toggleAndSetLoaderDescription(false,0,'');
279 },
280 success: function(msg){
281 jQuery('.step3').hide();
282 jQuery('.step1, .right-col .steps, .vh-align-wait').hide();
283 jQuery('.step4.payment-final').show();
284 jQuery('body').attr('data-step', 4);
285 jQuery('.right-col .step4.payment-final').html(msg);
286 jQuery('#action-loader').hide();
287 jQuery('.have_tickets .bs_tickets_count').empty();
288 }
289 });
290 }
291}
292function handleTiwoPostMessage(event) {
293 if (event.origin != sitename) { return; }
294 var callData = JSON.parse(event.data);
295 if (callData.function && window[callData.function]) {
296 var func_string = callData.function + "("+callData.data.join()+")";
297 eval(func_string);
298 }
299}
300
301function setLoaderDescription(text){
302 jQuery('.widget-2 #action-loader-text').text(text);
303}
304
305function setStepTitle(text) {
306 if (text) jQuery('.blackstar_modal .widget-body .right-col .steps em').text(text);
307}
308
309function toggleAndSetLoaderDescription(on, t, text) {
310 on ? setTimeout(function(){setLoaderDescription(text);jQuery('.widget-2 #action-loader').show(0);}, t) : setTimeout(function(){jQuery('.widget-2 #action-loader').hide(0)}, t);
311}
312//конец обработки карты в виджете
313
314function sendOrderLeadToBsCrm(query) {
315 jQuery.ajax({ url: sitename + pathname + 'ajax/bsCrmSender.php', type: 'post', data: query});
316}
317
318function speedtest(message, start) {
319 if(false) return;
320 start = start || false;
321 if(!start) {
322 speedtestLog.push({ m: message, t: Date.now() - speedtestTime });
323 //console.log(message + ': ' + (Date.now() - speedtestTime));
324 } else {
325 speedtestLog = [];
326 }
327 speedtestTime = Date.now();
328}
329
330function speedtestSend() {
331 jQuery.ajax({ url: sitename + '/ajax/speedtest.php', type: 'post', data: { checkpoints: speedtestLog } });
332}
333
334function lockAjax(unlock) {
335 unlock = unlock || false;
336 unlock ? jQuery('body').removeClass('locked') : jQuery('body').addClass('locked');
337}
338
339function ajaxLocked() {
340 return jQuery('body').hasClass('locked');
341}
342function updateOldSumm($oldsumm) {
343 if (typeof($oldsumm) !== 'undefined' && $oldsumm!=false) {
344 jQuery(".ts-bottom-panel .total-summ-old").text($oldsumm).show().css('display', 'inline');
345 jQuery('.promo-message, .promo-group').hide();
346 }else{
347 jQuery(".ts-bottom-panel .total-summ-old").hide();
348 jQuery('.promo-message, .promo-group').show();
349 }
350}
351function updateCartLinesFromServer(json) {
352
353 if(!json || json.status != 200) return;
354 if(json.SUMM && typeof(window['updateTotalSum']) != 'undefined') {
355 updateTotalSum(json.SUMM);
356 }
357 updateOldSumm(json.OLD_SUMM);
358 if(json.TICKETS_LIST && typeof(window['addCartRow']) != 'undefined') {
359 jQuery('.your-choice .choice-item').not('.template').remove();
360 jQuery('.ts-basket-panel .ts-basket__item').not('.template').remove();
361 jQuery.each(json.TICKETS_LIST, function(id, t) {
362 if(ticketTypes[t.type] == 'XML_TAB')
363 jQuery('.choice-head .item:nth-child(2)').html('Стол');
364 if (tiwoEventType == 3) t.price = 0;
365 addCartRow(t.id, t.tribune, t.row, t.place, t.price, t.id, '', ticketTypes[t.type], ticketTribunes[t.tribune]);
366 });
367 }
368 commission_val = json.COMMISSION ? json.COMMISSION : 0;
369 jQuery('.your-choice .all-tick-price').html(number_format(json.SUMM, 1));
370 jQuery('.ts-bottom-panel .total-summ').text(number_format(json.SUMM, 1));
371 jQuery('.commission_value').text(commission_val);
372 if (commission_val > 0) {
373 jQuery('.final-group .commission').show();
374 } else {
375 jQuery('.final-group .commission').hide();
376 }
377}
378
379function isIE() {
380 var ua = window.navigator.userAgent, msie = ua.indexOf('MSIE ');
381 if (msie > 0) {
382 return parseInt(ua.substring(msie + 5, ua.indexOf('.', msie)), 10);
383 }
384 var trident = ua.indexOf('Trident/');
385 if (trident > 0) {
386 var rv = ua.indexOf('rv:');
387 return parseInt(ua.substring(rv + 3, ua.indexOf('.', rv)), 10);
388 }
389 var edge = ua.indexOf('Edge/');
390 if (edge > 0) {
391 return parseInt(ua.substring(edge + 5, ua.indexOf('.', edge)), 10);
392 }
393 return false;
394}
395
396function setCookie(name, value, options) {
397 options = options || {};
398 var expires = options.expires;
399 if (typeof expires == "number" && expires) {
400 var d = new Date();
401 d.setTime(d.getTime() + expires * 1000);
402 expires = options.expires = d;
403 }
404 if (expires && expires.toUTCString) {
405 options.expires = expires.toUTCString();
406 }
407 value = encodeURIComponent(value);
408 var data = name + "=" + value;
409 for (var propName in options) {
410 data += "; " + propName;
411 var propValue = options[propName];
412 if (propValue !== true) {
413 data += "=" + propValue;
414 }
415 }
416 document.cookie = data;
417}
418
419function getCookie(name) {
420 var matches = document.cookie.match(new RegExp("(?:^|; )" + name.replace(/([\.$?*|{}\(\)\[\]\\\/\+^])/g, '\\$1') + "=([^;]*)"));
421 return matches ? decodeURIComponent(matches[1]) : undefined;
422}
423
424function getCookie_v2(name) {
425 var matches = document.cookie.match(new RegExp("(?:^|; )" + name.replace(/([\.$?*|{}\(\)\[\]\\\/\+^])/g, '\\$1') + "=([^;]*)", "g"));
426 if(!matches) return undefined;
427 var lastItem = matches.pop();
428 matches = lastItem.match(new RegExp("(?:^|; )" + name.replace(/([\.$?*|{}\(\)\[\]\\\/\+^])/g, '\\$1') + "=([^;]*)"));
429 return matches ? decodeURIComponent(matches[1]) : undefined;
430}
431
432bsCookie = getCookie(bsCookieName);
433if(!bsCookie) {
434 bsCookie = Math.random().toString() + Date.now() + Math.random() + ';' + document.domain.toString();
435 setCookie(bsCookieName, bsCookie, { path: '/', expires: 3600 * 24 * 365 });
436}
437
438//Checking for Stars click_id in parameters or in cookies
439if (getParameterByName('click_id')) {
440 StarsClickId = getParameterByName('click_id');
441 setCookie('STARS_CLICK_ID', StarsClickId, { path: '/', expires: 3600 * 24});
442}else if(getCookie_v2('STARS_CLICK_ID')) {
443 StarsClickId = getCookie_v2('STARS_CLICK_ID');
444}
445//end of Stars checking
446
447//Checking for promo in parameters or in cookies
448if (getParameterByName('promocode')) {
449 tiwoStartPromocode = getParameterByName('promocode');
450 setCookie('tiwoStartPromocode', tiwoStartPromocode, { path: '/', expires: 3600 * 1});
451}else if(getCookie_v2('tiwoStartPromocode')) {
452 tiwoStartPromocode = getCookie_v2('tiwoStartPromocode');
453}
454//end of promo checking
455
456//user data processing for not payed orders checking and order form auto fill
457function saveUserDataFromOrderToCookies() {
458 if (jQuery('#blackstar_form_contact input[name="NAME"]').val()) {
459 setCookie('BS_USER_NAME', jQuery('#blackstar_form_contact input[name="NAME"]').val(), { path: '/', expires: 3600 * 24});
460 }
461 if (jQuery('#blackstar_form_contact input[name="PHONE"]').val()) {
462 setCookie('BS_USER_PHONE', jQuery('#blackstar_form_contact input[name="PHONE"]').val(), { path: '/', expires: 3600 * 24});
463 }
464 if (jQuery('#blackstar_form_contact input[name="EMAIL"]').val()) {
465 setCookie('BS_USER_EMAIL', jQuery('#blackstar_form_contact input[name="EMAIL"]').val(), { path: '/', expires: 3600 * 24});
466 }
467}
468
469function getUserEmailFromCookie() {
470 return getCookie_v2('BS_USER_EMAIL');
471}
472function getUserPhoneFromCookie() {
473 return getCookie_v2('BS_USER_PHONE');
474}
475function autoFillOrderFormFromCookies(){
476 if (getCookie_v2('BS_USER_PHONE')) {
477 jQuery('#blackstar_form_contact input[name="PHONE"]').val(getCookie_v2('BS_USER_PHONE'));
478 }
479 if (getCookie_v2('BS_USER_EMAIL')) {
480 jQuery('#blackstar_form_contact input[name="EMAIL"]').val(getCookie_v2('BS_USER_EMAIL'));
481 }
482 if (getCookie_v2('BS_USER_NAME')) {
483 jQuery('#blackstar_form_contact input[name="NAME"]').val(getCookie_v2('BS_USER_NAME'));
484 }
485}
486//end of userDataProcessing
487function initSchemeSwitcher() {
488 if (widgetStyle == 'sheme') {
489 jQuery('.event-style-switcher > span').click(function() {
490 if (!jQuery(this).hasClass('active')) {
491 var data_type = jQuery(this).data('type');
492 jQuery('.event-style-switcher > span').removeClass('active');
493 jQuery('.event-style-switcher span[data-type="'+data_type+'"]').addClass('active');
494 jQuery('.widget-2.widget-scheme').removeClass('widget-fullscr');
495 if (data_type == 'table') {//активируем таблицу
496 jQuery('.left-col .step2, .right-col .step1 .resize-widget').css('display', 'none');
497 jQuery('.left-col .step3').css('display', 'block');
498 jQuery('.right-col .step1 .choise-tickets-scheme').fadeOut(0);
499 jQuery('.right-col .step1 .choise-tickets-table').fadeIn();
500 jQuery('#hint-buy').hide();
501 //хак Ð´Ð»Ñ Ð³Ð»ÑŽÐºÐ° Ñ ÐºÐ°Ñтомным Ñкроллом - поÑле Ð¿ÐµÑ€ÐµÐºÐ»ÑŽÑ‡ÐµÐ½Ð¸Ñ Ñвайп не работает корректно, удалÑем каÑтомÑкроллбар Ð´Ð»Ñ Ð¼Ð¾Ð±Ð¸Ð»Ð¾Ðº
502 if(window['device'] && device.mobile()) {
503 jQuery('.step1 .js-scroll').mCustomScrollbar('destroy').css('overflow-y', 'scroll');
504 }
505 }else{//возвращаем Ñхемму
506 jQuery('.left-col .step3').css('display', 'none');
507 jQuery('.left-col .step1.step2, .right-col .step1 .resize-widget').css('display', 'block');
508 jQuery('.right-col .step1 .choise-tickets-table').fadeOut(0);
509 jQuery('.right-col .step1 .choise-tickets-scheme').fadeIn();
510 }
511 jQuery('body').toggleClass('widget-switched-to-table');
512 }
513 });
514 }
515}
516Object.size = function(obj) {
517 var size = 0, key;
518 for (key in obj) {
519 if (obj.hasOwnProperty(key)) size++;
520 }
521 return size;
522};
523
524function getUtmSrting() {
525 utm = {
526 'utm_source': getParameterByName('utm_source'),
527 'utm_medium': getParameterByName('utm_medium'),
528 'utm_campaign' : getParameterByName('utm_campaign'),
529 'utm_content' : getParameterByName('utm_content'),
530 'utm_term' : getParameterByName('utm_term'),
531 'gclid' : getParameterByName('gclid'),
532 '_ga' : getParameterByName('_ga'),
533 'resolution' : screen.width + 'x' + screen.height,
534 'user_agent' : navigator.userAgent
535 };
536 return JSON.stringify(utm);
537}
538
539//new functions for use cookies or local storadge instead if enabled
540function canLocalStrorage () {
541 if (typeof(Storage) !== "undefined") {
542 return true;
543 }
544 return false;
545}
546function setLocalStorageValueOrCookie(name, value, options) {
547 var savedInLocalStorage = false;
548 if (canLocalStrorage ()) {
549 try {
550 localStorage.setItem(name, value);
551 savedInLocalStorage = true;
552 } catch (e) {
553 console.log("Ошибка запиÑи в localStorage");
554 savedInLocalStorage = false;
555 }
556 }
557 if (!savedInLocalStorage) {
558 options = options || {};
559 var expires = options.expires;
560 if (typeof expires == "number" && expires) {
561 var d = new Date();
562 d.setTime(d.getTime() + expires * 1000);
563 expires = options.expires = d;
564 }
565 if (expires && expires.toUTCString) {
566 options.expires = expires.toUTCString();
567 }
568 value = encodeURIComponent(value);
569 var data = name + "=" + value;
570 for (var propName in options) {
571 data += "; " + propName;
572 var propValue = options[propName];
573 if (propValue !== true) {
574 data += "=" + propValue;
575 }
576 }
577 document.cookie = data;
578 }
579}
580
581function getLocalStorageValueOrCookie(name) {
582 var localMatch = false;
583 if (canLocalStrorage ()) {
584 try {
585 localMatch = localStorage.getItem(name);
586 } catch (e) {
587 console.log("Ошибка Ñ‡Ñ‚ÐµÐ½Ð¸Ñ Ð¸Ð· localStorage");
588 localMatch = false;
589 }
590 }
591 if (localMatch) return localMatch;
592 //we didnt found in local storage, lets find in cookie
593 var matches = document.cookie.match(new RegExp("(?:^|; )" + name.replace(/([\.$?*|{}\(\)\[\]\\\/\+^])/g, '\\$1') + "=([^;]*)", "g"));
594 if(!matches) return undefined;
595 var lastItem = matches.pop();
596 matches = lastItem.match(new RegExp("(?:^|; )" + name.replace(/([\.$?*|{}\(\)\[\]\\\/\+^])/g, '\\$1') + "=([^;]*)"));
597 return matches ? decodeURIComponent(matches[1]) : undefined;
598}
599//end of new local storage/cookies functions
600
601function getStatictic(event) {
602 var user, chain, event_number, order_id, event_id, deviceType, utmJsonString, referrer, url;
603 /* variable definitions */
604 user = TIWOAnalyticsUser || getLocalStorageValueOrCookie('BS_USER_COOKIE');
605 chain = TIWOAnalyticsChain;// || getLocalStorageValueOrCookie('BS_CHAIN_ID');//getParameterByName('chain');
606 utmJsonString = '';
607 referrer = '';
608 order_id = '';
609 url = '';
610 event_id = jQuery("input[name='EVENT_ID']").val();
611 console.log('Логируем ивент -' + event);
612 order_id = jQuery('input[name="ORDER_ID"]').val();
613 if((order_id <= 0 || order_id == undefined) && !!payment_finish_order_id) {
614 order_id = payment_finish_order_id;
615 } else if((order_id <= 0 || order_id == 'undefined')) {
616 if (getParameterByName('success')) {
617 order_id = getParameterByName('ordered');
618 } else {
619 order_id = getParameterByName('ordernumber');
620 }
621 }
622 /* variable definitions */
623 if(order_id && (event == 'w16_preview' || event == 'w16_buyclick' || event == 'w16_buywindow')){
624 return true;
625 }
626
627 if(chain && event == 'w16_preview')
628 return true;
629
630 if(!user) {
631 user = 'user' + Math.random().toString() + Date.now() + Math.random();
632 setLocalStorageValueOrCookie('BS_USER_COOKIE', user, { path: '/', expires: 3600 * 24 * 365 });
633 }
634 if(!chain) {
635 if (event == 'w16_preview') {
636 chain = 'chain' + Math.random().toString() + Date.now() + Math.random();
637 utmJsonString = getUtmSrting();
638 referrer = document.referrer;
639 url = window.location.href;
640 setLocalStorageValueOrCookie('BS_CHAIN_ID', chain, {path: '/', expires: 3600 * 24 * 365});
641 } else {
642 chain = getLocalStorageValueOrCookie('BS_CHAIN_ID');
643 }
644 } else {
645 setLocalStorageValueOrCookie('BS_CHAIN_ID', chain, {path: '/', expires: 3600 * 24 * 365});
646 }
647
648 TIWOAnalyticsChain = chain;
649 TIWOAnalyticsUser = user;
650
651 if(window['device'] || typeof(device) != 'undefined') {
652 if (device.mobile() || device.tablet()) {
653 deviceType = "mobile";
654 } else {
655 deviceType = "desktop";
656 }
657 } else {
658 if(jQuery(".mob_data").length)
659 deviceType = "mobile";
660 else
661 deviceType = "desktop";
662 }
663
664 switch (event) {
665 case 'w16_preview':
666 event_number = 1;
667 break;
668 case 'w16_buyclick':
669 event_number = 2;
670 break;
671 case 'w16_buywindow':
672 event_number = 3;
673 break;
674 case 'w16_book_1step':
675 case 'step1':
676 event_number = 4;
677 break;
678 case 'w16_book_2step':
679 event_number = 5;
680 break;
681 case 'w16_pay_error':
682 event_number = 6;
683 break;
684 case 'w16_pay_4step':
685 event_number = 7;
686 break;
687 case 'w16_thanks':
688 event_number = 8;
689 break;
690 case 'return':
691 event_number = 999;
692 break;
693 default:
694 return false;
695 }
696 jQuery.ajax({
697 url: sitename + '/analytics/ajax/analytics.php',
698 type: 'post',
699 data: {
700 analitycs: 'Y',
701 event_id: event_id,
702 event: event_number,
703 user: user,
704 chain: chain,
705 order_id: order_id,
706 utm: utmJsonString,
707 device: deviceType,
708 referrer: referrer,
709 url: url
710 }
711 });
712}
713
714function goToPaymentPage($url) {
715 var global_url = $url;
716 setTimeout(function() {
717 parent.location.href = global_url;
718 }, 100);
719}
720
721function getPayMethodCount() {
722 var count = 0;
723 jQuery('.step3 .ts-payment-methods .ts-payment-methods__item').each(function() { count++; });
724 return count;
725}
726
727function hideStep4() {
728 var needHide = getPayMethodCount() < 2;
729 jQuery('.steps .content').each(function() {
730 needHide ? jQuery(this).find('.item').eq(3).hide() : jQuery(this).find('.item').eq(3).show();
731 });
732}
733
734function initCheckoutFormCheck() {
735
736 jQuery('#blackstar_step3_back').click(function() {
737 changeGlobalStep(2);
738 });
739 jQuery('#blackstar_form_contact input[type!=checkbox]').blur(function() {
740 var ok = validation(jQuery(this).attr('name'), false, true) && validation('', true, true);
741 ok = ok && validation_checkboxes();
742 jQuery('#blackstar_pay, .blackstar_step1_checkout').prop('disabled', !ok).css('opacity', ok ? 1 : 0.5);
743 }).keypress(function(e) {
744 var ok = returnValue = true;
745 if(jQuery(this).attr('name') == 'NAME' && [37, 38, 39, 40, 8, 9, 32].indexOf(e.keyCode) == -1
746 && ((e.key && !/^[\sa-zA-Zа-ÑÐ-ЯёÐ-]+$/.test(e.key)))) {
747 returnValue = false;
748 }
749 setTimeout(function() {
750 ok = validation('', true, true, { NAME: !returnValue });
751 ok = ok && validation_checkboxes();
752 jQuery('#blackstar_pay, .blackstar_step3_checkout').prop('disabled', !ok).css('opacity', ok ? 1 : 0.5);
753 }, 100);
754 return returnValue;
755 }).each(function() {
756 jQuery(this).change(function() {//allchange
757 ok = validation('', true, true);
758 ok = ok && validation_checkboxes();
759 jQuery('#blackstar_pay, .blackstar_step3_checkout').prop('disabled', !ok).css('opacity', ok ? 1 : 0.5);
760 });
761 });
762
763 jQuery('#blackstar_form_contact input[type=checkbox]').on('change', function() {
764 var ok1, ok2;
765 ok1 = validation('', true); ok2 = validation_checkboxes();
766 if (ok1 && ok2) {
767 jQuery('#blackstar_pay, .ts-bottom-panel .blackstar_step3_checkout').prop('disabled', false).css('opacity', 1);
768 } else {
769 jQuery('#blackstar_pay, .ts-bottom-panel .blackstar_step3_checkout').prop('disabled', true).css('opacity', 0.5);
770 }
771 });
772}
773
774function initAjaxLinks() {
775 jQuery('body').on('click', '.widget-ajax-link', function() {
776 var url = jQuery(this).data('url'), target = jQuery(this).data('target') ? jQuery(this).data('target') : '#ajax-content';
777 var $txt_array_key=jQuery('input[name=txt_array_key]').val();
778 var $txt_scheme=jQuery('input[name=txt_scheme]').val();
779 var dataClass = jQuery(this).data('class');
780 if(!url || jQuery(target).length == 0) return;
781 var txt_query='txt_array_key='+$txt_array_key+'&txt_scheme='+$txt_scheme+'&lang='+data_lang+'&auto_user_refund='+auto_user_refund;
782 jQuery.ajax({
783 url: url, data:txt_query,success: function(response) {
784 jQuery(target).show().find('.place-for-ajax-content').html(response);
785 jQuery(target).find('.place-for-ajax-content > div').show();
786 jQuery(target).find(".js-scroll-1").mCustomScrollbar({
787 axis: "y",
788 scrollbarPosition: "outside",
789 documentTouchScroll: true,
790 advanced: {
791 updateOnContentResize: true
792 }
793 });
794 if(jQuery(target).find('.place-for-ajax-content').height() < jQuery(target).height() - jQuery(target).find('.final-group').height()) {
795 jQuery(target).find('.final-group').addClass('final-group_fixed');
796 } else {
797 jQuery(target).find('.final-group').removeClass('final-group_fixed');
798 }
799 /*if(history.pushState) {
800 history.pushState(null, null, '#bsw_' + dataClass);
801 } else {
802 location.hash = '#bsw_' + dataClass;
803 }*/
804 }
805 });
806 TiwoBasket.updateTTLforBasket();
807 return false;
808 });
809
810 //подпиÑка
811 jQuery('body').on('click','form.form-subscribe input[type=submit]', function(){
812 var button = jQuery(this);
813 var form = jQuery(this).parents('form');
814 button.css('visibility', 'hidden');
815 if (!form.hasClass('tiwo_error')
816 && form.find('input[name="phone-number"]').val()
817 && form.find('input[name="email"]').val() ) {
818 var data = form.serialize();
819 var action = sitename + pathname + 'ajax/subscribe.php';
820 jQuery.ajax({
821 url:action, data:data, async:true, dataType : 'json',
822 success:function(suc){
823 button.css('visibility', 'visible');
824 if (suc.success) {
825 jQuery('.modal-subsc-ok').bPopup({
826 appendTo :'#tiwo_widget_wrapper',
827 closeClass:'modal-close',
828 });
829 form.find('input.clearable').val('');
830 } else {
831 form.addClass('tiwo_error');
832 if (suc.message) {
833 form.find('.form-error-massege').text(suc.message);
834 }
835 }
836 }
837 });
838
839 }else{
840 button.css('visibility', 'visible');
841 }
842 return false;
843 });
844 //конец модалки Ñ Ð¿Ð¾Ð´Ð¿Ð¸Ñкой
845
846 //обработка дополнительного ÑоглаÑÐ¸Ñ Ñ Ð¾Ð±Ñ€Ð°Ð±Ð¾Ñ‚ÐºÐ¾Ð¹ личных данных в формах
847 jQuery('body').on('click', '.sopd-agree-row input.external-sopd-check', function() {
848 var checked = jQuery(this).prop('checked');
849 if (checked) {
850 jQuery(this).parents('form').find('input[type=submit]').prop('disabled', false);
851 } else {
852 jQuery(this).parents('form').find('input[type=submit]').prop('disabled', true);
853 }
854 });
855}
856function validateCheckOrderRefundForm(){
857 var validation_result = {},
858 request = {},
859 //инпуты
860 order_number_input = jQuery('.refund-container.first input[name=order-number]'),
861 email_phone_input = jQuery('.refund-container.first input[name=email-phone]'),
862 isValid = true;
863 //лейблы
864 var order_number_label = order_number_input.closest('label');
865 var email_phone_label = email_phone_input.closest('label');
866 //значениÑ
867 var order_number = order_number_input.val();
868 var email_phone = email_phone_input.val();
869 if (order_number) {
870 request['order_id'] = order_number;
871 order_number_label.removeClass('tiwo_error');
872 } else{
873 order_number_label.addClass('tiwo_error');
874 isValid = false;
875 };
876 if (email_phone) {
877 request['email_phone'] = email_phone;
878 email_phone_label.removeClass('tiwo_error');
879 } else{
880 email_phone_label.addClass('tiwo_error');
881 isValid = false;
882 };
883
884 if (isValid)
885 validation_result.post = request;
886
887 validation_result['success'] = isValid;
888 return validation_result;
889}
890function goToRefundStep(){
891 var ifrm = document.createElement('iframe');
892 ifrm.setAttribute('id', 'refund_iframe');
893 ifrm.style.cssText = "flex-grow: 1;width:100%;border: none;height: 100%;";
894 ifrm.setAttribute('src', sitename + '/frames/user_refund/?refundTickets=Y');
895 jQuery('.place-for-ajax-content').empty().append(ifrm);
896 jQuery('#action-loader-full').remove();
897}
898
899function widgetGoal(yandexType, googleEvent, googleGroup, googleAction) {
900 googleEvent = googleEvent || false;
901 googleGroup = googleGroup || false;
902 googleAction = googleAction || false;
903 if(window['yaCounter40045595']) yaCounter40045595.reachGoal(yandexType);
904 if(yacode && window['yaCounter'+yacode]) window['yaCounter'+yacode].reachGoal(yandexType);
905 if (TIWOexternalYandexCounters.length) {
906 jQuery.each(TIWOexternalYandexCounters, function (i, code) {
907 if (window['yaCounter'+code]) window['yaCounter'+code].reachGoal(yandexType);
908 });
909 }
910 if(window['ga'] && googleGroup && googleEvent && googleAction) {
911 ga('send', googleEvent, googleGroup, googleAction);
912 }
913 if(window['gtag'] && googleGroup && googleEvent && googleAction) {
914 gtag('event', googleAction, {
915 'event_category': googleGroup,
916 'event_label' : googleEvent
917 });
918 }
919 //закомментировал, пока не нужно @battarejka
920 //jQuery.ajax({ url: sitename + '/analytics/ajax/metrika.php', type: 'post', data: { metrika: 'Y', isMobile: isMobile, event: event_id, cookie: bsCookie, yandex: yandexType, google: { event: googleEvent, group: googleGroup, action: googleAction } }});
921 getStatictic(yandexType || googleAction);
922}
923
924function TiwoWidgetAfterLoadGoalsProcess() {
925 if (TiwoAfterWidgetLoadGoals.length) {
926 for (var i = 0; i < TiwoAfterWidgetLoadGoals.length; i++) {
927 widgetGoal(TiwoAfterWidgetLoadGoals[i][0], TiwoAfterWidgetLoadGoals[i][1], TiwoAfterWidgetLoadGoals[i][2], TiwoAfterWidgetLoadGoals[i][3]);
928 }
929 }
930}
931
932function prepend(tag, ele){
933 var x = document.getElementsByTagName(tag)[0];
934 x.insertBefore(ele ,x.children[0]);
935}
936
937function setInnerHTML(element, content) {
938 element.innerHTML = content;
939 return element;
940}
941
942function getParameterByName(name, url) {
943 if (!url) url = window.location.href;
944 name = name.replace(/[\[\]]/g, "\\$&");
945 var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)"),
946 results = regex.exec(url);
947 if (!results) return null;
948 if (!results[2]) return '';
949 return decodeURIComponent(results[2].replace(/\+/g, " "));
950}
951
952var gaLoading = setInterval(function() {
953 if(!window['ga']) return;
954 try {
955 ga('create', 'UA-71572748-14', 'auto', {'allowLinker': true});
956 ga('require', 'linker');
957 ga('linker:autoLink', ['kreed.black-star.ru', 'mot.black-star.ru', 'black-star.ru', 'widget.black-star.ru']);
958 } catch(e) {
959 console.log(e);
960 }
961 clearInterval(gaLoading);
962}, 1000);
963
964function widgetSetStepActive(step) {
965 var middleClass = jQuery('.steps .steps-content').length > 0 ? 'steps-content' : 'content';
966 jQuery('.steps .' + middleClass + ' .item').removeClass('active');
967 if(jQuery('.steps .' + middleClass + ' .item').eq(step - 1).hasClass('not-active')) {
968 step = step + (jQuery('body').attr('data-step') > step ? -1 : 1);
969 }
970 jQuery('.steps .' + middleClass + ' .item').each(function(i, o) {
971 var temp_step=step;
972 if (step>1) {temp_step=step-1;}
973 if(i >= temp_step) return false;
974 jQuery(this).addClass('active');
975 });
976 if(jQuery('body').attr('data-step') > step) {
977 jQuery('.widget').animate({ scrollTop: 0 }, 0);
978 }
979 return step;
980}
981
982function changeGlobalStep(step) {
983 var currentStep = jQuery('body').attr('data-step');
984 if(step == currentStep || currentStep == 4) {
985 return -1;
986 }
987 step = widgetSetStepActive(step);
988 //console.log('step', step);
989 //console.log('currentStep', currentStep);
990 jQuery('body').attr('data-step', step);
991 jQuery('.step').hide();
992 if (step == 1 && currentStep == 3) {
993 jQuery('#step1_buy_tickets').text(jQuery('#step1_buy_tickets').data('default-text'));
994 TiwoWidgetOnBackToFirstStep();
995 } else if(currentStep == 1){
996 jQuery('#step1_buy_tickets').text(jQuery('.step3 #contact_details').text());
997 } else if(currentStep == 3){
998 jQuery('#step1_buy_tickets').text(jQuery('.step4 #contact_details').text());
999 }
1000 jQuery('.step' + step).not('.step-start-hidden').show();
1001 jQuery('.widget-body > .step1').removeClass('choose-sector choose-seat').addClass(step === 1 ? 'choose-sector' : 'choose-seat');
1002 jQuery('.final-group button.blackstar_step1_checkout').removeClass('blackstar_step2_checkout blackstar_step3_checkout blackstar_step4_checkout');
1003 jQuery('.final-group button.blackstar_step1_checkout').addClass('blackstar_step'+step+'_checkout');
1004 jQuery('.final-group button.blackstar_step1_checkout').removeClass('gtm_step1 gtm_step2 gtm_step3 gtm_step4').addClass('gtm_step' + step);
1005 if (jQuery('.widget.widget-scheme.widget-fullscr').length) {
1006 jQuery('.widget.widget-scheme').removeClass('widget-fullscr');
1007 fullShemeZoom(0, 0);
1008 jQuery('#canvas-svg-sector-constructor').css({"height":"100%", "width":"100%", "top":"0px", "left":"0px"});
1009 }
1010 //inserting start promocode from url parameter or cookie to the promo field and sending it
1011
1012 if(!tiwoStartPromocode)
1013 {
1014 data_promo = jQuery('body input[name="pre_promo"]').val() || data_promo;
1015 tiwoStartPromocode = data_promo;
1016 }
1017
1018 if (step == 3 && tiwoStartPromocode && jQuery('#blackstar_form_contact input[name=PROMO]').length) {
1019 tiwoPromoBackgroundSend = true;
1020 jQuery('#blackstar_form_contact input[name=PROMO]').val(tiwoStartPromocode);
1021 jQuery('#blackstar_form_contact .activate_promo').click();
1022 }
1023
1024 if (step == 3) {
1025 TiwoWidgetOnStepOrderFormShown();
1026 }
1027 return step;
1028};
1029
1030jQuery.fn.allchange = function (callback) {
1031 var me = this, last = "";
1032 var infunc = function () {
1033 var text = jQuery(me).val();
1034 if (text != last) {
1035 last = text;
1036 callback();
1037 }
1038 setTimeout(infunc, 100);
1039 }
1040 setTimeout(infunc, 100);
1041};
1042
1043//jQuery(window).load(function() {
1044jQuery(window).on('load', function(){
1045 /*заккоментировано, пока еÑть блокировка!!!
1046 if(BS_GTM !== '') {
1047 (function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
1048 new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
1049 j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
1050 'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
1051 })(window,document,'script','dataLayer',BS_GTM);
1052 }*/
1053
1054 jQuery('body').on('click', '.back.ht_close, .close-ajax-content.ht_close', function() {
1055 changeGlobalStep(jQuery('body').attr('data-step'));
1056 jQuery('.left-col, .right-col').show();
1057 jQuery('#ajax-content, #action-loader').hide();
1058 });
1059
1060 /*yacode = jQuery('input[name="yacode"]').val();
1061
1062 if (yacode) {
1063 var YandexScriptCustom = document.createElement("script");
1064 YandexScriptCustom.innerHTML = '(function (d, w, c) {(w[c] = w[c] || []).push(function() {try {w.yaCounter'+yacode+' = new Ya.Metrika({id:'+yacode+',clickmap:true,trackLinks:true,accurateTrackBounce:true,webvisor:true});} catch(e) { console.log(e) }}); var n = d.getElementsByTagName("script")[0],s = d.createElement("script"),f = function () { n.parentNode.insertBefore(s, n); };s.type = "text/javascript";s.async = true;s.src = "https://mc.yandex.ru/metrika/watch.js";if (w.opera == "[object Opera]") {d.addEventListener("DOMContentLoaded", f, false);} else { f(); }})(document, window, "yandex_metrika_callbacks");';
1065 prepend('head', YandexScriptCustom);
1066 }
1067
1068 if(window['device'] || typeof(device) != 'undefined') {
1069 if (device.mobile()) {
1070 widgetGoal('w16_mobile', 'event', 'code', 'w16_mobile');
1071 } else if (device.tablet()) {
1072 widgetGoal('w16_tablet', 'event', 'code', 'w16_tablet');
1073 }
1074 }*/
1075
1076 if(jQuery('[data-event_id]').length == 1) {
1077 event_id = jQuery('[data-event_id]').data('event_id');
1078 }
1079
1080 payment_finish_payu = getParameterByName('payu');
1081 //widgetGoal('w16_preview', 'event', 'code', 'w16_preview');
1082
1083 if (getParameterByName('secret')) {
1084 payment_finish_secret = getParameterByName('secret');
1085 var xhr = new XMLHttpRequest();
1086 xhr.open('POST', sitename + pathname + 'ajax/eventid.php', false);
1087 xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
1088 if (getParameterByName('success')) {
1089 payment_finish_order_id = getParameterByName('ordered');
1090 } else {
1091 payment_finish_order_id = getParameterByName('ordernumber');
1092 }
1093 xhr.send('order_id=' + payment_finish_order_id);
1094 if (xhr.status != 200) {
1095 //console.log(xhr.status + ': ' + xhr.statusText);
1096 } else {
1097 payment_finish_event_id = parseInt(xhr.responseText);
1098 }
1099 location.hash = '';
1100 if (getParameterByName('lang_id')) {
1101 TiwoTxtMessages.WaitingForPSConfirm = 'Please wait, <br> waiting for confirmation from payment system';
1102 TiwoTxtMessages.WaitingForOrderProcessing = 'Please wait, <br>we are processing Your order';
1103 }
1104 if (history) {
1105 history.pushState('', document.title, window.location.pathname);
1106 }
1107 }
1108
1109 if (payment_finish_event_id) {
1110 document.getElementsByTagName('body')[0].appendChild(setInnerHTML(document.createElement('style'), '.vh-align-wait{background-color:rgba(0,0,0,.75);position:fixed;left:0;right:0;top:0;bottom:0;z-index:10;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}.vh-align-wait *{-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}.modal-wait{width:460px;height:232px;padding:30px;margin:-116px auto 0 -230px;background-color:#fff;position:absolute;left:50%;top:50%}#circularG{position:relative;width:83px;height:83px;margin:0 auto 30px}.circularG{position:absolute;background-color:#000;width:19px;height:19px;border-radius:12px;-o-border-radius:12px;-ms-border-radius:12px;-webkit-border-radius:12px;-moz-border-radius:12px;animation-name:bounce_circularG;-o-animation-name:bounce_circularG;-ms-animation-name:bounce_circularG;-webkit-animation-name:bounce_circularG;-moz-animation-name:bounce_circularG;animation-duration:1.1s;-o-animation-duration:1.1s;-ms-animation-duration:1.1s;-webkit-animation-duration:1.1s;-moz-animation-duration:1.1s;animation-iteration-count:infinite;-o-animation-iteration-count:infinite;-ms-animation-iteration-count:infinite;-webkit-animation-iteration-count:infinite;-moz-animation-iteration-count:infinite;animation-direction:normal;-o-animation-direction:normal;-ms-animation-direction:normal;-webkit-animation-direction:normal;-moz-animation-direction:normal}#circularG_1{left:0;top:33px;animation-delay:.41s;-o-animation-delay:.41s;-ms-animation-delay:.41s;-webkit-animation-delay:.41s;-moz-animation-delay:.41s}#circularG_2{left:8px;top:8px;animation-delay:.55s;-o-animation-delay:.55s;-ms-animation-delay:.55s;-webkit-animation-delay:.55s;-moz-animation-delay:.55s}#circularG_3{top:0;left:33px;animation-delay:.69s;-o-animation-delay:.69s;-ms-animation-delay:.69s;-webkit-animation-delay:.69s;-moz-animation-delay:.69s}#circularG_4{right:8px;top:8px;animation-delay:.83s;-o-animation-delay:.83s;-ms-animation-delay:.83s;-webkit-animation-delay:.83s;-moz-animation-delay:.83s}#circularG_5{right:0;top:33px;animation-delay:.97s;-o-animation-delay:.97s;-ms-animation-delay:.97s;-webkit-animation-delay:.97s;-moz-animation-delay:.97s}#circularG_6{right:8px;bottom:8px;animation-delay:1.1s;-o-animation-delay:1.1s;-ms-animation-delay:1.1s;-webkit-animation-delay:1.1s;-moz-animation-delay:1.1s}#circularG_7{left:33px;bottom:0;animation-delay:1.24s;-o-animation-delay:1.24s;-ms-animation-delay:1.24s;-webkit-animation-delay:1.24s;-moz-animation-delay:1.24s}#circularG_8{left:8px;bottom:8px;animation-delay:1.38s;-o-animation-delay:1.38s;-ms-animation-delay:1.38s;-webkit-animation-delay:1.38s;-moz-animation-delay:1.38s}@keyframes bounce_circularG{0%{transform:scale(1)}100%{transform:scale(.3)}}@-o-keyframes bounce_circularG{0%{-o-transform:scale(1)}100%{-o-transform:scale(.3)}}@-ms-keyframes bounce_circularG{0%{-ms-transform:scale(1)}100%{-ms-transform:scale(.3)}}@-webkit-keyframes bounce_circularG{0%{-webkit-transform:scale(1)}100%{-webkit-transform:scale(.3)}}@-moz-keyframes bounce_circularG{0%{-moz-transform:scale(1)}100%{-moz-transform:scale(.3)}}.modal-wait .wait-message{text-align:center;color:#000;font-family:Arial,Arial,Helvetica,sans-serif;font-weight:700;font-size:20px;margin-bottom:0}'));
1111 var div = document.createElement('div'), waitText = '';
1112 div.className = "vh-align-wait";
1113 if(payment_finish_payu == 'Y') {
1114 waitText = TiwoTxtMessages.WaitingForPSConfirm;
1115 } else {
1116 waitText = TiwoTxtMessages.WaitingForOrderProcessing;
1117 }
1118 document.getElementsByTagName('body')[0].appendChild(setInnerHTML(div, '<div class="modal-wait"><div id="circularG"><div id="circularG_1" class="circularG"></div><div id="circularG_2" class="circularG"></div><div id="circularG_3" class="circularG"></div><div id="circularG_4" class="circularG"></div><div id="circularG_5" class="circularG"></div><div id="circularG_6" class="circularG"></div><div id="circularG_7" class="circularG"></div><div id="circularG_8" class="circularG"></div></div><p class="wait-message">'+waitText+'</p></div>'));
1119 }
1120
1121 jQuery('body').on('click', '.widget-footer .links-grp a, .notice-link', function () {
1122 var goal = '';
1123 switch (jQuery(this).data('class')) {
1124 case 'ht_order':
1125 goal = 'w16_how_order';
1126 break;
1127 case 'ht_pay':
1128 goal = 'w16_pay';
1129 break;
1130 case 'ht_refund':
1131 goal = 'w16_return';
1132 break;
1133 case 'contacts-page':
1134 goal = 'w16_contact';
1135 break;
1136 }
1137 widgetGoal(goal, 'event', 'button', goal);
1138 });
1139
1140 if (/^#bsw_/.test(hash)) {
1141 infowindow = hash.substr(5);
1142 }
1143
1144 if (payment_finish_event_id) {
1145 payment_finish_button = document.querySelector('[data-event_id="'+payment_finish_event_id+'"]');
1146 if (!payment_finish_button) {
1147 var button = document.createElement("button");
1148 button.className = 'blackstar_ticketseller';
1149 button.style['display'] = 'none';
1150 button.setAttribute('data-event_id', payment_finish_event_id);
1151 var x = document.getElementsByTagName('body')[0];
1152 x.insertBefore(button ,x.children[0]);
1153 payment_finish_button = button;
1154 }
1155 if(payment_finish_payu == 'Y') {
1156 var checkoutCounter = 0, interval = 12000;
1157 function orderPaymentCheckout(order_id, secret) {
1158 jQuery.post(
1159 sitename + pathname + 'ajax/payment_checkout.php?order_id=' + order_id + '&secret=' + secret,
1160 function(result){
1161 //console.log(result);
1162 if(result.ACTION == 'FINISH' || checkoutCounter > 10) {
1163 payment_finish_button.click();
1164 } else {
1165 setTimeout(orderPaymentCheckout(payment_finish_order_id, payment_finish_secret), interval);
1166 }
1167 checkoutCounter += 1;
1168 }, 'json'
1169 );
1170 }
1171 orderPaymentCheckout(payment_finish_order_id, payment_finish_secret);
1172 } else {
1173 payment_finish_button.click();
1174 }
1175 }
1176
1177 if (getParameterByName('expired_order')) {
1178 var expired_order_arr = getParameterByName('expired_order').split(':');
1179 if (parseInt(expired_order_arr[2],10) > 0) {
1180 expired_order = getParameterByName('expired_order');
1181 location.hash = '';
1182 if (history) {
1183 history.pushState('', document.title, window.location.pathname);
1184 }
1185 ticketseller_showWidget(parseInt(expired_order_arr[2],10));
1186 }
1187 }
1188
1189 if (infowindow) {
1190 infowindow_button = document.getElementsByClassName('blackstar_ticketseller');
1191 infowindow_button[0].click();
1192 }
1193
1194}); //WINDOW LOADED
1195
1196if (typeof jQuery.fn.live == 'undefined' || !(jQuery.isFunction(jQuery.fn.live))) {
1197 jQuery.fn.extend({
1198 live: function (event, callback) {
1199 if (this.selector) {
1200 jQuery(document).on(event, this.selector, callback);
1201 }
1202 }
1203 });
1204}
1205
1206function declOfNum(number, titles) {
1207 var cases = [2, 0, 1, 1, 1, 2];
1208 return titles[ (number%100>4 && number%100<20)? 2 : cases[(number%10<5)?number%10:5] ];
1209}
1210
1211function initMap(){
1212
1213 centerLatlng = new google.maps.LatLng(50.4501,30.5234);
1214
1215 var map_options = {
1216 zoom: 12,
1217 center:centerLatlng,
1218 disableDefaultUI: true,
1219 mapTypeId: google.maps.MapTypeId.ROADMAP
1220 };
1221
1222 var gMap = document.getElementById("map");
1223 if (gMap != void 0) {
1224 var map = new google.maps.Map(gMap, map_options);
1225 }
1226
1227 //ОбъÑвлÑем маÑÑив Ñ Ð½Ð°ÑˆÐ¸Ð¼Ð¸ меÑтами и маркерами
1228 var markers = [],
1229 myPlaces = [];
1230
1231 //Добавить точки
1232 myPlaces.push(new Place('Торговый центр молл 1', 50.459842,30.528213, 'ПроÑпект Миру, 49,Чернігів, ЧернігівÑька облаÑть,14000', '0462 675 170', 'ЛубÑнка', 'Ñ 9:00 до 21:00'));
1233 myPlaces.push(new Place('Торговый центр молл 2', 50.453232,30.524903, 'ПроÑпект Миру, 49,Чернігів, ЧернігівÑька облаÑть,14000', '0462 675 170', 'ЛубÑнка', 'Ñ 9:00 до 21:00'));
1234
1235 //Замена картинки маркера
1236 var markerImage = new google.maps.MarkerImage(
1237 pathname + 'images/marker.png',
1238 new google.maps.Size(30,40),
1239 new google.maps.Point(0,0)
1240 );
1241
1242 //Добваить маркеры Ð´Ð»Ñ ÐºÐ°Ð¶Ð´Ð¾Ð¹ точки
1243 for (var i = 0, n = myPlaces.length; i < n; i++) {
1244 var marker = new google.maps.Marker({
1245 //раÑположение на карте
1246 position: new google.maps.LatLng(myPlaces[i].latitude, myPlaces[i].longitude),
1247 map: map,
1248 icon: markerImage
1249 });
1250 //Окно Ñ Ð¸Ð½Ñ„Ð¾Ð¹
1251 var infowindow = new google.maps.InfoWindow({
1252 content:
1253 '<div class="mapInfo">'+
1254
1255 '<p class="hint-title">' + myPlaces[i].name + '</p>' +
1256 '<p class="address">' + '<span class="bse_ico">' + '</span>' + myPlaces[i].address + '</p>' +
1257 '<p class="phone">' + '<span class="bse_ico">' + '</span>' + myPlaces[i].phone + '</p>' +
1258 '<p class="metro">' + '<span class="bse_ico">' + '</span>' + '<span class="descr">' + "Ð¡Ñ‚Ð°Ð½Ñ†Ð¸Ñ Ð¼ÐµÑ‚Ñ€Ð¾: " + '</span>' + myPlaces[i].metro + '</p>' +
1259 '<p class="time">' + '<span class="bse_ico">' + '</span>' + '<span class="descr">' + "Ð’Ñ€ÐµÐ¼Ñ Ñ€Ð°Ð±Ð¾Ñ‚Ñ‹: " + '</span>' + myPlaces[i].time + '</p>' +
1260 '</div>',
1261 });
1262 //привÑзываем попап к маркеру на карте
1263 makeInfoWindowEvent(map, infowindow, marker);
1264 markers.push(marker);
1265 }
1266
1267 function makeInfoWindowEvent(map, infowindow, marker) {
1268 //Открыть окно по клику на маркер
1269 google.maps.event.addListener(marker, 'click', function() {
1270 infowindow.open(map, marker);
1271 });
1272 }
1273
1274 //ÐšÐ»Ð°Ñ Ð´Ð»Ñ Ð´Ð¾Ð±Ð°Ð²Ð»ÐµÐ½Ð¸Ñ ÐºÐ¾Ð½Ñ‚ÐµÐ½Ñ‚Ð° в InfoWindow
1275 function Place(name, latitude, longitude, address, phone, metro, time){
1276 this.name = name; // название
1277 this.latitude = latitude; // широта
1278 this.longitude = longitude; // долгота
1279 this.address = address; // адреÑ
1280 this.phone = phone; // номер телефона
1281 this.metro = metro; // метро
1282 this.time = time; // Ð²Ñ€ÐµÐ¼Ñ Ñ€Ð°Ð±Ð¾Ñ‚Ñ‹
1283 }
1284
1285}
1286
1287isMobile = /(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|ipad|iris|kindle|Android|Silk|lge |maemo|midp|mmp|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino/i.test(navigator.userAgent) || /1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(navigator.userAgent.substr(0,4))
1288
1289function fs_loader(show, onload) {
1290
1291 if(show !== false) {
1292 show = true;
1293 }
1294
1295 onload = onload || function() {};
1296 var id = 'fsbsld';
1297
1298 if(!show) {
1299 jQuery('#'+id).hide();
1300 } else {
1301 if(jQuery('#'+id).length == 0) {
1302 var $i = jQuery('<img src="//widget.tiwo.ru/img/loader.svg" />'), $l = jQuery('<div id="'+id+'"><div></div></div>');
1303 $l.find('> div').append($i);
1304 $i.on('load', onload);
1305 $l.css({
1306 top: 0, left: 0, 'z-index': 9999999999,
1307 position: 'fixed', width: '100%', height: '100%',
1308 'background-color': 'rgba(0,0,0,0.85)', 'text-align': 'center',
1309 }).find('div').css({
1310 margin: '-110px 0 0 -175px',
1311 top: '50%', left: '50%', width: '300px', height: '170px',
1312 padding: '25px', color: '#000', position: 'fixed',
1313 });
1314 jQuery('body').append($l);
1315 }
1316 jQuery('#'+id).show();
1317 }
1318}
1319
1320function globalCommissionInit(type) {
1321 type = type || 'full';
1322 commission = parseFloat(jQuery('input[name="commission"]').val());
1323 commission_val = 0;
1324 jQuery('.blackstar_modal').css({ display: 'block' });
1325 /*jQuery('.select[name="lang"]').chosen();
1326 jQuery('select[name="lang"]').on('change', function(){
1327 jQuery.post(sitename+pathname+'/ajax/lang.php?lang='+jQuery(this).val(), function(data_lang) {
1328 for (var lang_id in data_lang) {
1329 jQuery('em.bs_lang#'+lang_id).text(data_lang[lang_id]);
1330 }
1331 }, 'json')
1332 });*/
1333
1334 jQuery('.sector:not(.dance-floor) .sector-head').on('click', function(){
1335 var _this = jQuery(this);
1336 if (_this.parent().hasClass('dealer')) {
1337 // nothing to do
1338 } else if (_this.parent().hasClass('opened')) {
1339 _this.parent().removeClass('opened');
1340 _this.children().children('.open-link').html('<span class="open-link-text">'+TiwoTxtMessages.ShowSector+' </span><span class="open-link-icon"></span>');
1341 } else if (_this.parent().find('.sector-body').html()) {
1342 jQuery('.sector:not(.dance-floor) .sector-head').children().children('.open-link').html('<span class="open-link-text">'+TiwoTxtMessages.ShowSector+' </span><span class="open-link-icon"></span>');
1343 jQuery('.sector:not(.dance-floor) .sector-head').parent('.opened').removeClass('opened');
1344 _this.parent().addClass('opened');
1345 _this.children().children('.open-link').html('<span class="open-link-text">'+TiwoTxtMessages.HideSector+' </span><span class="open-link-icon"></span>');
1346 if(window['device']) {
1347 if (device.mobile()) {
1348 jQuery('.widget').animate({scrollTop: jQuery('.sector.opened').offset().top + jQuery('.widget').scrollTop()}, '200');
1349 } else {
1350 jQuery('.step1 .js-scroll').mCustomScrollbar("scrollTo", jQuery('.sector.opened').position().top);
1351 }
1352 } else {
1353 jQuery('.step1 .js-scroll').mCustomScrollbar("scrollTo", jQuery('.sector.opened').position().top);
1354 }
1355 } else {
1356 if (_this.data('sector-id')) {
1357 jQuery.post(sitename+pathname+'ajax/rows.php', {sector_id: _this.data('sector-id'), event_id: event_id}, function(data) {
1358 var html = '';
1359 for (var i = 0; i < data.length; i++) {
1360 html += '<div class="row"><div class="head row-head" data-sector-id="'+_this.data('sector-id')+'" data-row="'+data[i].number+'" data-table="'+data[i].table+'"><div class="head-title"><span class="open-icon"></span>';
1361 html += '<span class="value">'+data[i].number+'</span><em class="bs_lang" id="line"> '+(data[i].table ? TiwoTxtMessages.table : TiwoTxtMessages.row)+'</em></div>';
1362 html += '<div class="free-seats">'+data[i].free_tickets+'</span></div>';
1363 if (tiwoEventType == 3) {
1364 html += '<div class="price-min"><span>'+TiwoTxtMessages.Free+'</span></div>';
1365 }else if (data[i].min_price == data[i].max_price) {
1366 html += '<div class="price-min"><span>'+data[i].min_price+'</span><em class="bs_lang" id="rub">'+valuta+'</em></div>';
1367 } else {
1368 html += '<div class="price-min"><em class="bs_lang" id="from">от</em> <span class="from">'+data[i].min_price+'</span><span><em class="bs_lang" id="rub">'+valuta+'</em></span><em class="bs_lang" id="to">до</em> <span class="to">'+data[i].max_price+'</span><span><em class="bs_lang" id="rub">'+valuta+'</em></span></div>';
1369 }
1370 html += '<div class="bse_buy"><a href="javascript:void(0);" class="open-link"><span class="open-link-text">'+TiwoTxtMessages.ShowPlaces+'</span><span class="open-link-icon"></span></a></div>';
1371 html += '</div><div class="row-body"></div></div>';
1372 }
1373 _this.parent().children('.sector-body').html(html);
1374
1375 }, 'json');
1376 }
1377 jQuery('.sector:not(.dance-floor) .sector-head').children().children('.open-link').html('<span class="open-link-text">'+TiwoTxtMessages.ShowSector+' </span><span class="open-link-icon"></span>');
1378 jQuery('.sector:not(.dance-floor) .sector-head').parent('.opened').removeClass('opened');
1379 _this.parent().addClass('opened');
1380 _this.children().children('.open-link').html('<span class="open-link-text">'+TiwoTxtMessages.HideSector+' </span><span class="open-link-icon"></span>');
1381 if(window['device']) {
1382 if (device.mobile()) {
1383 jQuery('.widget').animate({scrollTop: jQuery('.sector.opened').offset().top + jQuery('.widget').scrollTop()}, '200');
1384 } else {
1385 setTimeout(function(){jQuery('.step1 .js-scroll').mCustomScrollbar("scrollTo", jQuery('.sector.opened').position().top)}, 200);
1386 }
1387 } else {
1388 setTimeout(function(){jQuery('.step1 .js-scroll').mCustomScrollbar("scrollTo", jQuery('.sector.opened').position().top)}, 200);
1389 }
1390 }
1391 });
1392
1393 if (document.documentElement.clientWidth <= 992 && document.documentElement.clientWidth > 767) {
1394 jQuery('.step1 .right-col').outerHeight(jQuery('.step1').height() - jQuery('.step1 .left-col').outerHeight());
1395 var aboutMarginTop = (jQuery('.step1 .left-col').height() - parseInt(jQuery('.step1 .left-col').css('padding-top'), 10) - jQuery('.step1 .about-container').height())/2;
1396 jQuery('.step1 .about-container').css('margin-top', aboutMarginTop);
1397 jQuery('.modal-scheme').css({
1398 height: '100%',
1399 width: '100%',
1400 'max-width': 'none'
1401 })
1402 }
1403}
1404
1405function global_free_tickets_init() {
1406
1407 jQuery('.free-tickets').on('click', '.row .row-head', function(){
1408 _this = jQuery(this);
1409 if(_this.parent().hasClass('dealer')){
1410 // nothing to do
1411 }else if(_this.parent().hasClass('opened')){
1412 _this.parent().removeClass('opened');
1413 _this.children().children('.open-link').html('<span class="open-link-text">'+TiwoTxtMessages.ShowPlaces+'</span><span class="open-link-icon"></span>');
1414 } else if (_this.parent().find('.row-body').html()) {
1415 jQuery('.row .row-head').children().children('.open-link').html('<span class="open-link-text">'+TiwoTxtMessages.ShowPlaces+'</span><span class="open-link-icon"></span>');
1416 jQuery('.row .row-head').parent('.opened').removeClass('opened');
1417 _this.parent().addClass('opened');
1418 _this.children().children('.open-link').html('<span class="open-link-text">'+TiwoTxtMessages.HidePlaces+'</span><span class="open-link-icon"></span>');
1419 if(window['device']) {
1420 if (device.mobile()) {
1421 jQuery('.widget').animate({scrollTop: jQuery('.row.opened').offset().top + jQuery('.widget').scrollTop()}, '200');
1422 } else {
1423 jQuery('.step1 .js-scroll').mCustomScrollbar("scrollTo", jQuery('.row.opened').position().top);
1424 }
1425 } else {
1426 jQuery('.step1 .js-scroll').mCustomScrollbar("scrollTo", jQuery('.row.opened').position().top);
1427 }
1428 }else{
1429 if (_this.data('row')) {
1430 jQuery.post(sitename+pathname+'ajax/places_fast.php', {sector_id: _this.data('sector-id'), row: _this.data('row'), event_id: event_id}, function(data) {
1431 var html = '';
1432 for (var i = 0; i < data.length; i++) {
1433 html += '<div class="seat">';
1434 if (data[i].comment) {
1435 html += '<div class="number">'+TiwoTxtMessages.place+' '+data[i].comment+'</div>';
1436 }else if (data[i].group_count > 0) {
1437 html += '<div class="number">'+TiwoTxtMessages.place+' '+data[i].place+'<span class="table-group-tickets-description">('+data[i].group_count+' '+declOfNum(data[i].group_count, TiwoTxtMessages.ticketsCountsArray)+')</span></div>';
1438 }else{
1439 html += '<div class="number">'+TiwoTxtMessages.place+' '+data[i].place+'</div>';
1440 }
1441 if (tiwoEventType == 3) {
1442 html += '<div class="price"><span class="value"><span>'+TiwoTxtMessages.Free+'</span></span></div>';
1443 } else {
1444 html += '<div class="price"><span class="value"><span>'+data[i].price+'</span><span>'+valuta+'</span></span></div>';
1445 }
1446 html += '<div class="bse_buy"><a href="javascript:void(0);" class="open-link blackstar_place_chkbx"';
1447 html += 'data-id="'+data[i].id+'"';
1448 html += 'data-price="'+data[i].price+'"';
1449 html += 'data-sector="'+_this.data('sector-id')+'"';
1450 html += 'data-row="'+_this.data('row')+'"';
1451 html += 'data-place="'+data[i].place+'"';
1452 html += 'data-type="'+(_this.data('table') ? TiwoTxtMessages.table : TiwoTxtMessages.row)+'"';
1453 html += 'data-checked="no">';
1454 html += '<span class="open-link-text">'+TiwoTxtMessages.ChooseButton+'</span><span class="open-link-icon"></span></a></div>';
1455 html += '</div>';
1456 }
1457 _this.parent().children('.row-body').html(html);
1458
1459 }, 'json');
1460 }
1461 jQuery('.row .row-head').children().children('.open-link').html('<span class="open-link-text">'+TiwoTxtMessages.ShowPlaces+'</span><span class="open-link-icon"></span>');
1462 jQuery('.row .row-head').parent('.opened').removeClass('opened');
1463 _this.parent().addClass('opened');
1464 _this.children().children('.open-link').html('<span class="open-link-text">'+TiwoTxtMessages.HidePlaces+'</span><span class="open-link-icon"></span>');
1465 if(window['device']) {
1466 if (device.mobile()) {
1467 jQuery('.widget').animate({scrollTop: jQuery('.row.opened').offset().top + jQuery('.widget').scrollTop()}, '200');
1468 } else {
1469 setTimeout(function(){jQuery('.step1 .js-scroll').mCustomScrollbar("scrollTo", jQuery('.row.opened').position().top);}, 200);
1470 }
1471 } else {
1472 setTimeout(function(){jQuery('.step1 .js-scroll').mCustomScrollbar("scrollTo", jQuery('.row.opened').position().top);}, 200);
1473 }
1474 }
1475 });
1476
1477 jQuery('#blackstar_show_scheme').on('click', function(){
1478 jQuery(this).hide();
1479 jQuery('.choise-tickets').hide();
1480 jQuery('.scheme').show();
1481 })
1482 jQuery('#blackstar_to_list').on('click', function(){
1483 jQuery('.choise-tickets').show();
1484 jQuery('.scheme').hide();
1485 jQuery('#blackstar_show_scheme').show();
1486 })
1487
1488}
1489
1490function show_modal_too_much() {
1491 jQuery('.modal-too-much').bPopup({
1492 appendTo :'#tiwo_widget_wrapper',
1493 closeClass:'modal-close', zIndex: 100000
1494 });
1495}
1496
1497if (!Object.keys) {
1498 Object.keys = function (obj) {
1499 var keys = [],
1500 k;
1501 for (k in obj) {
1502 if (Object.prototype.hasOwnProperty.call(obj, k)) {
1503 keys.push(k);
1504 }
1505 }
1506 return keys;
1507 };
1508}
1509
1510function global_steps_init() {
1511 jQuery('.step1').on('click', '.jq-number__spin.plus', function(e) {
1512 $dance_input = jQuery(this).parents('.jq-number').find('input[type="number"]');
1513 var cursector = $dance_input.data("sector-id"), _this = jQuery(this);
1514 _this.hide();
1515 if (TiwoBasket.basketItems.length >= tiwo_cart_max_tickets) {
1516 e.preventDefault();
1517 e.stopPropagation();
1518 show_modal_too_much();
1519 return;
1520 }
1521 checkTicketAndAddToBasket(cursector, false, false, function(result){
1522 mystatus = result.status;
1523 if(typeof mystatus != "undefined") {
1524 if(mystatus == 200) {
1525 //_this.hide();
1526 $dance_input.val(parseInt($dance_input.val())+1);
1527 _this.parents('.jq-number').find('.jq-number__spin.minus').show();
1528 if(parseInt($dance_input.attr('max')) > parseInt($dance_input.val())) {
1529 _this.show();
1530 }
1531 var summ = result.SUMM, count = result.TICKETS.length ? result.TICKETS.length : Object.keys(result.TICKETS).length,
1532 commission_val = result.COMMISSION ? result.COMMISSION : 0;
1533 //hack for event type - registration
1534 if (tiwoEventType == 3) {
1535 summ = 0;
1536 }
1537 if (summ > 0 || tiwoEventType == 3 && count > 0) {
1538 jQuery('.final-group').show();
1539 jQuery('.widget').addClass('final-group-visible');
1540 jQuery('.blackstar_step1_checkout').css('visibility', 'visible');
1541 } else {
1542 jQuery('.final-group').hide();
1543 jQuery('.blackstar_step1_checkout').css('visibility', 'hidden');
1544 }
1545 jQuery('#blackstar_step2_summ, #blackstar_summ_preview, .ts-bottom-panel .value').text(summ);
1546 jQuery('.commission_value').text(commission_val);
1547 if (commission_val > 0) {
1548 jQuery('.final-group .commission').show();
1549 } else {
1550 jQuery('.final-group .commission').hide();
1551 }
1552 jQuery('.bs_tickets_count').text(count);
1553 jQuery('.bs_tickets_title').text(declOfNum(count, TiwoTxtMessages.ticketsCountsArray));
1554 jQuery('.step1 .final-group .total-title:eq(1), .step2 .final-group .total-title:eq(1), .ts-bottom-panel .total-title').text(declOfNum(count, TiwoTxtMessages.ticketsCountsArray)+', '+ TiwoTxtMessages.ticketsCountsToPay+' ');
1555 jQuery('.text-for-ticket-count').text(declOfNum(count, TiwoTxtMessages.ticketsCountsArray));
1556 updateOldSumm(result.OLD_SUMM);
1557 }
1558 else
1559 {
1560 jQuery('.tickeybusy').bPopup({
1561 closeClass:'modal-close',
1562 appendTo :'#tiwo_widget_wrapper',
1563 zIndex: 100000
1564 });
1565 }
1566 }
1567 });
1568 });
1569
1570 /*jQuery('.modal-too-much .blackstar_step1_checkout').click(function() {
1571 changeGlobalStep(3);
1572 });*/
1573
1574 jQuery('.step1').on('click', '.jq-number__spin.minus', function(){
1575 $dance_input = jQuery(this).parents('.jq-number').find('input[type="number"]');
1576 var cursector = $dance_input.data("sector-id"), _this = jQuery(this);
1577 _this.hide();
1578 removeFromBasket(cursector, false, false, function(result) {
1579 if(result.status != 200) {
1580 return;
1581 }
1582 //_this.hide();
1583 $dance_input.val(parseInt($dance_input.val())-1);
1584 _this.parents('.jq-number').find('.jq-number__spin.plus').show();
1585 if(0 < parseInt($dance_input.val())) {
1586 _this.show();
1587 }
1588 var summ = result.SUMM, count = result.TICKETS.length ? result.TICKETS.length : Object.keys(result.TICKETS).length,
1589 commission_val = result.COMMISSION ? result.COMMISSION : 0;
1590
1591 if (summ > 0 || tiwoEventType == 3 && count > 0) {
1592 jQuery('.final-group').show();
1593 jQuery('.widget').addClass('final-group-visible');
1594 jQuery('.blackstar_step1_checkout').css('visibility', 'visible');
1595 } else {
1596 jQuery('.final-group').hide();
1597 jQuery('.widget').removeClass('final-group-visible');
1598 jQuery('.blackstar_step1_checkout').css('visibility', 'hidden');
1599 }
1600 jQuery('#blackstar_step2_summ, #blackstar_summ_preview, .ts-bottom-panel .value').text(summ);
1601 jQuery('.commission_value').text(commission_val);
1602 if (commission_val > 0) {
1603 jQuery('.final-group .commission').show();
1604 } else {
1605 jQuery('.final-group .commission').hide();
1606 }
1607 jQuery('.bs_tickets_count').text(count);
1608 jQuery('.bs_tickets_title').text(declOfNum(count, TiwoTxtMessages.ticketsCountsArray));
1609 jQuery('.step1 .final-group .total-title:eq(1), .step2 .final-group .total-title:eq(1), .ts-bottom-panel .total-title').text(declOfNum(count, TiwoTxtMessages.ticketsCountsArray)+', '+ TiwoTxtMessages.ticketsCountsToPay+' ');
1610 jQuery('.text-for-ticket-count').text(declOfNum(count, TiwoTxtMessages.ticketsCountsArray));
1611 });
1612 });
1613 jQuery('.step1 .jq-number__spin.minus').hide();
1614}
1615
1616function global_order_init(type) {
1617 type = type || 'full';
1618 jQuery('.blackstar_order_confirm').on('click', function(){
1619 changeGlobalStep(3);
1620 //widgetGoal('w16_book_2step', 'event', 'button', 'w16_book_2step');
1621 if (parseInt(jQuery('#blackstar_step2_summ').text()) > 0) {
1622 jQuery('.step3').show();
1623 if (window['device'] && device.mobile()) {
1624 jQuery('.common_back').show();
1625 }
1626 jQuery('.step2').hide();
1627 if (document.documentElement.clientWidth <= 992 && document.documentElement.clientWidth > 767) {
1628 var blockHeight = 0;
1629 jQuery('.step3 .form-contact label').each(function(){
1630 blockHeight += jQuery(this).outerHeight();
1631 })
1632 blockHeight += jQuery('.step3 .contacts .bse_title').outerHeight() + 65;
1633 var bseMarginTop = Math.ceil((jQuery('.step3').height() - jQuery('.step3 .left-col').outerHeight() - jQuery('.step3 .steps').outerHeight() - blockHeight) / 2) - 40;
1634 }
1635 }
1636 });
1637
1638 validation = function(name, ignoreCss, ignoreValueFix, invalidChars) {
1639 if (!name) name = '';
1640 ignoreCss = ignoreCss || false;
1641 ignoreValueFix = ignoreValueFix || false;
1642 invalidChars = invalidChars || {};
1643 if(!ignoreValueFix) {
1644 jQuery('#blackstar_form_contact input').each(function() {
1645 this.value = this.value ? this.value.toString().trim() : '';
1646 this.value = this.value ? this.value.replace(/\s{2,}/gi, ' ') : '';
1647 });
1648 }
1649 var v = '', form_valid = true, fields = ['EMAIL', 'PHONE', 'NAME'], regx = [
1650 /^\s*[a-zA-Z0-9][a-zA-Z0-9_\-\.\+]+@[a-zA-Z0-9][a-zA-Z0-9\-\.]*[a-zA-Z0-9]\.[a-zA-Z]{2,8}\s*$/gi,
1651 /^((\+?\d+)[ ]?)?(\(?\d{3}\)?[\- ]?)?[\d\- ]{9}/, null
1652 ], setErrorMessage = function(name, where, text) {
1653 jQuery('#blackstar_form_contact input[name="' + where + '"]').parents('label').find('.error_content').text(text);
1654 if (name == '' || jQuery('#blackstar_form_contact input[name="' + where + '"]').val().length){
1655 jQuery('#blackstar_form_contact input[name="' + where + '"]').parents('label').addClass('tiwo_error');
1656 } else if (!jQuery('#blackstar_form_contact input[name="' + where + '"]').hasClass('regexp-error')) {
1657 jQuery('#blackstar_form_contact input[name="' + where + '"]').parents('label').removeClass('tiwo_error');
1658 }
1659 };
1660 if((name == '' || name == 'NAME') && invalidChars['NAME']) {
1661 form_valid = false;
1662 jQuery('#blackstar_form_contact input[name="NAME"]').parents('label').addClass('tiwo_error').find('.error_content').text(TiwoTxtMessages.InvalidSymbol);
1663 } else {
1664 var v = jQuery('#blackstar_form_contact input[name="NAME"]').val();
1665 if (typeof(v) == 'undefined' || v == null) v=''; v = v.trim();
1666 var isNotFull = (name == '' || name == 'NAME') && !/^\s*[a-zа-ÑÑ‘,.'-]+\s+[a-zа-ÑÑ‘,.'-]+\s*$/i.test(v) && /^\s*[a-zа-ÑÑ‘,.'-]+\s*$/i.test(v),
1667 isIncorect = (name == '' || name == 'NAME') && (v == '' || !/^\s*[a-zа-ÑÑ‘,.'-]+\s+[a-zа-ÑÑ‘,.'-]+[a-zа-ÑÑ‘,.'-\s]*$/i.test(v));
1668 if(isNotFull || isIncorect) {
1669 form_valid = false;
1670 jQuery('#blackstar_form_contact input[name="NAME"]').addClass('regexp-error');
1671 if(!ignoreCss) {
1672 setErrorMessage(name, 'NAME', isNotFull ? TiwoTxtMessages.SecondNameRequired : TiwoTxtMessages.RequiredField);
1673 }
1674 }else{
1675 jQuery('#blackstar_form_contact input[name="NAME"]').removeClass('regexp-error');
1676 }
1677 }
1678 for(var i = 0; i < fields.length; ++i) {
1679 if(regx[i] == null) {
1680 continue;
1681 }
1682 v = jQuery('#blackstar_form_contact input[name="' + fields[i] + '"]').val();
1683 if (typeof(v) == 'undefined' || v == null) v=''; v = v.trim();
1684 if ((name == '' || name == fields[i]) && (v == '' || !regx[i].test(v))) {
1685 jQuery('#blackstar_form_contact input[name="' + fields[i] + '"]').addClass('regexp-error');
1686 form_valid = false;
1687 if(!ignoreCss) {
1688 if (name == '' || jQuery('#blackstar_form_contact input[name="' + fields[i] + '"]').val().length){
1689 jQuery('#blackstar_form_contact input[name="' + fields[i] + '"]').parents('label').addClass('tiwo_error');
1690 } else if (!jQuery('#blackstar_form_contact input[name="' + fields[i] + '"]').hasClass('regexp-error')) {
1691 jQuery('#blackstar_form_contact input[name="' + fields[i] + '"]').parents('label').removeClass('tiwo_error');
1692 }
1693 }
1694 }else{
1695 jQuery('#blackstar_form_contact input[name="' + fields[i] + '"]').addClass('regexp-error');
1696 }
1697 if(!invalidChars[fields[i]] && !jQuery('#blackstar_form_contact input[name="' + fields[i] + '"]').hasClass('regexp-error')) {
1698 jQuery('#blackstar_form_contact input[name="' + fields[i] + '"]').parents('label').removeClass('tiwo_error');
1699 }
1700 }
1701 return form_valid;
1702 }
1703
1704 validation_checkboxes = function(){
1705 var valid_1 = true, valid_2 = true;
1706 var sopd_input = jQuery('#blackstar_form_contact input[name=sopd_agree]');
1707 var sopd_label = sopd_input.siblings('.checkbox-label');
1708 var oferta_input = jQuery('#blackstar_form_contact input[name=oferta_agree]');
1709 var oferta_label = oferta_input.siblings('.checkbox-label');
1710
1711 if (!sopd_input.prop('checked')) {
1712 valid_1 = false;
1713 sopd_label.addClass('has-error');
1714 } else {
1715 sopd_label.removeClass('has-error');
1716 }
1717 if (!oferta_input.prop('checked')) {
1718 valid_2 = false;
1719 oferta_label.addClass('has-error');
1720 } else {
1721 oferta_label.removeClass('has-error');
1722 }
1723 return valid_1 && valid_2;
1724 }
1725
1726 jQuery('#blackstar_form_contact input').focus(function() {
1727 jQuery(this).parents('label').removeClass('tiwo_error');
1728 jQuery(this).removeClass('regexp-error');
1729 jQuery('#blackstar_form_contact input').not('.regexp-error').parents('label').removeClass('tiwo_error');
1730 });
1731
1732 //user email mutator
1733 jQuery('#blackstar_form_contact input[name=EMAIL]').keyup(function() {
1734 var value = jQuery(this).val();
1735 if (value) {
1736 var res = value;
1737 res = res.replace('@gmail.ru', '@gmail.com');
1738 res = res.replace('@mail.com', '@mail.ru');
1739 res = res.replace('@mial.ru', '@mail.ru');
1740 if (res != value) jQuery(this).val(res);
1741 }
1742 });
1743
1744 jQuery('.js-open-feedback').click(function(){
1745 widgetGoal('w16_question', 'event', 'button', 'w16_faq_form');
1746 })
1747
1748 if(jQuery.fn.inputmasks) {
1749 var listCountries = jQuery.masksSort(jQuery.masksLoad("https://cdn.rawgit.com/andr-04/inputmask-multi/master/data/phone-codes.json"), ['#'], /[0-9]|#/, "mask"),
1750 maskOpts = {
1751 inputmask: { definitions: { '#': { validator: "[0-9]", cardinality: 1 } },
1752 showMaskOnHover: false, autoUnmask: true, clearMaskOnLostFocus: false
1753 }, match: /[0-9]/, replace: '#', listKey: "mask"
1754 }, maskChangeWorld = function(maskObj, determined) {
1755 //console.log(maskObj);
1756 jQuery('#input_phone_example').text(TiwoTxtMessages['Example'] + ': ' + maskObj.mask.replace(/#/g, '0'));
1757 };
1758
1759 jQuery('input[name="PHONE"]').inputmasks(jQuery.extend(true, {}, maskOpts, {
1760 list: listCountries,
1761 onMaskChange: maskChangeWorld
1762 }));
1763 }
1764}
1765
1766function reinit_widget(event){
1767 if (!event) {
1768 window.location.hash='#reinit_widget';
1769 }else{
1770 window.location.hash='#tiwowidget='+event;
1771 }
1772 window.location.reload();
1773}
1774
1775function reinit_widget_check(){
1776 if (window.location.hash.indexOf('#reinit_widget')>=0){
1777 window.location.hash='';
1778 if(jQuery('.blackstar_ticketseller')){
1779 ticketseller_showWidget(jQuery('.blackstar_ticketseller').data('event_id'));
1780 }
1781 }else if(window.location.hash.indexOf('#concert=')>=0) {
1782 var id=parseInt(window.location.hash.split( /#concert=/i )[1]);
1783 if (id) {
1784 window.location.hash='';
1785 ticketseller_showWidget(id);
1786 }
1787 }else if(window.location.hash.indexOf('#tiwowidget=')>=0) {
1788 var id=parseInt(window.location.hash.split( /#tiwowidget=/i )[1]);
1789 if (id) {
1790 window.location.hash='';
1791 ticketseller_showWidget(id);
1792 }
1793 }
1794}
1795
1796
1797function number_format(number,decimals,dec_point,thousands_sep) {
1798 number = number*1;//makes sure `number` is numeric value
1799 //check for integer value
1800 if (number % 1 === 0) decimals = 0;
1801 var str = number.toFixed(decimals?decimals:0).toString().split('.');
1802 var parts = [];
1803 for ( var i=str[0].length; i>0; i-=3 ) {
1804 parts.unshift(str[0].substring(Math.max(0,i-3),i));
1805 }
1806 str[0] = parts.join(thousands_sep?thousands_sep:' ');
1807 return str.join(dec_point?dec_point:'.');
1808}
1809
1810function checkTicketAndAddToBasket(sector, ticket, detail, callback){
1811 var sector = sector || false;
1812 var ticket = ticket || false;
1813 var detail = detail || 0;
1814 if (ticket || sector) {
1815 callback = callback || false;
1816 var query = { sector:sector, ticket: ticket, detail: detail, event_id: event_id, uniqueID: jQuery('input[name="SESSION_ID"]').val(), type: 'add', sessid: jQuery('input[name="sessid"]').val() }
1817 lockAjax();
1818 jQuery.ajax({ type: 'post', dataType: 'json', url: sitename+pathname+'ajax/basket.php',
1819 data: query, success: callback, complete: function(res) {
1820 lockAjax(true);
1821 var basket_res = jQuery.parseJSON(res.responseText);
1822 if (basket_res.status == 200) {
1823 TiwoBasket.basketItems = jQuery.makeArray(basket_res.TICKETS);
1824 if (TiwoBasket.isActive()) {
1825 TiwoBasket.prolongate();
1826 } else {
1827 TiwoBasket.run();
1828 }
1829 TiwoWidgetBasketItemsChangeAfter();
1830 }
1831 }});
1832
1833 jQuery.ajax({ type: 'post', dataType: 'json', url: sitename+pathname+'ajax/notify.php',
1834 data: query, complete: function() {}});
1835 }
1836}
1837
1838function removeFromBasket(sector, ticket, detail, callback) {
1839 var sector = sector || false;
1840 var ticket = ticket || false;
1841 var detail = detail || 0;
1842 if (ticket || sector) {
1843 callback = callback || function() {};
1844 var query = {sector:sector, ticket: ticket, detail: detail, event_id: event_id, uniqueID: jQuery('input[name="SESSION_ID"]').val(), type: 'remove'};
1845 lockAjax();
1846 jQuery.ajax({ type: 'post', dataType: 'json', url: sitename+pathname+'ajax/basket.php',
1847 data: query, success: callback, complete: function(res) {
1848 lockAjax(true);
1849 var basket_res = jQuery.parseJSON(res.responseText);
1850 if (basket_res.status == 200 && basket_res.SUMM > 0) {
1851 TiwoBasket.basketItems = jQuery.makeArray(basket_res.TICKETS);
1852 }else if (basket_res.status == 200 && basket_res.SUMM == 0) {
1853 TiwoBasket.stop();
1854 }
1855 TiwoWidgetBasketItemsChangeAfter();
1856 }
1857 });
1858 }
1859}
1860
1861function ClearBasket(callback){
1862 var query = {event_id: event_id,uniqueID: jQuery('input[name="SESSION_ID"]').val(),type: 'removeAll'};
1863 lockAjax();
1864 var callback = callback || function() {};
1865 jQuery.ajax({ type: 'post', dataType: 'json', url: sitename+pathname+'ajax/basket.php',
1866 data: query, success: callback, complete: function(res) {
1867 lockAjax(true);
1868 var basket_res = jQuery.parseJSON(res.responseText);
1869 if (basket_res.status == 200) {
1870 TiwoBasket.stop();
1871 }
1872 TiwoWidgetBasketItemsChangeAfter();
1873 }
1874 });
1875}
1876
1877function step1_height() {
1878 //jQuery('.free-tickets').outerHeight(jQuery('.right-col').height() - jQuery('.steps').outerHeight());
1879 //jQuery('.free-tickets .scroll').outerHeight(jQuery('.free-tickets').height() - jQuery('.free-tickets .title-row').height() - 20);
1880}
1881
1882function ticketseller_showWidget(event_id) {
1883 var button = document.querySelector('[data-event_id="'+event_id+'"]');
1884 if (button) {
1885 button.click();
1886 } else {
1887 var button = document.createElement("button");
1888 button.className = 'blackstar_ticketseller';
1889 button.style['display'] = 'none';
1890 button.setAttribute('data-event_id', event_id);
1891 var x = document.getElementsByTagName('body')[0];
1892 x.insertBefore(button ,x.children[0]);
1893 setTimeout(function(){button.click()}, 400);
1894 }
1895}
1896
1897function loadScript(url, callback) {
1898 var head = document.getElementsByTagName('head')[0], script = document.createElement('script'), old_script = document.getElementById('bs_script');
1899 if (old_script) {
1900 head.removeChild(old_script);
1901 }
1902 script.type = 'text/javascript';
1903 script.id = 'bs_script';
1904 script.src = url;
1905 script.onreadystatechange = callback;
1906 script.onload = callback;
1907 head.appendChild(script);
1908}
1909
1910function loadStyle(url, callback) {
1911 var head = document.getElementsByTagName('head')[0], script = document.createElement('link');
1912 script.type = 'text/css';
1913 script.rel = 'stylesheet';
1914 script.href = url;
1915 script.onload = script.onreadystatechange = callback;
1916 head.appendChild(script);
1917}
1918
1919function loadScriptRecursive(url_array, callback, key) {
1920 if (!key) key = 0;
1921 var head = document.getElementsByTagName('head')[0], script = document.createElement('script');
1922 script.type = 'text/javascript';
1923 script.id = 'bs_script_'+key;
1924 script.src = sitename + pathname + url_array[key];
1925 if (key++ < url_array.length - 1) {
1926 script.onload = script.onreadystatechange = function(){
1927 loadScriptRecursive(url_array, callback, key)
1928 };
1929 } else {
1930 script.onload = script.onreadystatechange = callback;
1931 }
1932 head.appendChild(script);
1933}
1934
1935function showCartElements(showStep) {
1936 if (!jQuery('body').hasClass('billInvoiceStep')) {
1937 var $btn = jQuery('.ts-bottom-panel .blackstar_step1_checkout');
1938 $btn.prop('disabled', false);
1939 $btn.find('em').text($btn.attr('data-default'));
1940 jQuery('.ts-bottom-panel .total').show();
1941 changeGlobalStep(showStep);
1942 setTimeout(function() {
1943 if(jQuery('body').attr('data-step') == 1) {
1944 jQuery('.ts-bottom-panel .back').css('visibility', 'hidden');
1945 }
1946 }, 50);
1947 }
1948}
1949
1950var validateInnField = function(input_element){
1951 var validateInnFunction = function(inn){return inn.length == 10 || inn.length == 12;};
1952 var value = input_element.val();
1953 //console.log('validateInnField', value, validateInnFunction(value));
1954 return validateBillField(input_element, validateInnFunction, TiwoTxtMessages.INNValidateError);
1955}
1956
1957var validateBikField = function(input_element){
1958 var validateBikFunction = function(bik){return bik.length == 9;};
1959 var value = input_element.val();
1960 //console.log('validateBikField', value, validateBikFunction(value));
1961 return validateBillField(input_element, validateBikFunction, TiwoTxtMessages.BIKValidateError);
1962}
1963
1964var validateFieldCommon = function(input_element){
1965
1966}
1967
1968function validateBillField(input_element, custom_valid_function, custom_valid_message){
1969 var value = input_element.val();
1970 var empty_text = TiwoTxtMessages.RequiredField;
1971 if (!value) {
1972 setBillFieldError(input_element, empty_text);
1973 return false;
1974 } else if (typeof custom_valid_function == 'function')
1975 {
1976 if (!custom_valid_function(value)) {
1977 setBillFieldError(input_element, custom_valid_message);
1978 return false;
1979 }
1980 }
1981 clearBillFieldError(input_element);
1982 return true;
1983}
1984
1985function setBillFieldError(input_element, errorText){
1986 input_element.siblings('.error_content').text(errorText);
1987 input_element.closest('label').addClass('tiwo_error');
1988}
1989
1990function clearBillFieldError(input_element){
1991 input_element.siblings('.error_content').empty();
1992 input_element.closest('label').removeClass('tiwo_error');
1993}
1994
1995function sendAutoFillAjax(type, value)
1996{
1997 if (type == 'inn' || type == 'bik')
1998 {
1999 jQuery.getJSON(sitename + pathname + 'ajax/autoFill.php', {value : value, type : type}, function(data) {
2000 //console.log(data);
2001 if (data.found)
2002 {
2003 if (type == 'inn')
2004 {
2005 if (data.fields.KPP)
2006 jQuery('#billForm input[name=KPP]').val(data.fields.KPP);
2007
2008 if (data.fields.NAME_SHORT)
2009 jQuery('#billForm input[name=PAYER]').val(data.fields.NAME_SHORT);
2010 else if (data.fields.IP_NAME)
2011 jQuery('#billForm input[name=PAYER]').val(data.fields.IP_NAME);
2012 }
2013 if (type == 'bik') {
2014 jQuery('#billForm input[name=PAYERS_BANK]').val(data.fields.UF_BANK_NAME);
2015 jQuery('#billForm input[name=CORESPONDENT_ACCOUNT]').val(data.fields.UF_CORR_ACCOUNT);
2016 }
2017 }
2018 });
2019 };
2020}
2021
2022function validateBillForm(){
2023 var result = true;
2024 var function_name;
2025 jQuery('#billForm input[type=text], #billForm input[type=tel]').each(function(){
2026 var field_name = jQuery(this).attr('name');
2027 var element = jQuery(this);
2028 if (!element.data('no-validate'))
2029 {
2030 if (field_name == 'INN')
2031 {
2032 function_name = validateInnField;
2033 } else if (field_name == 'BIK')
2034 {
2035 function_name = validateBikField;
2036 } else {
2037 function_name = validateBillField;
2038 }
2039 //console.log(field_name, function_name);
2040 if (!function_name(element)) {
2041 result = false;
2042 }
2043 }
2044 });
2045 return result;
2046}
2047
2048function initLastOrdersBlock () {
2049 if (jQuery('.last-orders-container').length) {
2050 jQuery('.last-orders-btn_zoom').click(function(){
2051 jQuery('.last-orders').toggleClass('is-open');
2052 });
2053 setTimeout(function(){jQuery('.last-orders-container').slideDown();},1000);
2054 jQuery('.last-orders-container .last-orders-close').click(function(){
2055 jQuery('.last-orders-container').slideUp();
2056 });
2057 jQuery('.last-order__pay_link').click(function(){
2058 goToPaymentPage(jQuery(this).data('link'));
2059 });
2060 jQuery('.last-order__cancel_link').click(function(){
2061 var cancel_link = jQuery(this).data('link');
2062 jQuery(this).parents('.last-order').addClass('last-order-processing');
2063 var xhr = new XMLHttpRequest();
2064 xhr.open('GET', cancel_link, true);
2065 xhr.send();
2066 if (!jQuery('.last-orders-container .last-order').not(".last-order-processing").length) {
2067 jQuery('.last-orders-container').slideUp();
2068 }else{
2069 jQuery('.last-orders-container .last-order-processing').slideUp();
2070 }
2071 /*xhr.onreadystatechange = function() {
2072 if (xhr.readyState != 4) return;
2073 if (xhr.status == 200) {
2074 if (!jQuery('.last-orders-container .last-order').not(".last-order-processing").length) {
2075 jQuery('.last-orders-container').slideUp();
2076 }else{
2077 jQuery('.last-orders-container .last-order-processing').slideUp();
2078 }
2079 }
2080 }*/
2081 });
2082 }
2083}
2084
2085(function(){
2086 /*заккоментировано, пока еÑть блокировка!!!
2087 /// GTM script
2088 var GTMscript = document.createElement("script");
2089 GTMscript.innerHTML = "(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src='https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);})(window,document,'script','dataLayer','GTM-TP6VKS');";
2090 prepend('head', GTMscript);*/
2091 //подгружаем аналитику Ñ Ð½Ð°ÑˆÐµÐ³Ð¾ Ñервера
2092 var googleAnalitycs = document.createElement("script");
2093 googleAnalitycs.type = 'text/javascript';
2094 googleAnalitycs.src = sitename+pathname+'js/libs/google-analytics.js';
2095 prepend('head', googleAnalitycs);
2096 /// Yandex Script
2097 var YandexScript = document.createElement("script");
2098 YandexScript.innerHTML = '(function (d, w, c) {(w[c] = w[c] || []).push(function() {try {w.yaCounter40045595 = new Ya.Metrika2({id:40045595,clickmap:true,trackLinks:true,accurateTrackBounce:true,webvisor:true});} catch(e) { console.log(e) }}); var n = d.getElementsByTagName("script")[0],s = d.createElement("script"),f = function () { n.parentNode.insertBefore(s, n); };s.type = "text/javascript";s.async = true;s.src = "https://mc.yandex.ru/metrika/tag.js";if (w.opera == "[object Opera]") {d.addEventListener("DOMContentLoaded", f, false);} else { f(); }})(document, window, "yandex_metrika_callbacks2");';
2099 prepend('head', YandexScript);
2100 // raven.js
2101 var RavenScript = document.createElement("script");
2102 RavenScript.type = 'text/javascript';
2103 RavenScript.src = 'http://cdn.ravenjs.com/3.16.0/raven.min.js';
2104 RavenScript.onload = function () {Raven.config('https://99110c830d7845078d3e2604eeea62b6@sentry.io/182407', {
2105 whitelistUrls: [
2106 /widget\.tiwo\.ru/,
2107 /widget\.black-star\.ru/
2108 ]
2109 }).install();};
2110 prepend('head', RavenScript);
2111 // end raven.js
2112 var digitalScript = document.createElement("script");
2113 digitalScript.type = 'text/javascript';
2114 digitalScript.src = 'https://tag.digitaltarget.ru/adcm.js';
2115 digitalScript.innerHTML = "(function (var adcm_config ={id: 6338, platformId: ,profileId: '${USER_ID}', init: function () { window.adcm.call(); }};)";
2116 digitalScript.innerHTML+= "(function (var adcm_config ={id: 6358, platformId: ,profileId: '${USER_ID}', init: function () { window.adcm.call(); }};)";
2117 prepend('head', digitalScript);
2118 // re-target block
2119 var facebookPixelScript = document.createElement("script");
2120 facebookPixelScript.innerHTML = "!function(f,b,e,v,n,t,s){if(f.fbq)return;n=f.fbq=function(){n.callMethod?n.callMethod.apply(n,arguments):n.queue.push(arguments)};if(!f._fbq)f._fbq=n;n.push=n;n.loaded=!0;n.version='2.0';n.queue=[];t=b.createElement(e);t.async=!0;t.src=v;s=b.getElementsByTagName(e)[0];s.parentNode.insertBefore(t,s)}(window, document,'script','https://connect.facebook.net/en_US/fbevents.js');fbq('init', '1944335159169032');fbq('track', 'PageView');";
2121 prepend('head', facebookPixelScript);
2122 var mailRaitingScript = document.createElement("script");
2123 mailRaitingScript.innerHTML = "var _tmr = window._tmr || (window._tmr = []);_tmr.push({id: '2956736', type: 'pageView', start: (new Date()).getTime()});(function (d, w, id) {if (d.getElementById(id)) return;var ts = d.createElement('script'); ts.type = 'text/javascript'; ts.async = true; ts.id = id;ts.src = (d.location.protocol == 'https:' ? 'https:' : 'http:') + '//top-fwz1.mail.ru/js/code.js';var f = function () {var s = d.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ts, s);};if (w.opera == '[object Opera]') { d.addEventListener('DOMContentLoaded', f, false); } else { f(); }})(document, window, 'topmailru-code');";
2124 prepend('head', mailRaitingScript);
2125
2126 //cloud
2127 var cloudSctipt = document.createElement("script");
2128 cloudSctipt.type = 'text/javascript';
2129 cloudSctipt.src = 'https://widget.cloudpayments.ru/bundles/cloudpayments';
2130 prepend('head', cloudSctipt);
2131
2132 /*custom srcripts for domains*/
2133 var tiwo_check_host = window.location.host;
2134 if (tiwo_check_host == 'black-star.ru') {
2135 tiwo_check_host = 'black-star.ru';
2136 loadScript(sitename + pathname + 'js/hosts/' + tiwo_check_host + '.js?v=1212');
2137 }
2138
2139 TiwoReferrer.run();
2140
2141 if (window.location.host == 'profkassa.com' && window.location.pathname == '/concerts/pevcov') {
2142 var YandexScriptPevcov = document.createElement("script");
2143 YandexScriptPevcov.innerHTML = '(function (d, w, c) {(w[c] = w[c] || []).push(function() {try {w.yaCounter50846021 = new Ya.Metrika2({id:50846021,clickmap:true,trackLinks:true,accurateTrackBounce:true,webvisor:true});} catch(e) { console.log(e) }}); var n = d.getElementsByTagName("script")[0],s = d.createElement("script"),f = function () { n.parentNode.insertBefore(s, n); };s.type = "text/javascript";s.async = true;s.src = "https://mc.yandex.ru/metrika/tag.js";if (w.opera == "[object Opera]") {d.addEventListener("DOMContentLoaded", f, false);} else { f(); }})(document, window, "yandex_metrika_callbacks2");';
2144 prepend('head', YandexScriptPevcov);
2145 var facebookPixelScriptPevcov = document.createElement("script");
2146 facebookPixelScriptPevcov.innerHTML = "!function(f,b,e,v,n,t,s){if(f.fbq)return;n=f.fbq=function(){n.callMethod?n.callMethod.apply(n,arguments):n.queue.push(arguments)};if(!f._fbq)f._fbq=n;n.push=n;n.loaded=!0;n.version='2.0';n.queue=[];t=b.createElement(e);t.async=!0;t.src=v;s=b.getElementsByTagName(e)[0];s.parentNode.insertBefore(t,s)}(window, document,'script','https://connect.facebook.net/en_US/fbevents.js');fbq('init', '1584692795010393');fbq('track', 'PageView');";
2147 prepend('head', facebookPixelScriptPevcov);
2148 var mailRaitingScriptPevcov = document.createElement("script");
2149 mailRaitingScriptPevcov.innerHTML = "var _tmr = window._tmr || (window._tmr = []);_tmr.push({id: '3064608', type: 'pageView', start: (new Date()).getTime()});(function (d, w, id) {if (d.getElementById(id)) return;var ts = d.createElement('script'); ts.type = 'text/javascript'; ts.async = true; ts.id = id;ts.src = (d.location.protocol == 'https:' ? 'https:' : 'http:') + '//top-fwz1.mail.ru/js/code.js';var f = function () {var s = d.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ts, s);};if (w.opera == '[object Opera]') { d.addEventListener('DOMContentLoaded', f, false); } else { f(); }})(document, window, 'topmailru-code');";
2150 prepend('head', mailRaitingScriptPevcov);
2151 var vkPixelScriptPevcov = document.createElement("script");
2152 vkPixelScriptPevcov.innerHTML = '!function(){var t=document.createElement("script");t.type="text/javascript",t.async=!0,t.src="https://vk.com/js/api/openapi.js?157",t.onload=function(){VK.Retargeting.Init("VK-RTRG-296970-c950o"),VK.Retargeting.Hit()},document.head.appendChild(t)}();';
2153 prepend('head', vkPixelScriptPevcov);
2154 }
2155 /*end of custom scripts for domains*/
2156
2157 jQuery(document).ready(function(){
2158 widgetGoal('w16_preview', 'event', 'code', 'w16_preview');
2159
2160 var handler = function(event){
2161 var self = this;
2162 speedtest('Click', self);
2163 widgetGoal('w16_buyclick', 'event', 'button', 'click1');
2164 if(buyClickLoader) {
2165 fs_loader(true, function() { setTimeout(function() { premain.call(self, event); }, 10); });
2166 } else {
2167 premain.call(self, event);
2168 }
2169 }
2170 var init_buttons = function(){
2171 jQuery(document).on('click','.blackstar_ticketseller',handler);
2172 }
2173
2174 init_buttons();
2175 reinit_widget_check();
2176
2177 function setInnerHTML(element, content) {
2178 element.innerHTML = content;
2179 return element;
2180 }
2181
2182 function premain(event){
2183 event.preventDefault();
2184 event.stopPropagation();
2185 metaviewport = document.querySelector('meta[name="viewport"]');
2186 if (metaviewport) {
2187 metaviewport_content = metaviewport.content;
2188 metaviewport.content = "width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no";
2189 } else {
2190 var meta = document.createElement('meta');
2191 meta.name = "viewport";
2192 meta.content = "width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no";
2193 document.getElementsByTagName('head')[0].appendChild(meta);
2194 }
2195 if(isMobile) {
2196 (document.addEventListener || document.attachEvent)('gesturestart', function (e) {
2197 e.preventDefault();
2198 });
2199 }
2200 event_id = this.getAttribute('data-event_id');
2201 data_lang = this.getAttribute('data-lang') || data_lang;
2202 branch = this.getAttribute('data-branch');
2203
2204 if (!tiwoStartPromocode && jQuery('input[name="pre_promo"]').length) {
2205 data_promo = jQuery('input[name="pre_promo"]').val() || data_promo;
2206 tiwoStartPromocode = data_promo;
2207 setCookie('tiwoStartPromocode', tiwoStartPromocode, { path: '/', expires: 3600 * 1});
2208 }
2209
2210 var main = function(lang){
2211 speedtest('Main');
2212 lang = lang || data_lang;
2213 btn_offset = jQuery('.blackstar_ticketseller').offset();
2214 btn_width = jQuery('.blackstar_ticketseller').width();
2215 btn_height = jQuery('.blackstar_ticketseller').height();
2216 jQuery('.blackstar_ticketseller').prop('disabled', true);
2217 if (!jQuery('.blackstar_modal').html()) {
2218 var debug = '';
2219 var pu = sitename+pathname+'?' + debug + 'event_id='+event_id+(lang ? '&lang='+lang : '')+(payment_finish_order_id ? '&order_id='+payment_finish_order_id : '')+(payment_finish_secret ? '&secret='+payment_finish_secret : '');
2220 if(getParameterByName('shemeNew') == 'Y') {
2221 pu += '&shemeNew=Y';
2222 }
2223 if(getParameterByName('suffix')) {
2224 pu += '&suffix=' + getParameterByName('suffix');
2225 }
2226 if(getParameterByName('branch')) {
2227 pu += '&branch=' + getParameterByName('branch');
2228 }
2229 if(getParameterByName('force_show')) {
2230 pu += '&force_show=Y';
2231 }
2232 if(getUserEmailFromCookie() && getUserPhoneFromCookie()) {
2233 pu += '&savedEmail=' + getUserEmailFromCookie() + '&savedPhone=' + getUserPhoneFromCookie();
2234 }
2235 if(expired_order) {
2236 pu += '&expired_order=' + expired_order;
2237 }
2238 if(branch!== null)
2239 {
2240 pu += '&branch=' + branch;
2241 pu += '&nosave=true';
2242 pu += '&nocache=true';
2243 pu += '&sheme=Y';
2244 }
2245 //console.log(pu)
2246 if(getParameterByName('cssmin') == 'N') {
2247 loadStyle(sitename + pathname + 'css/reset.css?' + Math.random());
2248 loadStyle(sitename + pathname + 'css/new.css?' + Math.random());
2249 loadStyle(sitename + pathname + 'css/mediaqueries.css?' + Math.random());
2250 } else {
2251 loadStyle(sitename + pathname + 'css/minify.css?' + minified_css_timestamp, step1_height);
2252 }
2253 jQuery.ajax({ type: 'post', url: pu, async: true, success: function(data) {
2254 speedtest('Post 1 Done.');
2255 jQuery('body').addClass('widget-loaded').append('<div class="blackstar_shadow"></div><div style="display:none" class="blackstar_modal" id="tiwo_widget_wrapper">'+data+'</div>');
2256 jQuery('.blackstar_modal').css({
2257 'z-index': '1000', position: 'fixed',
2258 top: 0, right: 0, left: 0, bottom: 0,
2259 height: '100%'
2260 });
2261 isTableView = jQuery('.free-tickets.grow').length > 0;
2262 speedtest('Post 1 Done333.');
2263
2264 var $stepItems = jQuery('.steps .content').length > 0 ? jQuery('.steps .content .item') : jQuery('.steps .steps-content .item');
2265 $stepItems.click(function() {
2266 var step = jQuery(this).index() + 1;
2267 if(jQuery(this).hasClass('active')) {
2268 showCartElements(step);
2269 }
2270 });
2271 speedtest('Post 1 Done343.');
2272
2273 if (payment_finish_event_id) {
2274 jQuery('body').on('click', '.js-open-confirm-close', function(e) {
2275 e.preventDefault();
2276 jQuery('.blackstar_shadow, .blackstar_modal').hide();
2277 window.location.hash='';
2278 location.reload();
2279 });
2280 } else {
2281 jQuery('body').on('click', '.js-open-confirm-close', function(e) {
2282 var isTicketInCart = parseInt(jQuery('.have_tickets .bs_tickets_count').text()) > 0;
2283 if (isTicketInCart) {
2284 jQuery('.have_tickets').show();
2285 } else {
2286 jQuery('.have_tickets').hide();
2287 }
2288 if(!isTicketInCart) {
2289 window.location.hash='';
2290 window.location.reload();
2291 } else {
2292 modalConfirm_bPopup = jQuery('.modal-confirm-close').bPopup({
2293 appendTo :'#tiwo_widget_wrapper',
2294 closeClass:'modal-close'
2295 });
2296 }
2297 });
2298 }
2299 // Ñкопировал Ñюда куÑок, каÑтомные Ñчетчики не работали
2300 yacode = jQuery('input[name="yacode"]').val();
2301 if (yacode) {
2302 var YandexScriptCustom = document.createElement("script");
2303 YandexScriptCustom.innerHTML = '(function (d, w, c) {(w[c] = w[c] || []).push(function() {try {w.yaCounter'+yacode+' = new Ya.Metrika({id:'+yacode+',clickmap:true,trackLinks:true,accurateTrackBounce:true,webvisor:true});} catch(e) { console.log(e) }}); var n = d.getElementsByTagName("script")[0],s = d.createElement("script"),f = function () { n.parentNode.insertBefore(s, n); };s.type = "text/javascript";s.async = true;s.src = "https://mc.yandex.ru/metrika/watch.js";if (w.opera == "[object Opera]") {d.addEventListener("DOMContentLoaded", f, false);} else { f(); }})(document, window, "yandex_metrika_callbacks");';
2304 prepend('head', YandexScriptCustom);
2305 }
2306 if(window['device'] || typeof(device) != 'undefined') {
2307 if (device.mobile()) {
2308 widgetGoal('w16_mobile', 'event', 'code', 'w16_mobile');
2309 } else if (device.tablet()) {
2310 widgetGoal('w16_tablet', 'event', 'code', 'w16_tablet');
2311 }else{
2312 widgetGoal('w16_desctop', 'event', 'code', 'w16_desctop');
2313 }
2314 }
2315 widgetGoal('w16_buywindow', 'event', 'code', 'w16_buywindow');
2316 //конец манипулÑции Ñо Ñчетчиками
2317 jQuery('.blackstar_ticketseller').prop('disabled', false);
2318 jQuery('.blackstar_shadow').on('click', function(){
2319 jQuery('.blackstar_shadow, .blackstar_modal').hide();
2320 });
2321 loadScriptRecursive(['js/minify.js?' + minified_js_timestamp], function(){
2322 speedtest('loadScriptRecursive Done');
2323 globalCommissionInit('full');
2324 global_free_tickets_init()
2325 jQuery('#total_close').on('click', function(e){
2326 e.preventDefault();
2327 e.stopPropagation();
2328 jQuery('.blackstar_shadow, .blackstar_modal').hide();
2329 if (metaviewport_content) {
2330 jQuery('meta[name="viewport"]').attr('content', metaviewport_content);
2331 } else {
2332 jQuery('meta[name="viewport"]').remove();
2333 }
2334 modalConfirm_bPopup.close();
2335 location.reload();
2336
2337 })
2338
2339 jQuery('.free-tickets').on('click', '.seat', function(e){
2340 jQuery(this).find('.blackstar_place_chkbx').trigger('click');
2341 });
2342
2343 function AddOrRemoveFromCart(obj, json) {
2344 json = json || {};
2345 if(!json.status || json.status != 200) return;
2346 var _this = obj;
2347 if(_this.parent().parent().hasClass('dealer')) {
2348
2349 } else if(_this.parent().parent().hasClass('current')) {
2350 _this.parent().parent().removeClass('current');
2351 _this.html('<span class="open-link-text">'+TiwoTxtMessages.ChooseButton+'</span>' + '<span class="open-link-icon"></span>');
2352 } else {
2353 _this.parent().parent().addClass('current');
2354 _this.html('<span class="open-link-text">'+TiwoTxtMessages.CancelButton+'</span>' + '<span class="open-link-icon"></span>');
2355 }
2356 var summ = json.SUMM, count = json.TICKETS.length ? json.TICKETS.length : Object.size(json.TICKETS), commission_val = json.COMMISSION ? json.COMMISSION : 0;
2357 if (_this.hasClass('checked')) _this.removeClass('checked'); else _this.addClass('checked');
2358
2359 //hack for event type - registration
2360 if (tiwoEventType == 3) {
2361 summ = 0;
2362 }
2363
2364 if (summ > 0 || tiwoEventType == 3 && count > 0) {
2365 jQuery('.final-group').show();
2366 jQuery('.widget').addClass('final-group-visible');
2367 jQuery('.blackstar_step1_checkout').css('visibility', 'visible');
2368 } else {
2369 jQuery('.final-group').hide();
2370 jQuery('.widget').removeClass('final-group-visible');
2371 jQuery('.blackstar_step1_checkout').css('visibility', 'hidden');
2372 }
2373
2374 step1_height();
2375 jQuery('#blackstar_step2_summ, #blackstar_summ_preview, .blackstar_summ_preview, .ts-bottom-panel .value').text(summ);
2376 jQuery('.commission_value').text(commission_val);
2377 if (commission_val > 0) {
2378 jQuery('.final-group .commission').show();
2379 } else {
2380 jQuery('.final-group .commission').hide();
2381 }
2382 jQuery('.bs_tickets_count').text(count);
2383 jQuery('.bs_tickets_title').text(declOfNum(count, TiwoTxtMessages.ticketsCountsArray));
2384 jQuery('.step1 .final-group .total-title:eq(1), .step2 .final-group .total-title:eq(1), .ts-bottom-panel .total-title').text(declOfNum(count, TiwoTxtMessages.ticketsCountsArray)+(isMobile == 1?'':', '+ TiwoTxtMessages.ticketsCountsToPay+' '));
2385 updateOldSumm(json.OLD_SUMM);
2386 }
2387
2388 jQuery('.free-tickets').on('click', '.blackstar_place_chkbx', function(e) {
2389 e.preventDefault();
2390 e.stopPropagation();
2391 if(TiwoBasket.basketItems.length >= tiwo_cart_max_tickets && !jQuery(this).hasClass('checked')){
2392 e.stopPropagation();
2393 show_modal_too_much();
2394 } else {
2395 var idtick = jQuery(this).data('id'), _this = jQuery(this);
2396 if (jQuery(this).hasClass('checked')) {
2397 removeFromBasket(false, idtick, false, function(result) {
2398 AddOrRemoveFromCart(_this, result);
2399 });
2400 } else {
2401 checkTicketAndAddToBasket(false , idtick, false, function(result){
2402 mystatus = result.status;
2403 if(typeof mystatus != "undefined") {
2404 if(mystatus == 200) {
2405 AddOrRemoveFromCart(_this, result);
2406 } else {
2407 jQuery('.tickeybusy').bPopup({
2408 appendTo :'#tiwo_widget_wrapper',
2409 closeClass:'modal-close',
2410 zIndex: 100000
2411 });
2412 }
2413 }
2414 })
2415 }
2416 }
2417 })
2418 /** Alexey - Ñмена активного ÑпоÑоба оплаты */
2419 jQuery('.ts-payment-methods .ts-payment-methods__link').on('click', function(e){
2420 e.preventDefault();
2421 jQuery('.ts-payment-methods .ts-payment-methods__link').removeClass('current');
2422 jQuery(this).addClass('current');
2423 orderPayMethod = jQuery(this).data('payment-type');
2424 //console.log('orderPayMethod', orderPayMethod);
2425 var oferta_link = jQuery('a[data-class=oferta]');
2426 var oferta_merchant_link = oferta_link.data('file-merchant');
2427 var oferta_requisites_link = oferta_link.data('file-requisites');
2428 //console.log(oferta_merchant_link, oferta_requisites_link);
2429
2430 if (orderPayMethod == 'invoice') {
2431 jQuery('#ofertaCard').hide();
2432 jQuery('#ofertaInvoice').show();
2433 jQuery('#sopdCard').hide();
2434 jQuery('#sopdInvoice').show();
2435 } else {
2436 jQuery('#ofertaCard').show();
2437 jQuery('#ofertaInvoice').hide();
2438 jQuery('#sopdCard').show();
2439 jQuery('#sopdInvoice').hide();
2440 };
2441 });
2442 /** Обработка дейÑтвий Ñ Ð¿Ð¾Ð»Ñми ввода в форме Ñчета*/
2443 jQuery('#billForm input[type=text], #billForm input[type=tel]').each(function(){
2444 var input_name = this.name;
2445 var input_element = jQuery(this);
2446 if (input_element.data('digitfield'))
2447 {
2448 var incorrect_symbol_text = TiwoTxtMessages.InvalidSymbol;
2449 input_element.on('keypress', function(e){
2450 //console.log(e);
2451 var symbol = (e.which) ? e.which : e.keyCode;
2452
2453 if (symbol < 48 || symbol > 57) {
2454 setBillFieldError(input_element, incorrect_symbol_text);
2455 return false;
2456 } else {
2457 clearBillFieldError(input_element);
2458
2459 }
2460 }).on('focus', function(e){
2461 clearBillFieldError(input_element);
2462 });
2463 };
2464 if (!input_element.data('no-validate'))
2465 {
2466 input_element.on('focus', function(e){
2467 clearBillFieldError(input_element);
2468 }).on('blur', function(e){
2469 var field_name = e.target.name;
2470 var field_value = e.target.value;
2471 if (field_name == 'INN')
2472 {
2473 if (validateInnField(input_element)) {
2474 sendAutoFillAjax('inn', field_value);
2475 }
2476 } else if (field_name == 'BIK')
2477 {
2478 if (validateBikField(input_element)) {
2479 sendAutoFillAjax('bik', field_value);
2480 }
2481 } else {
2482 validateBillField(input_element);
2483 }
2484 });
2485 }
2486 });
2487 jQuery('.blackstar_step4_checkout').on('click', function(event){
2488 event.preventDefault();
2489 jQuery('#dowloadPdfInvoice').click();
2490 });
2491 global_steps_init();
2492
2493 jQuery('.ts-bottom-panel .back').click(function() {
2494 var prevStep = jQuery('body').attr('data-step') - 1;
2495 if(prevStep > 0) {
2496 showCartElements(prevStep);
2497 }
2498 jQuery('.blackstar_step1_checkout').css('opacity', 1);
2499 });
2500
2501 jQuery('.blackstar_step1_checkout').on('click', function(e){
2502 var step = jQuery('body').attr('data-step');
2503 if(!jQuery(this).attr('data-default')) {
2504 jQuery(this).attr('data-default', jQuery(this).find('em').text());
2505 }
2506 switch(step) {
2507 case "1": //Ðа шаг Ñ Ñ„Ð¾Ñ€Ð¼Ð¾Ð¹ клиента
2508 jQuery('.activate_promo').removeClass('success');
2509 changeGlobalStep(3);
2510 jQuery('.ts-bottom-panel .back').css('visibility', 'visible');
2511 if (parseInt(jQuery('#blackstar_step2_summ').text()) <= 0) {
2512 return;
2513 }
2514 jQuery('.step3').show();
2515 widgetGoal('w16_book_1step', 'event', 'button', 'w16_book_1step');
2516 if (window['device'] && device.mobile()) {
2517 jQuery('.common_back').show();
2518 }
2519 jQuery('.step2').hide();
2520 if (document.documentElement.clientWidth <= 992 && document.documentElement.clientWidth > 767) {
2521 var blockHeight = 0;
2522 jQuery('.step3 .form-contact label').each(function(){
2523 blockHeight += jQuery(this).outerHeight();
2524 })
2525 blockHeight += jQuery('.step3 .contacts .bse_title').outerHeight() + 65;
2526 var bseMarginTop = Math.ceil((jQuery('.step3').height() - jQuery('.step3 .left-col').outerHeight() - jQuery('.step3 .steps').outerHeight() - blockHeight) / 2) - 40;
2527 }
2528 if(jQuery('.blackstar_modal input[name="EVENT_ID"]').val() == 235)
2529 jQuery(this).find('em').text("Далее");
2530 else
2531 jQuery(this).find('em').text(TiwoTxtMessages.PayButton);
2532 if(validation() && validation_checkboxes()) {
2533 jQuery(this).prop('disabled', false);
2534 } else {
2535 jQuery('.form-contact label.tiwo_error').removeClass('tiwo_error');
2536 jQuery(this).prop('disabled', true);
2537 }
2538 //jQuery('.ts-bottom-panel .total').hide();
2539 TiwoBasket.updateTTLforBasket();
2540 if(window['$hintBuy']) $hintBuy.hide();
2541 if(window['$hint']) $hint.hide();
2542 break;
2543 case "3": //Оплата
2544 var $btnPaySelf = jQuery(this);
2545 $btnPaySelf.prop('disabled', true);
2546 e.preventDefault();
2547 if (validation() && validation_checkboxes()) {
2548 widgetGoal('w16_book_2step', 'event', 'button', 'w16_book_2step');
2549 var query = {
2550 sid: jQuery('input[name="SESSION_ID"]').val(),
2551 NAME: jQuery('#blackstar_form_contact input[name="NAME"]').val(),
2552 PHONE: jQuery('#blackstar_form_contact input[name="PHONE"]').val(),
2553 EMAIL: jQuery('#blackstar_form_contact input[name="EMAIL"]').val(),
2554 PAY_METHOD : orderPayMethod,//метод оплаты. Либо банковÑкой картой, либо по Ñчету
2555 PAY_SYSTEM_ID : jQuery('.ts-payment-methods .ts-payment-methods__link.current').data('pay_system_id'),
2556 PAY_PS_MERCHANT_ID : jQuery('.ts-payment-methods .ts-payment-methods__link.current').data('ps_merchant_id'),
2557 url_return:window.location.href,
2558 referrer_id:TiwoReferrer.referrer_id,
2559 //PROMO: jQuery('#blackstar_form_contact input[name="PROMO"]').val(), ПОКРÐЕ РЕÐЛИЗОВÐÐО Ð’ ÐПИ
2560 payElem: jQuery('.ts-payment-methods .ts-payment-methods__link.current').data('id'),
2561 //STARS_CLICK_ID: StarsClickId, //еÑли еÑть click_id в параметрах - будет не нулевое значение, и запишем в заказ ПОКРÐЕ РЕÐЛИЗОВÐÐО Ð’ ÐПИ
2562 //lang: data_lang,//текущий Ñзык виджета, в котором Ñделали заказ ПОКРÐЕ РЕÐЛИЗОВÐÐО Ð’ ÐПИ
2563 }
2564 $insideLoader.show();
2565 jQuery.post(sitename+pathname+'ajax/buy.php', query, function(data) {
2566 sendOrderLeadToBsCrm(query);
2567 TiwoBasket.stop();
2568 var json = null, order_id = 0;
2569 json = jQuery.parseJSON(data);
2570 order_id = json.id;
2571 if(json.ERROR == "Y")
2572 {
2573 if (json.messages) {
2574 jQuery.each(json.messages, function (index, value) {
2575 jQuery('#blackstar_form_contact input[name="' + index + '"]').parents('label').addClass('tiwo_error').find('.error_content').text(value);
2576 });
2577 $insideLoader.hide();
2578 return;
2579 }else{
2580 jQuery('.modal-fail-order').bPopup({
2581 appendTo :'#tiwo_widget_wrapper',
2582 closeClass:'modal-close',
2583 zIndex: 100000
2584 });
2585 jQuery('.modal-fail-order .btn2, .modal-fail-order .modal-close').click(function() {
2586 reinit_widget(event_id);
2587 });
2588 $insideLoader.hide();
2589 changeGlobalStep(2);
2590 Raven.captureMessage(window.location.href + ' ошибка ÑÐ¾Ð·Ð´Ð°Ð½Ð¸Ñ Ð·Ð°ÐºÐ°Ð·Ð°');
2591 return;
2592 }
2593 }
2594 invoiceName = pdfInvoicesFileNameTemplate.replace('#order#', order_id.toString());
2595 if(order_id && jQuery.isNumeric(order_id)){
2596 saveUserDataFromOrderToCookies();
2597 if (json) {
2598 if (typeof(ga) != 'undefined') {
2599 ga('require', 'ecommerce');
2600 ga('ecommerce:addTransaction', {
2601 'id': order_id,
2602 'affiliation': window.location.href,
2603 'revenue': json.cart.price,
2604 'shipping': '0', 'tax': '0'
2605 });
2606 jQuery.each(json.cart.items[0].tickets, function() {
2607 //console.log(this);
2608 ga('ecommerce:addItem', this);
2609 });
2610 ga('ecommerce:send');
2611 }
2612 }
2613 jQuery('span.total_cost').text(jQuery('#blackstar_step2_summ').text());
2614 jQuery('input[name="ORDER_ID"]').val(order_id);
2615 widgetGoal('w16_pay_4step', 'event', 'code', 'w16_pay_4step');
2616 TiwoWidgetOrderCreateAfter();
2617 if (query.PAY_SYSTEM_ID == payMethodInvoice)
2618 {
2619 changeGlobalStep(4);
2620 jQuery('#billForm input[name=ORDER_ID]').val(order_id);
2621 jQuery('.step4.payment #cardMethods').hide();
2622 jQuery('.step4.payment #billInvoiceForm').show();
2623 jQuery('body').addClass('billInvoiceStep');
2624 $insideLoader.hide();
2625 jQuery('.step4.payment').show();
2626 jQuery('.step3').hide();
2627 if(isMobile) {
2628 jQuery('.widget').animate({ scrollTop: 0 }, 0);
2629 }
2630 }
2631 else if(query.PAY_SYSTEM_ID == 10 && json.cart.price > 0) //hack for referrer orders (we change ps, so lets go to the link) or its 100%promo
2632 {
2633 initCPPayment(order_id, json);
2634 return;
2635 }
2636 else {
2637 if (json.payment_link) {
2638 //parent.location.href = sitename + json.pay_link;
2639 goToPaymentPage(json.payment_link);
2640 return;
2641 }else{
2642 Raven.captureMessage(window.location.href + ' ORDER_ID = '+ order_id+' не получил ÑÑылку на оплату заказа');
2643 }
2644 }
2645 /*} else {
2646 $insideLoader.hide();
2647 jQuery('.step4 .method .link').eq(0).trigger('click');
2648 }*/
2649 }else{
2650 Raven.captureMessage(window.location.href + ' ошибка ÑÐ¾Ð·Ð´Ð°Ð½Ð¸Ñ Ð·Ð°ÐºÐ°Ð·Ð°');
2651 }
2652 }).always(function() {
2653 $btnPaySelf.prop('disabled', false);
2654 });
2655 } else {
2656 $btnPaySelf.prop('disabled', false);
2657 }
2658 break;
2659 case "4":
2660 /** Оплата по Ñчету - заполнили форму и нажали Оплатить */
2661 if (validateBillForm() && !jQuery('.blackstar_step4_checkout').hasClass('download-invoice'))
2662 {
2663 var dataForm = jQuery('#billForm').serialize();
2664 var order_id = $('#billForm input[name=ORDER_ID]').val();
2665 jQuery.post(sitename + pathname + 'invoice/createBillDocument.php', dataForm, function(dataOrder){
2666 jQuery('.step4.payment #billInvoiceForm').hide();
2667 jQuery('.step4.payment #billInvoiceFinal').html(dataOrder).show();
2668 var link_to_download = jQuery('<a>'+TiwoTxtMessages.BillDownload+'</a>');
2669 link_to_download.attr({
2670 'href' : sitename + pathname + 'invoice/download.php?order=' + order_id,
2671 download : ""
2672 }).css('line-height', '45px').addClass('btn2');
2673 jQuery('#step1_buy_tickets').text(
2674 jQuery('#billInvoiceForm .bse_title #contact_details').data('invoice-funal-text')
2675 );
2676 jQuery('.blackstar_step4_checkout').replaceWith(link_to_download);
2677 jQuery('.have_tickets .bs_tickets_count').empty();
2678 jQuery('.step4.payment #billInvoiceFinal.js-scroll-1').mCustomScrollbar("update");
2679 }, "html");
2680 }
2681 break;
2682 }
2683 });
2684
2685
2686 var bPopupRemove;
2687 jQuery('.basket').on('click', '.remove', function(){
2688 bPopupRemove = jQuery('.js-confirm-remove').bPopup({
2689 appendTo :'#tiwo_widget_wrapper',
2690 amsl: 0, closeClass: 'modal-close'
2691 });
2692 var id = jQuery(this).data('id');
2693 jQuery('.js-confirm-remove .confirm-ticket').hide();
2694 if (id == 'dance'){
2695 jQuery('.js-confirm-remove .place .sector').text(jQuery(this).data('sector'));
2696 jQuery('.js-confirm-remove .price').text(jQuery(this).data('price'));
2697 jQuery('.js-confirm-remove .place > span:not(:first-child)').hide();
2698 jQuery('.js-confirm-remove .remove_confirm').data('sector', jQuery(this).data('sector'));
2699 jQuery('.js-confirm-remove .remove_confirm').data('id', jQuery(this).data('id'));
2700 jQuery('.js-confirm-remove .remove_confirm').data('count', jQuery(this).data('count'));
2701 jQuery('.js-confirm-remove .remove_confirm').data('price', jQuery(this).data('price'));
2702 jQuery('.js-confirm-remove .confirm-ticket.confirm-dance-floor').show();
2703 } else {
2704 jQuery('.js-confirm-remove .place span').show();
2705 jQuery('.js-confirm-remove .place .sector').text(jQuery('.blackstar_place_chkbx[data-id="'+id+'"]').data('sector'));
2706 jQuery('.js-confirm-remove .place .row').text(jQuery('.blackstar_place_chkbx[data-id="'+id+'"]').data('row'));
2707 jQuery('.js-confirm-remove .place .seat').text(jQuery('.blackstar_place_chkbx[data-id="'+id+'"]').data('place'));
2708 jQuery('.js-confirm-remove .price').text(jQuery(this).data('price'));
2709 jQuery('.js-confirm-remove .remove_confirm').data('id', jQuery(this).data('id'));
2710 jQuery('.js-confirm-remove .remove_confirm').data('count', jQuery(this).data('count'));
2711 jQuery('.js-confirm-remove .remove_confirm').data('price', jQuery(this).data('price'));
2712 jQuery('.js-confirm-remove .confirm-ticket').not('.confirm-dance-floor').show();
2713 }
2714 });
2715
2716 jQuery('.js-confirm-remove').on('click', '.remove_confirm', function(){
2717 bPopupRemove.close();
2718 var summ = parseInt(parseFloat(jQuery('#blackstar_step2_summ').text()) - commission_val - jQuery(this).data('price'));
2719 var count = parseInt(jQuery('.bs_tickets_count').html()) - jQuery(this).data('count'), id = jQuery(this).data('id');
2720 if (id == 'dance'){
2721 jQuery('.dance_count[data-sector="'+jQuery(this).data('sector')+'"]').val('0');
2722 jQuery('.basket .remove[data-sector="'+jQuery(this).data('sector')+'"]').parents('.basket-item').remove();
2723 } else {
2724 jQuery('.blackstar_place_chkbx[data-id="'+id+'"]').removeClass('checked');
2725 jQuery('.blackstar_place_chkbx[data-id="'+id+'"]').parent().parent().removeClass('current');
2726 jQuery('.blackstar_place_chkbx[data-id="'+id+'"]').html('<span class="open-link-text">'+TiwoTxtMessages.ChooseButton+'</span>' + '<span class="open-link-icon"></span>');
2727 jQuery('.basket .remove[data-id="'+id+'"]').parents('.basket-item').remove();
2728 }
2729 commission_val = summ * commission / 100;
2730 jQuery('.commission_value').text(commission_val);
2731 summ += commission_val;
2732 jQuery('#blackstar_step2_summ, #blackstar_summ_preview, .blackstar_summ_preview').text(summ);
2733 jQuery('.bs_tickets_count').text(count);
2734 if (summ <= 0) {
2735 jQuery('.sector:not(.dance-floor) .sector-head').children().children('.open-link').html('<span class="open-link-text">'+TiwoTxtMessages.ShowSector+' </span><span class="open-link-icon"></span>');
2736 jQuery('.sector:not(.dance-floor) .sector-head').parent('.opened').removeClass('opened');
2737 jQuery('.row .row-head').children().children('.open-link').html('<span class="open-link-text">'+TiwoTxtMessages.ShowPlaces+'</span><span class="open-link-icon"></span>');
2738 jQuery('.row .row-head').parent('.opened').removeClass('opened');
2739 changeGlobalStep(1);
2740 jQuery('.step1 .final-group').hide();
2741 jQuery('.widget').removeClass('final-group-visible');
2742 step1_height();
2743 } else {
2744 jQuery('.final-group').show();
2745 jQuery('.widget').addClass('final-group-visible');
2746 }
2747 })
2748 jQuery('#blackstar_step2_back').on('click', function(){
2749 jQuery('.sector:not(.dance-floor) .sector-head').children().children('.open-link').html('<span class="open-link-text">'+TiwoTxtMessages.ShowSector+' </span><span class="open-link-icon"></span>');
2750 jQuery('.sector:not(.dance-floor) .sector-head').parent('.opened').removeClass('opened');
2751 jQuery('.row .row-head').children().children('.open-link').html('<span class="open-link-text">'+TiwoTxtMessages.ShowPlaces+'</span><span class="open-link-icon"></span>');
2752 jQuery('.row .row-head').parent('.opened').removeClass('opened');
2753 jQuery('.step1').show();
2754 jQuery('.step2').hide();
2755 jQuery('.step2 .scroll').remove();
2756 jQuery('.choosen-tickets').html('');
2757 changeGlobalStep(1);
2758 })
2759 global_order_init('full')
2760 if(window.widgetStyle) {
2761 jQuery('body').addClass('widget-shown widget-' + widgetStyle);
2762 }
2763 if(buyClickLoader && !addonLoad) fs_loader(false);
2764 if (payment_finish_event_id) {
2765 jQuery('.step1, .right-col .steps, .vh-align-wait').hide();
2766 jQuery('.step4.payment-final').show();
2767 jQuery('body').attr('data-step', 4);
2768 } else {
2769 changeGlobalStep(1);
2770 }
2771 hideStep4();
2772 initCheckoutFormCheck();
2773 speedtest('Popup loaded');
2774 step1_height();
2775 initAjaxLinks();
2776 initLastOrdersBlock();
2777 autoFillOrderFormFromCookies();
2778 initSchemeSwitcher();
2779 TiwoWidgetAfterLoadInit();
2780 TiwoWidgetAfterLoadGoalsProcess();
2781 if(isMobile == 1) {
2782 jQuery('.widget-sheme .js-open-scheme').off('click').click(function() {
2783 changeGlobalStep(1);
2784 });
2785 if(isTableView) {
2786 jQuery('.widget').scroll(function() {
2787 if(jQuery('.widget').scrollTop() > jQuery('.free-tickets.grow').height()) {
2788 jQuery('.step1 .final-group').removeClass('xs-fixed');
2789 } else {
2790 jQuery('.step1 .final-group').addClass('xs-fixed');
2791 }
2792 });
2793 }
2794 jQuery('.back.xs').click(function() {
2795 if(jQuery('body').attr('data-step') > 0) {
2796 changeGlobalStep(jQuery('body').attr('data-step') - 1);
2797 }
2798 });
2799 }
2800 $insideLoader = jQuery('#action-loader');
2801 $insideLoader.hide(0);
2802
2803 if (infowindow) {
2804 console.log('Open hash Link', infowindow);
2805 if (infowindow == 'ht_refund') {
2806 goToRefundStep();
2807 } else {
2808 jQuery('a.widget-ajax-link[data-class="' + infowindow + '"]').click();
2809 location.hash='';
2810 }
2811 }
2812 setTimeout(function() {
2813 jQuery('#action-loader-full').remove();
2814 jQuery('.show-after-widget-load').show().removeClass('show-after-widget-load');
2815 }, 500);
2816
2817 jQuery(".activate_promo").on('click', function(e){
2818 e.preventDefault();
2819 e.stopPropagation();
2820 jQuery(this).removeClass('success');
2821 var promo = jQuery('#blackstar_form_contact input[name="PROMO"]').val();
2822 var event = jQuery('input[name="EVENT_ID"]').val();
2823 var session = jQuery('input[name="SESSION_ID"]').val();
2824
2825 if(promo.length > 0)
2826 {
2827 var isAjaxBusy = false;
2828 jQuery.ajax({
2829 type: 'post',
2830 url: sitename+'/ajax/promo.php',
2831 data: {
2832 'promo' : promo,
2833 'event_id' : event,
2834 'session' : session,
2835 'send_promo' : "Y"
2836 },
2837 dataType: "json",
2838 beforeSend:function(){
2839 if(isAjaxBusy){
2840 return false;
2841 }
2842 else
2843 {
2844 isAjaxBusy = true;
2845 }
2846 },
2847 complete:function(){
2848 isAjaxBusy = false;
2849 },
2850 success: function(msg){
2851 if(msg.SUC == "Y")
2852 {
2853 jQuery('#blackstar_form_contact input[name="PROMO"]').addClass("used_promo");
2854 jQuery('#blackstar_form_contact input[name="PROMO"]').prop("readonly", true);
2855 jQuery(".ts-bottom-panel .total .bs_tickets_count").text(msg.CNT);
2856 jQuery(".ts-bottom-panel .total .total-summ").text(msg.SUMM);
2857 jQuery('.ts-bottom-panel .total .total-title').text(declOfNum(msg.CNT, TiwoTxtMessages.ticketsCountsArray));
2858 jQuery(".ts-bottom-panel .total-summ-old").text(msg.OLD_SUMM).show().css('display', 'inline');
2859 jQuery(".ts-bottom-panel .total .commission_value").text(msg.COMISSION);
2860 jQuery(".ts-bottom-panel .total").show();
2861 jQuery('.step3 .contacts').addClass('total_visible');
2862 jQuery('.error_content.error_promo').hide();
2863 jQuery('.activate_promo').addClass('success').hide();
2864 jQuery('#blackstar_form_contact input[name="NAME"]').trigger('blur');
2865 TiwoWidgetPromoApplyAfter();
2866 }
2867 else
2868 {
2869 if (!tiwoPromoBackgroundSend) {
2870 jQuery('.error_content.error_promo').show();
2871 }else{
2872 tiwoPromoBackgroundSend = tiwoStartPromocode = false;
2873 jQuery('#blackstar_form_contact input[name="PROMO"]').val('');
2874 }
2875 }
2876 }
2877 });
2878 }
2879 });
2880
2881 jQuery(".final-group #back").on('click', function(e){
2882 if(jQuery('#blackstar_form_contact input[name="PROMO"]').length > 0 && jQuery('#blackstar_form_contact input[name="PROMO"]').val().length > 0) {
2883 jQuery.ajax({
2884 type: 'post',
2885 url: sitename+'/ajax/promo.php',
2886 data: {
2887 'event_id' : jQuery('input[name="EVENT_ID"]').val(),
2888 'session' : jQuery('input[name="SESSION_ID"]').val(),
2889 'clear_promo' : "Y"
2890 },
2891 dataType: "json",
2892 success: function(msg){
2893 if(msg.SUC == "Y")
2894 {
2895 jQuery(".ts-bottom-panel .total-summ-old").text("").hide();
2896 jQuery(".ts-bottom-panel .total .total-summ").text(msg.OLD_SUMM);
2897 jQuery('#blackstar_form_contact input[name="PROMO"]').val("");
2898 jQuery('#blackstar_form_contact input[name="PROMO"]').removeClass("used_promo");
2899 jQuery(".ts-bottom-panel .total .commission_value").text(msg.COMISSION);
2900 jQuery('.activate_promo').show();
2901 jQuery('#blackstar_form_contact input[name="PROMO"]').prop("readonly", false);
2902 jQuery('.blackstar_step1_checkout').css('opacity', 1);
2903 TiwoWidgetPromoCancelAfter();
2904 }
2905 }
2906 });
2907 }
2908 TiwoBasket.updateTTLforBasket();
2909 });
2910 jQuery(document).on('click', '.widget-table .clear-all, .widget-switched-to-table .clear-all', function() {
2911 jQuery('.blackstar_place_chkbx.checked').each(function(){
2912 jQuery(this).trigger('click');
2913 });
2914 jQuery('.sector.dance-floor').each(function(){
2915 var dance_count=jQuery(this).find('input.number.dance_count').val();
2916 for (var i=1;i<=dance_count;i++){
2917 jQuery(this).find('.jq-number__spin.minus').trigger('click');
2918 }
2919 });
2920 });
2921 }); //loadScriptRecursive
2922 //}, 'json') //end post
2923 //});
2924 }}); //post popup content
2925 } else {
2926 jQuery('.blackstar_shadow, .blackstar_modal').show();
2927 jQuery('.blackstar_ticketseller').prop('disabled', false);
2928 jQuery('body').addClass('widget-shown');
2929 }
2930 }
2931 // jQuery
2932 if (typeof(jQuery) == 'undefined') {
2933 loadScript('http://ajax.googleapis.com/ajax/libs/jquery/1.12.2/jquery.min.js', main);
2934 } else {
2935 main(data_lang);
2936 }
2937 }
2938 }); //DOM LOADED
2939})()