jQuery(function() {
	var $ = jQuery;
	
	// Open/close sections of text
	
	$('.moreContent').hide().each(function() {
		var moreContent = $(this);
		$("<p class='moreToggle'><a href='#'>More</a></p>").insertBefore(moreContent).find('a').toggle(
			function() {
				$(this).text("Close").addClass('open');
				moreContent.slideDown();
			},
			function() {
				$(this).text("More").removeClass('open');
				moreContent.slideUp();
			}
		);
	});
	
	$('.wpTableOfContents').hide().each(function() {
		var wpTableOfContents = $(this);
		$("<p class='moreToggle'><a href='#'>View Table of Contents</a></p>").insertBefore(wpTableOfContents).find('a').toggle(
			function() {
				$(this).text("Hide Table of Contents").addClass('open');
				wpTableOfContents.slideDown();
			},
			function() {
				$(this).text("View Table of Contents").removeClass('open');
				wpTableOfContents.slideUp();
			}
		);
	});

	// Slide Scroller
	
	var slideScroller = $(".slideScroller")
		.scrollable({
			size: 1,
			loop: true,
			clickable: false
		})
		.circular()
		.autoscroll({
			interval: 11000,
			api: true
		});
		
	if (slideScroller) {
		prettyPhotoCallback = function() {
			setTimeout(slideScroller.play, 2000);
		}
	}
	
	// Tooltip Hovers
	
	var tooltip = $(document).ready(function() {
		$(".tooltipLink").tooltip({ 
			effect: 'fade',
			position: 'bottom center'
		});
	});
	
	// Search Box Placeholder
	
	var searchBoxPlaceholder = $("input[placeholder]").placeHeld({
	  className: "placeheld"
	});
	
	// Pretty photo popins

	var params = {
		theme: 'marklogic',
		callback: function() { // let pages set this function
			try {
				prettyPhotoCallback();
			} catch(e) {}
		}
	};
	
	if (typeof prettyPhotoWidth != 'undefined') params['default_width'] = prettyPhotoWidth;
	$("a[rel^='prettyPhoto']:not(.oneOff)").prettyPhoto(params);
});

if (typeof sIFR == "function") {
	sIFR.replaceElement("h2.pageTitle, .resourceBox h2, .split .side h2", named({
		sFlashSrc: "/js/sifr/fago.swf",
		sColor: "#F96D07",
		sWmode: "opaque"
	}));
	
	sIFR.replaceElement(".subTitle, .footer h2", named({
		sFlashSrc: "/js/sifr/fago.swf",
		sColor: "#333333",
		sWmode: "transparent"
	}));
	
	sIFR.replaceElement(".subTitle2", named({
		sFlashSrc: "/js/sifr/fago.swf",
		sColor: "#3366CC",
		sWmode: "transparent"
	}));
}

