// skript na otoceni mailove adresy po castech
function mailReverse(el)
{

  if (el.href.substr(0, 7) != 'mailto:') return;
  var res = 'mailto:';
  for(var i=1; i<=el.href.length-7;i++)
    res+=el.href.charAt(el.href.length-i);
  el.href = res;
  el.onclick = '';
}

function otoc_retezec(retezec) // otoci retezec (vypise pozpatku)
{
  var pom = "";
  for (i=retezec.length-1;i>=0;i--)
    pom = pom + retezec.charAt(i);
  return pom;
}

function zmen_mail(el,ocas) // el je klikatelny element s adresou; ocas je delka retezce za mailovou adresou
{
  var adresa = el.href;
  var delka = adresa.length;
  adr = adresa.substring(7,delka-ocas); // orizne mailto a kecy na konci
  var vystup = "mailto:";
  var casti = adr.split("@");
  if (casti.length>1)
  {
    var casti1 = casti[0].split(".");
    var casti2 = casti[1].split(".");
    vystup = vystup + otoc_retezec(casti1[0]);
    for (var i=1;i<casti1.length;i++)
      vystup = vystup + "." + otoc_retezec(casti1[i]);
    vystup = vystup + "@" + otoc_retezec(casti2[0]);
    for (var i=1;i<casti2.length;i++)
      vystup = vystup + "." + otoc_retezec(casti2[i]);
    el.href=vystup;
    //window.location.href(vystup);
  }
  else
    el.href=adresa; //vrati se adresa beze zmeny
  el.onclick = ''; 
}
