$(document).ready(function() {
	
	//page transition start
	$(window).bind("unload", function() {});
	$("#pictureBar,#breadcrumb>span").css("display", "none");
	$("#pictureBar,#breadcrumb>span").fadeIn(400);
	
	$("#navigation a").click(function(event) {
	//	event.preventDefault();
		linkLocation = this.href;
		$("#pictureBar,#breadcrumb>span").fadeOut(300, redirectPage);
		$("#mainContent").animate({opacity:0}, 300);
	});

	function redirectPage() {
		window.location=linkLocation;
	}
	
	//page transition end




	//hoverintent configuration:
	var config = {    
    	over: makeTall, // function = onMouseOver callback (REQUIRED)    
    	timeout: 400, // number = milliseconds delay before onMouseOut    
    	out: makeShort // function = onMouseOut callback (REQUIRED)    
	};
	//end hoverintent configuration



	function accordion_nav() {
		$("body").addClass("enhanced");
		$("#navigation > li").not(".current_page_item").find("ul").hide();
		
		$("#navigation > li.current_page_item").find("ul").show();
		$("#navigation > li.current_page_ancestor").find("ul").show();
		
		$("#navigation > li a").hoverIntent(config);
	}
	
	$("#mainContent,#header,#footer,#pictureBar,#homepage_image").mouseover(function() {restore_nav();});
	
	$(accordion_nav);


	$('li.current_page_item a:first').addClass('on');


	//contact form handler
	$("#ajax-contact-form").submit(function() {

	var str = $(this).serialize();

	$.ajax({
	  	type: "POST",
	   	url: "/wp-content/themes/pirco/formmail/formmail.php",
	   	data: str,
	  	success: function(msg) {

		$("#note").ajaxComplete(function(event, request, settings){
	
			if(msg == 'OK') { // Message Sent? Show the 'Thank You' message and hide the form
				result = '<div class="notification_ok" style="height:700px; color:#000; font-weight:normal;">Thank you for your Volunteer registration.<br /><br />We will contact you shortly.</div>';
				$("#volunteer_form").hide();
			} else {
				result = "<span style='color:red;'>"+msg+"</span>";
			}
	
			$(this).html(result);
		});

		}

	 });

	return false;

	});

	// end contact form handler



 });

function restore_nav() {
		$("body").addClass("enhanced");
		$("#navigation > li").not(".current_page_item").find("ul").slideUp();
		$("#navigation > li.current_page_item").find("ul").slideDown();
		
}


function makeTall() {
			if ($(this).parent().find("ul").is(":hidden")) {
				$("#navigation ul:visible").slideUp();
				$("#navigation > li").removeClass("selected");
				$(this).parent().addClass("selected");
				$(this).parent().find("ul").slideDown();
			}};


function makeShort() {};


