jQuery( function($) {
	$('header a.login').click( function() {
		$('header a.login, header form').slideToggle();
		return false;
	});
	
	$('body.home .subsection').equalHeights();
	
	if( !$.support.placeholder ) {
		$('input[placeholder]').placeholder();
	}
});

jQuery.support.placeholder = (function(){
    var i = document.createElement('input');
    return 'placeholder' in i;
})();

(function($){
	jQuery.fn.equalHeights = function(minHeight, maxHeight) {
		tallest = (minHeight) ? minHeight : 0;
		this.each(function() {
			if($(this).height() > tallest) {
				tallest = $(this).height();
			}
		});
		if((maxHeight) && tallest > maxHeight) tallest = maxHeight;
		return this.each(function() {
			$(this).height(tallest).css("overflow","auto");
		});
	}

	$.fn.placeholder = function() {
		return this.each( function() {
			el = $(this);
			el.focus( function() {
				var input = $(this);
				if( $.trim( input.val() ) == input.attr('placeholder') ) {
					input.val('').removeClass('placeholder');
				}
			}).blur( function() {
				var input = $(this);
				if( $.trim( input.val() ) == '' ) {
				 	input.addClass('placeholder').val( input.attr('placeholder') );
				}
			}).blur().parents('form').first().submit( function() {
				$('[placeholder]', this).each( function() {
					var input = $(this);
					if( $.trim( input.val() ) == input.attr('placeholder') ) {
						input.val('');
					}
				});
			});
		});
	}
})(jQuery);

