jQuery(document).ready(function($){
	
	// Banner cycling
	$('.slide').cycle({
		fx: 'fade',
		speed: 1500
	});

	//Scroll To Top
	$('a.top-link').click(function(){
		$('html, body').animate({scrollTop:0}, 'slow');
		return false;
	});
	
	// Sidebar contact form.
	$('.labelify').labelify(); 
	$('#contact, #volunteer').validate({
		ignoreTitle: true,
		errorElement: 'div',
		errorPlacement: function(error, element) {
			error.insertBefore(element);
			$('.labelify').labelify();
 		},
		submitHandler: function(form) {
			$(form).ajaxSubmit({
 				success: function(){
					$(form).slideUp(function(){
						$('.notification.success').slideDown();
 					});
				}
			});
 		}
	});

	//Homepage Banner Slideshow
	$(".bannertabs").tabs(".banner > div", {
	
		// enable "cross-fading" effect
		effect: 'fade',
		fadeOutSpeed: "slow",
		// start from the beginning after the last tab
		rotate: true
	//Use the slideshow plugin. It accepts its own configuration
	}).slideshow({autoplay: true, interval: 5000});
	
	
	//Hide and Show Archive Article Excerpts	
	$(".excerpt").hide();
	$("div.readmore").click(function() {
	
		// Get associated div
		var excerptDiv = $(this).next('div.excerpt');
		
		if($(excerptDiv).is(':hidden')) {
			//alert('hidden');
			
			$(excerptDiv).slideDown({
				duration: 400,
				easing: 'easeInOutSine'});						
		}else{
			$(excerptDiv).slideUp({
			duration: 400, 
			easing: 'easeInOutSine'});
			//alert('visable');		
		}				
											
	});
	
	
	// Rounded corners.
	$('.team, .inner').corner('8px');
	
	// main vertical scroll
	$("#main-about").scrollable({
		// basic settings
		vertical: true,
		// up/down keys will always control this scrollable
		keyboard: 'static'
	// main navigator (thumbnail images)
	}).navigator("#main-navi");
	
	// horizontal scrollables. each one is circular and has its own navigator instance
	var horizontal = $(".flowpanes").scrollable({ circular: true }).navigator({

		// select #flowtabs to be used as navigator
		navi: ".navi",

		// select A tags inside the navigator to work as items (not direct children)
		naviItem: 'a',

		// assign "current" class name for the active A tag inside navigator
		activeClass: 'current',

		// make browser's back button work
		history: true

	});

	// when page loads setup keyboard focus on the first horzontal scrollable
	//horizontal.eq(0).data("scrollable").focus();

});
