// author: Plotnikov AV, verstalo.com

$(document).ready(function(){

		client = $(".clents-col li>a");

	    $(client).click(function(){
	       $(this).toggleClass("active");
		   $(this).next("p").slideToggle("normal");

			return false;

	     });

		var path = location.pathname;
		if (path.indexOf('services')>=0) { // если на странице услуги
			/* если в ссылке передан номер услуги, которую надо открыть */
			var openPanel = location.hash.slice(1);
			if (openPanel != '') { /*pavelk*/
                           $('.'+openPanel).find('a').toggleClass("active");
			   $('.'+openPanel).find("div").slideToggle("normal");
                        }
		}
		
		
		
		
		service = $(".service-col li>a");

	    $(service).click(function(){
		   location.hash = $(this).parent().attr('class'); // меняем значение после #, чтобы можно было кидать ссылку, открывающую блок
	       $(this).toggleClass("active");
		   $(this).next("div").slideToggle("normal");

			return false;

	     });
		 
		$(".request-lnk").click(function(){
	       $("#request").slideToggle("normal");
			return false;
	     });
	     
	     // работа с табами
	     
	     // клик по кнопке отправить
		$(".submit").click(function(){
			// если email и телефон пустые, то ошибка 
			if ($('#req1').val()=='' && $('#req2').val()=='') {
				$('#form_status').html('Заполните контактные данные!');
				
				$("#tab-5").css({display: 'block'}).siblings("div").css({display: 'none'});
				$(".req-tabs li[rel='tab-5']").toggleClass("active").siblings("li").removeClass("active");
				// right_block - не скрываем
				$(".right_block").css({display: 'block'});
			
			
				return false;
			}
		});

	     
	     $(".req-tabs span").click(function(){    
			var rel = $(this).parent().attr("rel");
			$("#"+rel).css({display: 'block'}).siblings("div").css({display: 'none'});
			$(this).parent().toggleClass("active").siblings("li").removeClass("active");
			// right_block - не скрываем
			$(".right_block").css({display: 'block'});
			return false;
	     });
		 
		 
		 
		 
		 
	     
	     // работа с выпадашками
	     $(".select p span").css({display: 'none'})
	     $("body").click(function(){	
	     		$(".select p span").css({display: 'none'});
	     		$(".select p").css({'z-index': '0'});
	     });
	     
	     $(".select p").click(function(){
	         
	     		$(".select p").css({'z-index': '0'});
	     		$(this).css({'z-index': '10'});
	     		$(this).find("span").toggle();
	       
			return false;
	     });
	     
	     $(".select p span a").click(function(){
	         
	   		var sel_text = $(this).text();
	     		$(this).addClass("selected").siblings("a").removeClass("selected").parent().parent().find("input").val(sel_text);
	     		$(this).parent().css({display: 'none'});
	     	//	$(this).find("span").toggle();
	       
			return false;
	     });
		 
		 // инициализация всплывашек (prettyPhoto)
		 
		 $("a[rel^='prettyPhoto']").prettyPhoto({animationSpeed:'slow',theme:'light_square',allow_resize:false, gallery_markup: ''});
		 $("a[rel^='prettyPhoto-780']").prettyPhoto({animationSpeed:'slow',theme:'light_square', default_width: '780',allow_resize:false, gallery_markup: ''});
			
	 });
	 
