/*
 * (c) 2004 Richard "Ritchie" Chudoba -- http://ritchie.cz
 * Released under BSD licence.
 *
 * Article to this script is located at 
 * http://ritchie.cz/articles/ochrana-emailu-xhtml-strankach.xhtml
 *
 * This is modified version for this site purpose only.
 */

a = document.getElementsByTagName('a');
for( i = 0; i < a.length; i++ )
  if( a[i].href.indexOf('posta:') == 0 )
    restoreEmail(a[i]);


function restoreEmail(node) {

  email = null;

  reg = /.+ \(na\) .+ \(tečka\) .+/
    
  if ( reg.test(node.title) ) {
    email = node.title;
    node.title='';
  }
  
  if( reg.test(node.firstChild.data) ) {
    email = node.firstChild.data;
    node.firstChild.data = '';
  }

  if( email ) {
    email = email.replace(/ \(tečka\) /g, '.');
    email = email.replace(/ \(na\) /g, '@');
    node.href = 'mailto:' + email;
    if(!node.firstChild.data)
      node.firstChild.data = email;
    if(!node.title)
      node.title = email;
  }
}
