$().ready(function() {
	$(".sattelite-f a").click(function() {
		$(".sattelite-f a").attr("class","fav-p");
		$(this).attr("class","fav-a");
		$("#sat-on,#sat-off").slideUp(350);
		$("#sat-"+$(this).attr("id")).slideDown(350);
	});
	$("#menu a[id!=]").mouseenter(
		function() {
			$(".submenu").css("display","block");
			$(".submenu .none").css("display","none");
			$(".submenu #sm"+$(this).attr("id").substr(-1)).css("display","block");
			$(".submenu").offset({top:$(this).offset().top+32,left:$(this).offset().left+15});
			$(".submenu #sm"+$(this).attr("id").substr(-1)).css("display","none");
			$(".submenu #sm"+$(this).attr("id").substr(-1)).slideDown(250);
		}
	);
	$("#menu a[id=],#site,#top").mouseenter(function() {$(".submenu").fadeOut(150);});
	
	$(".mega-play,.mega-glr img").hover(
		function() {$(this).animate({"opacity":"1"},300);}	,
		function() {$(this).animate({"opacity":"0.6"},300);}	
	);	
	//$(".mega-video").click(function() {window.location='/media/?filter=video'});
	days = Math.floor((utc_block-utc_now)/86400);
	window.milli = (utc_block-utc_now-10800)*1000;
	function refresh_time() {
		dt = new Date(window.milli);
		var h = dt.getHours()<10 ? "0"+dt.getHours() : dt.getHours();
		var m = dt.getMinutes()<10 ? "0"+dt.getMinutes() : dt.getMinutes();
		var s = dt.getSeconds()<10 ? "0"+dt.getSeconds() : dt.getSeconds();
		$("#time").html(h+" : "+m+" : "+s);
		window.milli-=1000;
		if(window.milli==-10800000) {window.location='./';}
	}
	if(lang=="ru") {
		langs = ["осталось","Турнир","уже идет","осталось дней"];
	}
	else {
		langs = ["starts after","Tournament","started","days left"];
	}
	if(days==0) {$("#left").html("<span style='color:#ca1616'>"+langs[0]+"</span>");dt_interval = setInterval(refresh_time,1000);}
	else if(days<0) {$("#left").html(langs[1]+" <span style='color:#ca1616'>"+langs[2]+"</span>");$(".mega-left").css({"padding-top":"13px","height":"40px"});}
	else {$("#left").html(langs[3]+": <span style='color:#ca1616'>"+days+"</span>");dt_interval = setInterval(refresh_time,1000);}
	
	k = 1;
	function slide_tr() {
		$("#changer").animate({"opacity":"0"},300, function() {
			k++;
			$("#changer").attr("src","/img/p_block"+k+".jpg");
			$("#changelink").attr("href","/img/block"+k+".jpg");			
			$("#changer").animate({"opacity":"1"},300);		
		});
		if(k==3) {k=0;}
	}
	tr_interval = setInterval(slide_tr,6000);
});

function pic(source) {
	sm=window.open("/pic/?img="+source, "pic","resizable=no, scrollbars=yes, height=1050, width=780, left=0, top=0");
	sm.focus();
}
function zoom(page) {
	sm=window.open(page, "zoom","resizable=no, scrollbars=yes, height=1050, width=780, left=0, top=0");
	sm.focus();
}
