/*!
 * jQuery local library for Casagrande Consulting
 * http://www.casagrandeconsulting.ca
 */
 $(document).ready(function(){

	$('#pethaybadge a').click(function(event) {
		$('.black_overlay').fadeIn('fast');
		$('.popup').fadeIn('slow');
	});

	$('.black_overlay').click(function(event) {
		$('.popup').fadeOut('fast');
		$('.black_overlay').fadeOut('slow');
	});


	//Form prep....
	$('form.signup').attr( 'action', "javascript:alert('success!');" );
	$('form.signup').attr( 'method', "post" )
	$('form .info, form .error').hide();

	$('form.signup input[type=text]').focus(function(){
        $(this).parent().find('.error').fadeOut("slow");
    }).blur(function(){

    });


	//Email field prep....
	var email_nag="please enter your email address...";
	$('.emailfield').val(email_nag)
	
	$('.emailfield').focus(function(event) {
		$('.emailfield').val("");
	}).blur(function(event) {
		if($('.emailfield').val()=="")
			$('.emailfield').val(email_nag)
	});



	//AJAX-y form submission with validation....
	$("form").submit(function(){  

		// 'this' refers to the current submitted form  
		var str = $(this).serialize();  


		//de ghettoize this by making it use proper html error code 
		$.ajax({  
			type: "POST",  
			url: "/signup.php",  
			data: str,  
			success: function(msg){  

				if(msg == 'OK') // Message Sent? Show the 'Thank You' message and hide the form  
				{  
					alert("Thank you!");
					$('.popup').fadeOut('fast');
					$('.black_overlay').fadeOut('slow');
				}  
				else  
				{  
			        $('.signup').find('.error').fadeIn("fast");
				}  
				 
			}
		});
	  
		 
	  
		return false;  
	  
	}); 
  


});		   