$("document").ready(function()
{
	var pos = 1;
	var count = 3;
	$("#akt").everyTime(5000,function(i) {
		$(this).find("#news_"+pos).hide();
		$(this).find("#news_link_block").find("#news_link_"+pos).css("background","url('mainpage/images/home/news_ch_"+pos+"_off.png')");
		pos++
		if (pos>count) { pos = 1; }
		$(this).find("#news_"+pos).fadeIn(250);
		$(this).find("#news_link_block").find("#news_link_"+pos).css("background","url('mainpage/images/home/news_ch_"+pos+"_on.png')");
	});	
	
	$("#news_link_block a").click(function(){
		$("#akt").find("#news_"+pos).hide();
		$("#akt").find("#news_link_block").find("#news_link_"+pos).css("background","url('mainpage/images/home/news_ch_"+pos+"_off.png')");
		pos = $(this).attr("id").substr(10);
		$("#akt").find("#news_"+pos).fadeIn(250);
		$("#akt").find("#news_link_block").find("#news_link_"+pos).css("background","url('mainpage/images/home/news_ch_"+pos+"_on.png')");
		return false;
	});		
	
	var ppos = 1;
	var pcount = 3;
	$("#per_content").everyTime(8000,function(i) {
		$(this).find("#pnews_"+ppos).hide();
		$(this).find("#pnews_link_block").find("#pnews_link_"+ppos).css("background","url('mainpage/images/home/news_ch_"+ppos+"_off.png')");
		ppos++
		if (ppos>pcount) { ppos = 1; }
		$(this).find("#pnews_"+ppos).fadeIn(250);
		$(this).find("#pnews_link_block").find("#pnews_link_"+ppos).css("background","url('mainpage/images/home/news_ch_"+ppos+"_on.png')");
	});	
	
	var posG = 1;
	var countG = 5;
	$("#galerySlide").everyTime(10000,function(i) {
		$(this).find("#perGal_" + posG).hide();
		posG++
		if (posG > countG) { posG = 1; }
		$(this).find("#perGal_" + posG).fadeIn(250);
	});	

	$("#per.open").click(function(){
		if ($(this).hasClass("open"))
		{		
			$(this).removeClass("open");
			$(this).addClass("close");
			$("#per_content").hide();
		} else if ($(this).hasClass("close")) {
			$(this).addClass("open");
			$(this).removeClass("close");
			$("#per_content").show();
		}
	});
});
