function onBlur() {
    document.body.className = 'blurred';
};
function onFocus(){
    document.body.className = 'focused';
};

if (/*@cc_on!@*/false) { // check for Internet Explorer
    document.onfocusin = onFocus;
    document.onfocusout = onBlur;
} else {
    window.onfocus = onFocus;
    window.onblur = onBlur;
}



$(document).ready(function() {

		// Services Accordion
		
		// $("#accordion").tabs("#accordion div.pane", {tabs: 'h2', effect: 'slide', initialIndex: null});
		$("#accordion h2").click(function(){
			if ($(this).hasClass('current')) {
				$(this).toggleClass('current').next("div.pane").toggle('slow');
			} else {
				$("#accordion h2.current").toggleClass('current').next("div.pane").hide('slow');
				$(this).toggleClass('current').next("div.pane").toggle('slow');
			}
		});
		
				
		// Set all but first image to faded out
		$('#customer_slideshow img').fadeOut(0);
		$('#customer_slideshow_img_0').fadeIn(0);
		
		// Set up timer to rotate slideshow
		window.setTimeout (rotateSlideshow, 4000 );	
		
		// Wow tracking stuff
// 		WOWTracking.ClientId = '2a2ddc30-6ca5-413c-8956-cdbfa2d8b260';
// 		WOWTracking.url = 'http://www.wowanalytics.co.uk';
// 		WOWTracking.InitialiseTracker();

});

var cus_slideshow_pos = 1;
var flipflop = true; // alternate between long and short waiting times
function rotateSlideshow() {
	if ($("body").hasClass('blurred')){
		window.setTimeout (rotateSlideshow, 8000 );
	} else {
		$('#customer_slideshow img').fadeOut(1500);
		$('#customer_slideshow_img_'+cus_slideshow_pos).fadeIn(1500);
		cus_slideshow_pos++;
		var cus_slideshow_size = $('#customer_slideshow img').size();
		if (cus_slideshow_pos == cus_slideshow_size) cus_slideshow_pos = 0; //loop
		window.clearTimeout();
		if (flipflop) {
			window.setTimeout (rotateSlideshow, 8000 );
		} else {
			window.setTimeout (rotateSlideshow, 4000 );
		}
		flipflop = !flipflop;
	}
}
