$(document).ready(function() {

  $('.menu-list li').hover(function() {
    $(this).addClass('open');
  }, function() {
    $(this).removeClass('open');
  });
  
  $('.js-gallery a').lightBox({
        imageBlank: '/xtpl/images/lightbox-blank.gif',
	imageLoading: '/xtpl/images/lightbox-ico-loading.gif',
	imageBtnClose: '/xtpl/images/lightbox-btn-close.gif',
	imageBtnPrev: '/xtpl/images/lightbox-btn-prev.gif',
	imageBtnNext: '/xtpl/images/lightbox-btn-next.gif'
  });
  
  $('.js-partners').load(function(){
  
	var gallery = $(this),
		galleryUl = gallery.find("ul"),
		galleryLi = galleryUl.find("li"),
		galleryLiL = galleryLi.length,
		galleryLiH = galleryLi.eq(0).outerHeight(),
		cur = 1;
		
	function gMove(){
		if ( cur+1 < Math.ceil(galleryLiL/2) ){
			cur++;
			galleryUl.animate({"top": -galleryLiH*(cur-1) })
		}else{
			cur=1;
			galleryUl.animate({"top": 0 })
		}
	}
  
	setInterval(gMove, 2000)
  
  }).trigger("load")

  var v = jQuery("#repairs-form").validate({
  	submitHandler: function(form) {
  		jQuery(form).ajaxSubmit({
                        success: function (responseText, statusText, xhr, $form) {
                          if (responseText!="1") {
                            alert("Произошла ошибка при отправлении заявки на ремонт");
                          } else {
                            jQuery("#repairs-form").hide();
                            jQuery("#repairs-form-result").show();
                          }
                        }
  		});
  	}
  });
});
