/*****
	FUNCTIONS
*****/

// Equal column height
jQuery.fn.equalCols = function(){
	var sortNumber = function(a,b){return b - a;};
	var heights = [];
	$(this).each(function(){
		heights.push($(this).height());
	});
	heights.sort(sortNumber);
	var maxHeight = heights[0];
	return this.each(function(){
		$(this).css({'height': maxHeight});
	});
};

/*****
	CALLS
*****/

// Apply rules to every table without them.
$(function(){
	$("table").attr("rules","all");
});

$(function(){

	// Equal height columns
    $("#homeConsulting, #homeCoaching, #homeTraining").equalCols();
    
	// Odd colouring of comments
	$("#commentList li:odd").addClass("oddComment");
	$("#commentList li:even").addClass("evenComment");
	$("#commentList li:last").addClass("lastComment");
	
	// Apply .cufon class to headers I select her
	$("#sidebarRight h3, #sidebarRight h5").addClass('cufonBebas');
	
	// Add classes to iFrames for Digg & Tweetmeme
	$('#social iframe[src*="tweetmeme"]').addClass('tweetmeme');
	setTimeout(function(){
		//$('#social iframe[src*="digg.com"]').addClass('digg');
		$('#social .db-wrapper').addClass('digg');
	}, 1800);
	
	// Show more sidebar 'about blog' contewnt on click, toggle it
	$("#aboutThisBlog").append('<a href="#" class="aboutThisBlogTriggerOff">More...</a>');
	$("#aboutThisBlog").find('p').slice(2,10).hide().css("opacity","0");
	$("#aboutThisBlog a").toggle(function() {
		$("#aboutThisBlog").find('p').slice(2,10).slideDown().animate({opacity: 1});
		$(this).removeClass("aboutThisBlogTriggerOff");
		$(this).addClass("aboutThisBlogTriggerOn");
		$(this).html('Less...');
	},function() {
		$("#aboutThisBlog").find('p').slice(2,10).animate({opacity: 0}).slideUp();
		$(this).removeClass("aboutThisBlogTriggerOn");
		$(this).addClass("aboutThisBlogTriggerOff");
		$(this).html('More...');
	});

			
});


