  /**
   *  Protect: decoder for mailto: links
	*  -----------------------------------------------------------------------
	*  @copyright Copyright (c) 2006-2008 fCMS Development Team
   *  @author Arne Blankerts <theseer@fcms.de>
	*	
	*  $Id: fprotect.fscript.js,v 1.10 2009/01/20 15:01:54 theseer Exp $
	* 
	*  This code automagically registers for body.onload and replaces all
	*  protect: links by mailto: links
	* 
	*/
	
  fScript.registerOnload( 
  
     function() {  
        var list=document.getElementsByTagName('a');
        for (var i=0; i<list.length; i++) {
           var curA=list[i];
           var href=curA.getAttribute('href');
           if (!href) { continue; }
           
           if (href.indexOf('protect:')==0) {
              
              var r=fJson.decode(fBase64.decode(href.substr(8)));
              var m=r.split('||');                                  
              curA.setAttribute('href','mailto:'+m[0]+(m[1]!=''?'?subject='+encodeURIComponent(m[1]):''));
              if (m[2]!='') {
                 curA.setAttribute('title',m[2]);
              }              
              if (m[3]!='') {
                 curA.innerHTML=m[3];
              } else {
                 curA.innerHTML=m[0];   
              }
              
           }
           
        }      
     }
     
  );
	