$(function() {
	$('#who-join .shout li').hover(function() {
		$(this).children('span').fadeIn('fast');
	}, function() {
		$(this).children('span').fadeOut('fast');
	});
	
	$('#do li.shout').hover(function() {
		$(this).children('span').fadeIn('fast');
	}, function() {
		$(this).children('span').fadeOut('fast');
	});
	
// 	$('ul.people').hover(function() {
// 		$('div.people #'+$('ul.people').data('person')).removeClass('active');
// 		}, function() {
// 		$('div.people #'+$('ul.people').data('person')).addClass('active');
// 	});
	
	$('ul.people a').hover(function() {
		$('div.people #'+$(this).data('person')).addClass('active').siblings().removeClass('active');
		}, function() {
//		$('div.people #'+$('ul.people').data('person')).addClass('active');
		$('div.people .active').removeClass('active');
	});
	
	$('img.client').click(function() {
//		history.pushState(null, null, location.href.split('#')[0]+'#'+$(this).data('client'));
		$client = $('div#'+$(this).data('client'));
		$client.fadeIn();
	});
	
	$('div.client').click(function() {
		$(this).fadeOut();
//		history.pushState(null, null, location.href.split('#')[0]);
	});
	
	$(document).keyup(function(e) { 
		if (e.which == 27) {
			$('div.client').each(function() {
				$(this).fadeOut();
			})
		}
	});
	
	/* home page */
	if ($('#case-studies').length) {
		var studies = [
			['chorus', 'Chorus has laid enough fibre to reach from Kaitaia to Bluff 12 times.'],
			['justice', 'What do New Zealanders currently owe in fines? Only about $710 million.'],
			['acc', 'ACC received an injury claim on average every 17 seconds in 2010.'],
			['nzte', 'NZTE represents New Zealand through a network of 37 international offices.'],
			['tvnz', 'TVNZ broadcasts its services to approximately over a million households.'],
			['auckland', 'Auckland City Council delivered more products and services than any other organisation in NZ.'],
			['fh', 'Fulton Hogan lays millions of tonnes of asphalt every year.'],
			['watercare', 'Each day, Watercare supplies over 370 million litres of drinking water to the people of Auckland.']
		];
		var calls = [
			'Read on …',
			'See what we have done …',
			'Davanti helps …'
		];
		var study = studies[Math.floor(Math.random() * studies.length)];
		var call = calls[Math.floor(Math.random() * calls.length)];
		$('#case-studies p').html(study[1]+' '+'<a href="/done/#'+study[0]+'">'+call+'</a>');
	}	
});

