$(document).ready(function() {
	
	$('#menubar button').click(function(){
		$('#menubar button.selected').removeClass('selected');
		$(this).addClass('selected');
		$('#content').load('html/' + $(this).attr('id') + '.htm');
		
	});
	
	$('#home').click();
	
	var resourceLinks = [
			'Webinar: <a href="javascript:openWebinarWindow()">Long Term Conditions</a>. View our webinar on LTCs.',
			'Publication: <a href="http://www.icareplanning.com/downloads/TheBenefits.pdf">Whole Systems - The Benefits</a>. Discover the benefits of the Whole Systems approach.',
			'Presentation: <a href="http://www.icareplanning.com/downloads/Expo-2011-Presentation.pps">Expo 2011</a>. View our Expo 2011 presentation.'];
	
	var quotes = [
	              '...patient-centred, clinically led...',
	              '...outcome focused...',
	              '...creating common understanding...',
	              '...clinically robust...',
	              '...fostering public and staff inclusion...',
	              '...sustainable...',
	              '...evidence-based...',
	              '...rapidly deployable...',
	              '...repeatable for all LTCs...',
	              '...collaboration and consensus...'
	              ];
	
	function updateResources(i){
		$('#resources').fadeOut(500, function(){
			$(this).html(resourceLinks[i]).fadeIn(500);
		});
		
		var newIndex = i + 1;
		if (newIndex >= resourceLinks.length){
			newIndex = 0;
		}
		
		setTimeout(function(){
			updateResources(newIndex);
		}, 10000);
	}
	
	function updateQuotes(j){
		$('#quote').fadeOut(500, function(){
			
			$('.quote').html(quotes[j]);
			$(this).fadeIn(500);
		});
		
		var newIndex = j + 1;
		if (newIndex >= quotes.length){
			newIndex = 0;
		}
		
		setTimeout(function(){
			updateQuotes(newIndex);
		}, 10000);
	}
	
	setTimeout(function(){
		updateQuotes(1);
		updateResources(1);
	}, 10000);
	
});


function openWebinarWindow() {
	var w = window.open('http://www.icareplanning.com/view-webinar.html','','scrollbars=no,menubar=no,height=390,width=640,resizable=yes,toolbar=no,location=no,status=yes,top=200,left=100');
}
