var news_pic_moving = false;

$(function () {
	$('select#sc_group_changer').change (function (){
		get_group ($(this).val (), 1);
	});
	
	$('.news-pic .news-caption').css ({opacity : 0.35});
	$('.news-pic').hover (function () {
		if (news_pic_moving) return;
		news_pic_moving = true;
		
		$(this).children('.news-caption').animate ({opacity : 1}, function () {
			news_pic_moving = false
		});
	},
	function () {
		$(this).children('.news-caption').animate ({opacity : 0.35});
	});
	
	$('.boxed .title').each (function (){
		var $this = $(this);
		
		if (!$this.find ('a').length) return;
		
		$this.hover (function () {
			$this.css ('border-color', '#C00');
			$this.css ('cursor', 'pointer');
		},
		function () {
			$this.css ('border-color', '#C3C3C3');
		});
		
		$this.click (function () {
			window.location = $this.find ('a').attr ('href');
		});
	});
	
	get_group (group_id, 1);
	get_matches (1);
});

function get_group (group, season) {
	$.get (base_url + '/group-ajax', {'group' : group, 'season' : season}, function (data) {
		$('div#sc_group_container').html (data);
		$('#footer').css ('bottom', 0);
	});
}

function get_matches (season) {
	var gdata = {'season' : season};
	if (typeof (team_id) !== 'undefined') gdata.team = team_id;
	
	$.get (base_url + '/match-ajax', gdata, function (data) {
		$('div#matches_container').html (data);
		$('#footer').css ('bottom', 0);
	});
}
