$(document).ready(function(){
	
	$('h1').click(function(){ location.href = 'index.php' })
	
	//FORMULÁRIO
	$('form#ajax').submit(function(e){
	var iconCarregando = '<img src="imgs/layout/carregando.gif" />';									  
	var url = $(this).attr('action')
	var serializeDados = $(this).serialize()
	e.preventDefault()
	$.ajax({
			url: url, 
			dataType: 'html',
			type: 'POST',
			timeout: 50000,
			data: serializeDados,
			beforeSend: function(){
				$('div#status').html(iconCarregando)
				$('div#msg').hide()
				$('div#status').fadeIn("slow")
			},
			complete: function() {
				$('div#status').css('display','none');
			},
			success: function(data, textStatus) {
				$('div#msg').html(data)
				$('div#msg').fadeIn()
			},
			error: function(xhr,er) {
				$('div#msg').html('<strong>Por favor, tente novamente mais tarde.</strong>')
				$('div#msg').fadeIn()
			}		
		})
	})
})
