function slideSwitch() {
    var $active = $('#slideshow IMG.active');

    if ( $active.length == 0 ) $active = $('#slideshow IMG:last');

    var $next =  $active.next().length ? $active.next()
        : $('#slideshow IMG:first');

    $active.addClass('last-active');

    $next.css({opacity: 0.0})
        .addClass('active')
        .animate({opacity: 1.0}, 1000, function() {
            $active.removeClass('active last-active');
        });
}




function fnStartGrid(sUrl) {
	var nScript = document.createElement('script');nScript.setAttribute('language','JavaScript');nScript.setAttribute('src',sUrl);document.body.appendChild(nScript);
	}


$(document).ready(function(){

	
	$("ul.grid-gallery a").fancybox({
		'imageScale':	true,
		'frameWidth':	600
	});
	
	/* $("div.post div.storycontent a.lightbox").fancybox({
		'imageScale':	true,
		'frameWidth':	600
	});
	*/
	
	$("dl.gallery-item a").fancybox({
		'imageScale':	true,
		'frameWidth':	600
	});
	
	$("a.video-overlay-button").fancybox({
		'hideOnContentClick': false,
		'frameWidth':	600,
		'frameHeight': 405
	});
	
	
	/*
	NOTE: So it seems that these controls are un-needed. They are what was causing the issue with the slideshow on the first page because there was an issue in referencing SWFObject.js. Anyway, it seems that not having them around doesn't do anything. Must have been an different method of embedding that I decided not to work with.
	
	
	//Video Player Controls
	var params = { allowScriptAccess: "always" };
	//swfobject.embedSWF("http://www.youtube.com/v/JTcQYU1Dwjs&enablejsapi=1&playerapiid=video-one", "video-one", "500", "338", "8", null, null, params);
	
	
	var so = new SWFObject('http://www.youtube.com/v/lSx7XAcc0Lk&enablejsapi=1&playerapiid=video-two','video-two','500','338','8'); 
	so.addParam('allowscriptaccess','always'); 
	so.addParam('allowfullscreen','true'); 
	//so.addParam('flashvars','&file=../video/SouthBayChamps.flv&image=video/Sout hBayChamps.jpg'); 
	so.write('video-two'); 
	
	*/
	
	$('#grid_overlay').click(function(){ 
		fnStartGrid('http://www.sprymedia.co.uk/design/grid/media/js/grid-loader.js');
		return false;
	});
	
	
	setInterval( "slideSwitch()", 5000 );
	//firstLoad();
	

});
