$(function() {
	//Set up smooth scrolling for anchors with the class inner
    $('a.inner').click(function() {
	    var target = $(this).attr('href');
		var offset = $(target).offset().top;
		
		$('html,body').animate({scrollTop: offset}, 700);
		
		return false;
	});
    
    //Set up process slider
    $('#content_intro_process a').click(function() {
		var target = $(this).attr('href');
		var offset = $('#content_intro_process_slider').offset().left-$('#content_intro_process_slider li' + target).offset().left;
		
		$('#content_intro_process_slider').animate({left: offset}, 700);

		$('#content_intro_process a.current').removeClass('current');
		$(this).addClass('current')
		
		return false;
	});
	
	//Make previews open in new window (temporary)
	$('.preview a').attr('target', '_blank');
	
	$('#footer_contact #submit').click(function(e) {
		e.preventDefault();
		
		$.ajax({
			type: 'POST',
			url: '/sendmail.php',
			data: $('#footer_contact').serialize(),
			success: function(xml) {
				var code = $('code', xml).text();
				var text = $('text', xml).text();
				
				switch(code) {
					case 'success':
					case 'error_general':
						$('#footer_contact').append('<p id="footer_contact_message"></p>');
						$('#footer_contact_message').hide();
						$('#footer_contact dl').fadeOut('fast', function() {
							$('#footer_contact_message').text(text);
						});
						$('#footer_contact_message').fadeIn('fast');
						break;
					default:
						$('#footer_contact_warning').text(text);
						break;
				}
			}
		});
	});
});
