jQuery(function($) {
    // adds the browser name and js to the homepage
    if($.browser.mozilla) {
        $("html").addClass("js mozilla");
    } else if($.browser.safari) {
        $("html").addClass("js safari");
    } else if($.browser.msie) {
        $("html").addClass("js msie");
    } else {
        $("html").addClass("js");
    }
    
    if ( $('#tweet-textarea').length > 0 ) {
        $('#char-count').html(baseCharLength);
        
        $('#tweet-textarea').keyup(function() {
            var charLength = $(this).val().length;

            // Displays count
            $('#char-count').html(baseCharLength - charLength);

            // Alerts when max characters is reached
            if($(this).val().length > baseCharLength){
                $('#char-count').css('color','red');
                $('#tweet button').attr('disabled','disabled');
            } else{
                $('#char-count').css('color','black');
                $('#tweet button').removeAttr('disabled');
            }
        });
        
        $('#tweet-textarea').focus(function(){
          $(this).keyup()
        })
    }
});

        