// JavaScript Document

function switchnews()
{	
	//alert(flagover);	
	if (flagover == 0) {
		$curelement = $(".top_content_links_content:visible");
		$nextelement = $curelement.next().next();
		if ($nextelement.html() != null) {$cursidenews = $curelement.next();} else {$cursidenews =  $(".top_content_links_content:first").prev();}
		$prevsidenews = $curelement.prev(); // get prev sidenews
		
		//alert($prevsidenews.html());
		// if last, then nextelement is first
		if ($nextelement.html() == null) {
			$nextelement = $(".top_content_links_content:first:next");
		}
		if ($cursidenews.html() == null) {
			$cursidenews = $(".top_content_links_content:first");
		}
		
		// if first, then prevelement is last
		if ($prevsidenews.html() == null) {
			$prevsidenews = $(".top_content_links_content:last:next");
		}
		
		
		//execute animation
		if ($nextelement.css('display') == 'none') {
			$curelement.fadeOut(0);
			$nextelement.fadeIn(0);
			
		$(".top_content_links .links").css("background-image","url(../img/bg_links_block.gif)");
		$(".top_content_links .links").css("background-repeat","repeat-x");
		$(".top_content_links .links").css("background-position","bottom");

			// highlight style current element
			$cursidenews.css("background-color", "#636463");
			$cursidenews.css("color","#ffffff");
			$cursidenews.css("background-color","#636463"); 
			$cursidenews.css("background-image","url(../img/bg_links_block_item_a.gif)");
			$cursidenews.css("background-repeat","no-repeat"); 
			$cursidenews.css("background-position","5px center");
			
			// turn off prev
			$prevsidenews.css("background-color", "");
			$prevsidenews.css("color","#000000");
			$prevsidenews.css("background-image","none");

		}
	}	
}

function informerSetCSS()
{
	$informer_turnir_ul= $("[id^='sportacentrs'] ul");
	$informer_turnir_link= $("[id^='sportacentrs'] ul li a");
	//alert(   $fh4.html()   );
	$informer_turnir_link.css("font-size", "11px");
	$informer_turnir_link.css("font-weight", "normal");
	$informer_turnir_link.css("color", "black");
	$informer_turnir_ul.css("background-color", "white");
}


function flagover(){
	this.flagover = 0;
}

$(document).ready(function () {
	
 	
	
	flagover=0;

	var newsint=setInterval("switchnews()",5000);
	setInterval("informerSetCSS()",100);
	//informerSetCSS()
	
	$firstnews = $(".top_content_links_content:visible").prev();
	
	$firstnews.css("background-color", "#636463");
	$firstnews.css("color","#ffffff");
	$firstnews.css("background-color","#636463"); 
	$firstnews.css("background-image","url(../img/bg_links_block_item_a.gif)");
	$firstnews.css("background-repeat","no-repeat"); 
	$firstnews.css("background-position","5px center");	     
		 
//////////////////////		 
	 $(".turtablehidelnk").click(function () { 
	   if($(this).next("table.table_result_big").css('display') == 'none')
	   		{
	          	$(this).next('table.table_result_big').show(); 
				$(this).html('Свернуть календарь и результаты');
			}
			else
			{
				$(this).next('table.table_result_big').hide(); 
				$(this).html('Развернуть календарь и результаты');
			}
	 }); 
	 
	 
    $("a[rel=external]").click(function() {
          window.open(this.href);  
          return false;
     });
	
	
	$("a.link_calendar").click(function(){
		if($(this).next("div.table_result_calendar").css('display') == 'none'){
			$(this).removeClass('hide').addClass('open');
			$(this).html('Свернуть календарь и результаты');
			$(this).next("div.table_result_calendar").css('display', 'block');
            

		} else {
			$(this).removeClass('open').addClass('hide');
			$(this).html('Развернуть календарь и результаты');
			$(this).next("div.table_result_calendar").css('display', 'none');
		}
	});


    $(".top_content_links .links a").mouseenter(function(){
		flagover=1;
	//	alert(fo.flagover);
			

			$(".top_content_links .links a").css("background-color", "");
			$(".top_content_links .links a").css("color","#000000");
			$(".top_content_links .links a").css("background-image","none"); 
	
			
			// highlight style current element
			$(this).css("background-color", "#636463");
			$(this).css("color","#ffffff");
			$(this).css("background-color","#636463"); 
			$(this).css("background-image","url(../img/bg_links_block_item_a.gif)");
			$(this).css("background-repeat","no-repeat"); 
			$(this).css("background-position","5px center");
			
			if ($(this).next(".top_content_links_content").css('display') == 'none') {
			$(this).siblings(".top_content_links_content").fadeOut(0);
			$(this).next(".top_content_links_content").fadeIn(0);
			
		}
    }).mouseleave(function(){
			flagover=0;
			// turn off prev
			//$(this).css("background-color", "");
			$(this).css("color","#FFFFFF");
			//$(this).css("background-image","none");
    });
	
	
	
	$(".scrollable").scrollable({ 
		size: 4
	});
});

function video_photo(block, hide){

	if($('#' + block).css('display') == 'none'){
		$('.' + block).removeClass(block).addClass( block +'_act');
		$('.' + hide + '_act').removeClass(hide + '_act').addClass(hide);

		$('#' + hide).css('display', 'none');
		$('#' + block).css('display', 'block');
		
	}
}



