/*
 * jquery.geekSkypeRemover.js - jQuery plugin to remove Skype Call buttons
 * 
 * Version 1.0
 */
(function($) {
  
  /**
   * Remove Skype Call buttons that were dynamically added, e.g.:
   * 
   *   $(document).ready(function() {
   *     $.geekSkypeRemover(10000);
   *   }
   */
  $.geekSkypeRemover = function(microsecondsLeft) {
  
    //check if the predefined time limit was reached:
    if (microsecondsLeft == 0) {
      return false;
    }
    
    microsecondsLeft = microsecondsLeft - 0;
    
    
    //seek elements added by the Skype Browser Plugin; remove them if
    //they exist or try again in microsecondsLeft microseconds if they don't:
    if ($('span.skype_pnh_container').length == 0) {
      //no Skype Call buttons exist (yet):
      setTimeout('$.geekSkypeRemover(' + microsecondsLeft + ')', 0);
    } else {
      //Skype Call buttons exist:
      var originalText = '';
      
      //determine and set the original textual telephone number:
      $('span.skype_pnh_print_container').each(function() {
        originalText = $(this).html();
        originalText = originalText.substring(0,1) + '<span style="display: none;">_</span>' + originalText.substring(1);
        $(this).after(originalText);
      });
      
      //remove the Skype Call button elements:
      $('span.skype_pnh_container').remove();
      $('span.skype_pnh_print_container').remove();
    }
    
    
    return true;
  
  };
  
})(jQuery);
