// Footieflux website - jQuery functions

// set width of div#wrapper depending on browser window width
function wrapperWidth() {
	$('#wrapper').css({width: $(window).width()});
};
	
// set class on div#main-wrapper depending on browser window width
function boxesWrapperWidth() {
	if ($(window).width() < 1200) {
		$('#main-wrapper').removeClass('narrow, wide').addClass('narrow');
		$('#slide-wrapper').css({width: 1628});
		$('#up-arrows-wrapper').css({width: 945});
	} else {
		$('#main-wrapper').removeClass('narrow, wide').addClass('wide');
		$('#slide-wrapper').css({width: 1861});
		$('#up-arrows-wrapper').css({width: 1178});
	}
};
	
$(document).ready(function() {

	// run width functions on document load
	wrapperWidth();
	boxesWrapperWidth();
	
	// run width functions on browser resize
	$(window).resize(function() {
		wrapperWidth();
		boxesWrapperWidth();
	});

/* --- @HOMEPAGE NEWS TICKER --- */
	$('#news-ticker').liScroll({travelocity: 0.07});
	
/* --- @PLAYER FILTERS -- */
	
	$('#price-filters-link').click(function() {
		$('#team-filters, #position-filters').fadeOut();
		$('#price-filters').fadeIn();
		return false;
	});
	$('#team-filters-link').click(function() {
		$('#price-filters, #position-filters').fadeOut();
		$('#team-filters').fadeIn();
		return false;
	});
	$('#position-filters-link').click(function() {
		$('#price-filters, #team-filters').fadeOut();
		$('#position-filters').fadeIn();
		return false;
	});
	$('#leaderboard-weeks-link').click(function() {
		$('#leaderboard-weeks').fadeIn();
		return false;
	});
	$('#leagues-list-link').click(function() {
		$('#leagues-list').fadeIn();
		return false;
	});
	$('div').click(function() {
		$('#filters-wrapper > ul > li > ul, .table-filters-wrapper > ul > li > ul').fadeOut();	
	});
	
	
/* --- @OVERLAYS --- */

// overlay - help
	$('#overlay-link-help').click(function() {
		$('#overlays-wrapper').children().hide();
		$('#overlays-wrapper').addClass('absolute');
		$('#grey-overlay, #overlays-wrapper, #help-overlay-wrapper').show();
		$('#help-overlay-wrapper').load('ajax.php?panel=help');
		$('#help-overlay-wrapper').bind('clickoutside', function() {
			$('#grey-overlay, #overlays-wrapper').hide();
			$('#overlays-wrapper').children().hide();
			$('#overlays-wrapper').removeClass('fixed');
			$('#help-overlay-wrapper').html('');
			$('#help-overlay-wrapper').unbind();
		});
		return false;
	});
	
// overlay - info link in header
	$('#overlay-link-info').click(function() {
		$('#overlays-wrapper').children().hide();
		$('#overlays-wrapper').addClass('absolute');
		$('#grey-overlay, #overlays-wrapper, #info-overlay-wrapper').show();
		$('#info-overlay-wrapper').load('ajax.php?panel=info');
		$('#info-overlay-wrapper').bind('clickoutside', function() {
			$('#grey-overlay, #overlays-wrapper').hide();
			$('#overlays-wrapper').children().hide();
			$('#overlays-wrapper').removeClass('fixed');
			$('#info-overlay-wrapper').html('');
			$('#info-overlay-wrapper').unbind();
		});
		return false;
	});
	
// overlay - sign up
	$('a.sign-up-now-link').click(function() {
		$('#overlays-wrapper').children().hide();
		$('#overlays-wrapper').addClass('absolute');
		$('#grey-overlay, #overlays-wrapper, #signup-overlay').show();
		$('#signup-overlay').load('ajax.php?panel=signup');
		$('#signup-overlay').bind('clickoutside', function() {
			$('#grey-overlay, #overlays-wrapper').hide();
			$('#overlays-wrapper').children().hide();
			$('#overlays-wrapper').removeClass('fixed');
			$('#signup-overlay').removeClass('bottom');
			$('#signup-overlay').html('');
			$('#signup-overlay').unbind();
		});
		return false;
	});
	$('#sign-up-bottom-link').click(function() {
		$('#signup-overlay').addClass('bottom');	
	});

});
$(window).load(function() {
	
});
