function setCookie (name, value, expires, path, domain, secure)
{
	document.cookie = name + "=" + escape(value) +
	((expires) ? "; expires=" + expires : "") +
	((path) ? "; path=" + path : "") +
	((domain) ? "; domain=" + domain : "") +
	((secure) ? "; secure" : "");
}


$(document).ready(	  
	function() {
		var heightes = [];
		$(".more_text").each(function(index,domElement) {
			heightes[index]=$(this).height();
			$(this).css({'overflow':'hidden', 'height':'1px'});
		});
		$(".more_text_link").attr('href','javascript:void(0);');
		$(".more_text_link").each(function(index){
			$(this).click(function(){
				elem = this;
				if ($(this).text()=='Читать дальше') 
				{
					$(this).parent().find('.more_text').animate({'height':heightes[index]+'px'}, "slow", function(){$(elem).text('Скрыть'); $(elem).attr('class','more_text_link_open');});		
				}
				else if($(this).text()=='Скрыть') 
				{
					$(this).parent().find('.more_text').animate({'height':'1px'}, "slow", function(){$(elem).text('Читать дальше');  $(elem).attr('class','more_text_link');});			
				}
				else
				{
					if ($(this).parent().find('.more_text').css('height')=='1px') {$(this).parent().find('.more_text').animate({'height':heightes[index]+'px'}, "slow");}
					else {$(this).parent().find('.more_text').animate({'height':'1px'}, "slow");		}
				}
			});
		});
		
		
		var service_menu_height = $("#service_block_body").height();
		var COOKIE_NAME = 'services_menu';
		var options = { path: '/', expires: 10 };
		if (!$.cookie(COOKIE_NAME) || ($.cookie(COOKIE_NAME)!='opened' && $.cookie(COOKIE_NAME)!='closed')) $.cookie(COOKIE_NAME, 'opened', options);
		if ($.cookie(COOKIE_NAME)=='opened')
			{
				$(".sh_services_menu_open").text('Скрыть');
				$('#service_block_body').css('height',service_menu_height+'px');
				$(".sh_services_menu_open").click(function(){
					elem = this;
					if ($(this).attr('class') == 'sh_services_menu_open')
						{
							$('#service_block_body').animate({'height':'90px'}, "slow", function(){$(elem).text('Открыть'); $(elem).attr('class','sh_services_menu');$.cookie(COOKIE_NAME, 'closed', options);});			
						}
					else if ($(this).attr('class') == 'sh_services_menu')
						{
							$('#service_block_body').animate({'height':service_menu_height +'px'}, "slow", function(){$(elem).text('Скрыть'); $(elem).attr('class','sh_services_menu_open');$.cookie(COOKIE_NAME, 'opened', options);});			
						}		
					});
			}
		else if ($.cookie(COOKIE_NAME)=='closed')
			{
				
				$(".sh_services_menu_open").text('Открыть');
				$(".sh_services_menu_open").attr('class','sh_services_menu');
				$('#service_block_body').css('height','90px');
				$(".sh_services_menu").click(function(){
				elem = this;
				if ($(this).attr('class') == 'sh_services_menu_open')
					{
						$('#service_block_body').animate({'height':'90px'}, "slow", function(){$(elem).text('Открыть'); $(elem).attr('class','sh_services_menu');$.cookie(COOKIE_NAME, 'closed', options);});			
					}
				else if ($(this).attr('class') == 'sh_services_menu')
					{
						$('#service_block_body').animate({'height':service_menu_height +'px'}, "slow", function(){$(elem).text('Скрыть'); $(elem).attr('class','sh_services_menu_open');$.cookie(COOKIE_NAME, 'opened', options);});			
					}
				});
			}	
	});

