// JavaScript Document
jQuery(document).ready(function($){
	
	//
	// Slideshow functionality
	//
	/*
		TODO adjust speed
	*/
	$('#slideshow').cycle('fade');
	
	//
	// Add class to round corners of form input elements
	//
	$('.gform_wrapper input').addClass('rounded');
	$('.gform_wrapper select').addClass('rounded');
	$('.gform_wrapper textarea').addClass('rounded');
	
	//
	//Empty form values when field is selected
	//
	$('.gform_wrapper input, .gform_wrapper textarea').focus(function() {	
		if ($(this).val() == this.defaultValue) {
			$(this).val("");
		}
		
	});
	
	//
	// Expand Learning Center Section
	//
	$(".post_header").hover(function() {
		$(this).css("cursor", "pointer");
		
	});
	$( ".post_header" ).click( function() {
		var index = $( ".post_header" ).index( this );
		if ( $( ".post_data" ).eq( index ).is( ":visible" ) ) {
			$(".image").eq( index ).removeClass("active_image").addClass("inactive_image");
			$(".status").eq( index ).removeClass("open_status").addClass("closed_status");
			$( ".post_data" ).slideUp( "slow" );
			console.log(index);
			
			
		} else {
			$( ".post_data" ).slideUp( "slow" );
				$(".image").removeClass("active_image").addClass("inactive_image");
				$(".status").removeClass("open_status").addClass("closed_status");
			var index = $( ".post_header" ).index( this );
				$(".image").eq(index).removeClass("inactive_image").addClass("active_image");
				$(".status").eq(index).removeClass("closed_status").addClass("open_status");
			$( ".post_data" ).eq( index ).slideDown( "slow" );
		
		}
		
	});
	
	//
	// Header Popup Display
	//
	$("#promo").hover( function() {
		$("#popup").show();
	});
	// Hide popup when clicked outside
	$('#close').click(function() {
		$('#popup').hide();
	})
	$('body').click(function() {
		$('#popup').hide();
	})
	// Prevent clicking inside popup from hiding it
	$('#popup').click(function(event){
		event.stopPropagation();
	})
	
    
});