  $(document).ready(function(){

	$('form .spinner, p.form-message').hide();
	$('form.inactive :input').attr('disabled', true);
	
	$('#banner-container').load('banner.html');
	$('#portfolio-container').load('portfolio.html');
							 
	$('.form-container a').click(function(){	
		$('form.active').parent('div').children('a').removeClass('active');
		$('form.active').removeClass('active').addClass('inactive');
		$(this).addClass('active');
		$(this).parent('div').children('form').removeClass('inactive').addClass('active');
		$('form.inactive :input').attr('disabled', true);
		$('form.active :input').removeAttr('disabled');
		return false
	});
		
	$('#form-hello').submit(function(){
		$('form.active .submit').hide();
		$('form.active .spinner').show();
		var dataString = $("form").serialize();
		$.ajax({
			type: "POST",
			url: "contact-process-hello.php",
			data: dataString,
			success: function(){
				$('form.active .submit').show();
				$('form.active .spinner').hide();
				$('form.active p.form-message').text("Thank you for contacting me; your email has been sent.").slideDown("fast");	
			},
			error: function(){
				$('form.active .submit').show();
				$('form.active .spinner').hide();
				$('form.active p.form-message').text("Oops!  Something didn't work out, can you try sending again?").slideDown("fast");				
			}
		});
		return false;
	});
	
	$('#form-work').submit(function(){
		$('form.active .submit').hide();
		$('form.active .spinner').show();
		var dataString = $("form").serialize();
		$.ajax({
			type: "POST",
			url: "contact-process-work.php",
			data: dataString,
			success: function(){
				$('form.active .submit').show();
				$('form.active .spinner').hide();
				$('form.active p.form-message').text("Thank you for contacting me; your email has been sent.").slideDown("fast");	
			},
			error: function(){
				$('form.active .submit').show();
				$('form.active .spinner').hide();
				$('form.active p.form-message').text("Oops!  Something didn't work out, can you try sending again?").slideDown("fast");				
			}
		});
		return false;
	});
							 
	$('.skills-content div').hide();
	$('.skills-content div.active').show();
	$('#skill-box ul a').click(function(){
		$('#skill-box ul a.active').removeClass('active');
		var next = $(this).attr('id');
		$('.skills-content div.active').hide();
		$('.skills-content div.active').removeClass('active');
		$('.skills-content div.'+next).addClass('active');
		$('.skills-content div.active').show();
		$('#skill-box ul a#'+next).addClass('active');
		return false;
	});
	
							 
	// This code is for the naviagtion and back to top links
	$('.scroll-page').click(function() {
	   var elementClicked = $(this).attr("href");
	   var destination = $(elementClicked).offset().top;
	   $("html:not(:animated),body:not(:animated)").animate({ scrollTop: destination}, 500 );
	   return false;
	});
	$("a[href='#top']").click(function() {
		$("html").animate({ scrollTop: 0 }, "slow");
	});
  });
