$(function() {

    $('input.default').each(function () {
        var default_val = $(this).attr('default');
		$(this).val(default_val);

        $(this).focus(
            function() {
                if(default_val == $(this).val()) {
                    $(this).val('');
                }
                $(this).addClass('focus');
            }
        ).blur(
            function() {
                if('' == $(this).val()) {
                    $(this).val(default_val);
                }
                $(this).removeClass('focus');
            }
        );
    });
	
    //homepage hero slideshow, from http://malsup.com/jquery/cycle/
    $('#slideshow').cycle({
		fx: 'fade',
		next:   '#ss_next', 
		prev:   '#ss_prev',
		pager:  '#slideshow_nav', 
	    // callback fn that creates a thumbnail to use as pager anchor 
	    pagerAnchorBuilder: function(idx, slide) { 
	        return '<a href="#" class="dot"></a>'; 
	    },
		after: function(options) {
			$('#slide_index').html($(this).index() + 1);
		}
	});
	
	$('#hero').hover(function () {
		$('#slideshow').cycle('pause'); 
	}, function () {
		$('#slideshow').cycle('resume'); 
	});

    $('#header').click(function() {window.location=root;});
});

// Fix FOUT for font replacement (http://paulirish.com/2009/fighting-the-font-face-fout/)
(function(){
	// if firefox 3.5+, hide content till load (or 3 seconds) to prevent FOUT
	var d = document, e = d.documentElement, s = d.createElement('style');
	if(e.style.MozTransform === '') { // gecko 1.9.1 inference
		s.textContent = 'body{visibility:hidden}';
		e.firstChild.appendChild(s);
		var f = function(){s.parentNode && s.parentNode.removeChild(s);};
		addEventListener('load',f,false);
		setTimeout(f,3000);
	}
})();
