// JavaScript Document
$(document).ready(function(){
    //  Contact Form
        
        $('#invitation .error').hide();
        $('form#invitation .submit').click(function(e){
            $('#invitation .error').hide();
            
            var name = $('input#name').val();
            if (name == "" || name == " ") {
                $('input#name').focus().before('<span class="error">Please enter your name.</span>');
                return false;
            }
            
            var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
            var email = $('input#email').val();
            if (email == "" || email == " ") {
                $('input#email').focus().before('<span class="error">Please enter your email address.</span>');
                return false;
            } else if (!emailReg.test(email)) {
                $('input#email').select().before('<span class="error">Please enter a valid email address.</span>');
                return false;
            }
            
            var message = $('#message').val();
            if (message == "" || message == " ") {
                $('#message').focus().before('<span class="error">Don\'t forget to add your message.</span>');
                return false;
            }
            
            var dataString = $('form#invitation').serialize();
            $.ajax({
                type:       "POST",
                url:        "email.php",
                data:       dataString,
                success:    function() {
                    $('form#invitation').slideUp('fast').before('<div id="thanks"></div>');
                    $('#thanks').html('<p class="updates">Thanks! Watch your email for updates.</p>');
                }
			})
			
			return false;

        })
	
	//	Clear Input
		var values = new Array();

		$('.ci').each(function(i){
			$(this).removeClass('ci').addClass('ci'+i);
			values.push($(this).val());

			$(this).focus(function(){
				if($(this).val() == values[i]) {
					$(this).val('');
				}
			});
			$(this).blur(function(){
				var valStore = values[i];
				if($(this).val()==''){
					$(this).val(valStore);
				}
			})
		});
            
})