$(document).ready(function(){
$('a.btn.menu').click(function(){
$('aside.menu').fadeToggle();
return false;
});
$('nav ul.sub_nav').prev().click(function(){
$(this).next().fadeToggle();
return false;
});
$('.obj .tile .item .img').slick({
dots: true,
infinite: true,
arrows: false,
slidesToShow: 1
});
$('section.index .flex .item a').click(function(){$('section.index .to_open').not($(this).next()).slideUp(); $(this).next().slideToggle(); return false;});
/*
$('section.index .flex .item #adv_1').click(function(){$('section.index .to_open > div').slideUp(); $('section.index .to_open #adv_1').slideToggle(); return false;});
$('section.index .flex .item #adv_2').click(function(){$('section.index .to_open > div').slideUp(); $('section.index .to_open #adv_2').slideToggle(); return false;});
$('section.index .flex .item #adv_3').click(function(){$('section.index .to_open > div').slideUp(); $('section.index .to_open #adv_3').slideToggle(); return false;});
*/
$('.cboxElement').colorbox({inline:true});
maskPhone("input[name$=str_phone]");
});
function maskPhone(field) {
$(field).mask("+7 (999) 999-99-99", {
translation: {
'Z': {
pattern: /[0-9]/, optional: true
}
}
});
}
function sendVopros(parent)
{
$(document).css('cursor', 'wait');
var el = $(parent);
$.ajax({
url: "/ajax.php?mid=6",
type: 'POST',
data: el.serialize() + '&mode=send_request',
dataType: "json",
success: function(res){
if (res['success'])
{
ga('send', 'event', 'lead', 'vopros', res['id']);
//yaCounter28279971.reachGoal('makeConsalt');
el.html('
Спасибо за Ваш вопрос. Мы свяжемся с Вами в ближайшее время!
');
setTimeout(function(){$.colorbox.close()}, 5000);
$(document).css('cursor', 'auto');
}
else
{
alert('Ошибка: ' + res['error'] + '. Пожалуйста, повторите попытку или свяжитесь с нами. Приносим извинения за неудобства.');
$(document).css('cursor', 'auto');
}
}
});
return false;
}
function sendCallback(parent)
{
$(document).css('cursor', 'wait');
var el = $(parent);
$.ajax({
url: "/ajax.php?mid=7",
type: 'POST',
data: el.serialize() + '&mode=send_request',
dataType: "json",
success: function(res){
if (res['success'])
{
ga('send', 'event', 'lead', 'callback', res['id']);
//yaCounter28279971.reachGoal('callBack');
if (el.closest('#cboxContent').length)
{
el.html('Спасибо за Вашу заявку. Мы свяжемся с Вами в ближайшее время!
');
setTimeout(function(){$.colorbox.close()}, 5000);
}
else
{
swal('Спасибо!', 'Ваша заявка отправлена. Мы свяжемся с Вами в ближайшее время!', 'success');
el.trigger('reset');
}
$(document).css('cursor', 'auto');
}
else
{
alert('Ошибка: ' + res['error'] + '. Пожалуйста, повторите попытку или свяжитесь с нами. Приносим извинения за неудобства.');
$(document).css('cursor', 'auto');
}
}
});
return false;
}
function scaleMenu()
{
if ($(window).width() < 700)
return;
if (($('aside.menu nav>ul>li').length) * 68 + 222 > $(window).height())
{
var shift = ($('aside.menu nav>ul>li').length + 1) * 68 + 222 - $(window).height();
shift = shift / 4;
if (shift > 40) shift = 40;
$('aside.menu').css('padding-top', 40 - shift / 2 + 'px');
$('aside.menu nav').css('margin-top', 47 - shift / 2 + 'px');
var h = $(window).height() - 222 + shift;
h = h / ($('aside.menu nav>ul>li').length);
$('aside.menu nav ul li a').css('height', h + 'px');
if (h < 42)
{
$('aside.menu nav ul li a').css('font-size', (h-10)/2 + 'px');
}
}
else
{
$('aside.menu nav ul li a').css('height', '');
$('aside.menu nav ul li a').css('font-size', '');
$('aside.menu').css('padding-top', '');
$('aside.menu nav').css('margin-top', '');
}
}
function sendOtzyv(parent){
$(document).css('cursor', 'wait');
var el = $(parent);
$.ajax({
url: "/ajax.php?mid=3",
type: 'POST',
data: el.serialize() + '&action=send',
dataType: "json",
success: function(res){
console.log(res.status);
console.log(res.result);
if(res.status == 'sucess' && res.result == 1){
$('div.reviews-form').html('');
$('div.reviews-form').html('Ваш отзыв опубликован!
');
var html = '';
html += '
'+ res.name + '
';
html += '
';
html += '
' + res.text +'
';
html += '
'+ res.date + '
';
html += '
';
$('div.reviews-form').after(html);
setTimeout(function () {
$('div.reviews-form').hide('slow');
$('div.last-rewiew').show('slow');
}, 1000)
}else{
alert('Что-то пошло не так! И ваш отзыв не отправлен!');
}
},
fail: function(e){
console.log(e);
}
});
}
$(window).load(function() {
scaleMenu();
});
$(window).resize(function(){
scaleMenu();
});