/* ============================================================
National Geographic Expand for More Demo JavaScript (Using JQuery)
* Created by Brian Talbot on 4008-08-30.
* Copyright (c) 4008 National Geographic. All rights reserved.

============================================================ */

// Initiating things when the DOM loads
$(document).ready(function() {

/* ------------------------------------------------------------
+For Boxes Class lesson-plans
------------------------------------------------------------ */
	// Making sure that there are at least three paragraphs
	if ($('.box-expand .lesson-plans > *').size() > 4) {

		// insert a wrapper div after the 4nd paragraph (and hide it)
		var $xwrapper = $('<div class="expand-container"></div>').insertAfter('.box-expand .lesson-plans > *:eq(3)').hide();

		// append all paragraphs following the 4nd into that wrapper div
		$('.box-expand .lesson-plans > *:gt(4)').appendTo($xwrapper);

		// Add in Toggle Button
		$('.box-expand .lesson-plans').append('<a class="lesson-plans-toggle" href="">Expand/Collapse This</a>');

		// Toggles the newly made and hidden container up and down
		$('.lesson-plans-toggle').click(function(){

			// Slowly expand/collapse
			$xwrapper.slideToggle('slow');

			// Toggles class on Toggle Button
			$(this).toggleClass('lesson-plans-toggle-opened')

			// Disables the default HTML behavior of the <a> element
			return false;
		   });
	}	
/* ------------------------------------------------------------ */
	
});

// Initiating things when the DOM loads
$(document).ready(function() {

/* ------------------------------------------------------------
+For Boxes Class lesson-plans-mod
------------------------------------------------------------ */
	// Making sure that there are at least three paragraphs
	if ($('.box-expand .lesson-plans-mod > *').size() > 2) {

		// insert a wrapper div after the 2nd paragraph (and hide it)
		var $xwrapper = $('<div class="expand-container"></div>').insertAfter('.box-expand .lesson-plans-mod > *:eq(1)').hide();

		// append all paragraphs following the 2nd into that wrapper div
		$('.box-expand .lesson-plans-mod > *:gt(2)').appendTo($xwrapper);

		// Add in Toggle Button
		$('.box-expand .lesson-plans-mod').append('<a class="lesson-plans-toggle" href="">Expand/Collapse This</a>');

		// Toggles the newly made and hidden container up and down
		$('.lesson-plans-toggle').click(function(){

			// Slowly expand/collapse
			$xwrapper.slideToggle('slow');

			// Toggles class on Toggle Button
			$(this).toggleClass('lesson-plans-toggle-opened')

			// Disables the default HTML behavior of the <a> element
			return false;
		   });
	}	
/* ------------------------------------------------------------ */
	
});

// Initiating things when the DOM loads
$(document).ready(function() {

/* ------------------------------------------------------------
+For Boxes Class maps
------------------------------------------------------------ */
	// Making sure that there are at least two paragraphs
	if ($('.box-expand .maps > *').size() > 4) {

		// insert a wrapper div after the 4nd paragraph (and hide it)
		var $xwrapper = $('<div class="expand-container"></div>').insertAfter('.box-expand .maps > *:eq(3)').hide();

		// append all paragraphs following the 4nd into that wrapper div
		$('.box-expand .maps > *:gt(4)').appendTo($xwrapper);

		// Add in Toggle Button
		$('.box-expand .maps').append('<a class="maps-toggle" href="">Expand/Collapse This</a>');

		// Toggles the newly made and hidden container up and down
		$('.maps-toggle').click(function(){

			// Slowly expand/collapse
			$xwrapper.slideToggle('slow');

			// Toggles class on Toggle Button
			$(this).toggleClass('maps-toggle-opened')

			// Disables the default HTML behavior of the <a> element
			return false;
		   });
	}	
/* ------------------------------------------------------------ */
	
});


// Initiating things when the DOM loads
$(document).ready(function() {

/* ------------------------------------------------------------
+For Boxes Class activities
------------------------------------------------------------ */
	// Making sure that there are at least three paragraphs
	if ($('.box-expand .activities > *').size() > 4) {

		// insert a wrapper div after the 4nd paragraph (and hide it)
		var $xwrapper = $('<div class="expand-container"></div>').insertAfter('.box-expand .activities > *:eq(3)').hide();

		// append all paragraphs following the 4nd into that wrapper div
		$('.box-expand .activities > *:gt(4)').appendTo($xwrapper);

		// Add in Toggle Button
		$('.box-expand .activities').append('<a class="activities-toggle" href="">Expand/Collapse This</a>');

		// Toggles the newly made and hidden container up and down
		$('.activities-toggle').click(function(){

			// Slowly expand/collapse
			$xwrapper.slideToggle('slow');

			// Toggles class on Toggle Button
			$(this).toggleClass('activities-toggle-opened')

			// Disables the default HTML behavior of the <a> element
			return false;
		   });
	}	
/* ------------------------------------------------------------ */
	
});


// Initiating things when the DOM loads
$(document).ready(function() {

/* ------------------------------------------------------------
+For Boxes Class resources
------------------------------------------------------------ */
	// Making sure that there are at least three paragraphs
	if ($('.box-expand .resources > *').size() > 4) {

		// insert a wrapper div after the 4nd paragraph (and hide it)
		var $xwrapper = $('<div class="expand-container"></div>').insertAfter('.box-expand .resources > *:eq(3)').hide();

		// append all paragraphs following the 4nd into that wrapper div
		$('.box-expand .resources > *:gt(4)').appendTo($xwrapper);

		// Add in Toggle Button
		$('.box-expand .resources').append('<a class="resources-toggle" href="">Expand/Collapse This</a>');

		// Toggles the newly made and hidden container up and down
		$('.resources-toggle').click(function(){

			// Slowly expand/collapse
			$xwrapper.slideToggle('slow');

			// Toggles class on Toggle Button
			$(this).toggleClass('resources-toggle-opened')

			// Disables the default HTML behavior of the <a> element
			return false;
		   });
	}	
/* ------------------------------------------------------------ */
	
});


