/*
  UNU-specific JavaScript
*/

var UNU = {

prepareNavigation:function()
{
  var lis = $('navul').childNodes;
  for(var i=0;i<lis.length;i++)
  {
    // grab just the list items
    if(lis[i].nodeType == 1 && lis[i].tagName.toLowerCase() == 'li')
    {
      // grab the subnav if there is one
      var sub = lis[i].getElementsByTagName("ul");
      if(sub.length > 0)
      {
        // attach a rollup effect and onclick event to the span inside the list item
        // this element must be the first element (ie: no space between the open
        // li and the <span> or <a>
        lis[i].childNodes[0].fx = new fx.Height(sub[0], {duration:300});
        lis[i].childNodes[0].fx.hide();
        lis[i].childNodes[0].onclick = this.fxonclick;
      }
    }
  }
  var lis = $('navul').getElementsByTagName('li');
  for(var i=0;i<lis.length;i++)
  {
      if(lis[i].className && lis[i].className.match(/current_page_item/))
      {
        if(lis[i].childNodes[0].fx)
        {
          lis[i].childNodes[0].fx.toggle();
        }else if(lis[i].parentNode.parentNode.childNodes[0].fx){
          lis[i].parentNode.parentNode.childNodes[0].fx.toggle();
        }
      }
  }
},

fxonclick:function(){
  this.fx.toggle();
  return false;
},

prepareTables:function(){
  var tbodys = document.getElementsByTagName("tbody");
  for(var i=0,j=tbodys.length;i<j;i++)
  {
    var trs = tbodys[i].getElementsByTagName("tr");
    for(var k=1,l=trs.length;k<l;k=k+2)
    {
      if(trs[k]) trs[k].style.backgroundColor = "#F2F6E8";
    }
  }

}

};
