/**
 * Client.js
 */

$(function() {

	var navItems;
	
	// Add Placeholders to every input with the placeholder attr
	$('input[placeholder]').placeholder();

	/**
	 * Modernizr Tests
	 */

	if (!Modernizr.cssanimations) {
		// Establish some variables
		navItems 	= $('#header .navigation > ul').children();
		
		/* Navigation Items moving up/down */
		navItems.hover(function() {
			$(this).animate({top: '-8px'}, 150);
			$(this).find('.dropdown').fadeIn(150);
		});
		navItems.mouseleave(function() {
			$(this).animate({top: '0px'}, 150);
			$(this).find('.dropdown').fadeOut(150);
		});
	}
	
	/**
	 * Autosize Section Headers
	 */
	$.fn.textfill = function(options) {
        var fontSize = options.maxFontPixels;
        var ourText = $('span:visible:first', this);
        var maxHeight = $(this).height();
        var maxWidth = $(this).width();
        var textHeight;
        var textWidth;
        do {
            ourText.css('font-size', fontSize);
            textHeight = ourText.height();
            textWidth = ourText.width();
            fontSize = fontSize - 1;
        } while ((textHeight > maxHeight || textWidth > maxWidth) && fontSize > 3);
        return this;
    }
	$('#container .section > .header .title').textfill({ maxFontPixels: 22 });
});
