$(document).ready(function(){
	$('.tf_button').click(function(){
		b=$(this).find('b');
		if ($(b).attr('class')=='active')
		{
			$(b).attr('class','');
			$('.tf_text').animate({'width':'18px'},500);
		}
		else
		{
			$(b).attr('class','active');
			$('.tf_text').animate({'width':'343px'},500);
		}
	});
	$('.web_and_ad').click(function(){
		$('.bubble').toggle();
		//$('.bubble input').focus();
	});
	
	// подсчет символов
	$.fn.substring = function(a){
		var num=a;
		var obj=$(this);
		$(obj).keyup(function(){
			symbols();
		});
		$(obj).blur(function(){
			symbols();
		});
		function symbols(){
			length=$(obj).val().length;
			if ($(obj).val()=='')
			{	
				length='0';
			}
			razn=num-length;
			if (razn==0) razn='0';
			if (num-length)
			if (length<num)
			{
				$(obj).parent().parent().find('.words span').html(razn);
				$(obj).parent().parent().find('.words span').attr('class','');
			}
			if (length==num)
			{
				$(obj).parent().parent().find('.words span').html(razn);
				$(obj).parent().parent().find('.words span').attr('class','active');
			}
			if (length>num)
			{
				$(obj).val($(obj).val().substr(0,num));
				$(obj).parent().parent().find('.words span').attr('class','active');
			}
		}
	}
}); 
