/***************
*
* Contains common scripts for Mercy29 site, including some common start-up scripts
*
****************/

// add bounce in effects for newsletter signup
$(document).ready(function() {
	$('#newslettersubscribe').hover(function() {
		var h = 105; //parseInt($('#newsletterForm').height())+'px';
		$("#newsletterSlide").stop().animate({height: h}, {queue:false, duration: 500, easing: 'easeOutBounce'});
	}, function() {
		$("#newsletterSlide").stop().animate({height: 0}, {queue:false, duration: 500});
	});
});
	
// setup ajax request for newsletter sign-up
$(document).ready(function() {
	$("#signupbuttonlink").click(function() {
		var u = $("#u").val();
		var id = $("#id").val();
		var email = $("#email").val();
		var dataString = 'u=' + u + '&id=' + id + '&email=' + email;

		if (email == '') {
			$('#signupsuccess').fadeOut(750);
		}
		else {
			$.ajax({
				type: "GET",
				url: "store-address.php",
				data: dataString,
				success: function(msg) {
					$("#signupsuccess").ajaxComplete(function(event, request, settings){
						$("#newsletterform").hide();
						result = msg;
						$(this).html(result);
						$(this).fadeIn(750);
					});	
				},
				error: function(msg) {
					$("#signupsuccess").ajaxComplete(function(event, request, settings){
						$("#newsletterform").hide();
						result = msg;
						$(this).html(result);
						$(this).fadeIn(750);
					});
				}
			});
		}
		return false;
	});
});

$(document).ready(function() {
	$("#navigation a, .subnav a").removeAttr('title');
	$(" #navigation ul ").css({display: "none"}); // Opera Fix
	
	$("#navigation li").each(function()
	{	
		
		var $sublist = jQuery(this).find('ul:first');
		
		$(this).hover(function()
		{	
			$sublist.stop().css({overflow:"hidden", height:"auto", display:"none"}).slideDown(400, function()
			{
				$(this).css({overflow:"visible", height:"auto"});
			});	
		},
		function()
		{	
			$sublist.stop().slideUp(400, function()
			{	
				$(this).css({overflow:"hidden", display:"none"});
			});
		});	
	});
});
