var collapsedHeight = 65;

$(document).ready(function(){
	$('#tabs td:not(.noajax) a').click(function(event) {
		event.preventDefault(); // stop normal link behaviour
		$.ajax({
			url: $(this).attr('href'), // use href of link for ajax target
			cache: false,	//always get latest version
			success: function(html) {
				$("#ajax").html(html);	// put result in div#ajax
				
				// Accordion menus
				$('.collapse').css('overflow', 'hidden').each(function() { // hide content when section isn't large enough
					$(this).css('max-height', $(this).height()); // assign expanded height to max-height css property
				}).height(collapsedHeight); 
			
				$('.collapse h6').mousedown(function(){	// attach function to click event
					if ($(this).parent().height() > collapsedHeight) {
						$('.collapse').animate({height: collapsedHeight}, 1000);	// close all collapsible sections
					} else {
						$('.collapse').animate({height: collapsedHeight}, 1000);	// close all collapsible sections
						$(this).parent().animate({height: $(this).parent().css('max-height')}, 1000); // open clicked on section
					}
				});
			}
		});
	
		$('#tabs td a').css('background-color', '#EFEFEF'); // reset background color for tabs
		$(this).css('background-color', '#E6E6E6'); // set darker bg color for selected tab
		$(this).hideFocus = true; // remove focus border

	});
	
	$('#aims_tab').click();

});


