// 
// MappingDuBois.org
// Michelle Rajunov
// JQuery - about page
// Feb 7, 2009
//
// contains:
// 	- ajax contact form 
// 	- staff scrolling, using ScrollTo plugins
//


$(document).ready(function() {  

	// send contact form via AJAX
   	$('#contact_form').submit(function(){
		var data = [];					//data array
		data.push("action=contact");	//action for php
		data.push("blanky=blank"+$("#blanky").val()); //for spam protection, value must be "blank"
		data.push("contact_name="+ $("#contact_name").val());
		data.push("contact_email="+ $("#contact_email").val());
		data.push("contact_subject="+ $("#contact_subject").val());
		data.push("contact_message="+ $("#contact_message").val());
		jQuery.ajax({ 
			type: "POST", 
			url:  "../php/update.php",		//send to update.php
			data: data.join("&"), 	
			success: contactSuccess
		}); 
		return false;
	});
	


	////////////  Preload Plugin for images
	// doesn't really seem to make a difference sometimes
	$("#staff_info img").preload(); 


	// serialScroll plugin  for staff list
	// staff list is organized by:
	// 	each year has a ul
	// 	scroll vertical y for each year, horizontal on x for each person
	//  
	// http://flesler.blogspot.com/2008/02/jqueryserialscroll.html
	//
	$('#staff').serialScroll({
		target:'#staff_info',	//
		items:'li', // Selector to the items ( relative to the matched elements )
		axis:'xy',
		queue: true,
		navigation:'#staff_list li a',
		duration: 1200,
		hash: true,
		constant: false,
		stop: true,
		lock: false,
		force: true,
		easing:'easeOutQuart'
	});


});

// callback for ajax
// regular text to populate #contact_success div with success message
// text = message of status/success
function contactSuccess(text, status){
	$('#contact_success').html(text).slideDown(1000).animate({opacity: 1.0}, 2000).slideUp(1000);
}