
var loadingImg = "<img src='/images/ajax-loader.gif' alt='Loading' title='Loading'/>";

function popUp(url, title) {
  window.open( url, title, 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=0,width=525,height=425' );
}

$(document).ready(function(){

  $('#tweetResult').hide();
        
  $('#frmTweet').submit(function() {
      $('#tweetResult').html( loadingImg ).show();
      var tweetOptions = {
          url:$('#frmTweet').attr('action'),
          data:$('#frmTweet').serialize(), 
          dataType:'json',
          type:'post', 
          success: function( json ) { 
              $('#tweetResult').html( json.message ).show();
          }
      }
      
      $.ajax(tweetOptions);

      return false;
  });
  
  $(".shareInput").focus(function(){
    this.select();
  });

  $(".toggleField").each( function()
  {
    $(this).data( "labelName", $(this).val() );
  });

  $('.toggleField').focus(function(){
    if ( $(this).val() == $(this).data("labelName") )
    {
      $(this).val("");
    }
    })
    .blur(function(){
      if ( $(this).val() == "" )
      {
        $(this).val($(this).data("labelName"));
      }
  });
  
});
