jQuery(document).ready(function(){ 


       var themeUrl = 'http://www.woothemes.com/wp-content/themes/woo2'; 
       
       var anchor = jQuery('#theme-docs .doc-magic h3:first-child').next();

       jQuery('#theme-docs .doc-magic > *').each(function(){ 
            
           if (this.tagName != 'H3' && this.tagName != 'H2' && this.tagName != 'H6'){  
            anchor = anchor.add(this);  

           }
           if (this.tagName == 'H3' || this.tagName == 'H6'){ 
           
           
           anchor.wrapAll('<div class="docs-content"></div>');
           anchor = jQuery(this).next();    
           } 
           
       });
       
       jQuery('#theme-docs .doc-magic h3').addClass('fl').after('<div class="plus fr"><img src="' + themeUrl + '/images/ico-plus.png" alt="+" /></div>');
       jQuery('#theme-docs .doc-magic .docs-content').after('<div class="fix"></div>'); 
       
       var anchor2 = jQuery('#theme-docs .doc-magic h2:first-child').next();
       var h2_fix = 0;
       jQuery('#theme-docs .doc-magic > *').each(function(){
        
           h2_fix++; 
           
           if (this.tagName != 'H2' && this.tagName != 'H6'){  
            anchor2 = anchor2.add(this);  

           }
           if ((this.tagName == 'H2' || this.tagName == 'H6') && h2_fix != 1){ 
           
           
           anchor2.wrapAll('<div class="docs-paged"></div>');
           anchor2 = jQuery(this).next();    
           } 
            
       });  
       
      
      jQuery('#theme-docs .doc-magic h3').next().next().slideUp('fast');
      
      jQuery('#theme-docs .doc-magic h2').each(function(){jQuery(this).next().children('.docs-content:first').slideDown();});
      
      jQuery('#theme-docs .doc-magic h2').hide();
      
      var pages = 1; 
      
      jQuery('#theme-docs .doc-magic .docs-paged').each(function(){
        //alert(pages);
        jQuery(this).addClass('docs-paged-' + pages);
         if(pages >= 2){
            jQuery(this).hide()
         }
         pages++;
          
          
      });
      
  //create Clickable h3 & .plus heading
  
    jQuery('#theme-docs .doc-magic h3').each(function(){
          jQuery(this).next('.plus').add(this).wrapAll('<div class="docs-heading cl"></div>'); 
    
    }) 
       
    jQuery('#theme-docs .doc-magic .docs-heading').click(function(){
    
        jQuery(this).next('.docs-content').slideToggle('slow');
    
    });

    
    var page_index = 1;
    
   


    
    
    jQuery('#theme-docs .doc-magic h2').each(function(){
    
        var tabString = jQuery(this).text().replace(/ /g,'');
        
        jQuery('#theme-docs #page-tabber').append('<li class="'+ tabString +'"><a href="#'+ tabString +'" rel="'+ page_index +'">' + jQuery(this).text() + '</a></li>');
        page_index++; 
      });
    

    jQuery('#theme-docs #page-tabber li:first-child').addClass('active');
   

      
    jQuery('#theme-docs #page-tabber li a').click(function(){
    
        
        var cur_page = jQuery('#theme-docs #page-tabber li.active a').attr('rel');

        jQuery('#theme-docs .docs-paged-'+cur_page).fadeOut('fast',function(){
                jQuery('#theme-docs .docs-paged-' + page_clicked).fadeIn('slow')
            });
        
        jQuery('#theme-docs #page-tabber a').parent().removeClass('active');

        var page_clicked = jQuery(this).attr('rel');
                          
        
        jQuery(this).parent().addClass('active');
    
    })
    
    

    
    jQuery('ul.changelog-entry:empty').remove();
    
    
    

});

jQuery(window).load(function(){
        
    var page = location.hash;
    page = page.substr(1);
  
    
   
    if(page != ''){
    
    
     jQuery('#theme-docs #page-tabber li.'+ page +' a').click();
    }
    
})