// clearOnFocus - Clears search box when clicked
(function($) {
	$.fn.clearOnFocus = function() {
		
		function clearOnFocusFocus(event)
		{
			if($(this).val() == $(this).data('clearOnFocus'))
			{
				$(this).val('');
			}
		}
		
		function clearOnFocusBlur(event)
		{
			if($.trim($(this).val()) == '')
			{
				$(this).val($(this).data('clearOnFocus'));
			}
		}
		
		return this.each(function()
			{
				$(this).data('clearOnFocus', $(this).attr('value'));
				
				//	unbind any previous listeners
				$(this).unbind('focus', clearOnFocusFocus);
				$(this).unbind('blur', clearOnFocusBlur);
				
				//	bind listeners to the functions
				$(this).bind('focus', clearOnFocusFocus);
				$(this).bind('blur', clearOnFocusBlur);
			}
		);
	};
})(jQuery);

// Equal Column Heights
jQuery(function($) {
	$("#content, #sidebar, #content-sidebar-wrap").addClass("equal");
	
	// Adjustment for carousel on Associations page
	$(".page-template-project-associations-landing-php #content-sidebar-wrap").removeClass("equal");
	
	$("#content-sidebar-wrap").css("background-color", "#fff").css("padding-bottom", "20px");
	var maxHeight = 0;
	$(".equal").each(function(){
	   if ($(this).height() > maxHeight) { maxHeight = $(this).height(); }
	});
	$(".equal").height(maxHeight);
});
