document.domain = 'goalhi.com';

var group1 = new Array(0,'n','p');
var firstTdIndex = 0;
var current_tab = 3;
var newsMouseOver = false;
var total = new Array();

$(document).ready(function(){
	total[1] = $('#table_recent_match td[name="notFinished"]').length;
	total[2] = $('#table_recent_match td[name="finished"]').length;
	total[3] = $('#table_recent_match td').length;
	
	if(1 || window.location.href.toString().indexOf('schedule')==-1){
		$('#table_recent_match td').live('mouseover',function(){
			if($(this).children().length<2) return;
			$($(this).children()[0]).hide();
			$($(this).children()[1]).show();
		});
		$('#table_recent_match td').live('mouseout',function(){
			if($(this).children().length<2) return;
			$($(this).children()[1]).hide();
			$($(this).children()[0]).show();
		});
	}
	
	/* $('#a_notFinished').mouseout(function(){
		if(current_tab==1) return;
		else $(this).removeClass('spanon').addClass('spanoff');
	});
	$('#a_finished').mouseout(function(){
		if(current_tab==2) return;
		else $(this).removeClass('spanon').addClass('spanoff');
	});
	$('#a_all').mouseout(function(){
		if(current_tab==3) return;
		else $(this).removeClass('spanon').addClass('spanoff');
	}); */
	
	
});

function AutoScroll(obj){
	if(newsMouseOver) return;

	$(obj).find("ul:first").animate({
		marginTop:"-25px"
	},500,function(){
		$(this).css({marginTop:"0px"}).find("li:first").appendTo(this);
	});
}


function go(n){
	var count = 5;
	firstTdIndex += n*5;
	
	if(firstTdIndex<0) firstTdIndex = 0;
	else if(firstTdIndex>total[current_tab]-1) firstTdIndex = firstTdIndex-5;
	
	$('#table_recent_match td').hide();
	var start = firstTdIndex-1;
	var end = firstTdIndex+5;
	if(start==-1){
		if(current_tab==1)
			$('#table_recent_match td[name="notFinished"]:lt('+end+1+')').show();
		else if(current_tab==2)
			$('#table_recent_match td[name="finished"]:lt('+end+1+')').show();
		else
			$('#table_recent_match td:lt('+end+1+')').show();
	}else{
		if(current_tab==1){
			$('#table_recent_match td[name="notFinished"]:gt('+start+'):lt('+end+')').show();
		}else if(current_tab==2){
			$('#table_recent_match td[name="finished"]:gt('+start+'):lt('+end+')').show();
		}else{
			$('#table_recent_match td:gt('+start+'):lt('+end+')').show();
		}
	}
}

function tab_league_match(t){
	if(	($.inArray(league_id,group1)>-1 && $.inArray(t,group1)==-1) ||
		($.inArray(league_id,group1)==-1 && $.inArray(t,group1)>-1)
		){
		league_id = t;
		
		getforbbsContent();
	}
	
	league_id = t;
	
	if(t=='n' || t=='p'){
		np(t);
		return;
	}
	
	$('a[id^="tab_"]').removeClass('spanon').addClass('spanoff');
	$('#tab_'+t).removeClass('spanoff').addClass('spanon');
	
	if(t==0){
		$('#table_recent_match td').show();
	}else{
		$('#table_recent_match td').hide();
		$('#table_recent_match td[name^="td_'+t+'"]').show();
	}
}

function span_out(t){
	if(league_id==t) return;
	
	if(t=='n' || t=='p'){
		$('#tab_'+t).removeClass('spanon').addClass('spanoff');
		return;
	}
	
	$('#tab_'+t).removeClass('spanon').addClass('spanoff');
}

function np(t){
	$('a[id^="tab_"]').removeClass('spanon').addClass('spanoff');
	$('#tab_'+t).removeClass('spanoff').addClass('spanon');
	
	$('#table_recent_match td').hide();
	$('#table_recent_match td[name$="_'+t+'"]').show();
}


function getforbbsContent(){
	var options = {
		type: 'GET',
		data: 'league_id='+league_id,
		dataType: 'text',
		url: '/recent_matches.php',
		cache: false,
		async: false,
		success: function(s){//alert(s);return;
			$('#header3_recent_match').html(s);
			
			//if($.inArray(league_id, group1)>-1 && league_id!=0)
				//tab_league_match();
			
			PageWidth_1 = pagewidth;
			
			
		}
	};
	$.ajax(options);	
}

/* function tab_recent_match(t){
	current_tab = t;
	$('#table_recent_match td').hide();
	if(current_tab==1){
		$('#table_recent_match td[name="notFinished"]').show();
		$('#a_notFinished').removeClass('spanoff').addClass('spanon');
		$('#a_finished').removeClass('spanon').addClass('spanoff');
		$('#a_all').removeClass('spanon').addClass('spanoff');
	}else if(current_tab==2){
		$('#table_recent_match td[name="finished"]').show();
		$('#a_notFinished').removeClass('spanon').addClass('spanoff');
		$('#a_finished').removeClass('spanoff').addClass('spanon');
		$('#a_all').removeClass('spanon').addClass('spanoff');
	}else{
		$('#table_recent_match td').show();
		$('#a_notFinished').removeClass('spanon').addClass('spanoff');
		$('#a_finished').removeClass('spanon').addClass('spanoff');
		$('#a_all').removeClass('spanoff').addClass('spanon');
	}
	firstTdIndex = 0;
} */
