// Place your application-specific JavaScript functions and classes here
// This file is automatically included by javascript_include_tag :defaults
jQuery(function($){
  clear_tweet_box = function() {
    $('#tweet-textarea').attr('value', '')
    $('#char-count').html(baseCharLength);
    $('#tweet-textarea').focus()
  }
  
  update_tweets = function() {
    $.ajax({success:function(request){$('#tweets').html(request);}, type:'get', url:'/tweets/updates'})
  }
  
  enable_tweets = function() {
    $('#tweet_btn span').html('tweet')
    $('#tweet_btn').removeAttr("disabled");
  }
  
  disable_tweets = function() {
    $('#tweet_btn span').html('tweeting...')
    $('#tweet_btn').attr("disabled", "disabled");
  }
  
  if ($('#tweet-textarea') != null) {
    $('#tweet-textarea').focus()
  }
  
  if($('#username') != null){
    $('#username').focus()
  }
  
  $('#tweet').submit(function(){
    disable_tweets()
  })
  
})