	// call relevant gallery
	/*
	if ($('#gallery').length > 0) {
		$.post("get-image-list.php", {
				cache 		: false
			},
			function(data) {
				$("#gallery").html(data);
			}
		);
	}
	*/
 
 // index page slideshow
	if ($('.index-slideshow').length > 0) {
		$('.index-slideshow').cycle({ 
			fx:     'fade', 
			speed:  800, 
			timeout: 6000 
		});
 }
 
	// calendar slider
	if ($('#calendar').length > 0) {
		function showHide(i){
			if ($("#info" + i).css("display") == "none") {
				$("#info" + i).slideDown({ 
					duration: 1000, 
					easing: 'easeInOutSine'
				});
				$("#shlink" + i).text("Close timetable and more information");
				$("#shlink" + i).css("background", "url(images/bg-hide.jpg) no-repeat");
			}
			else {
				$("#info" + i).slideUp({ 
					duration: 1000, 
					easing: 'easeInOutSine'
				});
				$("#shlink" + i).text("View timetable and more information");
				$("#shlink" + i).css("background", "url(images/bg-view.jpg) no-repeat");
			}
		};
	}
	
	// rider class select
	if ($('#riders').length > 0) {
		$(".rider-link").click(function(){
			$("#ridertitle").text("Maxxis " + this.id + " Riders");			
			$(".rider-link").removeClass("active");															 
			$(this).addClass("active");
			$(".rider-list").css("display", "none");
			$("#rider-list-" + this.id).css("display", "inline");
		});
	}
	
	// results class select
	if ($('#results').length > 0) {
		$(".class-link").click(function(){
			$(".classtitle").text("" + this.title + "");			
			$(".class-link").removeClass("active");															 
			$(this).addClass("active");
			$(".result-link").removeClass("active");
			$("#"+ this.id + "qu").addClass("active");
			$(".result-nav").css("display", "none");
			$("#result-nav-" + this.id).css("display", "inline");
			$(".results-list").css("display", "none");
			$("#results-list-" + this.id + "qu").css("display", "inline");
			$(".resultstitle").text("Qualifying 1");
			
		});
	}
	
	// results select
	if ($('#results').length > 0) {
		$(".result-link").click(function(){
			$(".resultstitle").text("" + this.title + "");			
			$(".result-link").removeClass("active");															 
			$(this).addClass("active");
			$(".results-list").css("display", "none");
			$("#results-list-" + this.id).css("display", "inline");
		});
	}
	
	// navigation dropdown
	$(".navlink").hover(	
		function(){
			if (this.id.length > 0) {
				$("#" + this.id + "menu").css("display", "block");
			}
		},
		function(){	
			if (this.id.length > 0) {
				$("#" + this.id + "menu").css("display", "none");
			}
		}
	);
	$(".subnav").hover(	
		function(){
			$(this).css("display", "block");
			$("." + this.id).addClass("hover");
		},
		function(){	
			$(this).css("display", "none");
			$("." + this.id).removeClass("hover");
		}
	);
	
	// center in window function
	jQuery.fn.center = function () {
    this.css("position","absolute");
    this.css("top", ( $(window).height() - this.height() ) / 2+$(window).scrollTop() + "px");
    this.css("left", ( $(window).width() - this.width() ) / 2+$(window).scrollLeft() + "px");
    return this;
	}
	
	// subscribe popup
	$(".subscribe").click(function(){
		//$(this).addClass("active");
		$("#subscribe").css("display", "block");
		$("#overlay").css("display", "block");
		$("#overlay").css("opacity", "0.8");
		$("body").css("background", "#000");
		$("#subscribe").centerInClient({forceAbsolute: true});
	});
	
	// subscribe form contents
	$.post("get-subscribe-form.php", {
			cache 		: false
		},
		function(data) {
			$("#subform").html(data);
		}
	);
	
	// subscribe form action
	function subSubmit() {
		submitted = $("#submitted").value;
		subname 	= $("#subname").innerHTML;
		
		submitted = document.getElementById("submitted").value;
		subname = document.getElementById("subname").value;
		subemail = document.getElementById("subemail").value;
		subanswer = document.getElementById("subanswer").value;
		
		$.post("get-subscribe-form.php", {
			cache 		: false,
			"submitted" : submitted,
			"subname" 	: subname,
			"subemail" 	: subemail,
			"subanswer" : subanswer
		},
		function(data) {
			$("#subform").html(data);
		}
		);
		
	}
	
	// reset the subscription form
	function subReset() {
		// subscribe form contents
	$.post("get-subscribe-form.php", {
			cache 		: false
		},
		function(data) {
			$("#subform").html(data);
		}
	);
	}
	
	
	
	function closeSub() {
		$("#subscribe").css("display", "none");
		$("#overlay").css("display", "none");
		$("body").css("background", "#000 url(images/bg-body.jpg) no-repeat center top");
		$.post("get-subscribe-form.php", {
			cache 		: false
		},
		function(data) {
			$("#subform").html(data);
		}
	);
	}
	
	function popout(image) {
		$("#popout").css("display", "block");
		$("#popout").centerInClient({forceAbsolute: true});
		$("#popout").css("background", "#fff url(uploads/images/medium/" + image + ") no-repeat 50% 50%");
		$("#overlay").css("display", "block");
		$("#overlay").css("opacity", "0.8");
		$("body").css("background", "#000");
	}
	
	function closePopout() {
		$("#popout").css("display", "none");
		$("#overlay").css("display", "none");
		$("body").css("background", "#000 url(images/bg-body.jpg) no-repeat center top");
	}
	
	
	
	
	
