/* YWCA Plugins */
$.fn.fadeToggle = function(speed, easing, callback) {
	return this.animate({opacity: 'toggle'}, speed, easing, callback);
};
	 
$(document).ready(function() {
	
   	// Home Page Scroller
   	$('#featureScroller').before('<div id="fs-nav">').cycle({ 
		fx:     	'fade', 
		speed:   	1000, 
		timeout: 	8000,
		delay: 		-3000,
		pause: 		1,
		pager: 		'#fs-nav'
	});
	
	// News & Events Tabs (home & sidebar)
	var tabContainers = $('#newsEvents > div');
    $('#newsEvents ul#ne-nav a').click(function () {
        tabContainers.hide().filter(this.hash).show();
        
        $('#newsEvents ul#ne-nav a').removeClass('selected');
        $(this).addClass('selected');
        
        return false;
    }).filter(':first').click();
	
	$('.ne-listing li:last-child').css('border-bottom','none');
	
	// Mailto: add class
	$('a[href^=mailto:]').addClass('mailto');
	// PDF: add class
	$('a[href$=pdf]').addClass('pdf');
	// Word: add class
	$('a[href$=doc], a[href$=docx]').addClass('doc');
	// Excel: add class
	$('a[href$=xls], a[href$=xlsx]').addClass('xls');
	
	// Opens new window for external sites
	$("a.external").click(function(){
		window.open(this.href);
		return false;
	});
	
	// Search focus remove
	$("#search-field").focus(function() {
		if( this.value == this.defaultValue ) {
			this.value = "";
		}
	}).blur(function() {
		if( !this.value.length ) {
			this.value = this.defaultValue;
		}
	});
	
	// Tell a Friend
	$("#tellfriend").hide();
	$("a.email, a.close").click(function() {
		$("#tellfriend").fadeToggle('slow');
			return false;
	});
	
	// Gallery
	$("a.gallery").colorbox();
	
}); // end doc ready
