$(document).ready(function() {
			
	// Menu Scroll
	$('a.nav').click(function() {
		$.scrollTo(this.hash, 1000, {offset: {top:-130}});
		return false;
	});


	// Thumb Hover
	$('#featured li').hover(function() {
		$(this).find('img').stop().animate({ 'opacity': '0.05' }, 'fast');
	}, function() {
		$(this).find('img').stop().animate({ 'opacity': '1' }, 'fast');
	});
	
	
	// Featured Nav
	var slider = $('.slider1').bxSlider({
		wrapperClass: 'wrapper'
	});
	
	$('#featured li a').click(function(){
		var thumbIndex = $('#featured li a').index(this);
		slider.goToSlide(thumbIndex);
		$('#featured li a').removeClass('pager-active');
		$(this).addClass('pager-active');
		return false;
	});

	
	// Project Slider
	$('.slider2').each(function(){
		$(this).cycle({
			timeout: 0,
			next: $(this).parent().find('.next'),
			prev: $(this).parent().find('.prev')
		});
	});
	
	// Form
	$('input[type="submit"]').click(function() {
		var errorcount = 0;
		$('input[type="text"]').each(function() {
			var inputval = $(this).val();
			if (inputval == ''){
				$(this).prev().addClass('error');
				errorcount++;
			}
		});
		if (errorcount == 0) {
			var name = $('input#name').val();
			var email = $('input#email').val();
			var message = $('textarea').val();
			var formData = 'name='+ name +'&email='+ email +'&message='+ message +'&submit=Send';
			$.ajax({
			type: 'POST',
			url:  'submit.php',
			data:  formData,
			success: function(data) {
				$('form').html('<h2>Thank You!</h2><p>I will be in touch with you soon.</p>').hide().fadeIn(1500);
				console.log(data);
				}
			});
		}
		return false;
	});
	$('input[type="text"]').focus(function() {
	   if ($(this).hasClass('error')) {
	       $(this).keyup(function() {
	           $(this).prev().removeClass('error');
	       });
	   }
	});

    

});
