/**
 * jquery.antispam.js
 *
 * @version 1.0
 * @author Alessandro Alessio
 * @copyright 2010
 * @site www.acktel.com
 */

(function($){  
   $.fn.antispam = function(options) {  
      
      var defaults = {  
         splitter           : '/'
      };
      
      var options = $.extend(defaults, options);
            
      return this.each(function() {       //<---- per ogni elemento identificato da jquery
		 email = $(this).html();
         array_email = email.split(options.splitter);
         //se non è definito un testo per l'a metto la mail
         if (array_email[3]=='' || array_email[3]==undefined){
            into_a = array_email[0] + '@' + array_email[1] + '.' + array_email[2];
         } else {
            into_a = array_email[3];
         }
         //se è definito il soggetto lo aggiungo
         if (array_email[4]!='' && array_email[4]!=undefined){
            subject = '?subject=' + array_email[4];
         } else {
            subject = '';
         }
         $(this).html('<a href="mailto:' + array_email[0] + '@' + array_email[1] + '.' + array_email[2] + subject + '">' + into_a + '</a>');
      });  
   };  
})(jQuery);
