$(document).ready(function () {

	//player slider on home page
	$('ul.gameScoresAndSchedules li').hover(function () {
		$(this).addClass('bg');
	},
    function () {
    	$(this).removeClass('bg');
    });

	$('#players').bxSlider({
		pager: true,
		randomStart: true,
		pagerSelector: '#playersPager'
	});

	/* SUBNAVI START */

	$("#nav ul li").hover(function () { //Hover over event on list item
		$(this).has("ul li").addClass('hovered');
		$(this).find(".subMenu").removeClass('hidden');
		$(this).find("ul").show(); //Show the subnav
		/*if($(this).has("#visible li a")) {
		$(this).find(".subMenu").css('width','380px');
		} */
	}, function () { //on hover out...
		$(this).removeClass('hovered');
		$(this).find(".subMenu").addClass('hidden');
		$(this).find("ul").hide(); //Hide the subnav
	});

	$('#nav .vijesti .subMenu').remove();
	$('#nav .galerija .subMenu').remove();

	/* SUBNAVI END */


	youngSelectionHover();
	youngSelectionClick();
	leagueTablesHover();
	leagueTablesClick();
	selectYearForCalendar();
	selectYear();
	selectYearOnCalendar();
	Active();

	//slides numbers on player slider on home page
	$('a.bx-next').click(function () {
		var i = $('a.pager-active').html();
		if (i < 5) {
			$('#playersPager').animate({
				marginLeft: '0'
			}, 100);
		}

		if ((i > 4) && (i < 9)) {
			$('#playersPager').animate({
				marginLeft: '-184'
			}, 100);
		}

		if ((i > 8) && (i < 13)) {
			$('#playersPager').animate({
				marginLeft: '-368'
			}, 100);
		}

		if (i == 13) {
			$('#playersPager').animate({
				marginLeft: '-552'
			}, 100);
		}

		if ((i > 13) && (i < 18)) {
			$('#playersPager').animate({
				marginLeft: '-598'
			}, 100);
		}
	});

	$('a.bx-prev').click(function () {
		var i = $('a.pager-active').html();
		if (i < 5) {
			$('#playersPager').animate({
				marginLeft: '0'
			}, 100);
		}

		if ((i > 4) && (i < 9)) {
			$('#playersPager').animate({
				marginLeft: '-184'
			}, 100);
		}

		if ((i > 8) && (i < 13)) {
			$('#playersPager').animate({
				marginLeft: '-368'
			}, 100);
		}

		if (i == 13) {
			$('#playersPager').animate({
				marginLeft: '-552'
			}, 100);
		}

		if ((i > 13) && (i < 18)) {
			$('#playersPager').animate({
				marginLeft: '-598'
			}, 100);
		}
	});

	function Active() {
		var i = $('a.pager-active').html();
		if (i < 5) {
			$('#playersPager').animate({
				marginLeft: '0'
			}, 100);
		}

		if ((i > 4) && (i < 9)) {
			$('#playersPager').animate({
				marginLeft: '-184'
			}, 100);
		}

		if ((i > 8) && (i < 13)) {
			$('#playersPager').animate({
				marginLeft: '-368'
			}, 100);
		}

		if (i == 13) {
			$('#playersPager').animate({
				marginLeft: '-552'
			}, 100);
		}

		if ((i > 13) && (i < 18)) {
			$('#playersPager').animate({
				marginLeft: '-598'
			}, 100);
		}
	}

});


