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
	});
	
	$("a.video-overlay-button").fancybox({
		'hideOnContentClick': false,
		'frameWidth':	600,
		'frameHeight': 405
	});
	
	
	$('#grid_overlay').click(function(){ 
		fnStartGrid('http://www.sprymedia.co.uk/design/grid/media/js/grid-loader.js');
		return false;
	});
	
	

		

		
	setInterval( "slideSwitch()", 5000 );
	//firstLoad();
	

});