/*
  UnToggle, the unobtrusive show/hide toggle implementation for PmWiki

  Original JavaScript by BonRouge : bonrouge.com/br.php?page=togglit

  Adapted for PmWiki in 2009 by Petko Yotov http://5ko.fr
*/
function toggleNext(el) {
 var nex=el.nextSibling;
 while(nex.nodeType != 1) nex=nex.nextSibling;
 nex.style.display=((nex.style.display=="none") ? "block" : "none");
}

function getElementsByTagAndClassName(tag,cname) {
 var tags=document.getElementsByTagName(tag);
 var cEls=new Array();
 for (i=0; i<tags.length; i++) {
  var rE = new RegExp("(^|\\s)" + cname + "(\\s|$)");
   if (rE.test(tags[i].className)) {
   cEls.push(tags[i]);
   }
  }
 return cEls;
}
function toggleNextByTagAndClassName(tag,cname) {
 var ccn="clicker";
 clickers=getElementsByTagAndClassName(tag,cname);
 for (i=0; i<clickers.length; i++) {
  clickers[i].className+=" "+ccn;
  clickers[i].onclick=function() {toggleNext(this)}
  toggleNext(clickers[i]);
 }
}

toggleNextByTagAndClassName("div",'toggle');
toggleNextByTagAndClassName("dt",'toggle');

