$(document).ready(function() {


// Swap form field values when focused
	$('input#searchTerm, input#keywordsearch, input#search-box').each(function() {
	    //var default_value = this.value;
		 var default_value = 'Enter Keywords';
	    $(this).focus(function() {
	        if(this.value == default_value) {this.value = '';}
	    });
	    $(this).blur(function() {
	        if(this.value == '') {this.value = default_value;}
	    });
	});

// Swap form field values when focused
	$('#coop-search input#searchBox').each(function() {
	    //var default_value = this.value;
		 var default_value = 'By Keyword';
	    $(this).focus(function() {
	        if(this.value == default_value) {this.value = '';}
	    });
	    $(this).blur(function() {
	        if(this.value == '') {this.value = default_value;}
	    });
	});


// Special list type from TinyMCE
	$('#content ul li.arrowlist:even').addClass('alt');
	

// Open certain links in new window/tab
	$('#related-resources li.photo-library a, #related-resources li.video-archive a').click(function() {
		$(this).attr('target','_blank');
	});
	

// Homepage slieshow configuration
	$('#home #slides').cycle({
		fx: "fade",
		timeout: 6000,
		activePagerClass: "active",
		pager:  '#home #slide-controls',
		prev: '#slide-functions a.prev',
		next: '#slide-functions a.next',
		pagerAnchorBuilder: function(idx, slide) { return '#slide-controls li:eq(' + idx + ') a'; } 
	});
	
	
// Homepage slideshow controls
	$('#slide-functions a.pause').click(function() {
		$('#home #slides').cycle('pause');
		$(this).hide();
		$('#slide-functions a.play').css('display','block');
	});
	
	$('#slide-functions a.play').click(function() {
		$('#home #slides').cycle('resume');
		$(this).hide();
		$('#slide-functions a.pause').css('display','block');
	});


// Toggle description for co-op tools resources
	$('#results .result-description a').click(function() {
		$(this).toggleClass('active');
		$(this).parent().find('.summary').toggle();
		
		return false;
	});
	
	
// Toggle date and description for member announcements
	$('#member #listings li').click(function() {
		$(this).parent().find('li.active').removeClass('active').find('.description, .date, .alt-date').toggle();
		$(this).toggleClass('active');
		$(this).find('.description, .date, .alt-date').toggle();
	});
	
	
// Print this page functionality
	$('#share li.print a').click(function() {
		window.print();		
		return false;
	});
	
	
// Show and hide the FAQ sections (one at a time only)
	$('#faq-list h2').click(function() {
		$('#faq-list ul').hide();
		$(this).next('ul').toggle();
		
		return false;
	});
	
	$('#faq-list').find('li.current').parent('ul').show();


// Decode encrypted blocks of text
	var encDivs=$('.jsNeeded');
	for (var i=0;i<encDivs.length;i++) {
		var encoded=$(encDivs[i]).attr("data-enc");
		eval(rot13(unescape(encoded)));
		$(encDivs[i]).html(decoded);
	}
	
	
// Apply CKEditor to campaign message field
	$('textarea.ckeditor').ckeditor({
		width: 540,
		height: 550,
		toolbar: [['Bold', 'Italic', '-', 'NumberedList', 'BulletedList', '-', 'Link', 'Unlink']],
		removePlugins: 'elementspath'
	});

	
}); // End of document ready
