jQuery.easing.def = "easeInOutExpo";

$(function() {
    // unobfuscates the e-mail addresses, converting the
    // string " [at] " to the actual "@"
    $('.email').each(function(){
        $(this)
            .attr('href', function(i, href){
                return href.replace(' [at] ', '&#64;');
            })
            .html(function(i, html){
                return html.replace(' [at] ', '&#64;');
            });
    });
    
    // if no errors are being displayed
    if( !$('.error').length ){
        // bring the focus to the first input
        $(':input:first').focus();
    } else {
        // otherwise, focus the first field with error
        var name = $('.message li:first').attr('class').replace('error', '');
        $(':input#id_' + name).focus();
    }

    var hideMsg = function(){ $('.message').slideUp(850); }    
    $('.message').hide().slideDown(850, function(){
        if( $(this).hasClass('success') ){
            setTimeout(hideMsg, 5000);
        }
    });
});
