$(document).ready(function() {
	$('#slideshow').cycle({
		speed: 5000
	});

	$('#navigation ul li').hover(
		function() {
			$('ul', this).slideDown(100);
		},
		function() {
			$('ul', this).slideUp(0);
		}
	);
	
	function map_it(lat, lng) {
		new google.maps.Marker({
			position: new google.maps.LatLng(lat, lng),
			map: new google.maps.Map(document.getElementById('map'), {
				zoom: 17,
				center: new google.maps.LatLng(lat, lng),
				mapTypeId: google.maps.MapTypeId.ROADMAP
			}),
			icon: '/assets/images/icons/pin.png'
		});
	}
	
	if ($('#map').length != 0) {
		map_it(50.791681,0.266966);
	}

	if ($('#picture_gallery').length != 0) {
		$("a[rel='picture_gallery']").colorbox();

		$('.show_picture_gallery').click(function() {
			$("a[rel='picture_gallery']:first").click();

			return false;
		});
	}

	$('.show_results_gallery').click(function() {
		$("a[rel='picture_" + this.id + "']").colorbox();

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

		return false;
	});

	$(".youtube_video").colorbox({
		iframe: true,
		innerWidth: 640,
		innerHeight: 390
	});
	
	$('.return_false').click(function() {
		return false;
	});

	// Set up the Newsletter form for validation.

	if ($('#form_newsletter').length != 0) {
		$('#form_newsletter_submit').click(function() {
			$('#form_newsletter').submit();

			return false;
		});

		$('#form_newsletter').validationEngine();
	}

	// Set up the Search form for validation.

	if ($('#form_search').length != 0) {
		$('#form_search_submit').click(function() {
			$('#form_search').submit();

			return false;
		});

		$('#form_search').validationEngine({
			promptPosition: "bottomLeft"
		});
	}
	
	//Colorbox for Player Profiles
	$(".pprofile").click(function(){
		var id = $(this).attr('id');
		$(".pprofile").colorbox({
   		width:"50%",
	   	href: "#pprofile" + id.substr(5),
 	    inline: true
  		});
	}); 
	
  	

	//Colorbox for Gallery 
	$("a[rel='gallery']").colorbox({width:500});
});
