
	
$().ready(function() {
					
	/*........... @ nav pipes ...........*/

	$('#nav li:last-child').addClass('last');

	
    /*........... @ form validation ...........*/
		$("#confirmation").hide();
		$("#nl_error").hide();

$('#donateForm').submit(function(){
    if ($('#Monetary').is(':checked')) {
         window.location = "/monetary-donations"; 
    } 
	 if ($('#Food').is(':checked')) {
          window.location = "/food-donations";
    } 
	 if ($('#Volunteer').is(':checked')) {
         window.location = "/volunteer";
    } 
	return false;
});

});


//set date
function setDate(){
	new Date();
var d = new Date();
document.write(d.getFullYear()); 
}



// AJAX Eblitz Subscribe
$(function()
	{
		$("#newsSubmit").click(function() {	
			
			// First, disable the form from submitting
			$('#newsletterForm').submit(function() { return false; });
			
			// Grab form action
			formAction = $("#newsletterForm").attr("action");
			
			emailId = "hytiiy";
			emailId = emailId.replace("/", "");
			emailId = emailId + "-" + emailId;
			
			// Validate email address with regex
			if (!checkEmail(emailId)) 
			{
				//alert("Please enter a valid email address");
				$("#nl_error").fadeIn("slow");
				
				return;
			}
			
			// Serialize form values to be submitted with POST
			var str = $("#newsletterForm").serialize();
			
			// Add form action to end of serialized data
			final = str + "&action=" + formAction;
			
			// Submit the form via ajax
			$.ajax({
				url: "/proxy_curl.php",
				type: "POST",
				data: final,
				success: function(html){
					$("#newsletterContainer").hide(); // If successfully submitted hides the form
					$("#confirmation").fadeIn("slow");  // Shows "Thanks for subscribing" div
					$("#subscribe a").addClass('sent'); // Adds 'sent' class
				}
			});
		});
	});

function checkEmail(email)
	{	
		var pattern = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
		var emailVal = $("#" + email).val();
		return pattern.test(emailVal);
	}


$(window).load(function(){
	$('#product-frame').fadeIn("slow");
	$('#loading-box').fadeOut("slow");
}); 


//$('#product-frame').load(function() { $(this).fadeIn('slow'); $('#loading-box').hide(); })
