var FAQ = {
   togglers : null,
   box: null,
   actual: -1,
   isOpen:false,
   init: function(){
      var cont = $('faq');
      if(!cont)
      return;
      this.togglers = getChildren(cont,'nodeName','H3');
      this.box = getChildren(cont,'className','descr');
      for(var i in this.togglers){
         if(this.togglers[i].className != 'open')
            this.box[i].style.display = 'none';
         addEvent(this.togglers[i],'click',this.toggle.bind(this,i));
      }
   },
   toggle: function(index){
      if(this.actual == index){
			this.box[index].style.display = this.isOpen ? 'none' : 'block';
			this.isOpen = !this.isOpen;
      }else{
		 this.isOpen = true;
         for(var i in this.box){
	         this.box[i].style.display = (i == index) ? 'block' : 'none';
         }
         this.actual = index;
     }
      return false;
   },
   showAll:function(){
      for(var i in this.box){
         this.box[i].style.display = 'block';
      }
   },
   hideAll:function(){
      for(var i in this.box){
         this.box[i].style.display = 'none';
      }
   }
};

addEvent(window, "load",function(){
   FAQ.init();
});
