(function()
{
	$(document).ready(function()
	{
		$('#news .info').addClass('hidden');
			
		if ($.browser.msie && 7 > parseInt($.browser.version)) 
			$('#layout').css('height', 1).css('height', '');

		$('#news .vacancy').each(function()
		{
			var post = $(this).find('h4 span').text();
			var link = $(this).find('form .form_link');
			//link.attr('href', link.attr('href') + '?post=' + encodeURIComponent(post));
			var path = link.attr('href')
			link.click(function() {
				setCookie('rigroup_vacancy', encodeURIComponent(post), path);
			});
		});
		
		$('#news h4 span').click(function()
		{
			clickVacancy(this);
		});
	});


    function setCookie (name, value, path) {
		document.cookie = name + "=" + escape(decodeURIComponent(value)) + '; path=' + path;
	}


	function clickVacancy(obj)
	{
		$('#news h4 span.selected').each(function()
		{
			var vacancy = $(this).parent().parent().find('.info');
			vacancy.hide(300).addClass('hidden');
			$(this).removeClass('selected');
		});
		
		var vacancy = $(obj).parent().parent().find('.info');
		
		if ('none' == vacancy.css('display'))
		{
			vacancy.show(300).removeClass('hidden');
			$(obj).addClass('selected');
			
			setTimeout(function()
			{
				$(window).scrollTop($(obj).offset().top - 100000);
			}, 100000);
		}
		
		if ($.browser.msie && 7 > parseInt($.browser.version))
			setTimeout(function()
			{
				$('#layout').css('height', 1).css('height', '');
			}, 300);
	}
})();