$(document).ready(function() { var show_cabinet = false; $('.has-datepicker').datepicker({dateFormat: 'dd.mm.yy', showOn:"button", buttonImageOnly:true, buttonImage:"/s/img/icon-calendar.png"}); $('#reasons').mouseout(function(e){ $('.extended-block').removeClass('active'); $('.extended-block-more').hide(); $('.extended-triangle').hide(); }); $('.extended-block').mouseover(function(e){ $('.extended-block').removeClass('active'); $('.extended-block-more').hide(); $('.extended-triangle').hide(); $(this).find('.extended-block-more').show(); $(this).find('.extended-triangle').show(); $(this).addClass('active'); }); $('#why_register').mouseout(function(e){ $('.desc-block').removeClass('active'); $('.desc-block-more').hide(); $('.desc-triangle').hide(); }); $('.desc-block').mouseover(function(e){ e.preventDefault(); $('.desc-block').removeClass('active'); $('.desc-block-more').hide(); $('.desc-triangle').hide(); $(this).find('.desc-block-more').show(); $(this).find('.desc-triangle').show(); $(this).addClass('active'); }); $('#other_docs').mouseover(function(e){ $('.other_docs_menu').show(); var other_width = $('#other_docs').width(); $('.other_docs_menu').css({width: other_width}); }); $('.other_docs_menu').mouseout(function(e){ $('.other_docs_menu').hide(); }); $('#other_docs').mouseout(function(e){ $('.other_docs_menu').hide(); }); $('.close-message').click(function(e){ e.preventDefault(); $(this).closest('li').hide(); var close_action = $(this).data('close'); $.cookie(close_action, true, {path: '/'}); }); // $('.return_to_index').click(function(e){ // e.preventDefault(); // window.location = '/'; // }); function show_overlay() { if ($('.ui-widget-overlay.ui-front').length == 0 ) { $('#cabinet-show').css({'z-index':'101'}); $('body').append('
'); } } function hide_overlay() { $('.ui-widget-overlay.ui-front').remove(); } function hide_popup() { setTimeout(function(){ if ($('#cabinet-popup').data('hover') + $('#cabinet-show').data('hover') == 0) { $('#cabinet-popup').hide(); hide_overlay(); } else { $('#cabinet-popup').show(); } }, 1000) } $('#cabinet-show').click(function(e){ e.preventDefault(); $('#cabinet-popup').show(); show_overlay(); }); $('#cabinet-show').mouseover(function(e){ $(this).data('hover',1); $('#cabinet-popup').show(); show_overlay(); }); $('#cabinet-popup').mouseover(function(e){ $(this).data('hover',1); $('#cabinet-popup').show(); }); $('#cabinet-popup').mouseout(function(e){ $(this).data('hover',0); hide_popup(); }); $('#cabinet-show').mouseout(function(e){ $(this).data('hover',0); hide_popup(); }); $('.captcha_refresh').click(function(e) { e.preventDefault(); var $form = $(this).parents('form'); var url = location.protocol + "//" + window.location.hostname + ":" + location.port + "/captcha/refresh/"; $.getJSON(url, {}, function(json) { $form.find('input[name="captcha_1"]').val(''); $form.find('input[name="captcha_0"]').val(json.key); $form.find('img.captcha').attr('src', json.image_url); }); }); $('input[data-type="number"]').on('input propertychange', function (e) { var el = $(this); var maxlength = el.data('maxlength'); setTimeout(function () { var text = el.val(); var new_text = text.replace(/\D/g,''); if (new_text.length > maxlength) { new_text = new_text.substring(0, maxlength); } if (text != new_text) { el.val(new_text); } }, 200); }); }); function fetch_data(url, async) { // makes ajax call (synced by default) var result = null; $.ajax({ 'async': async || false, 'global': false, 'cache': false, 'url': url, 'dataType': "json", 'timeout': 30000, 'success': function (data) { result = data; } }); return result; } function getUrlVars() { var vars = [], hash; var href = window.location.href; var hashes = href.slice(href.indexOf('?') + 1).split('&'); for (var i=0; i