Proto.UI.alltabs=[];
Proto.UI.tabs=function(classname)
    	{	
    		//document.title='div .'+classname+"::"+$$('.'+classname).length;
    		
        	$$('.'+classname).each(function(t){
        	Proto.UI.alltabs.push(t);
        	//document.title=t.tagName;
          	var contentarea=new Element ('div', { 'class': "Proto_tabs_content" });
          	t.wrap(contentarea);
          	var pane=new Element('div',{'id':'pane','class':"Proto_tabs_navigation_pane"});
          	contentarea.insertBefore(pane,t);
            var panewrap=new Element('div',{'class':"Proto_tabs_navigation_pane_wrap"});
          	pane.wrap(panewrap);
            var firstelement=false;
            var totwidth=0;
            t.childElements().each(function(c){
              if(c.tagName=="DIV"&&c.title!="")
                {
                  if(!firstelement)
                {
                  firstelement=c;
                }
                else
                {
                  if(typeof c.id=="string")
                    {
                      c.hide();
                    }
                }
                c.but=new Element('a',{'class':"Proto_tabs_navigation"+((firstelement==c)?" hightlight":""),'href':'#'+c.id});
                pane.insert(c.but);
                c.but.update(c.title);
                totwidth+=c.but.getAllDimensions().width;
                }
            });
            
            //pane.style.width = totwidth+"px";
			
          
          
          new PeriodicalExecuter(function(){
            if(document.location.hash.replace("#","")!=currenthash)
            {
            
              currenthash=document.location.hash.replace("#","");
              if(_(currenthash)){
              if(typeof _(currenthash).parentNode=="object")
            {
              if(_(currenthash).parentNode.hasClassName(classname))
                {
                
                var ans = _(currenthash).ancestors();
                           ans.each(function(t){
                           		if(t!=_(currenthash).parentNode&&!t.visible())
                           		{
                           			if(Proto.UI.alltabs.indexOf(t.parentNode)!=-1)
                           				{
	                           					t.parentNode.childElements().each(function(c){
	                           					c.hide(); 
	                           					c.but.removeClassName('hightlight');
												c.style.opacity=1;
                           					});
                           					t.show();t.but.addClassName('hightlight');	
                           				}
                           				
                           		}
                           	});
                           	
                
                  _(currenthash).parentNode.childElements().each(function(c)
                {
                    if(c.id!=currenthash&&c.tagName=="DIV"&&c.title!="")
                      {
                    		                    new Effect.Fade(c,{
		                    	duration:0.5,
		                    	afterFinish: function(){
		                    		c.but.removeClassName('hightlight');
                            		new Effect.Appear(currenthash,{
                            				duration:0.5,
		                    				afterFinish: function(){
		                    					_(currenthash).but.addClassName('hightlight');
		                    				}
                            			});
		                    	}
		                    })
		                    
                      
                      }
                      
                  
                });
                  
                  
                  }
            }
            }}
          }, 0.1);
          });


    }