(function($) {

	window.app = {

                init: function() {
                
		},

                customSlider: {

                },

                textFader: {

                },

                contactForm: {

			init: function() {
				if ($('#contactForm').size() != 0) {
					$('#contactFormContainer').click(function () {
						return false;
					});
					$('#errorContainer').hide();
					$('.jsSubmit').show();
					$('.nojsSubmit').hide();

					$('#contactFormSubmit a').click(function () {
						if (window.app.contactForm.checkForm()) {
							$('#contactForm').submit();
						}
						return false;
					});

					if ($('#contactForm.errorOccurred').size() != 0) {
						window.app.contactForm.error('Please fill in the entire form.');
					} else if ($('#contactForm.captchaError').size() != 0) {
						window.app.contactForm.error('The verification text did not match the image.');
					}
				}

                        },

			checkForm: function() {
                            if ($('#f_name').val()== '') {
                                            window.app.contactForm.error('Please enter your name.');
                                            return false
                            } else if ($('#f_email').val()== '') {
                                            window.app.contactForm.error('Please enter your email address.');
                                            return false
                            } else if ($('#f_message').val()== '') {
                                            window.app.contactForm.error('Please enter a message.');
                                            return false
                            }
                            return true;
                        },

			error: function(which) {
	      		var el = $("#errorContainer");
	      		if (el.css('display') == 'block') {
	      			el.fadeTo('fast', 0.1);
	      			el.fadeTo('fast', 1);
	      			el.fadeTo('fast', 0.1);
	      			el.fadeTo('fast', 1);
	      			el.fadeTo('fast', 0.1);
	      			el.fadeTo('fast', 1);
	      		} else {
					$("#errorContainer").html(which).stop().fadeIn('slow');
				}
                        }
		}
        };


	$(document).ready(function() {

		window.app.init();
                window.app.contactForm.init();
	});

})(jQuery);

