

// ********************************************************************************************** //
// 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();
	
	init_Slideshow();
	
	// Page specific functions:
	switch (curSection)
	{
		case("sect-products"):
			init_Products();
			break;
		case("sect-contact"):
			init_Contact_Maps();
			break;
	}
	
}




// ********************************************************************************************** //
// Functions

function init_MainNav_DropDowns()
{
	$("div.header>ul").superfish(
	{
		animation	: { height:"show" },
		speed		: "fast",
		delay		: 400
	});
}


function init_Slideshow() {
	$('#slideshow').cycle({
		fx:			'fade',
		timeout:	4000,
		speed:		1000,
		pager:		'#slideshow-thumbs', 
		pagerAnchorBuilder: function(idx, slide) {
			return '#slideshow-thumbs li:eq(' + idx + ') a'; 
		} 
	});
	$('#slideshow-thumbs a').click(function() {
		$('#slideshow').cycle('pause');
	});
}


function init_Products()
{
	$("div.product-info").hide();
	$("div.product-range a").click(function(e) {
		e.preventDefault();
		var myLink = $(this).attr("href");
		$("div.product-info").hide();
		$("div.product-range a").removeClass("selected");
		$(this).addClass("selected");
		$(myLink).show();
		$(myLink + " .cycle").cycle({
			fx:			'fade',
			timeout:	4000,
			speed:		1000
		});
	}).filter(':first').click();
	
}


function init_Contact_Maps()
{
	if (GBrowserIsCompatible()) {
		
		$('#map-south').css({ border:"1px solid #B5B5B5", width:"220px", height:"180px" });
		$('#map-north').css({ border:"1px solid #B5B5B5", width:"220px", height:"180px" });
		
		var map1 = new GMap2(document.getElementById("map-south"));
		map1.setCenter(new GLatLng(51.5148878, -0.1500528), 14);
		var point = new GLatLng(51.5148878, -0.1500528);
		var marker = new GMarker(point);
		map1.addOverlay(marker);
		map1.addControl(new GSmallMapControl());
		
		var map2 = new GMap2(document.getElementById("map-north"));
		map2.setCenter(new GLatLng(53.485807, -2.282559), 13);
		var point = new GLatLng(53.485807, -2.282559);
		var marker = new GMarker(point);
		map2.addOverlay(marker);
		map2.addControl(new GSmallMapControl());
		
	}
}



