/*
$(function() {
    var foundin = $('*:contains("I am a simple string")');
});
*/

$(document).ready(function(){
	$(".expandExcerpt").each(function() {
		// Grab the HTML and flatten it into a string
		var s = $(this).html();
		var s = String(s);

		// Break it at these characters
		var matchLoc = s.search(/PAGEBREAK/)
		
		// If there is a break then slice stuff up and add a button
		if (matchLoc != -1){
			var s1 = s.slice(0,matchLoc);
			var s2 = s.slice(matchLoc+9);
			var s = s1 + s2;
			
			// Add Button
			$(this).parent().parent().children(".expandButton").css("display","block");
			
			// Add Text
			$(this).parent().children(".expandContent").html(s);
			$(this).html(s1);
		
		}
		
	});
});


$(function() {

	$(".expandButton a").click(
		function (event) { 
	   		var expandContent = $(this).prevALL('.expandContent:first');
	   		var expandExcerpt = $(this).prevALL('.expandExcerpt:first');
			
			if ( expandContent.hasClass('is_on') ){
		   		expandContent.css({'display' : 'none'});
				expandExcerpt.css({'display' : 'block'});
				$(this).html("Read More &raquo;");
				expandContent.removeClass('is_on');
			} else {
				
		   		expandContent.css({'display' : 'block'});
				expandExcerpt.css({'display' : 'none'});
				$(this).html(" &laquo; Read Less");
				expandContent.addClass('is_on');
			}
	   	}
	);
	

});

