Your IP : 18.227.105.41


Current Path : /home/bitrix/ext_www/ballu.in.ua/promo/airmaster/js/
Upload File :
Current File : /home/bitrix/ext_www/ballu.in.ua/promo/airmaster/js/init.js

(function ($) {
  $(document).ready(function(){
     
	 var mobileSize = 420;

	 wow = new WOW(/*{mobile:false}*/);

	 function initWOW(){
	   if($(window).width()>mobileSize){
		 wow.init();
	   }else{
		 $('.wow').each(function(){ 
		   if($( this ).not('.cycle-slide').css('visibility')=='hidden') $( this ).css('visibility','visible');
		 });
		 wow.stop();
	   }
	 }

    function menuAddHeandler(){
	  var el = document.getElementById('hamburger-icon');
	  var ev = $._data(el,'events');
	  if($(window).width()<=mobileSize && !ev){
	    var hamburger = $(el);
	    var overlay   = $('.overlay-wrapper');
	    hamburger.click(function() {
          hamburger.toggleClass('active');
	      overlay.toggleClass('active');
          return false;
	    });
	    $('nav a').click(function() {
		    event.preventDefault();
		    var target = $(this.getAttribute('href'));
		    hamburger.removeClass('active');
		    overlay.removeClass('active');
            $('html, body').stop().animate({
              scrollTop: target.offset().top
            }, 1000);
	    });
		$('nav em').click(function() {
		    event.preventDefault();
		    hamburger.removeClass('active');
		    overlay.removeClass('active');
            $('html, body').stop().animate({
              scrollTop: 0
            }, 1000);
	    });
	  }
	  var evs = $._data( $('#buybutton')[0],'events');
	  if($(window).width()>mobileSize && !evs){
	    $('#buybutton').click(function() {
		  event.preventDefault();
          $('html, body').stop().animate({
              scrollTop: $('#buybutton-buy-block').offset().top
          }, 1000);
	    });
	  }
		  	let btn = document.querySelector(".buybutton");
			//
			function magic() {
			  if (window.pageYOffset > 20) {
			    btn.style.opacity = "1";
			  } else {
			    btn.style.opacity = "0";
			  }
			}
			//
			btn.onclick = function () {
			  window.scrollTo(0, 0);
			};

			// When scrolling, we run the function
			window.onscroll = magic;
		}

	/*************************************   Iconset panel  *****************************************/

	$('.idpan a').click(function(){
	  $parent = $(this).closest('.idpan').parent();
	  $parent.find('.itext2').hide();
	  $parent.find('a').removeClass('active');
	  $parent.find('.'+$(this).attr('data-class')).show().addClass('animated fadeIn');
	  $(this).addClass('active');
	  return false;
	});

	/*************************************   Steps line draw  **************************************/

    function getOffset( el ) {
      var rect = el.getBoundingClientRect();
	  var p = $( el );
      var position = p.position();
	  var offset = p.offset();

      return {
        left: offset.left,
        top: position.top,
        width: rect.width || el.offsetWidth,
        height: rect.height || el.offsetHeight
      };
    }

	  function stepsDrawLines(){
		  $('.js-line').remove();
		  if($(window).width()>mobileSize){
			  $('.scbtn a').each(function(item){
				  if(typeof $('.scbtn a')[item + 1] !== "undefined"){
					  var off1 = getOffset($(this)[0]);
					  var off2 = getOffset($('.scbtn a')[item + 1]);

					  // center right
					  var x1 = off1.left + off1.width;
					  var y1 = off1.top + (off1.height/2);
					  // center left
					  var x2 = off2.left;
					  var y2 = off2.top + (off2.height/2);
					  // distance
					  var length = Math.sqrt(((x2-x1) * (x2-x1)) + ((y2-y1) * (y2-y1)));
					  // center
					  var cx = x1;
					  var cy = y1;

					  var htmlLine = "<div class='js-line' style='background-color:#8b8b8a;padding:0px; margin:0px; height:1px; line-height:1px; position:absolute; left:" + cx + "px; top:" + cy + "px; width:" + length + "px;' />";
					  $('.scbtn').append(htmlLine);
				  }
			  });
		  }
	  }


    /**************************************   Imagemap process  *****************************************/
    function imageMapResize(){ 
		
	  if($(window).width()<=mobileSize){
	    $('.id7').attr('src','images/d7e.jpg');
	  }else{
		  $('.id7').css('transform','none');
		  if($('.id7').attr('src') != 'images/d7.jpg')  $('.id7').attr('src','images/d7.jpg');
	  }

	  $('#d7').waitForImages(function() {
		$('map').imageMapResize();

        // Image map for mobile version
		if($(window).width()<=mobileSize){
		  
		  $('#Map area').each(function(){
		    var center = {};
			var position = $(this).attr('coords').split(',');
            x1 = position[0];
		    x2 = position[6];
			center[$(this).attr('data-class')] =  (x1*1) + (((x2*1)-(x1*1))/2) +60;

			$('.'+$(this).attr('data-class')+' a').unbind('click').click(function(){

			  var translate = (center[$(this).parent().attr('class')] - ($(window).width()/2));
			  var sign='';
			  if(translate>0) sign="-"; else translate = translate*(-1);			
			  $('.id7').css('transform','translateX('+sign + translate +'px)');
			  $('.scbtn a').removeClass('active');
			  $(this).addClass('active');
			  mobilePagerReposition();
			  $('.scpan span').mHide();
			  $('.scpan').find('.'+$(this).parent().attr('class').substr(0,3)).fadeIn(500,mShow);

			  return false;
			});
		  });
		  $('#d7').off('swipeleft').on('swipeleft', function() {
           if($(this).find('.scbtn-next').is(":visible") == true) $(this).find('.scbtn-next').click();
          });
          $('#d7').off('swiperight').on('swiperight', function() {
             if($(this).find('.scbtn-prev').is(":visible") == true) $(this).find('.scbtn-prev').click();
          });
		   $("area").unbind('click').click(function(){ return false; });
		// End image map for mobile
		}else{
		  $("area").unbind();
		  $("area, .scbtn a").unbind('click').click(function(){ return false; });
	      $("area").mouseenter(function () {
	        $('.'+$(this).attr('data-class')+' a').addClass('active');
          });
	      $("area").mouseleave(function(){
	        $('.'+$(this).attr('data-class')+' a').removeClass('active');
          });
		}
		 
	  });
      
	 
	}

    /****************************************   Cycle slideshow  ****************************************/

	$( '#cycle' ).on( 'cycle-before', function( event, opts ) {
      $('#cycle h3').removeClass('animated').removeClass('fadeInUp');
    });
	$( '#cycle' ).on( 'cycle-after', function( event, optionHash, outgoingSlideEl, incomingSlideEl, forwardFlag) {
      $('h3',incomingSlideEl).addClass('animated fadeInUp');
    });

    /***************************************   Button heandlers  ****************************************/

	$('#d12 .button.first').click(function(){
	 if($('#d12-1').is(":visible") == true){
	   $('#d12-1').fadeOut(500);
	 }else{
	  $('#d12-1').fadeIn(500);
      $('html, body').stop().animate({
        scrollTop: $('#d12-1').offset().top
      }, 500);
	 }
	  return false;
	});

	$('#d12 .first_button').click(function(){
	  $('#popup-overlay').fadeIn(300);
	  $('.popup-submit').addClass('hidden-load').show(0, function(){
	    $('.popup-submit').addClass('animated fadeInDown');
	  });
	  return false;
	});


	$('#other1 .other__button-checkout').click(function(){
	  $('#popup-overlay').fadeIn(300);
	  $('.popup-model1-js').addClass('hidden-load').show(0, function(){
	    $('.popup-model1-js').addClass('animated fadeInDown');
	  });
	  return false;
	});
	$('#other2 .other__button-checkout').click(function(){
	  $('#popup-overlay').fadeIn(300);
	  $('.popup-model2-js').addClass('hidden-load').show(0, function(){
	    $('.popup-model2-js').addClass('animated fadeInDown');
	  });
	  return false;
	});
	$('#other3 .other__button-checkout').click(function(){
	  $('#popup-overlay').fadeIn(300);
	  $('.popup-model3-js').addClass('hidden-load').show(0, function(){
	    $('.popup-model3-js').addClass('animated fadeInDown');
	  });
	  return false;
	});

	$('.popup_js-3').click(function(){
	  $('#popup-overlay').fadeIn(300);
	  $('.popup-model3-js').addClass('hidden-load').show(0, function(){
	    $('.popup-model3-js').addClass('animated fadeInDown');
	  });
	  return false;
	});
	$('.popup_js-2').click(function(){
	  $('#popup-overlay').fadeIn(300);
	  $('.popup-model2-js').addClass('hidden-load').show(0, function(){
	    $('.popup-model2-js').addClass('animated fadeInDown');
	  });
	  return false;
	});
	$('.popup_js-1').click(function(){
	  $('#popup-overlay').fadeIn(300);
	  $('.popup-model1-js').addClass('hidden-load').show(0, function(){
	    $('.popup-model1-js').addClass('animated fadeInDown');
	  });
	  return false;
	});

	$('.popup_js-oneair').click(function(){
	  $('#popup-overlay').fadeIn(300);
	  $('.popup-submit').addClass('hidden-load').show(0, function(){
	    $('.popup-submit').addClass('animated fadeInDown');
	  });
	  return false;
	});

    $('input[type="text"]').bind('blur', function () {
        if(!$(this).val()) $(this).parent().removeClass('active');
    });

    $('input[type="text"]').bind('focus', function () {
        $(this).parent().addClass('active');
    });


	$('.popup .approve').click(function(){
	  var $at = $('.approval-text');
	  var sh = $('.popup').outerHeight();
	 
	  if($at.is(":visible") == true){
		var ah = $at.height();
	    $('.popup').animate({'height':(sh-ah)+'px'},500);
		$('.approval-text').slideUp(500);
	  }else{
		$at.css('visibility','hidden').show(0, function(){
		  var ah = $at.height();
	      $at.css('visibility','visible').hide(0, function(){
	        $('.popup').animate({'height':(((sh*1)+(ah*1))*1) +'px'},500);
		    $at.slideDown(500);
		  });
		});
		
	  }
	  
	  return false;
	});


	/**************************************   Process cities  ***************************************/




	$('.popup .close').click(function(){
	  $(this).closest('.popup').removeClass('hidden-load animated fadeInDown').fadeOut(500);
	  $('#popup-overlay').fadeOut(700);
	  return false;
	});
	  $('.popup-other .close_new').click(function(){
		  $(this).closest('.popup-other').removeClass('hidden-load animated fadeInDown').fadeOut(500);
		  $('#popup-overlay').fadeOut(700);
		  return false;
	  });

	function addScrollbar(){
      if($(window).width()>mobileSize){
        $('#popup-address .popup-content').slimScroll({
          height: '20.833vw',
	      color: '#00bbda',
          size: '3px',
	      railColor: '#8b8b8a',
          railOpacity: 0.5,
          railVisible: true,
          alwaysVisible: true,
        });
	  }else{
	    $('#popup-address .popup-content').slimScroll({
          height: '320px',
	      color: '#00bbda',
          size: '3px',
	      railColor: '#8b8b8a',
          railOpacity: 0.5,
          railVisible: true,
          alwaysVisible: true,
        });
	  }
	}

	/****************************************   Process form  *****************************************/
    $('.popup_oneair-complect form').on('submit',function(){
	  var err = false;
	  
	  var name_model = $(this).find('input[name="name_model"]').val();

	  var price_oneair_models = $(this).find('input[name="price_oneair_models"]').val();

	  var name  = $(this).find('input[name="name"]').val();
	  if(!name){ $(this).find('input[name="name"]').addClass('error'); err = true; console.log('name'); }
	  
	  var phone = $(this).find('input[name="phone"]').val();
	  if(!phone){ $(this).find('input[name="phone"]').addClass('error'); err = true; console.log('phone'); }
	  
	  var e_mail = $(this).find('input[name="e_mail"]').val();
	  
	  var yes  = $(this).find('.checkbox').is(':checked');
	  if(!yes){ $(this).find('.checkbox').addClass('error'); err = true; console.log('checkbox');}

	  var complectation = 'Комплектация: Базовая комплектация Oneair';
	  $('#d12 .checkbox:checked').each(function(){
		complectation += ' + ' + $(this).closest('.bpan').find('.title').text()
	  });
      
	  if(!err){
        $( "#popup-submit .popup-content" ).html('<div class="loader"><div class="lds-css ng-scope"><div style="width:100%;height:100%" class="lds-eclipse"><div></div></div></div></div>');
	  
	    $.post("php/send.php", { 'name_model':name_model,'price_oneair_models':price_oneair_models, 'name':name, 'phone': phone, 'e_mail':e_mail, 'complectation':complectation})
          .done(function( data ) {
            $('.popup_oneair-complect').removeClass('hidden-load animated fadeInDown').fadeOut(500);
            $('#popup-submit').removeClass('hidden-load animated fadeInDown').fadeOut(500);
	        $('#popup-result').addClass('hidden-load').show(0, function(){
		    $('#popup-result').addClass('animated fadeInDown');
			setTimeout(function() {$( "#popup-submit .popup-content" ).html($('#popup-result .popup-content').html());}, 2000);
	      });
        });
	  }
	  else
	  	console.log('something went wrong');
	  return false;
	});

    function getOffsetTop( elem ){
      var offsetTop = 0;
      do {
        if ( !isNaN( elem.offsetTop ) )
        {
            offsetTop += elem.offsetTop;
        }
      } while( elem = elem.offsetParent );
      return offsetTop;
    }

	/****************************************   Process mobile  ***************************************/
    
	function mobileTopIcons(){
	  function closeTopIcons(text){
	    $('#d1-1 .overlay').remove();
		$('#d1-1 .icon').removeClass('highlite').removeClass('active').removeClass('start');
		text.mHide().removeClass('qpane');
		text.find('.close').remove(0);
		text.text(text.text()); // !!!
	  }
	  if($(window).width()<=mobileSize){
	    $('#d1-1 .icon').unbind().bind('click', function(){
          $('#d1-1 .close').click();
	      $('#d1-1').append('<div class="overlay" style="display:none"></div>');
          var text = $(this).parent().find('.text');
	      $(this).parent().find('.text').wrapInner('<span></span>');
	      var close = $('<a href="#" class="close"></a>');
	      text.prepend(close);
          $('#d1-1 .overlay').mShow();//.fadeIn(500,mShow);
	      text.addClass('qpane').mShow();//.fadeIn(500,function(){
		    //${this).parent().find('.icon').addClass('start');
		    //$(this).mShow().parent().find('.icon').addClass('start');
	      //});
	      $('#d1-1 .icon').addClass('highlite');
	      $(this).addClass('active');
	        close.unbind().bind('click',function(){
	          closeTopIcons(text);
		      return false;
	      });
	      return false;
	    });
	  }else{
	    if($('#d1-1 .overlay').length){
	       $('#d1-1 .text.qpane').each(function(){
		     closeTopIcons($(this));
		   });
		}
	  }
	}
	      
	// Mobile wersion additional sliders
    function mobileSlidersProcess(){
	   
      var sliders ={
	    '#d3 .imenu':{log:false,swipe:true,'swipe-fx':'scrollHorz',fx:'scrollHorz', timeout:0,slides:"> a",pager:"#d3 .imenu-pager",next:"#d3 .imenu-next",prev:"#d3 .imenu-prev",clickevent:true},
	    '#d5 .imenu':{log:false,swipe:true,'swipe-fx':'scrollHorz',fx:'scrollHorz',timeout:0,slides:"> a",pager:"#d5 .imenu-pager",next:"#d5 .imenu-next",prev:"#d5 .imenu-prev",clickevent:true},
	    '#d8 .night .imenu':{log:false,swipe:true,'swipe-fx':'scrollHorz',fx:'scrollHorz',timeout:0,slides:"> a",pager:"#d8 .night .imenu-pager",next:"#d8 .night .imenu-next",prev:"#d8 .night .imenu-prev",clickevent:true},
	    '#d8 .day .imenu':{log:false,swipe:true,'swipe-fx':'scrollHorz',fx:'scrollHorz',timeout:0,slides:"> a",pager:"#d8 .day .imenu-pager",next:"#d8 .day .imenu-next",prev:"#d8 .day .imenu-prev",clickevent:true},
        '#d11-1 .slider':{log:false,swipe:true,'swipe-fx':'scrollHorz',fx:'scrollHorz',timeout:0,slides:"> .list",pager:".list-pager",},
        '#d9-1 .mobpan':{log:false,swipe:true,'swipe-fx':'scrollHorz',fx:'scrollHorz',timeout:0,slides:"> span",pager:".mobpan-pager",},
	  }
		
	  $.each(sliders,function(k,v){
		if($(window).width()<=mobileSize){
		  if($(k).data('cycle.opts') === undefined){
		    $(k).cycle(v);
		    if(v.clickevent)  $(k).on( 'cycle-before', function(event, optionHash, outgoingSlideEl, incomingSlideEl, forwardFlag){$(incomingSlideEl).click();});
		  }
		}else{
			if($(k).data('cycle.opts') !== undefined) $(k).cycle('destroy');
		}
	  });
    }

    // Mobile version filter pager position 
	function mobilePagerReposition(){
	  if($(window).width()<=mobileSize){
        $('.scbtn a').mHide();
	    if($('.scbtn a.active').length == 0) $('.scbtn a').first().addClass('active');
	   
	    var $abtnpr = $('.scbtn a.active');
	    var $nbtnpr = $abtnpr.parent().next().find('a');
	    var $pbtnpr = $abtnpr.parent().prev().find('a');
	    var $snbtnpr = $abtnpr.parent().next().next().find('a');
	    var $spbtnpr = $abtnpr.parent().prev().prev().find('a');
	    $abtnpr.removePrefixedClasses('mpager-').mShow().addClass('mpager-active');
	    if($spbtnpr.length) $spbtnpr.removePrefixedClasses('mpager-').mShow().addClass('mpager-sub-prev');
        if($pbtnpr.length)  $pbtnpr.removePrefixedClasses('mpager-').mShow().addClass('mpager-prev');
	    if($nbtnpr.length)  $nbtnpr.removePrefixedClasses('mpager-').mShow().addClass('mpager-next');
        if($snbtnpr.length) $snbtnpr.removePrefixedClasses('mpager-').mShow().addClass('mpager-sub-next')

	    if(!$pbtnpr.length) $('.scbtn-prev').hide(); else $('.scbtn-prev').show();
		if(!$nbtnpr.length) $('.scbtn-next').hide(); else $('.scbtn-next').show()
		$('.scbtn-prev').unbind('click').bind('click',function(){$pbtnpr.click();})
	    $('.scbtn-next').unbind('click').bind('click',function(){$nbtnpr.click();})
      }
	}

	function mobileDayNightSwitcher(){
      if($(window).width()<=mobileSize){
		if(!$('.moon').hasClass('active')){
          $('.moon').addClass('active');
	      $('.to-sun').mShow();
		}else $('.to-moon').mShow();

	    $('.to-sun,.sun').unbind('click').click(function(){
		  $('.to-sun').addClass('hidden');
		  $('.to-moon').fadeIn(500,mShow);
		  $('.id8').addClass('translate50').removeClass('translate10');
		  $('.moon').removeClass('active');
		  $('.sun').addClass('active');
		  $('.night').fadeOut(500,mHide);
		  $('.day').fadeIn(500,mShow);
	    });
	    $('.to-moon,.moon').unbind('click').click(function(){
		  $('.to-moon').addClass('hidden');
	      $('.to-sun').fadeIn(500,mShow);
		  $('.id8').addClass('translate10').removeClass('translate50');
		  $('.sun').removeClass('active');
		  $('.moon').addClass('active');
		  $('.night').fadeIn(500,mShow);
		  $('.day').fadeOut(500,mHide);
	    });

		$('.day-night').off('swipeleft').on('swipeleft', function() {
           $(this).find('.sun').click();
        });
        $('.day-night').off('swiperight').on('swiperight', function() {
           $(this).find('.moon').click();
        });
	  }else{
	    $('.to-sun').hide();
	    $('.to-moon').hide();
	  }
	}



	function mobileCityList(){
      if($(window).width()<=mobileSize){
	    $('#d12-1 .ccol').each(function(k,v){
	      if((k/3) === parseInt((k/3), 10) && k!=0) $(this).addClass('leftclear');
	    });
	  }
	}

	function mobileReviews(){
	  if($(window).width()<=mobileSize){
        if($('#cycle2').data('cycle.opts') !== undefined) $('#cycle2').cycle('destroy');
		
		if(!$('.moreellipses').length){
		var showChar = 300;
	    var ellipsestext = "...";
	    var moretext = "Развернуть";
	    var lesstext = "Свернуть";
		
		$('#d13 .text').each(function(){
		   
		  var span = $(this).find('span')[0].outerHTML;
		  $(this).find('span').remove();
		  $(this).text($(this).text());
		  if($(this).text().length > showChar){
			var c =  $(this).text().substr(0, showChar);
			var h =  $(this).text().substr(showChar, $(this).text().length - showChar);
			$(this).html( c + '<span class="moreellipses">' + ellipsestext+ '&nbsp;</span><span class="morecontent"><span>' + h + '</span>&nbsp;&nbsp;<a href="" class="morelink">' + moretext + '</a></span>');
		  }
		});
		$(".morelink").click(function(){
		  if($(this).hasClass("less")) {
			$(this).removeClass("less");
			$(this).html(moretext);
			$(this).parent().prev().mShow().addClass('inline');
		    $(this).prev().mHide();
		  } else {
			$(this).addClass("less");
			$(this).html(lesstext);
			$(this).parent().prev().mHide().removeClass('inline');
		    $(this).prev().mShow();
		  }
		  
		  return false;
	    });
		}
		
		$('#cycle2 .slide').each(function(k,v){
		  if(k!=0) $(this).mHide();
		});

	    if($('.morereviews').length) $('.morereviews').remove();
		var more = $('<a href="#" class="morereviews">Еще отзывы...</a>');
	    $('#cycle2').append(more);
		more.unbind('click').click(function(){
		  $('#cycle2 .slide').each(function(k,v){
		    $(this).mShow();
		  });
		  $(this).remove();
		  return false;
		});
	  }else{
		if($('#cycle2').data('cycle.opts') === undefined){
		  $('#cycle2').cycle({
		    swipe:true,
            'swipe-fx':'fade',
            fx:'fade',
		    log:false,
            timeout:0,
		    slides:'> div',
		    pager:'.cycle-pager-reviews'
		  });
		}
	  }
	}

	function onResize(){
	  menuAddHeandler();
	  initWOW();
	  mobileTopIcons();
	  stepsDrawLines();
	  imageMapResize();
	  mobileSlidersProcess();
	  mobilePagerReposition();
	  mobileDayNightSwitcher();
	  /*mobileBuyPanel();*/
	  mobileCityList();
	  addScrollbar();
	  mobileReviews();
	 
	  //console.log('orientationchange');
	}

    // Resize events  
	window.addEventListener('orientationchange', onResize);
	$(window).resize( $.debounce( 250, onResize) );
	
	// INIT
	menuAddHeandler();
	initWOW();
	mobileTopIcons();
    stepsDrawLines();
	imageMapResize();
	mobileSlidersProcess();
	mobilePagerReposition();
	mobileDayNightSwitcher();
	mobileCityList();
	addScrollbar();
	mobileReviews();
	
	

  }); // END DOCUMENT READY




  // Mutatless hide & show
  function mShow(){$(this).removeClass('hidden').css('display','inherit')}
  function mHide(){$(this).addClass('hidden').css('display','inherit')}

  jQuery.fn.extend({
    mShow: function () {$(this).removeClass('hidden').css('display','inherit'); return $(this);},
	mHide: function () {$(this).addClass('hidden').css('display','inherit'); return $(this);},
	removePrefixedClasses: function (prefix) {
      var classNames = $(this).attr('class').split(' '),
          className,
          newClassNames = [],
          i;
      //loop class names
      for(i = 0; i < classNames.length; i++) {
        className = classNames[i];
        // if prefix not found at the beggining of class name
        if(className.indexOf(prefix) !== 0) {
          newClassNames.push(className);
            continue;
          }
        }
        // write new list excluding filtered classNames
        $(this).attr('class', newClassNames.join(' '));
	    return $(this);
      }
  });

}( jQuery ));



function buttonOff(){
    document.getElementById(".second").disabled=true;
    document.getElementById(".first").disabled=true;
    }




$(document).ready(function() {

    // compare
    $('.compare__cell').hover(function() {
        var currentIndex = $(this).index();
        $(this).parents('.compare').find('.c-line').each(function(index, el) {
            $(this).find('.compare__cell').eq( currentIndex).addClass('hover');
        });

    }, function() {
        $(this).parents('.compare').find('.c-line').each(function(index, el) {
            $(this).find('.compare__cell').removeClass('hover');
        });
    });



    findCompareItemCellMaxHeight();
	setTimeout(function(){
		$('.compare__cell_same').hide();
	},500);

    $('.compare__slider_oneair').slick({
        infinite: false,
        dots: false,
        arrows:true,
        autoplay: true,
        autoplaySpeed:4000,
        slidesToShow: 3,
        slidesToScroll: 1,
        vertical:false,
        responsive: [
        	{
                breakpoint: 1441,
                settings: {
                    slidesToShow: 3,
                    slidesToScroll: 3,
                    arrows: true
                }
            },
            {
                breakpoint: 1025,
                settings: {
                    slidesToShow: 2,
                    slidesToScroll: 2,
                }
            },
            {
                breakpoint: 569,
                settings: {
                    slidesToShow: 1,
                    slidesToScroll: 1,
                }
            }

        ]

    });



    //short compare list or long list
    $('.control_delete').click(function() {
        $(this).toggleClass('active');
        var slideToggleCnt = $(this).parents('.compare').find('.compare__cell_same').length;
        $(this).parents('.compare').find('.compare__cell_same').slideToggle('slow',function(){
            slideToggleCnt = slideToggleCnt;
            if(slideToggleCnt === 0){
                findCompareItemCellMaxHeight();


                $(document).trigger('resize');
                $('html,body').animate({
                        scrollTop: $(this).parents('.compare').offset().top},
                    'fast');
            }

        });

    });
    //color
    $('.colors__item').click(function() {
        $('.colors__item').removeClass('active');
        $(this).addClass('active');
    });


});

//function to fix compare block cells height
function  findCompareItemCellMaxHeight()
{
    var maxHeights = [];
    setTimeout(function () {
        $('.compare').each(function() {
            currentCompare = $(this);
            for(j=0; j<currentCompare.find('.c-line .compare__cell').length / currentCompare.find('.c-line').length; j++)
            {
                height = 0;

                for(i=0; i < currentCompare.find('.c-line').length; i++)
                {
                    cell = currentCompare.find('.c-line').eq(i).find('.compare__cell').eq(j);

                    if(cell.is(":visible") === true)
                    {
                        if(height < cell.height())
                        {
                            height = cell.height();
                        }
                    }
                }
                maxHeights.push(height);
            }
            currentCompare.find('.compare__cell').each(function(){
                var index = $(this).index();
                if(maxHeights[index] > 0){
                    $(this).height(maxHeights[index]);
                }
            });
        });

    }, 500);
}

$(document).ready(function(){
	if($(window).width()<769) {
	    $('.other-slides').slick({
	        infinite: false,
	        dots: true,
	        arrows:true,
	        autoplay: true,
	        autoplaySpeed:4000,
	        slidesToShow: 2,
	        slidesToScroll: 2,
	        vertical:false,
	        responsive: [
	            {
	                breakpoint: 569,
	                settings: {
	                    slidesToShow: 1,
	                    slidesToScroll: 1,
	                }
	            }

	        ]

	    });
	}

	$('.podrobnee_block').hide();


	$('.other_js').click(function(){
		$(this).parents('.other_block1').next('.podrobnee_block').slideToggle(300);

		if($(this).parents('.other_block1').next('.podrobnee_block').find('.slick-initialized').length>0) {
			$(this).parents('.other_block1').next('.podrobnee_block').find('.other-slides').slick('unslick');
		}
		if($(window).width()<769) {
		    $(this).parents('.other_block1').next('.podrobnee_block').find('.other-slides').slick({
		        infinite: false,
		        dots: true,
		        arrows:true,
		        autoplay: true,
		        autoplaySpeed:4000,
		        slidesToShow: 2,
		        slidesToScroll: 2,
		        vertical:false,
		        responsive: [
		            {
		                breakpoint: 569,
		                settings: {
		                    slidesToShow: 1,
		                    slidesToScroll: 1,
		                }
		            }

		        ]

		    });
		}
		

		return false;
	});
});


if($(window).width()<769) {
	$('.installation-oneair').slick({
		infinite: true,
		dots: true,
		arrows: false,
		slidesToShow: 1,
		slidesToScroll: 1,
		autoplay: false
	});
}

//cities
$('.js-show-city-block').click(function(e){
	e.preventDefault();
	$(this).parents('.tech_block').find('.css-cities-list').slideToggle('fast');
	$('html,body').animate({
			scrollTop: $(this).parents('.tech_block').find('.css-cities-list').offset().top},
		'slow');
});
$('.city__item').click(function(e) {
	e.preventDefault();

	var currentObject = $(this);
	var country =  $(this).attr('data-country');
	var city =  $(this).attr('data-city');
	var city_name =  $(this).text();
	var category =  $(this).attr('data-category');
	var link = '' + $(this).attr('href') +'&format=json'+ '';

	$.getJSON(link, function( data ) {
		var obj = data;
		var text = '';
		$.each( data, function( key, val ) {
			var output = '';
			for (var property in val)
			{
				text += '<div class="shops__item">';
				var shop = val[property];
				if (shop.name !== null) {
					text += '<div class="shops_name">' + shop.name + '</div>';
				}
				if (shop.address !== null) {
					text += '<div class="shops_line">' + shop.address + '</div>';
				}
				if (shop.phone !== null) {
					text += '<div class="shops_line">' + shop.phone + '</div>';
				}
				if (shop.site !== null) {
					text += '<div class="shops_line"><a href="http://'+shop.site+'" target="_blank">' + shop.site + '</a></div>';
				}
				text += '</div>';
			}
		});
		$('.cities__modal-block').find('.shops').html(text);
		$('.cities__modal-block').find('.cities__header').text(city_name);

		$('.cities__modal-block').fadeIn('fast', function() {
			$('.cities__modal').addClass('active');
		});
		$('.shops').slimScroll({
			height: '220px',
			color: '#00bbda',
			size: '3px',
			railColor: '#8b8b8a',
			railOpacity: 0.5,
			railVisible: false,
			alwaysVisible: false,
			distance: '3px',
			disableFadeOut:  true,
		});
		/*
		$(".shops").mCustomScrollbar({
			theme:"minimal",
			autoHideScrollbar:false,
			alwaysShowScrollbar: 2
		});
*/
	});

});

$('.cities__close').click(function() {
	$('.cities__modal-block').fadeOut('fast', function() {
		$('.cities__modal').removeClass('active');
	});
	/*$(".shops").mCustomScrollbar("destroy");*/
	$('.shops').slimScroll({destroy:true});
});
$(document).click( function(event){
	if(( $(event.target).closest(".cities__body").length )||($(event.target).closest(".city__item").length))
		return;
	$('.cities__modal-block').fadeOut('fast', function() {
		$('.cities__modal').removeClass('active');
	});
	// $(".shops").mCustomScrollbar("destroy");
	$('.shops').slimScroll({destroy:true});
	event.stopPropagation();
});

$(document).resize(function(event) {
	block14Resize();
	var maxHeights = [];
	findCompareItemCellMaxHeight();
});


/****************************************   Add cities list  **************************************/
if(typeof cities !== "undefined"){
	var counter = 0;
	var html = '';
	var opts = '';
	var list = '';
	$.each(cities, function(key,val){

		counter++;
		if(counter==1) html += '<div class="crow">';
		html +='<div class="ccol"><h5>'+key+'</h5>';
		$.each(val, function(k,v){
			html +='<a href="#">'+v+'</a>';
			opts +='<option value="'+v+'">'+v+'</option>';
			list +='<li>'+v+'</li>';

		});
		html +='</div>';
		if(counter==5){ html += '</div>'; counter=0; }
	});
	// console.log(html);
	$('.css-cities-list').html(html);
}
else {
	// alert('cities.js not found');
}

/**************************************   Process cities  ***************************************/
$('#cities-list').append(opts);
$('.css-cities-list a').click(function(e){

	e.preventDefault();
	$('.cities__modal-block').find('.cities__header').text($(this).text());

	$.post("/php/getaddress.php", { city: $(this).text() }).done(function( data )
	{
		$('.cities__modal-block').find('.shops').html( data );
		$('.cities__modal-block').fadeIn('fast', function() {
			$('.cities__modal').addClass('active');
		});
		$(".shops").mCustomScrollbar({
			theme:"minimal",
			autoHideScrollbar:false,
			alwaysShowScrollbar: 2
		});
	});

	return false;

});

$(function($){
	$(".phone").mask("+38 (099) 999-9999",{placeholder:" "});
});



 $(document).ready(function(){
	 var header = $('.info-partner'),
			scrollPrev = 0;

	$(window).scroll(function() {
		var scrolled = $(window).scrollTop();
	 
		if ( scrolled > 100 && scrolled > scrollPrev ) {
			header.addClass('out');
		} else {
			header.removeClass('out');
		}
		scrollPrev = scrolled;
	});
});