/*
 * dropDowns.js
 * Toggles the display of the next sibling of each link <a></a> with a class
 * of 'listImg' and 'tables.hideClass|tables.showClass', provided the next
 * sibling has either class 'tables.hideClass|tables.showClass'
 */

tables={

hideClass: 'hide',
showClass: 'show',

init:function() {

         if (!document.getElementById || !document.getElementsByTagName) {
             return;
         }

         var a;
     
         /* ------------------------------------------------------------------
          * Add the drop down toggle function event to all links with class
          * listImg
          */
         a = document.getElementsByTagName('a');
         for (var i = 0; i < a.length; i++) {
             if (a[i].className.indexOf('listImg') == -1) {
                 continue;
             }
             dom.addEvent(a[i], 'click', tables.toggleTableVis, false);
         }
         // ------------------------------------------------------------------
     },

toggleTableVis:function(e) {

                   if (!document.getElementById ||
                           !document.getElementsByTagName ) {
                       return;
                   }

                   // Get the node that fired the event
                   var target = dom.getTarget(e);
                   if (!target) {
                       return;
                   }
                   var c1, c2;
                   if (target.className.indexOf(tables.hideClass) != -1) {
                       c1 = tables.hideClass;
                       c2 = tables.showClass;
                   }
                   else {
                       c1 = tables.showClass;
                       c2 = tables.hideClass;
                   }
                   
                   dom.cssjs('swap', target, c1, c2);

                    // Find the closest sibling...should be a table
                    var sib = dom.closestSibling(target, 1);
                    if (sib) {
                        dom.cssjs('swap', sib, c1, c2);
                    }

                   dom.cancelClick(e);

               }

}
// Add the object on window load
dom.addEvent(window, 'load', tables.init, false);


