$(document).ready(function(){
	
	//Add print functionality
	$('a.print').click(function(){
		window.print();
		return false;
	});
	
	//Setup FAQs and Leaders accordian
	$('#faqs,#leaders').accordian();
	
	//Setup photo galleries
	$("a[rel^='prettyPhoto']").prettyPhoto();
	
	//Setup form on home page
	function setFieldValue(id,value){
		$('#'+id).val(value).focus(function(){
			if( $(this).val() == value)
				$(this).val('');
		}).blur(function(){
			if( $(this).val() == '')
				$(this).val(value);
		});
	}
	setFieldValue('planning-a-trial-small-email','Enter your email');
	
	$('#tweets').each(function(){
		fetch_tweets(this);
	});
	
	//$('a[href^="http://"]').

	
});


(function($) {
    // Hides the text under each list item and shows
	// it when the header is clicked.
    $.fn.accordian = function() {
        // Iterate over each element
        return this.each(function() {
            $this = $(this);
            
            // Cache the list of items
            var items = $this.children('li');
			var answers = $('.answer', items);
            
            items.each(function() {
				// Cache the answer
				var answer = $('.answer', this);
                // And hide it
                answer.hide();
                
                // Set up the click event on the header
                $(this).children('h2')
					.wrap('<a href="#"></a>')
					.click(function() {

                    	answer.slideToggle(400);
						return false;
                	});
            });
        });
    };
})(jQuery);