// Place your application-specific JavaScript functions and classes here
// This file is automatically included by javascript_include_tag :defaults

// Sanity Check: Is jQuery available?
jQuery(document).ready(function($) {
  // $.facebox('jQuery is awesome...');
});

// Use facebox to open rel=facebox links
jQuery(document).ready(function($) {
  $('a[rel*=facebox]').facebox()
});

jQuery(document).ready(function($) {
  setFocus();
});

jQuery(document).ready(function($) {
  $('a[rel*=facebox]').each(function() {
      $(this).attr('href', $(this).attr('href') + '?facebox=true'); 
  });
});

jQuery(document).ready(function($) {
  $('.default-value').each(function() {

      var default_value = this.value;
      $(this).focus(function() {
          if(this.value == default_value) {
              this.value = '';
          }
      });
      $(this).blur(function() {
          if(this.value == '') {
              this.value = default_value;
          }
      });

      var el = $('.default-value')[0];
      if (true !== el.hadFocus) {
          el.focus();
      } else {
          el.blur();
      }
  });


});

function awardMagnifyingGlass(user_id)
{
    jQuery(document).ready(function($) {
        $.post("/award_magnifying_glass_award", {user_id: user_id}, function(data){
        })
    })
}

function awardTrenchCoat(user_id)
{
    jQuery(document).ready(function($) {
        $.post("/award_trench_coat_award", {user_id: user_id}, function(data){
        })
    })
}

jQuery(document).ready(function($) {


  $('.password-clear').show();
  $('.password-password').hide();

  $('.password-clear').focus(function() {
      $('.password-clear').hide();
      $('.password-password').show();
      $('.password-password').focus();
  });
  $('.password-password').blur(function() {
      if($('.password-password').val() == '') {
          $('.password-clear').show();
          $('.password-password').hide();
      }
  });
});

jQuery(document).ready(function($) {
  $('.text-default').show();
  $('.text-clear').hide();

  $('.text-default').focus(function() {
      $('.text-default').hide();
      $('.text-clear').show();
      $('.text-clear').focus();
  });
  $('.text-clear').blur(function() {
      if($('.text-clear').val() == '') {
          $('.text-default').show();
          $('.text-clear').hide();
      }
  });
});

// In public/javascripts/application.js. Will show the spinner whenever  
// an AJAX request is in process.  
// Ajax.Responders.register({   
//   onCreate: function(){   
//     $('spinner').show();   
//   },   
//   onComplete: function() {   
//     if(Ajax.activeRequestCount == 0)   
//       $('spinner').hide();   
//   }   
// });

  // jQuery(document).ready(function($) {
  //   $('a[rel*=facebox]').facebox({
  //     loading_image : 'images/loading.gif',
  //     close_image   : 'images/closelabel.gif'
  //   }) 
  // })

function recordInKissMetrics()
{
    _kmq.push(['record', 'Clicked Share on Facebook']);
}