/* ================================================================ 
This copyright notice must be untouched at all times.

The original version of this scriptt and the associated (x)html
is available at http://www.stunicholls.com/menu/simple.html
Copyright (c) 2005-2007 Stu Nicholls. All rights reserved.
This script and the associated (x)html may be modified in any 
way to fit your requirements.
=================================================================== */

clickMenu = function(outer) {
	if (document.getElementById(outer)) {
	var getEls = document.getElementById(outer).getElementsByTagName("LI");
	var getAgn = getEls;

	for (var i=0; i<getEls.length; i++) {
			getEls[i].onclick=function() {
				for (var x=0; x<getAgn.length; x++) {
				getAgn[x].className=getAgn[x].className.replace("unclick", "");
				getAgn[x].className=getAgn[x].className.replace("click", "unclick");
				}
			if ((this.className.indexOf('unclick'))!=-1) {
				this.className=this.className.replace("unclick", "");;
				}
				else {
				this.className+=" click";
				}
			}
		}
	}
}
	

hideacc = function() {
    // hide all
    var divs = document.getElementsByTagName('div');  
    var divsL = divs.length;  
    for(var i = 0; i< divsL; i++)  
        {  
         if(divs[i].className == "innerAccordion")  
            {  
            divs[i].style.display = "none";  
            }  
        }  
}  
/*
Node.prototype.__defineGetter__("nextElementSibling", function() {
if (!this.nextSibling) // lastChild
return null;
if (this.nextSibling.nodeType == Node.ELEMENT_NODE)
return this.nextSibling;
else
return this.nextSibling.nextElementSibling;
});

Element.prototype.next = function() {
    if (this.nextElementSibling) return this.nextElementSibling;
    var sib = this.nextSibling;
    while(sib && sib.nodeType !== 1) sib = sib.nextSibling;
    return sib;
};


getNextElementSibling = function(){
  if (this.nextElementSibling) return this.nextElementSibling;
  	
  var e = this.nextSibling;
  while(e && e.nodeType !== 1)
   e = e.nextSibling;
  return e;
}

*/

accordion = function() {
    var divs = document.getElementsByTagName('div');  
    var divsL = divs.length;  
	var getAgn = divs;
	
	hideacc();
    for(var i = 0; i< divsL; i++)  
        {  
		 if(divs[i].className == "outerAccordion") {
			   divs[i].onclick=function() {
				   
				 //  debugger
                   var nS = this.nextElementSibling || this.nextSibling.nextSibling  
				 
				 if (this.nextElementSibling) {
				      nS = this.nextElementSibling;
					 }
				   else
				     {
					 nS = this.nextSibling;
                      while(nS && nS.nodeType !== 1)
                            nS = nS.nextSibling ;
					 }
				   if(nS.style.display == "none")  
                     {  
					 hideacc();
                     nS.style.display = "inline";       
                     }  
                   else if(nS.style.display == "inline")  
                     {  
                     nS.style.display = "none"; 
                     }  
                  } 
		    } 
		 
         if(divs[i].className == "innerAccordion")  
            {  
            divs[i].style.display = "none";  
            }  
        }     
}  
	



	
