$(document).ready(function() {
	$("BODY").bind("keyup", function(e) {
		if (e.keyCode == 27) {
			hideNews();
		}
		return false;
	});
	callNews(5000);
});

function showNews() {
	var $rem	= 0;
 	$.get("/in_site/tools/ajax/news.php", function(html) {
 		if (html) {
			$("#notify .body").append(html);
			if ($("#notify .body UL").size() > 4) {
				$("#notify .body UL:first").remove();
			}
			$("#notify .body FORM:not(:first)").remove();
			$("#notify .body H1:not(:first)").remove();
			$("#notify .body .read:not(:last)").remove();

			$("#notify .body FORM INPUT").bind("change", function(e) {
				$.get("/in_site/tools/ajax/status.php?notifynews="+(this.checked?"0":"1"));

				return false;
			});

			// $("td:lt(4)").
			$("#notify").show("fast");

			$("#notify .close").click(function () {
				$("#notify").hide("fast");
				return false;
			});
//			window.setTimeout("hideNews()", 10000);
 		}
	});
	callNews();
}

function hideNews() {
	$("#notify .body").html("");
	$("#notify").hide("fast");
}

function callNews(timer) {
	timer	= timer ? timer : 15000;
	window.setTimeout("showNews()", timer);
}