/******************************************************************************
 *  Canted.com script add-on tca_colmenu_01.js, 20090318_0 
 *  Copyright 2006-2009, The Canted Arabesque (TCA), all rights reserved
 *  contact via e-msg at webmaster(at)canted(dot)com 
 * 
 *  Thanks for the Collapsible Menus
 *  Kae Verens - kae(at)verens(dot)com (w/ changes suggested in comments by "Michael")
 *  http://verens.com/archives/2005/03/21/collapsible-menus-updated/
 *
 *******************************************************************************/

/*******************************************************************************
 *  Collapsible Menus
 *  written by Kae Verens - kae(at)verens(dot)com (w/ changes suggested in comments by Michael")
 *   http://verens.com/archives/2005/03/21/collapsible-menus-updated/
 *  
 *  You are free to use this. please retain these comments, though.
 * if there are any questions/suggestions for the code, please email me.
 *  
 *  usage:
 *  1. create your menu as a hierarchy of unordered lists. for example
 *   <ul>
 *    <li><a href="/">home</a>
 *     <ul>
 *      <li><a href="/aboutme">about me</a></li>
 *      <li><a href="/contact">contact me</a></li>
  *    </ul>
 *    </li>
 *    <li><a href="/gallery">photo gallery</a></li>
 *   </ul>
 *  2. place this script in your /j directory (j for javascript)
 *  3. link this script into every page that has the menu:
 *******************************************************************************/
var parentLinkIsOpener=1; // whether to use parent link/text as opener, overriding its own link

if(window.attachEvent)window.attachEvent('onload',cm);
else if(window.addEventListener)window.addEventListener('load',cm,false);

function cm(){
 cmId=0;
 if(!document.getElementsByTagName)return; // reject non-compliant browsers
 a=document.getElementById('catMenu').getElementsByTagName('UL'); // change suggested by "Michael"
 for(i=0;a[i];i++){
  if(a[i].getElementsByTagName('UL')){
   // a[i] is an object which has a collapsible list in it
   b=a[i].childNodes;
   for(j=0;b[j];j++){
    if(b[j].nodeName=='LI'){
     d=b[j].getElementsByTagName('ul');
     if(d.length){
      c=document.createElement('a');
      c.setAttribute('href','javascript:cmSwitch("cm'+(cmId)+'")');
      c.setAttribute('id','cm'+(cmId)+'A');
      if(parentLinkIsOpener){
       // we've chosen to use the parent link as the opener
       var e=b[j].innerHTML;
       e=e.replace(/(\n|\r)/g,''); // change suggested by "Michael"
       e=e.replace(/(<ul|<UL).*/,'');
       e=e.replace(/<[^>]*>/g,'');
       c.innerHTML=e;
       b[j].replaceChild(c,b[j].childNodes[0]);
      }else{
       // create a new [+] link as the opener
       c.style.display='inline';
       c.innerHTML='[+]';
       b[j].insertBefore(c,b[j].firstChild);
      }
      d[0].setAttribute('id','cm'+(cmId++));
      d[0].style.display='none';
     }
    }
   }
  }
 }
}

function cmSwitch(id){
 a=document.getElementById(id);
 a.style.display=(a.style.display=='block')?'none':'block';
 if(parentLinkIsOpener)return;
 a=document.getElementById(id+'A');
 a.innerHTML=(a.innerHTML=='[+]')?'[-]':'[+]';
}

/*******************************************************************************/






