jQuery(document).ready(function(){
	$('#showcase-box-wrap').cycle({ 
		prev: '#showcase-nav_prev',
		next: '#showcase-nav_next',
		delay: 2000,
		pause: true,
		timeout: 10000,
		speed: 500
	});
	$('.disabled').click(function(event){
		event.stopImmediatePropagation();
		return false;
	});
	
	$('#contact-form').submit(function(){
		if ( $('#name').val().length == 0 || $('#gobbledy-gook').val().length == 0 || $('#subject').val().length == 0 || $('#message').val().length == 0 ) {
			alert('Please enter valid answers for all required fields.');
		} else {
			$('.loading').show();
			$.ajax({
				url: 'contact.php', type: 'POST', dataType: 'json', cache: false,
				data: $(this).serialize(),
				success: function(data, textStatus, XMLHttpRequest) {
					if ( data['code'] ) {
						$('#contact-form').fadeOut('fast',function(){
							$('#return_message').html(data['message']);
							$('html, body').animate({scrollTop:0}, 'fast');
						});
					} else {
						$('.loading').hide();
						alert(data['message']);
					}
				},
				error: function(XMLHttpRequest, textStatus, errorThrown) {
					alert(errorThrown);
				}
			});
		}
		return false;
	});
});
