function nome(){
	if($('#nome').val().replace(' ', '').length < 1){
		$('#onome').html(obrigatorio+'  O campo <b>NOME</b> é obrigatório.');
		return false;	
	}else if($('#nome').val().length < 3 ){
		$('#onome').html(obrigatorio+'  O <b>NOME</b> tem que ter mais de 3 caracteres.');
		return false;	
	}else{
		$('#onome').html('');
	}
	return true;	
}
function assunto(){
	if($('#assunto').val().replace(' ', '').length < 1){
		$('#oassunto').html(obrigatorio+'  O campo <b>ASSUNTO</b> é obrigatório.');
		return false;
	}else{
		$('#oassunto').html('');
	}
	return true;
}

function fone(){
	if($('#fone').val().replace(' ', '').length < 1){
		$('#ofone').html(obrigatorio+'  O campo <b>FONE</b> é obrigatório.');
		return false;
	}else{
		$('#ofone').html('');
	}
	return true;
}


function email() {
	var padraoEmail = /^[\w!#$%&amp;'*+\/=?^`{|}~-]+(\.[\w!#$%&amp;'*+\/=?^`{|}~-]+)*@(([\w-]+\.)+[A-Za-z]{2,6}|\[\d{1,3}(\.\d{1,3}){3}\])$/;
    if($("#email").val().length < 1){
		$("#oemail").html(obrigatorio+'  É necessário o preenchimento do <b>EMAIL</b>.');
//		$("#email").focus();
		return false;
    } else if(padraoEmail.test($("#email").val()) == false){
		$("#oemail").html(obrigatorio+'  É necessário o preenchimento de um endereço de <b>EMAIL</b> válido.');
//		$("#email").focus();
		return false;
	}else{
		$("#oemail").html('');
	}
	return true;
}




function validacao(){
	erro = new Array();
	er = true;
	msg = '';

	erro['nome'] = nome();
	erro['email'] = email();
	erro['fone'] = fone();

    if(erro['nome'] == false){
		 if(er == true) er = false;
		 msg += $('#onome').html()+'<br/>';
	}
	if(erro['email'] == false){
		 if(er == true) er = false;
		 msg += $('#oemail').html()+'<br/>';
	}
	if(erro['fone'] == false){
		 if(er == true) er = false;
		 msg += $('#ofone').html()+'<br/>';
	}


     if(er == false){
		return false;
	}
	return true;
	
}

$(document).ready(function(){
    $('form').css({'display':'block'});
    $("form").submit(function() {
            $('.button').attr("disabled",true);
            if (validacao() == true) {
                    return true;
            } else {
                            $('.button').attr("disabled",false);
                    return false;
            }
    });
    $('#nome').blur(function(event){ nome() });
    $('#email').blur(function(event){ email() });
    $('#fone').blur(function(event){ fone() });

});
