 jQuery(document).ready(function(){
       
	   jQuery('.gallery-icon a, .wp-caption a, a.colorbox').each(function() {
			jQuery(this).colorbox({rel: '.gallery-icon a, .wp-caption a, a.colorbox', title: jQuery(this).find('img').attr('title')});
		}); 													 
	   
	   jQuery("a.contact").click(function() { return false; });
	   jQuery("a.contact").colorbox({inline:true, href:"#contactpopup_paz"});
	   
	   jQuery("a.newsletter_link").click(function() { return false; });
	   jQuery("a.newsletter_link").colorbox({inline:true, href:"#newslettermenu"}); 
	   
	   jQuery("a.colorbox_content").click(function() {
	   		var target = jQuery(this).attr('id');
			jQuery.fn.colorbox({inline:true, href:"#target_" + target, open: true, title: '', width: 650});
			return false;
	   });
	   
	   jQuery("form.ccoptin").submit(function() {
	   	var ccString = jQuery(this).serialize();
		jQuery.fn.colorbox({iframe: true, href: 'http://oi.vresp.com?fid=8edfa6fbca&' + ccString, open: true, height: 500, width: 640});
		return false;
	   });
	   
	   jQuery('a.reveal, #contact_mis').click(function() { return false; });
	   jQuery('a.reveal, #contact_mis').colorbox({inline:true, href:"#missionarycontactform"});
	   
	   jQuery('a.credits').colorbox({inline:true, href:"#credits"});
	   
	   jQuery('a.youtubepopuplarge').colorbox({iframe:true, width: 853, height: 503});
	   
	   jQuery('a.youtubepopupsmall').colorbox({iframe:true, width: 480, height: 295});
	   
	   jQuery('.error, .error_mis').hide(); 
	   	  	   
	   jQuery(".contactpopups form").submit(function() {
		  jQuery(this).find('.error').hide();
		  var firstName = jQuery(this).find("input.first_name").val();
		  if (firstName == "") {
			jQuery(this).find("span.first_name_error").show();
			jQuery(this).find("input.first_name").focus();
			return false;
		  }
		  
		  var lastName = jQuery(this).find("input.last_name").val();
		  
		  var email = jQuery(this).find("input.email").val();
		  if (email == "") {
			jQuery(this).find("span.email_error").show();
			jQuery(this).find("input.email").focus();
			return false;
		  }
			
			var contactmessage = jQuery(this).find("textarea.contactmessage").val();
			if (contactmessage == "") {
			jQuery(this).find("span.contactmessage_error").show();
			jQuery(this).find("textarea.contactmessage").focus();
			return false;
		  }
		  
		  	var newsletter = jQuery(this).find("input:checkbox").attr('checked');
			var church = jQuery(this).find("input.church").val();
		    var dataString = jQuery(this).serialize();
			var thisForm = jQuery(this);
			var contactReturn = jQuery(this).parent('.contactreturn'); 
			var newsletterString = 'email_address=' + email + '&first_name=' + firstName + '&last_name=' + lastName;
			
			jQuery(this).html("<p>Sending Message...</p>");
			  jQuery.ajax({
				   type: "POST",
				   url: "http://www.projectamazon.org/wp-content/themes/PAZ 2014/email.php",
				   data: dataString,
				   cache: false,
				   success: function(status) {
					   jQuery(thisForm).hide();
					   jQuery(contactReturn).html(status);
					   if(newsletter==true) {
						    jQuery(contactReturn).append('<p>Signing up for PAZ Email Newsletter...</p>');
							//alert(newsletterString);
							setTimeout(function() {
								jQuery.fn.colorbox({iframe: true, href: 'http://oi.vresp.com?fid=8edfa6fbca&' + newsletterString, open: true, height: 570, width: 800});
									}, 3000);
					   }
					}				  
				});
				
			return false;

	    });
		
				
		jQuery(".navbarpage:not(.current_location_page)").hover(function() {
			jQuery(this).css('backgroundPosition' , '0px 0px');
			jQuery(this).stop().animate({ marginLeft: "40px", backgroundPosition: '-200px 0px', backgroundColor: "#fff"}, 500, function() { 
				jQuery(this).find("p").animate({ color: "#222" }, 200);} );
		}, function() {
			jQuery(this).stop().animate({ marginLeft: "0px", backgroundPosition: '0px 0px', backgroundColor: "#222"}, 100, function() { 
				jQuery(this).find("p").animate({ color: "#eee" }, 100);} );
			return false;
		});
		
		jQuery(".navbarpage:not(.current_location_page)").click(function() {
			jQuery(".navbarpage:not(.current_location_page)").unbind('mouseenter mouseleave');
			jQuery('.current_location_page').stop().animate({ marginLeft: "0px", backgroundPosition: '0px 0px', backgroundColor: "#222"}, 50 ).find("p").animate({ color: "#ccc" }, 50);
			jQuery(this).stop().animate({ marginLeft: "40px", backgroundColor: "#fff", backgroundPosition: '-200px 0px'}, 50).find("p").animate({ color: "#222" }, 50);
			window.location=jQuery(this).find("a").attr("href"); return false;
		});
		
		jQuery("#navbartop ul li").hover(function() {
			jQuery(this).stop().animate({ backgroundColor: "#0099ee" }, 400);
		}, function() {
			jQuery(this).stop().animate({ backgroundColor: "#222222" }, 100);
			return false;
		});
		
		jQuery(".rightcorners").hover(function() {
			jQuery(this).stop().animate({ backgroundColor: "#eee", color: "#222" }, 400);
		}, function() {
			jQuery(this).stop().animate({ backgroundColor: "#0099ee", color: "#eee" }, 100);
			return false;
		});
				
		jQuery(".webpro").click(function() {
			window.location=jQuery(this).find("a").attr("href"); return false;
		});
		
		jQuery("#insetlist div:not(.current_page_item)").hover(function() {
			jQuery(this).css('backgroundPosition' , '-180px 0px');													   
			jQuery(this).stop().animate({ marginLeft: "-40px", backgroundPosition: '0px 0px', backgroundColor: "#fff"}, 500, function() { 
				jQuery(this).find("span").animate({ color: "#222" }, 200);} );
		}, function() {
			jQuery(this).stop().animate({ marginLeft: "0px", backgroundPosition: '-180px 0px', backgroundColor: "#222"}, 100, function() { 
				jQuery(this).find("span").animate({ color: "#eee" }, 100);} );
			return false;
		});
		
		jQuery("#insetlist div:not(.current_page_item)").click(function() {
			jQuery("#insetlist div:not(.current_page_item)").unbind('mouseenter mouseleave');	
			jQuery('#insetlist div.current_page_item').stop().animate({ marginLeft: "0px", backgroundPosition: '-180px 0px', backgroundColor: "#222"}, 50 ).find("span").animate({ color: "#ccc" }, 50);
			jQuery(this).stop().animate({ marginLeft: "-40px", backgroundColor: "#fff", backgroundPosition: '0px 0px'}, 50 ).find("span").animate({ color: "#222" }, 50);
			window.location=jQuery(this).find("a").attr("href"); return false;
		});
		
		jQuery(".wp-caption, .webpro").hover(function() {
			jQuery(this).stop().animate({ backgroundColor: "#fff"}, 400).find("p, dd").animate({ color: "#222" }, 200);
		}, function() {
			jQuery(this).stop().animate({ backgroundColor: "#333"}, 100).find("p, dd").animate({ color: "#eee" }, 100 );
			return false;
		});
		
		jQuery(".gallery-item").hover(function() {
			jQuery(this).find(".gallery-icon img").stop().animate({ borderBottomColor: "#0099ee", borderRightColor: "#0099ee", borderLeftColor: "#0099ee", borderTopColor: "#0099ee" }, 400);
			jQuery(this).find(".gallery-caption").stop().animate({color: "#000"}, 400);
		}, function() {
			jQuery(this).find(".gallery-icon img").stop().animate({ borderBottomColor: "#ccc", borderRightColor: "#ccc", borderLeftColor: "#ccc", borderTopColor: "#ccc" }, 100);
			jQuery(this).find(".gallery-caption").stop().animate({color: "#222"}, 100);
			return false;
		});
										 
		jQuery(".styledbutton").hover(function() {
			jQuery(this).stop().animate({ backgroundColor: "#D0C000", color: "#ffffff", borderBottomColor: "#FFEC00", borderRightColor: "#FFEC00", borderLeftColor: "#FFEC00", borderTopColor: "#FFEC00" }, 400);
		}, function() {
			jQuery(this).stop().animate({ backgroundColor: "#00688B", color: "#cccccc", borderBottomColor: "#0080AB", borderRightColor: "#0080AB", borderLeftColor: "#0080AB", borderTopColor: "#0080AB" }, 100);
			return false;
		});
		
		jQuery(".styledbutton-alt").hover(function() {
			jQuery(this).stop().animate({ backgroundColor: "#D69700", color: "#ffffff", borderBottomColor: "#FF6600", borderRightColor: "#FF6600", borderLeftColor: "#FF6600", borderTopColor: "#FF6600" }, 400);
		}, function() {
			jQuery(this).stop().animate({ backgroundColor: "#5A873D", color: "#cccccc", borderBottomColor: "#84C95B", borderRightColor: "#84C95B", borderLeftColor: "#84C95B", borderTopColor: "#84C95B" }, 100);
			return false;
		});
		
		jQuery('a[href=#top]').click(function() {
			jQuery('html, body').animate({scrollTop:0}, 800);
			return false;
		});
			
});
