/**
 * show-hide-abstracts.js provide the functionality
 * for showing and hiding abstracts displayed in
 * the listing tables. it's written in an unobtrusive
 * manner so that user's who have disabled javascript
 * will see all abstracts in the expanded state.
 */
$(document).ready( function(){
	
//- only show the "Show/Hide Abstracts" link if we have one
	$(".show-hide-abstracts").each( function(){
		if( $(this).parent().parent().find(".abstract").size() > 0 ){
			$(this).css({"display":"inline"});
		}
	});
	
//- when the "hide" link is clicked -->	
	$(".hide-abstracts").click( function(){
		var t = $(this), p = t.parent();
		p.parent().parent().find(".abstract").slideUp();
		p.find(".show-abstracts").removeClass("inactive");
		t.addClass("inactive");
		return false;
	});
//- when the "show" link is clicked -->	
	$(".show-abstracts").click( function(){
		var t = $(this), p = t.parent();
		// open a collapsed section if it's closed and we click on a 'show' abstract link
		var ec = p.parent().find(".expand-section");
		if(ec.attr("class") && ec.attr("class").indexOf('inactive')<0){
			ec.click();
		}
		p.parent().parent().find(".abstract").slideDown();
		p.find(".hide-abstracts").removeClass("inactive");
		t.addClass("inactive");
		return false;
	});
	
	
//- when the Factbook TOC "hide" link is clicked -->	
	$("#factbooklinks .hide-abstracts").click( function(){
		var t = $(this), p = t.parent();
		$(".toc-wrapper").find(".factbook").find(".abstract").slideUp();
		p.find(".show-abstracts").removeClass("inactive");
		t.addClass("inactive");
		return false;
	});
//- when the Factbook TOC "show" link is clicked -->	
	$("#factbooklinks .show-abstracts").click( function(){
		var t = $(this), p = t.parent();
		$(".toc-wrapper").find(".factbook").find(".abstract").slideDown();
		p.find(".hide-abstracts").removeClass("inactive");
		t.addClass("inactive");
		return false;
	});
			
	
//- open any abstracts that we want open by default
	$(".default-to-open .show-abstracts").click();
	
});
// -- show the hide/show links & hide all the abstracts -->
document.write('<style type="text/css">.abstract{display: none}</style>');