jQuery(document).ready(function($) {
	$('.img_gallery, #cboxWrapper').bind("contextmenu", function(e) {e.preventDefault();});
	
	$('.submit').click(function(e) {
		$('#' + $(this).attr('id').substr(7)).submit();

		e.preventDefault();
	});

	$('.back').click(function(e) {
		history.go(-1);
		
		e.preventDefault();
	});

	if ($('.homepage_news').length > 0) {
		$('.homepage_news').cycle({
			fx: 'fade',
			before: function() {
				$('.homepage_news_titles').removeClass('homepage_news_titles_blue');
				$('.blue_triangles').css('display', 'none');

				$('#' + $(this).attr('id') + '_title').addClass('homepage_news_titles_blue');
				//$('#' + $(this).attr('id') + '_title img.blue_triangles').css('display', 'inline');
			},
			startingSlide: 1
		});
	}

	if ($('.league_tables').length > 0) {
		$('.league_tables').cycle({
			cleartype: true,
			cleartypeNoBg: true,
			fx: 'scrollHorz',
			timeout: 0
		});
	}

	if ($('.slideshow').length > 0) {
		$('.slideshow').cycle({
			fx: 'fade'
		});
	}

	$('.skip_to_league_1st').click(function(e) {
		$('.league_tables').cycle(0);

		e.preventDefault();
	});

	$('.skip_to_league_dev').click(function(e) {
		$('.league_tables').cycle(1);

		e.preventDefault();
	});

	$('.nav').click(function(e) {e.preventDefault();});

	$('tr:even').addClass('even');
	$('tr:odd').addClass('odd');

	$('#upcoming_other_teams div, .league_table div').dragscrollable();
	
	if (swfobject.hasFlashPlayerVersion("1"))
	{
		$('#homepage_video').css('height', '176px').css('padding', '0').css('width', '226px');

		$('#homepage_video span').replaceWith('<iframe width="226" height="176" src="' + $('#homepage_youtube_video').attr('href') + '" frameborder="0" allowfullscreen></iframe>');
	}

	$('#header_search, #footer_name, #footer_email').defaultvalue(
		"Search",
		"Name",
		"Email Address"
	);

	$('#navigation ul li').hover(
		function() {
			$('ul', this).slideDown(100);
		},
		function() {
			$('ul', this).slideUp(0);
		}
	);

	$("a[rel='gallery']").colorbox({
		slideshow: true
	});

	$('#watch_video').click(function(e) {
		$("a[rel='video_gallery']:first").click();

		e.preventDefault();
	});

	$('.watch_video').click(function(e) {
		var video_id = $(this).attr('id');

		$("#watch_" + video_id).click();

		e.preventDefault();
	});

	$("a[rel='video_gallery']").colorbox({
		current: false,
		iframe: true,
		innerWidth: '640px',
		innerHeight: '480px'
	});

	$('.match_gallery').click(function(e) {
		$("a[rel='" + $(this).attr('id') + "']").colorbox({
			slideshow: true
		});

		$("a[rel='" + $(this).attr('id') + "']:first").click();

		e.preventDefault();
	});
});
