/**
 * JS
 *
 * The custom JavaScript used for the added functionality.
 *
 * @author Will Morgan <will;@betterbrief.co.uk>
 * @version 1
 * @copyright 2010 Better Brief LLP
 *
 */

//Load jQuery
google.load("jquery", "1.4");

// effectively 'on document ready'
google.setOnLoadCallback(function() {

	var J = jQuery.noConflict();
	J(function($) {
		if(document.body.className == 'HomePage') {
			var $images = $('div.Slideshow').find('img').css({ position: 'absolute', zIndex: 1 }),
				$current = $images.filter(':first'),
				$next = $current.next('img');
			if ($images.length > 1) {
				$images.not($current).hide();
				window.setInterval(function() {
					$current.fadeOut(1000);
					$next.fadeIn(1000);
					$current = $next;
					$next = $next.next('img').length ? $next.next('img') : $next.parent().children('img:first');
				}, 4500);
			}
		}
	});

});

//Google analytics tracking
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-5532417-32']);
_gaq.push(['_trackPageview']);

(function() {
  var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
  ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
  (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(ga);
})();

