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

		this.blur();

	});

  $("a.[rel^='lightbox']").prettyPhoto({counter_separator_label: '/', showTitle:false})

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

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

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

	})



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

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




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

		var fullText = $(this).parents("div.item").find(".full")

		if (fullText.html() == '') {
			get_page($(this));

		} else {
			fullText.animate({

				height : 'toggle'

			}, 1000, '', function() {

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

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

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

				} else

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

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

			});



		}

		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;");
				floatImages('#news-id-' + $("id", xml).text());
			  $("a.[rel^='lightbox']").prettyPhoto({counter_separator_label:'/', showTitle:false})

			});

		});

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


});
