(function($){
    $(document).ready(function() {
        // open twitter share page in popup
        $(".social a.tw").click(function(){window.open(this.href,'share','width=600,height=450');return false;});
        
        // add class to sidebar links that have child pages
        $("#secondary li ul.children").prev().addClass("has_children");
      
        // collapse sidebar menus
        $("#secondary a.has_children").click(function(){
            $(this).closest("li").children("ul.children").toggle();
            $(this).closest("li").toggleClass('current_page_ancestor');
            // return false; // prevents actually going to the link's href 
        });
        $("#secondary li.current_page_parent>a").click(function(){
            return false;
            $(this).closest("li").children("ul.children").toggle();
            $(this).closest("li").toggleClass('current_page_ancestor');
        });
        
        // nice form labels
        $("#search label, #mailchimp label").inFieldLabels(); 
        
        // handy class for menu styling
		jQuery("#access li:last-child").addClass('last-child');
		
		// set up accordion
		jQuery(".spa-service .entry-content").accordion({
		    autoHeight: false,
			collapsible:true,
			change: function(event, ui){
				//$(ui.oldHeader)
				//jQuery(".spa-service .entry-content").accordion("activate", 2);
			}
		});
        
        
    });
})(jQuery);
