$(document).ready(function() {
				   
	$("a").focus(function() {

		this.blur();

	});


	$('#ac-marketing img').hover(function(){$(this).attr('src','http://ac-marketing.ru/copyright.gif')},function(){$(this).attr('src','http://ac-marketing.ru/copyright_trans.gif')});

	

	$("#error").append("<span id='close_error' class='close_link' href='#'>Щёлкните по этому сообщению, чтобы закрыть его.</span>");

	$("#error").click(function() {

		$("#error_container").slideUp("fast");

	})



	$("a.showfull_link").html("Развернуть&nbsp;&darr;").prev("div[id^='news-id-']").after("<div class=\"full\"></div>");

	$("a.showfull_link")

			.after("<img class=\"loading_img\" src=\"/3ngine/ajax/loader.gif\" />");

	$("img.loading_img").hide();

	$("div.full").hide();




	$("a.showfull_link").click(function() {

		$(this).next("img.loading_img").show();



		if ($(this).prev("div.full").html() == '') {

			get_page($(this));

		} else {

			$(this).prev("div.full").animate({

				height : 'toggle'

			}, 1000, '', function() {

				if ($(this).next("a.showfull_link").is(":contains('Свернуть')")) {

					$(this).next("a.showfull_link")

							.html("Развернуть&nbsp;&darr;")

							.next("img.loading_img").hide();;

				} else

					$(this).next("a.showfull_link")

							.html("Свернуть&nbsp;&uarr;")

							.next("img.loading_img").hide();;

			});



		}

		return false;



	}



	);



	$("#show_profile").click(function() {

		$('#options').toggle('slow')

	});

	$('#months').change(refreshCalendar);

	$('#years').change(refreshCalendar);



	function refreshCalendar() {

		$('#months').attr('disabled', 'disabled');

		$('#years').attr('disabled', 'disabled');

		$('#cal_wrap').fadeTo("slow", .3, function() {



			$.post("/3ngine/ajax/calendar.php", {

				month : $('#months').val(),

				year : $('#years').val()

			}, function(xml) {



				$('#calendar_content').html($('output', xml).text());

				$('#cal_wrap').fadeTo("slow", 1, function() {

					$('#months').attr('disabled', '');

					$('#years').attr('disabled', '');

				});



			});

		});

	}



	function get_page(obj) {

		$.post("/3ngine/ajax/pages.php", {

			newsid: $(obj).attr('id').replace('link-', 'news-id-'),	   


			lang : $('#lang').val()

		}, function(xml) {

			$('#news-id-' + $("id", xml).text()).next("div.full").html($("story",

					xml).text()).animate({

				height : 'toggle'

			}, 1000, '', function() {

				$(this).next("a.showfull_link").html("Свернуть&nbsp;&uarr;")

						.next("img.loading_img").hide();
				floatImages('#news-id-' + $("id", xml).text());

			});

		});

	}
	
	function floatImages(what) {
	
	if (!what) what = 'div.item';
	
	$(what+' img').each(function() {
		var float = $(this).css('float');
		if (float) {$(this).css('clear',float);}
	});
	
	}
	
	floatImages();


});
