$(document).ready(function () {
$('a').click(function () {
var id = $(this).attr('href').match(/#.+$/)[0].substr(1);
var offsetTop = $("a[id='" + id + "']").offset().top;
$('body,html').animate({
scrollTop: offsetTop
}, 1000);
return false;
});
$(window).resize(function () {
var w = $(window).width();
if (w > 960 && menu.is(':hidden')) {
menu.removeAttr('style');
}
});
$(window).scroll(function () {
$(".scroll").each(function () {
var window_top = $(window).scrollTop();
var div_top = $(this).offset().top;
var div_1 = $(this).attr('id');
if (window_top > div_top - 120) {
$('.top-menu-scroll').find('li').removeClass('active');
$('.top-menu-scroll').find('a[href="#' + div_1 + '"]').parent().addClass('active');
} else {
$('.top-menu-scroll').find('a[href="#' + div_1 + '"]').parent().removeClass('active');
};
});
});
var formhidden = document.getElementById('form-hidden').children;
var formhidden1 = formhidden[0].cloneNode(true);
if (document.getElementById('insert-form')) {
document.getElementById('insert-form').appendChild(formhidden[0]);
}
if (document.getElementById('insert-form1')) {
document.getElementById('insert-form1').appendChild(formhidden1);
}
$('.maskPhone').mask("+7 (999) 999-9999");
$('div.header-right>form.submit-form input[type=submit]').click(function () {
var targetInputPhone = 'div.header-right>form.submit-form input.maskPhone';
var valuePhone = $(targetInputPhone).val();
if (!valuePhone) {
$(targetInputPhone).css('border', '1px solid #fff');
if (!valuePhone) {
$(targetInputPhone).css('border', '1px solid #fd0101');
}
}
});
$('div#insert-form>form.submit-form input[type=submit]').click(function () {
var targetInputPhone = 'div#insert-form>form.submit-form input.maskPhone';
var valuePhone = $(targetInputPhone).val();
if (!valuePhone) {
$(targetInputPhone).css('border', '1px solid #fff');
if (!valuePhone) {
$(targetInputPhone).css('border', '1px solid #fd0101');
}
}
});
$('div#insert-form1>form.submit-form input[type=submit]').click(function () {
var targetInputPhone = 'div#insert-form1>form.submit-form input.maskPhone';
var valuePhone = $(targetInputPhone).val();
if (!valuePhone) {
$(targetInputPhone).css('border', '1px solid #fff');
if (!valuePhone) {
$(targetInputPhone).css('border', '1px solid #fd0101');
}
}
});
$('div.narrow-part>form.submit-form input[type=submit]').click(function () {
var targetInputPhone = 'div.narrow-part>form.submit-form input.maskPhone';
var valuePhone = $(targetInputPhone).val();
if (!valuePhone) {
$(targetInputPhone).css('border', '1px solid #fff');
if (!valuePhone) {
$(targetInputPhone).css('border', '1px solid #fd0101');
}
}
});
var aelement = document.getElementsByClassName("scroll");
var list = document.getElementsByClassName("top-menu-scroll")[0];
var arr_aelem = [];
var arr_list = [];
var arr = [];
for (var i = 0; i < aelement.length; i++) {
arr_aelem.push('#' + aelement[i].id);
if ('#' + aelement[i].id == list.children[i].children[0].hash) {
continue;
}
for (var j = 0; j < list.childElementCount - 1; j++) {
if ('#' + aelement[i].id == list.children[j].children[0].hash) {
list.insertBefore(list.children[j], list.childNodes[i + 1]);
}
}
}
for (var s = 0; s < list.childElementCount - 1; s++) {
arr_list.push(list.children[s].children[0].hash);
}
arr_list.push('#kontaknaya-informaciya');
for (var m = 0; m < arr_list.length; m++) {
if (arr_aelem.indexOf(arr_list[m]) < 0) {
arr.push(arr_list[m]);
}
}
for (var w = 0; w < arr.length; w++) {
for (var d = 0; d < list.childElementCount - 1; d++) {
if (arr[w] == list.children[d].children[0].hash) {
console.log(d);
list.children[d].parentNode.removeChild(list.children[d]);
}
}
}
});