

// ********************************************************************************************** //
// Determine Functions Relevant to Section to Initialise


// Boot up jQuery:
jQuery(document).ready(function($)
{
	init_PageContent();
});


// Determine functions to initialise at page load:
function init_PageContent()
{
	
	// Generic cross-site functions:
	$("a[href=#]").click(function() { return false; });
	init_MainNav_DropDowns();
	
	// Page specific functions:
	switch (curSection)
	{
		case("sect-home"):
			init_Slider();
			break;
			
		case("sect-retail"):
			$("[rel*=lightbox]").lightbox();
			break;
			
		case("sect-sponsorship"):
			$("[rel*=lightbox]").lightbox();
			break;
			
		case("sect-lubricants"):
			initAccordion();
			break;
	}
	
}




// ********************************************************************************************** //
// Functions

function init_MainNav_DropDowns()
{
	$("ul#nav").superfish(
	{
		animation	: { height:"show" },
		speed		: "fast",
		delay		: 400
	});
}



function init_Slider() {
	
	// -- slideAnything Plugin Functionality ---------------------------------------------------------------------------------------- //
	function formatText(index, panel) {
	  return index + "";
	}
	$(function () {
		$('.anythingSlider').anythingSlider({
			easing: "easeInOutExpo",				// Anything other than "linear" or "swing" requires the easing plugin
			autoPlay: true,					// This turns off the entire FUNCTIONALITY, not just if it starts running or not.
			delay: 5000,					// How long between slide transitions in AutoPlay mode
			startStopped: false,			// If autoPlay is on, this can force it to start stopped
			animationTime: 500,				// How long the slide transition takes
			hashTags: true,					// Should links change the hashtag in the URL?
			buildNavigation: false,			// If true, builds and list of anchor links to link to each slide
			pauseOnHover: true,				// If true, and autoPlay is enabled, the show will pause on hover
			startText: "Play",				// Start text
			stopText: "Pause",				// Stop text
			navigationFormatter: formatText	// Details at the top of the file on this use (advanced use)
		});
	});
	// ------------------------------------------------------------------------------------------------------------------------------ //

}



function initAccordion()
{
	$('.accordion div.acc-drawer').hide();
	
	$('.accordion>li>a').click(
		function() {
			
			var checkLink = $(this);
			var checkElement = $(this).next();
			
			$('.accordion a').removeClass('selected');
			
			if((checkElement.is('div')) && (checkElement.is(':visible'))) {
				$('.accordion div:visible').slideUp('normal');
				return false;
			}
			
			if((checkElement.is('div')) && (!checkElement.is(':visible'))) {
				$('.accordion div:visible').slideUp('normal');
				checkElement.slideDown('normal');
				checkLink.addClass('selected');
				return false;
			}
			
			return false;
			
		}
		
	);
	
}


