addFunction('initEmailCloacking', "null");

/**
 * content of tag a is decipgered
 * when hover mouse over link - create "mailto"
 *
 */
function initEmailCloacking() {
  //ciper email
  //cipher = new emailCloacking('valuetocipher');
  //cipher.ciphering();
  //alert(cipher.get());
 
  //display dechipered email
  $('.email-cloacking').each (function () {
    decipher = new emailCloacking($(this).html());
    decipher.deciphering();//deshiper
    $(this).html(decipher.get());//put deciphered data
  });
  //set mailto:
  $('.email-cloacking').hover( function () {
    //email is deciphered so
    var email = $(this).html();
    $(this).attr("href", 'mailto:'+email);
  });
}
/**
 * class to ciphering and deciphering
 * HTML: <a href="#">cipheredEmailAddress</a>
 * -cipheredEmailAddress you can get ciphering email (string) by this class
 *
 */
function emailCloacking(text) {
  /**
   * ciphering key
   */
  this.code = 'abc';
  /**
   * coded/decoded string
   */
  this.text = text;

  /**
   * cipher string
   * 
   */
  this.ciphering = function() {
    text = this.text;
    code = this.code;
    
    var tmp = new Array;
    var j = 0;//char from code
    for (i=0;i<text.length;i++) {
      
      if (j<code.lenght)
        j++;//next char from code
      else
        j = 0;//reset to first char of code
      
      var value = new Number((text.charCodeAt(i)+code.charCodeAt(j)));
      tmp[i] = String.fromCharCode(value);
    }
    this.text = tmp.join("");
  };
  /**
   * decipher string
   *
   */
  this.deciphering = function() {
    text = this.text;
    code = this.code;
    
    var tmp = new Array;
  
    var j = 0;//char from code
    for (i=0;i<text.length;i++) {
      
      if (j<code.lenght)
        j++;//next char from code
      else
        j = 0;//reset to first char of code
        
      var value = new Number(text.charCodeAt(i)-code.charCodeAt(j));
      tmp[i] = String.fromCharCode(value);
    }
    this.text = tmp.join("");
  };
  /**
   * getter
   */
  this.get = function() {
    return this.text;
  };
}