$(document).ready(function(){
		
		$.localScroll();

		$('#contactLink').click(function(){
			$('.sucess').html("");
			$('#myForm').show();
			$('.contactForm').slideDown('slow');
		});
		
		$('#nameinput').focus(function(){
			if($(this).val()=='Who are you?') $(this).val('');
			
		});
		
		$('#nameinput').blur(function(){
			 if($(this).val()=='') $(this).val('Who are you?');
		});
		
		$('#emailinput').focus(function(){
			if($(this).val()=='How can I get back to you?') $(this).val('');
			else if($(this).val()=='') $(this).val('How can I get back to you?');
		});
		
		$('#emailinput').blur(function(){
			if($(this).val()=='') $(this).val('How can I get back to you?');
		});
		
		$('#commentinput').focus(function(){
			if($(this).html()=='Your message') $(this).val('');
			
		});
		
		$('#commentinput').blur(function(){
			if($(this).val()=='') $(this).val('Your message');
		});	
		
		
		$('#myForm').ajaxForm(function(data) {
		
			
			$('.message').fadeOut("fast");
			
			if (data==1){
				
				$('#myForm').slideUp("fast");
				$('.sucess').html('Hurray! I will get back to you as soon as possible.');
				$('.sucess').fadeIn(2000);
				
			}
			else if (data==2){
				
				$('.error').html('Whoops! There seems to be a problem, please contact me using this e-mail: hello@josemarques.info.');
				$('.error').fadeIn("fast");
			}
			else if (data==3||data==5)
			{

				$('.error').html('Please fill in all the fields.');
				$('.error').fadeIn("slow");
			}
			else if (data==4)
			{
				$('.error').html('Oh no! It seems that the e-mail you provided is not valid.');
				$('.error').fadeIn("slow");
			}
		});
	});

	var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
	document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));

	try {
	var pageTracker = _gat._getTracker("UA-207342-6");
	pageTracker._trackPageview();
	} catch(err) {}