
function dec2hex(s) { 
	return ( s<15.5 ? '0' : '' ) + Math.round( s ).toString( 16 ); 
}

function subtractSteps(obj, steps) {
	return {
		'r': (obj.r - steps.r),
		'g': (obj.g - steps.g),
		'b': (obj.b - steps.b)
	}
}

function colToCSS(obj) { 
	return '#'+dec2hex(obj.r)+dec2hex(obj.g)+dec2hex(obj.b);
}

$(document).ready(function(){

	elements = $('#content').find('.c');

	$('div.slide_content').hide();
	$('div.open').show();
	$('div.slide h3 a, div.slide h2 a').click(function(){
		var theSlideContent = $(this).closest('div.slide').children('div.slide_content');
		// theSlideContent.height(theSlideContent.height());
		theSlideContent.slideToggle(350);
		return false;
	})

//	2010
	var start_colour = { 'r': 1, 'g': 96, 'b': 158 };
	var end_colour = { 'r': 240, 'g': 135, 'b': 29 };

//	2011
//	var start_colour = { 'r': 240, 'g': 135, 'b': 29 }; // #f0871d
//	var end_colour = { 'r': 1, 'g': 96, 'b': 158 };


	var current_colour = end_colour;

	var steps = elements.length;
	
	var colour_steps = {
		'r': Math.round((end_colour.r - start_colour.r)/steps),
		'g': Math.round((end_colour.g - start_colour.g)/steps),
		'b': Math.round((end_colour.b - start_colour.b)/steps)
	}
	
	i = steps - 1; // ???
	
	while(i--) {
		$(elements[i]).css('color',colToCSS(current_colour));
		current_colour = subtractSteps(current_colour, colour_steps)
	}
	
});
