$(document).ready(function() {
/*
 * google form validation
 */
	$('input.amount').focus(function() {
		$(this).val('');
	});
	
	$('form.donation').submit(function() {
		var amount = $('input.amount').val();
		if(amount.match(/[0-9]/)){
			return true;
		} else {
			alert('Please enter valid amount!\nOnly numbers are allowed!');
			return false;
		}
	});
/*
 * end google form validation
 */
	
/*
 * bottom banner 
 */
	$('.link a').css({ 'opacity' : '0.6' });	
	$('.link').hover(function(){
		$("a", this).stop().animate({top:'0'},{queue:false,duration:300});  
	}, function() {  
		$("a", this).stop().animate({top:'100%'},{queue:false,duration:300});  
	});
  
/*
 * Main nav bar
 */
	$('ul.dropdown li').hover(function() {
		$(this).parent().parent().toggleClass('active');
		}
	);
	
/*
 * Newsletter subscription form
 */
	$('.newsletter input#email').focus( function() {
		$(this).val('');
	});

	$('.newsletter #top').submit(function() {
		$.ajax({
			type: 'post',
			url: 'newsletter/signup',
			data: $("form#newsletter").serialize(),
			success: function( data ) {
				answer = jQuery.parseJSON(data);
				if(answer.bool === 'true') {
					$('#success h2').text('Thank You for your subscription');
				} else {
					$('#success h2').html(answer.message);
				}
			}
		});

		$(this).animate({top: -260}, 750,  function() {
			$('#success').animate({top: 0}, { queue: false, duration: 750});
		});

		return false;
	});
});

