﻿$(document).ready(function(){
	$('#q_fio').keyfilter(/^[A-Za-zА-Яа-я\s]$/);
	$('#q_email').keyfilter(/[a-zA-Zа-яА-Я0-9\.\-\_\+\@]/);
	$('#q_phone').keyfilter(/[\d\.\)\(\+\-\s]/);
	$('#q_msg').keyfilter(/[A-Za-zА-Яа-я0-9\.\,\;\:\-\_\+\@\(\)\%\!\?\s]/);
	
	$(".cbut").click(function(){
	    var fcustomer = $("#q_fio").val();
	    var ftext = $("#q_msg").val();
	    var fphone = $("#q_phone").val();
	    var fmail = $("#q_email").val();
	    
	    if(fcustomer==""||fmail == ""||fcustomer==""||fmail == ""){
	    	   msg = '<p style="color:red;">поля заполнены неверно</p>';
	    	    $(".fsend1").hide();
	    	    $("#q_answer").css("opacity", "1");
	    	    $("#q_answer").css("display", "block");
	        	$("#q_answer").html('<p style="color:red;">поля заполнены неверно</p>');
	        	$("#q_answer").animate({"opacity":0}, 2000, function(){
	        		$("#q_answer").css("display", "none");
		    	    $(".fsend1").fadeIn();
	        	});
    	}else{
		    $("#q_answer").html("пожалуйста подождите...");
		    $.post("/ajax/mail.php",{'q_fio':fcustomer,'q_email':fmail,'q_msg':ftext,'q_phone':fphone},function(msg){
		       if((fcustomer!="" && fmail!="")){
		    	   msg = '<p style="color:green;">cообщение отправлено</p>';
		       }else{
		    	   msg = '<p style="color:red;">поля заполнены неверно</p>';
			   }
			    $(".fsend1").hide();
			    $("#q_fio, #q_phone, #q_msg, #q_mail").val("");
	    	    $("#q_answer").css("opacity", "1");
		        	$("#q_answer").show();
		        	$("#q_answer").html(msg);
		        	$("#q_answer").fadeOut(3000);  
		 }); 
	    }
	return false;
	});
});
$(function(){
$(".top_menu li:last").addClass("blog_a");

var animate=0;

var body_height = $(window).height();
var content_height = $(".container").height();
if (content_height < body_height ) {
    $(".container").css("minHeight", body_height+"px");
}


var cont_height = $(".container").height();
$(".favor_podl").height(cont_height);

$(window).resize(function(){
    var body_height = $(window).height();
    var content_height = $(".container").height();
    $(".container").css("minHeight", body_height+"px");

    //слайдер на главной
    var win_width = $(".container").width()-140;
    var li3 =win_width/3;
    var li4 =win_width/4;
    var li5 =win_width/5;
    if ( win_width < 960 ) { $('.home_slid_ul li').css("width",li3+"px"); $(".nsc3").css("left","-"+li3+"px"); }
    if ( (win_width > 960) && (win_width < 1260) ) { $('.home_slid_ul li').css("width",li4+"px"); $(".nsc3").css("left","-"+li4+"px"); }
    if ( win_width > 1260 ) { $('.home_slid_ul li').css("width",li5+"px");  $(".nsc3").css("left","-"+li5+"px"); }


})

   Cufon.replace('h1, h2, h3, .top_menu, .lang_ul2, .td_numb, .author, .author_ul2 .data b, .rss, .cont_table span, .price span, .li_head');





$('.about_table .tr_head a').click(function() {
    //$(".about_table td").removeClass("act");
    $(".about_table td").animate({
    //width: '50%'
  }, 500, function() {

  });
    var td_numb1=$(this).parent("td").attr("class");
    //document.title=td_numb1;
    //$('.'+td_numb1).addClass("act");
    $('.'+td_numb1).animate({
    width: '50%'
  }, 500, function() {
        //$('.'+td_numb1).addClass("act");
  });

    return false;
});




$('.col2 .col_numb a').click(function() {
    var this_class = $(this).parent("div").parent("div").attr("class");
    if (this_class=="col col2 act")   {}
    else {
            var heights = [];  // переменная, которая будет хранить высоты элементов
            $(".col").each(function(indx, element){ // indx - номер элемента в наборе, element - сам элемент
              heights.push($(element).height());
            });
            heights.sort();
            heights.reverse();
            maxi = heights[0];
            $(".cols").animate({ height: maxi+''  }, 300, function() {    });
        $(".team_item").hide();
        $(".col3").animate({   width: '22%', fontSize: '8px'   }, 300, function() {  $(".cols div").removeClass("act");  });

        $(".col3 tdd").animate({    width: '65px', height: '130px'   }, 500, function() { $(this).addClass("act");});
        $(".col3 img").animate({    width: '65px'   }, 500, function() { $(this).addClass("act");});
        $(".col2").animate({    width: '47%',      fontSize: '14px'   }, 500, function() {
            $(this).addClass("act");
            var heights = [];  // переменная, которая будет хранить высоты элементов
            $(".col").each(function(indx, element){ // indx - номер элемента в наборе, element - сам элемент
              heights.push($(element).height());
            });
            heights.sort();
            heights.reverse();
            maxi = heights[0];
            $(".cols").animate({ height: maxi+''  }, 300, function() {    });
        });

    }
    return false;
});


$('.col3 .col_numb a').click(function() {
    var this_class = $(this).parent("div").parent("div").attr("class");
    if (this_class=="col col3 act")   {}
    else {
            var heights = [];  // переменная, которая будет хранить высоты элементов
            $(".col").each(function(indx, element){ // indx - номер элемента в наборе, element - сам элемент
              heights.push($(element).height());
            });
            heights.sort();
            heights.reverse();
            maxi = heights[0];
            $(".cols").animate({ height: maxi+''  }, 300, function() {    });
        $(".col2").animate({   width: '21%', fontSize: '8px'   }, 300, function() {  $(".cols div").removeClass("act");  });

        $(".col3 tdd").animate({   height: '230px',  width: '150px'   }, 500, function() { $(this).addClass("act");});
        $(".col3 img").animate({    width: '150px'   }, 500, function() {
            $(this).addClass("act");

        });
        $(".col3").animate({    width: '47%',      fontSize: '14px'   }, 500, function() {
                $(this).addClass("act");
                var heights = [];  // переменная, которая будет хранить высоты элементов
                $(".col").each(function(indx, element){ // indx - номер элемента в наборе, element - сам элемент
                  heights.push($(element).height());
                });
                heights.sort();
                heights.reverse();
                maxi = heights[0];
                $(".cols").animate({ height: maxi+''  }, 300, function() {    });
        });

    }
    return false;
});

$('.scol .col_numb a').click(function() {
    if ($(this).parent("div").parent("div").hasClass("act"))   { }
    else {
        var heights = [];  // переменная, которая будет хранить высоты элементов
        $(".scol").each(function(indx, element){ // indx - номер элемента в наборе, element - сам элемент
          heights.push($(element).height());
        });
        heights.sort();
        heights.reverse();
        maxi = heights[0];
        $(".scols").height(maxi);
        $(".scol").animate({   width: '18%', fontSize: '8px'   }, 300, function() {  $(".scols div").removeClass("act");  });
        $(".col_numb a").animate({   fontSize: '12px'   }, 300, function() {   });
        $(this).parent("div").parent("div").children(".col_numb").children("a").animate({   fontSize: '18px'   }, 300, function() {   });
        $(this).parent("div").parent("div").animate({    width: '33%',      fontSize: '14px'   }, 300, function() {

                $(this).addClass("act");
                var heights = [];  // переменная, которая будет хранить высоты элементов
                $(".scol").each(function(indx, element){ // indx - номер элемента в наборе, element - сам элемент
                  heights.push($(element).height());
                });
                heights.sort();
                heights.reverse();
                maxi = heights[0];
                //$(".scols").animate({ height: maxi+''  }, 300, function() {    });
                $(".scols").css("height","auto");
        });
    }
    return false;
});




$('.ccol3 .col_numb a').click(function() {
    var this_class = $(this).parent("div").parent("div").attr("class");
    if (this_class=="ccol ccol3 act")   {}
    else {
            var heights = [];  // переменная, которая будет хранить высоты элементов
            $(".ccol").each(function(indx, element){ // indx - номер элемента в наборе, element - сам элемент
              heights.push($(element).height());
            });
            heights.sort();
            heights.reverse();
            maxi = heights[0];
            $(".ccols").animate({ height: maxi+''  }, 300, function() {    });

        $(".ccol2").animate({   width: '33%', fontSize: '8px'   }, 300, function() {  $(".ccols div").removeClass("act");  });

        $(".ccol3 .cinput").animate({    width: '250px', paddingTop: '2px', paddingBottom: '2px', marginBottom: '15px'  }, 500, function() { });
        $(".ccol3 .carea").animate({    width: '250px', paddingTop: '2px', paddingBottom: '2px',      fontSize: '14px', marginBottom: '15px'   }, 500, function() { });
        $(".ccol3  .cbut ").animate({    width: '262px',      fontSize: '14px', paddingTop: '0px', height: '18px' }, 500, function() { });
        $(".ccol3").animate({    width: '34%',      fontSize: '14px'   }, 500, function() {
            $(this).addClass("act");
            var heights = [];  // переменная, которая будет хранить высоты элементов
            $(".ccol").each(function(indx, element){ // indx - номер элемента в наборе, element - сам элемент
              heights.push($(element).height());
            });
            heights.sort();
            heights.reverse();
            maxi = heights[0];
            $(".ccols").animate({ height: maxi+''  }, 300, function() {    });
        });
    }
    return false;
});


$('.clcol3 .col_numb a').click(function() {
    var this_class = $(this).parent("div").parent("div").attr("class");
    if (this_class=="clcol clcol3 act")   {}
    else {
            var heights = [];  // переменная, которая будет хранить высоты элементов
            $(".clcol").each(function(indx, element){ // indx - номер элемента в наборе, element - сам элемент
              heights.push($(element).height());
            });
            heights.sort();
            heights.reverse();
            maxi = heights[0];
            $(".clcols").animate({ height: maxi+''  }, 300, function() {    });

        $(".clcol2").animate({   width: '33%', fontSize: '8px'   }, 300, function() {  $(".clcols div").removeClass("act");  });

        $(".clcol3 .cinput").animate({    width: '250px', paddingTop: '2px', paddingBottom: '2px', marginBottom: '15px'  }, 500, function() { });
        $(".clcol3").animate({    width: '34%',      fontSize: '14px'   }, 500, function() {
            $(this).addClass("act");
            var heights = [];  // переменная, которая будет хранить высоты элементов
            $(".clcol").each(function(indx, element){ // indx - номер элемента в наборе, element - сам элемент
              heights.push($(element).height());
            });
            heights.sort();
            heights.reverse();
            maxi = heights[0];
            $(".clcols").animate({ height: maxi+''  }, 300, function() {    });
        });
    }
    return false;
});



$('.ccol2 .col_numb a').click(function() {
    var this_class = $(this).parent("div").parent("div").attr("class");
    if (this_class=="ccol ccol2 act")   {}
    else {
            var heights = [];  // переменная, которая будет хранить высоты элементов
            $(".ccol").each(function(indx, element){ // indx - номер элемента в наборе, element - сам элемент
              heights.push($(element).height());
            });
            heights.sort();
            heights.reverse();
            maxi = heights[0];
            $(".ccols").animate({ height: maxi+''  }, 300, function() {    });

        $(".ccol3").animate({   width: '21%', fontSize: '8px'   }, 300, function() {  $(".ccols div").removeClass("act");  });

        $(".ccol3 .cinput").animate({    width: '140px', paddingTop: '0px', paddingBottom: '0px', marginBottom: '5px'  }, 500, function() { });
        $(".ccol3 .carea").animate({    width: '140px', paddingTop: '0px', paddingBottom: '0px',      fontSize: '8px', marginBottom: '5px'   }, 500, function() { });
        $(".ccol3  .cbut ").animate({    width: '152px',      fontSize: '8px', paddingTop: '3px', height: '15px' }, 500, function() { });
        $(".ccol2").animate({    width: '47%',      fontSize: '14px'   }, 500, function() {
            $(this).addClass("act");
            var heights = [];  // переменная, которая будет хранить высоты элементов
            $(".ccol").each(function(indx, element){ // indx - номер элемента в наборе, element - сам элемент
              heights.push($(element).height());
            });
            heights.sort();
            heights.reverse();
            maxi = heights[0];
            //$(".ccols").animate({ height: maxi+''  }, 300, function() {    });
            $(".ccols").css("height","auto");
        });
    }
    return false;
});


$('.scols .ul_rask1 a').click(function() {
    var this_class = $(this).parent("li").attr("class");
    if (this_class=="act")   {}
    else {
        $(".ul_rask1 li").removeClass("act");
        $(this).parent("li").addClass("act");
        var heights = [];  // переменная, которая будет хранить высоты элементов
        $(".scol").each(function(indx, element){ // indx - номер элемента в наборе, element - сам элемент
          heights.push($(element).height());
        });
        heights.sort();
        heights.reverse();
        maxi = heights[0];
        $(".scols").animate({ height: maxi+''  }, 300, function() {    });
    }
    return false;
});

$('.ccols .ul_rask1 a').click(function() {
    var this_class = $(this).parent("li").attr("class");
    if (this_class=="act")   {}
    else {
        $(".ul_rask1 li").removeClass("act");
        $(this).parent("li").addClass("act");
        $(".dcont").hide();
        $(this).parent("li").children(".dcont").show(300);
        var heights = [];  // переменная, которая будет хранить высоты элементов
        $(".ccol").each(function(indx, element){ // indx - номер элемента в наборе, element - сам элемент
          heights.push($(element).height());
        });
        heights.sort();
        heights.reverse();
        maxi = heights[0];
        //$(".ccols").animate({ height: maxi+''  }, 300, function() {    });
        $(".ccols").css("height","auto");
    }
    return false;
});


$('.team_ul  a').click(function() {

var dtop=parseInt($(document).scrollTop());
    dtop=dtop+100;

    var this_rel = $(this).attr("rel");
    if ($(".team_item"+this_rel).is(":visible")) {$(".team_item"+this_rel).hide();}
    else {

        $(".team_item").hide();
        $(".team_item").css("top", dtop+"px");
        $(".team_item"+this_rel).show();
        var heights = [];  // переменная, которая будет хранить высоты элементов
        $(".col").each(function(indx, element){ // indx - номер элемента в наборе, element - сам элемент
          heights.push($(element).height());
        });
        heights.sort();
        heights.reverse();
        maxi = heights[0];
        $(".cols").css("height", "auto");
    }

    return false;
});






$('.pclose').click(function() {
    $(".team_item").hide();
  //  var heights = [];  // переменная, которая будет хранить высоты элементов
  //      $(".col").each(function(indx, element){ // indx - номер элемента в наборе, element - сам элемент
  //        heights.push($(element).height());
  //      });
  //      heights.sort();
  //      heights.reverse();
  //      maxi = heights[0];
  //      $(".cols").animate({ height: maxi+''  }, 300, function() {    });
    return false;
});


  $(".about_table tr td:last").css("paddingRight","0px");


  $('.clients_ul > li > table > tbody > tr > td > a').click(function() {
    var this_class = $(this).parents("li").attr("class");
    var cucols_height = $(".cucols").height();
    var clients_popup_height = $(this).next("div").height();
    //alert(clients_popup_height);
    //alert(this_class);
    if (this_class=="active")   {}
    else {
        $(".clients_popup").hide();
        if (cucols_height<clients_popup_height) { $(".cucols").css("height", clients_popup_height+"px");}
        $(".clients_ul li").removeClass("active");
        $(this).parent("td").parent("tr").parent("tbody").parent("table").parent("li").addClass("active");
        //$(this).parents("table").next(".clients_popup").show();

        if ($(this).parents("table").next(".clients_popup").children(".client_banner_table").next("p").html()=='') { /* если нет описания то не выводим окно */   }
        else {  $(this).parents("table").next(".clients_popup").show();   }
    }
    return false;
  });

  $('.proj_ul > li > a').click(function() {
    $(".clients_popup").hide();
    var this_class = $(this).parent("li").attr("class");
    var cucols_height = $(".cucols").height();
    var clients_popup_height = $(this).next("strong").next("div").height();
    if (this_class=="active")   {}
    else {
        if (cucols_height<clients_popup_height) { $(".cucols").css("height", clients_popup_height+"px");}
        $(".proj_ul li").removeClass("active");
        $(this).parent("li").addClass("active");
    }
    return false;
  });

  $('.cuclose').click(function() {
        $(".clients_ul li").removeClass("active");
        $(".cucols").css("height", "auto");
        $(".clients_popup").hide();
        return false;
  });

  $('.piclose').click(function() {
        $(".proj_ul li").removeClass("active");
        $(".cucols").css("height", "auto");
        //$(".clients_popup").hide();
        return false;
  });



$('.cucol3 .col_numb a').click(function() {
    $("div.clients_popup").hide();
    var this_class = $(this).parent("div").parent("div").attr("class");
    if (this_class=="cucol cucol3 act")   {}
    else {
            $(".clients_ul li").removeClass("active");
            var heights = [];  // переменная, которая будет хранить высоты элементов
            $(".cucol").each(function(indx, element){ // indx - номер элемента в наборе, element - сам элемент
              heights.push($(element).height());
            });
            heights.sort();
            heights.reverse();
            maxi = heights[0];
            //$(".cucols").animate({ height: maxi+''  }, 300, function() {    });
            $(".cucols").css("height","auto");

        $(".cucol2").animate({   width: '21%', fontSize: '8px'   }, 300, function() {
            //$(".ban_img img").animate({   width: '40px' }, 300, function() {$('.cucol2').removeClass("act");  });
            $(".ban_img img").animate({  }, 300, function() {$('.cucol2').removeClass("act");  });
        });
        $(".cucol2 .col_content").css({overflow: 'hidden', height : '490px'});

        //$(".cucol3 tdd").animate({   height: '230px',  width: '150px'   }, 500, function() { $(this).addClass("act");});
        //$(".cucol3 img").animate({    width: '150px'   }, 500, function() {          $(this).addClass("act");          });
        $(".cucol3").animate({    width: '47%',      fontSize: '14px'   }, 500, function() {
                $(this).addClass("act");
                var heights = [];  // переменная, которая будет хранить высоты элементов
                $(".cucol").each(function(indx, element){ // indx - номер элемента в наборе, element - сам элемент
                  heights.push($(element).height());
                });
                heights.sort();
                heights.reverse();
                maxi = heights[0];
                //$(".cucols").animate({ height: maxi+''  }, 300, function() {    });
                $(".cucols").css("height","auto");
        });

    }
    return false;
});






$('.cucol2 .col_numb a').click(function() {
    var this_class = $(this).parent("div").parent("div").attr("class");
    if (this_class=="cucol cucol2 act")   {}
    else {
            $(".proj_ul li").removeClass("active");
            var heights = [];  // переменная, которая будет хранить высоты элементов
            $(".cucol").each(function(indx, element){ // indx - номер элемента в наборе, element - сам элемент
              heights.push($(element).height());
            });
            heights.sort();
            heights.reverse();
            maxi = heights[0];
            $(".cucols").animate({ height: maxi+''  }, 300, function() {    });
        $(".cucol3").animate({   width: '21%', fontSize: '8px'   }, 300, function() {    $(this).removeClass("act"); });

        //$(".cucol3 tdd").animate({   height: '230px',  width: '150px'   }, 500, function() { $(this).addClass("act");});
        //$(".cucol3 img").animate({    width: '150px'   }, 500, function() {          $(this).addClass("act");          });
        $(".cucol2 .col_content").css({overflow: 'hidden', height : 'auto'});
        $(".cucol2").animate({    width: '47%',      fontSize: '14px'   }, 500, function() {
                //$(".ban_img img").animate({    width: '70px' }, 500, function() { });
                //$(".ban_img img").animate({    height: auto }, 500, function() { });
//                $(".ban_img img").css("width","auto");
                $(this).addClass("act");
                var heights = [];  // переменная, которая будет хранить высоты элементов
                $(".cucol").each(function(indx, element){ // indx - номер элемента в наборе, element - сам элемент
                  heights.push($(element).height());
                });
                heights.sort();
                heights.reverse();
                maxi = heights[0];
                //$(".cucols").animate({ height: maxi+''  }, 300, function() {    });
                 $(".cucols").css("height","auto");
        });

    }
    return false;
});

$('div.sc_menu').each(function(){
        var div = $(this);
    	var ul = $('ul.sc_menu',this),
    		ulPadding = 0;
    	var divWidth = div.width();
    	div.css({overflow: 'hidden'});
    	var lastLi = ul.find('li:last-child');
    	div.mousemove(function(e){
    		var ulWidth = lastLi[0].offsetLeft + lastLi.outerWidth() + ulPadding;
    		var left = (e.pageX - div.offset().left) * (ulWidth-divWidth) / divWidth;
    		div.scrollLeft(left);
    	});
});






$('.cucol3 .col_mask').click(function() {
    $("div.clients_popup").hide();
    var this_class = $(this).parent("div").parent("div").attr("class");
    if (this_class=="cucol cucol3 act")   {}
    else {
            $(".clients_ul li").removeClass("active");
            var heights = [];  // переменная, которая будет хранить высоты элементов
            $(".cucol").each(function(indx, element){ // indx - номер элемента в наборе, element - сам элемент
              heights.push($(element).height());
            });
            heights.sort();
            heights.reverse();
            maxi = heights[0];
            //$(".cucols").animate({ height: maxi+''  }, 300, function() {    });
            $(".cucols").css("height","auto");
        $(".cucol2").animate({   width: '21%', fontSize: '8px'   }, 300, function() {
            //$(".ban_img img").animate({   width: '40px' }, 300, function() {$('.cucol2').removeClass("act");  });
            $(".ban_img img").animate({  }, 300, function() {$('.cucol2').removeClass("act");  });
        });
        $(".cucol2 .col_content").css({overflow: 'hidden', height : '490px'});

        //$(".cucol3 tdd").animate({   height: '230px',  width: '150px'   }, 500, function() { $(this).addClass("act");});
        //$(".cucol3 img").animate({    width: '150px'   }, 500, function() {          $(this).addClass("act");          });
        $(".cucol3").animate({    width: '47%',      fontSize: '14px'   }, 500, function() {
                $(this).addClass("act");
                var heights = [];  // переменная, которая будет хранить высоты элементов
                $(".cucol").each(function(indx, element){ // indx - номер элемента в наборе, element - сам элемент
                  heights.push($(element).height());
                });
                heights.sort();
                heights.reverse();
                maxi = heights[0];
                //$(".cucols").animate({ height: maxi+''  }, 300, function() {    });
                $(".cucols").css("height","auto");
        });

    }
    return false;
});


$('.cucol2 .col_mask').click(function() {
    var this_class = $(this).parent("div").parent("div").attr("class");
    if (this_class=="cucol cucol2 act")   {}
    else {
            $(".proj_ul li").removeClass("active");
            var heights = [];  // переменная, которая будет хранить высоты элементов
            $(".cucol").each(function(indx, element){ // indx - номер элемента в наборе, element - сам элемент
              heights.push($(element).height());
            });
            heights.sort();
            heights.reverse();
            maxi = heights[0];
            $(".cucols").animate({ height: maxi+''  }, 300, function() {    });
        $(".cucol3").animate({   width: '21%', fontSize: '8px'   }, 300, function() {    $(this).removeClass("act"); });

        //$(".cucol3 tdd").animate({   height: '230px',  width: '150px'   }, 500, function() { $(this).addClass("act");});
        //$(".cucol3 img").animate({    width: '150px'   }, 500, function() {          $(this).addClass("act");          });
         $(".cucol2 .col_content").css({overflow: 'hidden', height : 'auto'});
        $(".cucol2").animate({    width: '47%',      fontSize: '14px'   }, 500, function() {
                //$(".ban_img img").animate({    width: '70px' }, 500, function() { });
                //$(".ban_img img").css("width","auto");
                $(this).addClass("act");
                var heights = [];  // переменная, которая будет хранить высоты элементов
                $(".cucol").each(function(indx, element){ // indx - номер элемента в наборе, element - сам элемент
                  heights.push($(element).height());
                });
                heights.sort();
                heights.reverse();
                maxi = heights[0];
                //$(".cucols").animate({ height: maxi+''  }, 300, function() {    });
                $(".cucols").css("height","auto");
        });

    }
    return false;
});




$('.ccol2 .col_mask').click(function() {
    var this_class = $(this).parent("div").parent("div").attr("class");
    if (this_class=="ccol ccol2 act")   {}
    else {
            var heights = [];  // переменная, которая будет хранить высоты элементов
            $(".ccol").each(function(indx, element){ // indx - номер элемента в наборе, element - сам элемент
              heights.push($(element).height());
            });
            heights.sort();
            heights.reverse();
            maxi = heights[0];
            $(".ccols").animate({ height: maxi+''  }, 300, function() {    });

        $(".ccol3").animate({   width: '21%', fontSize: '8px'   }, 300, function() {  $(".ccols div").removeClass("act");  });

        $(".ccol3 .cinput").animate({    width: '140px', paddingTop: '0px', paddingBottom: '0px', marginBottom: '5px'  }, 500, function() { });
        $(".ccol3 .carea").animate({    width: '140px', paddingTop: '0px', paddingBottom: '0px',      fontSize: '8px', marginBottom: '5px'   }, 500, function() { });
        $(".ccol3  .cbut ").animate({    width: '152px',      fontSize: '8px', paddingTop: '3px', height: '15px' }, 500, function() { });
        $(".ccol2").animate({    width: '47%',      fontSize: '14px'   }, 500, function() {
            $(this).addClass("act");
            var heights = [];  // переменная, которая будет хранить высоты элементов
            $(".ccol").each(function(indx, element){ // indx - номер элемента в наборе, element - сам элемент
              heights.push($(element).height());
            });
            heights.sort();
            heights.reverse();
            maxi = heights[0];
            //$(".ccols").animate({ height: maxi+''  }, 300, function() {    });
            $(".ccols").css("height","auto");
        });
    }
    return false;
});


$('.ccol3 .col_mask').click(function() {
    var this_class = $(this).parent("div").parent("div").attr("class");
    if (this_class=="ccol ccol3 act")   {}
    else {
            var heights = [];  // переменная, которая будет хранить высоты элементов
            $(".ccol").each(function(indx, element){ // indx - номер элемента в наборе, element - сам элемент
              heights.push($(element).height());
            });
            heights.sort();
            heights.reverse();
            maxi = heights[0];
            $(".ccols").animate({ height: maxi+''  }, 300, function() {    });

        $(".ccol2").animate({   width: '33%', fontSize: '8px'   }, 300, function() {  $(".ccols div").removeClass("act");  });

        $(".ccol3 .cinput").animate({    width: '250px', paddingTop: '2px', paddingBottom: '2px', marginBottom: '15px'  }, 500, function() { });
        $(".ccol3 .carea").animate({    width: '250px', paddingTop: '2px', paddingBottom: '2px',      fontSize: '14px', marginBottom: '15px'   }, 500, function() { });
        $(".ccol3  .cbut ").animate({    width: '262px',      fontSize: '14px', paddingTop: '0px', height: '18px' }, 500, function() { });
        $(".ccol3").animate({    width: '34%',      fontSize: '14px'   }, 500, function() {
            $(this).addClass("act");
            var heights = [];  // переменная, которая будет хранить высоты элементов
            $(".ccol").each(function(indx, element){ // indx - номер элемента в наборе, element - сам элемент
              heights.push($(element).height());
            });
            heights.sort();
            heights.reverse();
            maxi = heights[0];
            $(".ccols").animate({ height: maxi+''  }, 300, function() {    });
        });
    }
    return false;
});




$('.col2 .col_mask').click(function() {
    var this_class = $(this).parent("div").parent("div").attr("class");
    if (this_class=="col col2 act")   {}
    else {
            var heights = [];  // переменная, которая будет хранить высоты элементов
            $(".col").each(function(indx, element){ // indx - номер элемента в наборе, element - сам элемент
              heights.push($(element).height());
            });
            heights.sort();
            heights.reverse();
            maxi = heights[0];
            $(".cols").animate({ height: maxi+''  }, 300, function() {    });
        $(".team_item").hide();
        $(".col3").animate({   width: '22%', fontSize: '8px'   }, 300, function() {  $(".cols div").removeClass("act");  });

        $(".col3 tdd").animate({    width: '65px', height: '130px'   }, 500, function() { $(this).addClass("act");});
        $(".col3 img").animate({    width: '65px'   }, 500, function() { $(this).addClass("act");});
        $(".col2").animate({    width: '47%',      fontSize: '14px'   }, 500, function() {
            $(this).addClass("act");
            var heights = [];  // переменная, которая будет хранить высоты элементов
            $(".col").each(function(indx, element){ // indx - номер элемента в наборе, element - сам элемент
              heights.push($(element).height());
            });
            heights.sort();
            heights.reverse();
            maxi = heights[0];
            $(".cols").animate({ height: maxi+''  }, 300, function() {    });
        });

    }
    return false;
});


$('.col3 .col_mask').click(function() {
    var this_class = $(this).parent("div").parent("div").attr("class");
    if (this_class=="col col3 act")   {}
    else {
            var heights = [];  // переменная, которая будет хранить высоты элементов
            $(".col").each(function(indx, element){ // indx - номер элемента в наборе, element - сам элемент
              heights.push($(element).height());
            });
            heights.sort();
            heights.reverse();
            maxi = heights[0];
            $(".cols").animate({ height: maxi+''  }, 300, function() {    });
        $(".col2").animate({   width: '21%', fontSize: '8px'   }, 300, function() {  $(".cols div").removeClass("act");  });

        $(".col3 tdd").animate({   height: '230px',  width: '150px'   }, 500, function() { $(this).addClass("act");});
        $(".col3 img").animate({    width: '150px'   }, 500, function() {
            $(this).addClass("act");

        });
        $(".col3").animate({    width: '47%',      fontSize: '14px'   }, 500, function() {
                $(this).addClass("act");
                var heights = [];  // переменная, которая будет хранить высоты элементов
                $(".col").each(function(indx, element){ // indx - номер элемента в наборе, element - сам элемент
                  heights.push($(element).height());
                });
                heights.sort();
                heights.reverse();
                maxi = heights[0];
                $(".cols").animate({ height: maxi+''  }, 300, function() {    });
        });

    }
    return false;
});


$('.scol .col_mask').click(function() {
    if ($(this).parent("div").parent("div").hasClass("act"))   { }
    else {
        var heights = [];  // переменная, которая будет хранить высоты элементов
        $(".scol").each(function(indx, element){ // indx - номер элемента в наборе, element - сам элемент
          heights.push($(element).height());
        });
        heights.sort();
        heights.reverse();
        maxi = heights[0];
        $(".scols").height(maxi);
        $(".scol").animate({   width: '18%', fontSize: '8px'   }, 300, function() {  $(".scols div").removeClass("act");  });
        $(".col_numb a").animate({   fontSize: '12px'   }, 300, function() {   });
        $(this).parent("div").parent("div").children(".col_numb").children("a").animate({   fontSize: '18px'   }, 300, function() {   });
        $(this).parent("div").parent("div").animate({    width: '33%',      fontSize: '14px'   }, 300, function() {

                $(this).addClass("act");
                var heights = [];  // переменная, которая будет хранить высоты элементов
                $(".scol").each(function(indx, element){ // indx - номер элемента в наборе, element - сам элемент
                  heights.push($(element).height());
                });
                heights.sort();
                heights.reverse();
                maxi = heights[0];
                //$(".scols").animate({ height: maxi+''  }, 300, function() {    });
                $(".scols").css("height","auto");
        });
    }


    return false;
});


$('.scol2 .pism_rask > li > a').click(function() {
        var aclass=$(this).parent("li").attr("class");
        if (aclass=="acti") {
          $(this).parent("li").removeClass("acti");
          $(this).parent("li").children(".pism_per").hide();
        }
        else {
          $('.scol2 .pism_rask  li').removeClass("acti");
          $('.scol2 .pism_per').hide();
          $(this).parent("li").addClass("acti");
          $(this).parent("li").children(".pism_per").show();
        }
        $(".scols").css("height", "auto");
        return false;
});

$('.scol4 .pism_rask > li > a').click(function() {
        var aclass=$(this).parent("li").attr("class");
        if (aclass=="acti") {
          $(this).parent("li").removeClass("acti");
          $(this).parent("li").children(".pism_per").hide();
        }
        else {
          $('.scol4 .pism_rask  li').removeClass("acti");
          $('.scol4 .pism_per').hide();
          $(this).parent("li").addClass("acti");
          $(this).parent("li").children(".pism_per").show();
        }
        $(".scols").css("height", "auto");
        return false;
});


$('.scol3 .pism_rask > li > a').click(function() {
        var aclass=$(this).parent("li").attr("class");
        if (aclass=="acti") {
          $(this).parent("li").removeClass("acti");
          $(this).parent("li").children(".pism_per").hide();
        }
        else {
          $('.scol3 .pism_rask  li').removeClass("acti");
          $('.scol3 .pism_per').hide();
          $(this).parent("li").addClass("acti");
          $(this).parent("li").children(".pism_per").show();
        }
        $(".scols").css("height", "auto");
        return false;
});

$('.notarial_link').click(function() {
        $('.scol4 .pism_rask  li').removeClass("acti");
        $('.scol4 .pism_per').hide();
        $('.scol4 .pism_rask  li:eq(1)').addClass("acti");
        $('.scol4 .pism_rask  li:eq(1)').children(".pism_per").show();
        return false;
});


$('.sled_napr').click(function() {
        $(".sled_napr_content").toggle();
        return false;
});

$('.sled_napr2').click(function() {
        $(".sled_napr_content2").toggle();
        return false;
});

$('.sled_napr3').click(function() {
        $(".sled_napr_content3").toggle();
        return false;
});


var win_width = $(".container").width()-140;
var li3 =win_width/3;
var li4 =win_width/4;
var li5 =win_width/5;
if ( win_width < 960 ) { $('.home_slid_ul li').css("width",li3+"px"); $(".nsc3").css("left","-"+li3+"px"); }
if ( (win_width > 960) && (win_width < 1260) ) { $('.home_slid_ul li').css("width",li4+"px"); $(".nsc3").css("left","-"+li4+"px"); }
if ( win_width > 1260 ) { $('.home_slid_ul li').css("width",li5+"px");  $(".nsc3").css("left","-"+li5+"px"); }


var li_numb = 0;
$('.to_right').click(function() {
  if (animate==0){
       animate = 1;
       //$(".home_slid_ul li:first")
       //$('.home_slid_ul li:first').hide().appendTo('.home_slid_ul').animate({ width: "show" }, function() { animate=0; });
       $('.home_slid_ul li:first').animate({ width: "hide" }, function() {
        $(this).appendTo('.home_slid_ul').show();
        animate=0;
       })
    return false;
  }
});

$('.to_left').click(function() {
  if (animate==0){
       animate = 1;
       //$(".home_slid_ul li:first")
       $('.home_slid_ul li:last').hide().prependTo('.home_slid_ul').animate({ width: "show" }, function() { animate=0; });
    return false;
  }
});




$('.bposit > a').click(function() {
    $(".proj_ul li").removeClass("active");
    if ($(this).next(".clients_popup").css("display")=='none') {
        $(".clients_popup").hide();
        $(this).next(".clients_popup").show();
        $(".u_table").css("zIndex","100");
        var td_class=$(this).parent(".bposit").parent("td").attr("class");
        if (td_class=="td_last") {
            $(this).next(".clients_popup").css("left","auto");
            $(this).next(".clients_popup").css("right","0px");
        }
    }
    else {
        $(".clients_popup").hide();
        $(".u_table").css("zIndex","1");
        return false;
    }
//    return false;
});
$('.bposit .cuclose').click(function() {
    $(this).parent(".clients_popup").hide();
    $(".u_table").css("zIndex","1");
    return false;
});



    $("p.show_pr a").click(function(){
        var this_id = $(this).attr("class");
        this_id = parseInt(this_id.slice(8));
        $(this).parents("div.clients_popup").css("display", "none");
        $(this).parents("li").removeClass("active");



    var this_class = $("div#pr_item"+this_id).parent("li").attr("class");
        $("div#pr_item"+this_id).css("left","auto");
        $("div#pr_item"+this_id).css("right","0px");
        $("div#pr_item"+this_id+" p").css("fontSize","14px");
    var cucols_height = $(".cucols").height();
    var clients_popup_height = $("div#pr_item"+this_id).next("strong").next("div").height();
    if (this_class=="active")   {}
    else {
        if (cucols_height<clients_popup_height) { $(".cucols").css("height", clients_popup_height+"px");}
        $(".proj_ul li").removeClass("active");
        $("div#pr_item"+this_id).parent("li").addClass("active");
    }

        return false;
    });




var b_html=$(".team_b").html();
$(".team_nn").html(b_html, function(){alert("sdd");});
$(".team_b").remove();



var path=document.location+'';
  path=path.split('#');
  path=path[1];
    if (path !== '') {
  if(path=="l8"){
    $('.pism_rask > li:eq(0)').addClass("acti").children(".pism_per").show();
  }
  if(path=="l1"){
    $('.scol2 .pism_rask > li:eq(1)').addClass("acti").children(".pism_per").show();
  }
  if(path=="l2"){
    $('.pism_rask > li:eq(2)').addClass("acti").children(".pism_per").show();
  }
  if(path=="l3"){
    $('.pism_rask > li:eq(3)').addClass("acti").children(".pism_per").show();
  }
  if(path=="l4"){
    $('.pism_rask > li:eq(4)').addClass("acti").children(".pism_per").show();
  }
  if(path=="l5"){
    $('.pism_rask > li:eq(5)').addClass("acti").children(".pism_per").show();
  }
  if(path.slice(0, 2)=="cl"){
//    $('.pism_rask > li:eq(5)').addClass("acti").children(".pism_per").show();
//      alert(path.slice(3));
      $("div#client_"+path.slice(3)).show();
  }
  if(path.slice(0, 7)=="person_"){
//    $('.pism_rask > li:eq(5)').addClass("acti").children(".pism_per").show();
//      alert(path.slice(7));
      var person_nomber = path.slice(7);
//      $("div#client_"+path.slice(8)).show();


//открываем окошко с описание сотрудника


            var heights = [];  // переменная, которая будет хранить высоты элементов
            $(".col").each(function(indx, element){ // indx - номер элемента в наборе, element - сам элемент
              heights.push($(element).height());
            });
            heights.sort();
            heights.reverse();
            maxi = heights[0];
            $(".cols").animate({ height: maxi+''  }, 300, function() {    });
        $(".col2").animate({   width: '21%', fontSize: '8px'   }, 300, function() {  $(".cols div").removeClass("act");  });

        $(".col3 tdd").animate({   height: '230px',  width: '150px'   }, 500, function() { $(this).addClass("act");});
        $(".col3 img").animate({    width: '150px'   }, 500, function() {
            $(this).addClass("act");

        });
        $(".col3").animate({    width: '47%',      fontSize: '14px'   }, 500, function() {
                $(this).addClass("act");
                var heights = [];  // переменная, которая будет хранить высоты элементов
                $(".col").each(function(indx, element){ // indx - номер элемента в наборе, element - сам элемент
                  heights.push($(element).height());
                });
                heights.sort();
                heights.reverse();
                maxi = heights[0];
                $(".cols").animate({ height: maxi+''  }, 300, function() {    });
        });

        $(".team_item"+person_nomber).show();


//открываем окошко с описание сотрудника  конец





  }

   if(path=="l7"){
        var heights = [];  // переменная, которая будет хранить высоты элементов
        $(".scol").each(function(indx, element){ // indx - номер элемента в наборе, element - сам элемент
          heights.push($(element).height());
        });
        heights.sort();
        heights.reverse();
        maxi = heights[0];
        $(".scols").height(maxi);
        $(".scol").animate({   width: '18%', fontSize: '8px'   }, 300, function() {  $(".scols div").removeClass("act");  });
        $(".col_numb a").animate({   fontSize: '12px'   }, 300, function() {   });
        $(".scol3").children(".col_numb").children("a").animate({   fontSize: '18px'   }, 300, function() {   });
        $(".scol3").animate({    width: '33%',      fontSize: '14px'   }, 300, function() {

                $(this).addClass("act");
                var heights = [];  // переменная, которая будет хранить высоты элементов
                $(".scol").each(function(indx, element){ // indx - номер элемента в наборе, element - сам элемент
                  heights.push($(element).height());
                });
                heights.sort();
                heights.reverse();
                maxi = heights[0];
                //$(".scols").animate({ height: maxi+''  }, 300, function() {    });
                $(".scols").css("height","auto");
        });
  }

  if(path=="l6"){
        var heights = [];  // переменная, которая будет хранить высоты элементов
        $(".scol").each(function(indx, element){ // indx - номер элемента в наборе, element - сам элемент
          heights.push($(element).height());
        });
        heights.sort();
        heights.reverse();
        maxi = heights[0];
        $(".scols").height(maxi);
        $(".scol").animate({   width: '18%', fontSize: '8px'   }, 300, function() {  $(".scols div").removeClass("act");  });
        $(".col_numb a").animate({   fontSize: '12px'   }, 300, function() {   });
        $(".scol4").children(".col_numb").children("a").animate({   fontSize: '18px'   }, 300, function() {   });
        $(".scol4").animate({    width: '33%',      fontSize: '14px'   }, 300, function() {

                $(this).addClass("act");
                var heights = [];  // переменная, которая будет хранить высоты элементов
                $(".scol").each(function(indx, element){ // indx - номер элемента в наборе, element - сам элемент
                  heights.push($(element).height());
                });
                heights.sort();
                heights.reverse();
                maxi = heights[0];
                $(".scols").css("height","auto");
        });
        $('.scol4 .pism_rask  li').removeClass("acti");
        $('.scol4 .pism_per').hide();
        $('.scol4 .pism_rask  li:eq(1)').addClass("acti");
        $('.scol4 .pism_rask  li:eq(1)').children(".pism_per").show();

  }


  if (path=="l9"){
        var heights = [];  // переменная, которая будет хранить высоты элементов
        $(".scol").each(function(indx, element){ // indx - номер элемента в наборе, element - сам элемент
          heights.push($(element).height());
        });
        heights.sort();
        heights.reverse();
        maxi = heights[0];
        $(".scols").height(maxi);
        $(".scol").animate({   width: '18%', fontSize: '8px'   }, 300, function() {  $(".scols div").removeClass("act");  });
        $(".col_numb a").animate({   fontSize: '12px'   }, 300, function() {   });
        $(".scol4").children(".col_numb").children("a").animate({   fontSize: '18px'   }, 300, function() {   });
        $(".scol4").animate({    width: '33%',      fontSize: '14px'   }, 300, function() {

                $(this).addClass("act");
                var heights = [];  // переменная, которая будет хранить высоты элементов
                $(".scol").each(function(indx, element){ // indx - номер элемента в наборе, element - сам элемент
                  heights.push($(element).height());
                });
                heights.sort();
                heights.reverse();
                maxi = heights[0];
                //$(".scols").animate({ height: maxi+''  }, 300, function() {    });
                $(".scols").css("height","auto");
        });
        $('.scol4 .pism_rask  li').removeClass("acti");
        $('.scol4 .pism_per').hide();
        $('.scol4 .pism_rask  li:eq(2)').addClass("acti");
        $('.scol4 .pism_rask  li:eq(2)').children(".pism_per").show();
  }

  if (path=="l10"){
        var heights = [];  // переменная, которая будет хранить высоты элементов
        $(".scol").each(function(indx, element){ // indx - номер элемента в наборе, element - сам элемент
          heights.push($(element).height());
        });
        heights.sort();
        heights.reverse();
        maxi = heights[0];
        $(".scols").height(maxi);
        $(".scol").animate({   width: '18%', fontSize: '8px'   }, 300, function() {  $(".scols div").removeClass("act");  });
        $(".col_numb a").animate({   fontSize: '12px'   }, 300, function() {   });
        $(".scol4").children(".col_numb").children("a").animate({   fontSize: '18px'   }, 300, function() {   });
        $(".scol4").animate({    width: '33%',      fontSize: '14px'   }, 300, function() {

                $(this).addClass("act");
                var heights = [];  // переменная, которая будет хранить высоты элементов
                $(".scol").each(function(indx, element){ // indx - номер элемента в наборе, element - сам элемент
                  heights.push($(element).height());
                });
                heights.sort();
                heights.reverse();
                maxi = heights[0];
                //$(".scols").animate({ height: maxi+''  }, 300, function() {    });
                $(".scols").css("height","auto");
        });
        $('.scol4 .pism_rask  li').removeClass("acti");
        $('.scol4 .pism_per').hide();
        $('.scol4 .pism_rask  li:last').addClass("acti");
        $('.scol4 .pism_rask  li:last').children(".pism_per").show();
  }


  }

  //ссылки с главной конец


//question
$("span#qbut").click(function(){
    var fio = $("#q_fio").val();
    var email = $("#q_email").val();
    var phone = $("#q_phone").val();
    var msg = $("#q_msg").val();

    if (fio == '') {$("#q_answer").html('<p>Введите имя</p>'); return;}
    if (msg == '') {$("#q_answer").html('<p>Введите вопрос</p>'); return;}

    $("#q_answer").html("Wait...");

    $.post("/ajax/question.php",{'fio':fio,'email':email,'phone':phone,'msg':msg},function(msg){
        $("#q_answer").html(msg);
        if (msg == '<p>Вопрос успешно отправлен.</p>') {
            $("#q_fio").val('');
            $("#q_email").val('');
            $("#q_phone").val('');
            $("#q_msg").val('');
        }
    });
});

});

function flr() {
  var flr=0;
  $(".clients_popup").each(function(){
    if ($(this).is(":visible")) {flr=1;}
  });
  if (flr==0) return false;
  else return true;
}
//                   if (flr()) {}

function tehide() {$(".team_item").hide();  return false;    }

function equalHeight(group) {
        tallest = 0;
        group.each(function() {
            thisHeight = $(this).height();
            if(thisHeight > tallest) {
                tallest = thisHeight;
            }
            alert(tallest)
        });
        group.css("height", tallest+"px");
}
