$(document).ready( function() {

	// Print link
	$("p.print a").click( function(e) {
		e.preventDefault();
		window.print();
	});
	
	// Staff more/less
	$(".staff-bio").after("<a href='#' class='staff-more'>read more</a>");
	$(".staff-bio").height("3.5em");
	$(".staff").addClass("more");
	
	$(".staff-more").click( function(e) {
		e.preventDefault();
		
		// Expand or contract
		if( $(this).text() == 'read more' ) {
			// expand
			$(".staff-more").text('read more');
			$(".staff-more").removeClass('close');
			$(this).text('close');
			$(this).toggleClass('close');
			
			_shrink( $(".staff-bio") );
			_expand( $(this).prev() );
			
			
		} else {
			// contract
			$(this).text('read more');
			$(this).toggleClass('close');
			
			_shrink( $(this).prev() );
			
		}
		
	});
	
	// Implants collapsible items
	$(".collapsible").hide();
	$(".collapsible").after("<a href='#' class='collapsible-more'>implants</a>");
	
	$(".collapsible-more").click( function(e){
		e.preventDefault();
		
		if( $(this).text() == 'implants' ) {
			// expand
			$(".collapsible-more").text('implants');
			$(".collapsible-more").removeClass('close');
			$(this).text('close');
			$(this).toggleClass('close');
			
			
			$(".collapsible").slideUp();
			$(this).prev().slideDown();
		} else {
			// contract
			$(this).text('implants');
			$(this).toggleClass('close');
			$(this).prev().slideUp();
		}
		
	});
	
	//
	//
	//
	
	// Expand function
	function _expand(obj) {
		// Hack to animate to 100% - set height 100% and retrieve value and store then set back to starting value
		bio_height = obj.height("100%").height();			
		obj.height("3.5em");
		
		obj.animate({
				height: bio_height
			},
			{
				duration: 500,
				queue: false
			}
		);
	}
	//
	
	// Shrink function
	function _shrink(obj) {
		obj.animate({
				height: '3.5em'
			},
			{
				duration: 500,
				queue: false
			}
		);
	}
	//
	
	
});
