// JavaScript Document
function $(campo)
{
	return document.getElementById("" + campo + "");
}
function checkMail(mail){
    var er = new RegExp(/^[\w-]+(\.[\w-]+)*@(([A-Za-z\d][A-Za-z\d-]{0,61}[A-Za-z\d]\.)+[A-Za-z]{2,6}|\[\d{1,3}(\.\d{1,3}){3}\])$/);
    if(typeof(mail) == "string"){
        if(er.test(mail)){ return true; }
    }else if(typeof(mail) == "object"){
        if(er.test(mail.value)){ 
                    return true; 
                }
    }else{
        return false;
        }
}

function validaUs()
{
	if($("nome").value == "")
	{
		alert("O campo nome é obrigatório.");
		$("nome").focus();
		return false;
	}
	if($("email").value == "")
	{
		alert("O campo e-mail é obrigatório.");
		$("email").focus();
		return false;
	}
	else
	{
		if(!checkMail($("email").value))
		{
			alert("E-mail informado é inválido.");
			$("email").focus();
			return false;
		}
	}
	if($("assunto").value=="")
	{
		alert("Selecione um assunto");
		$("assunto").focus();
		return false;
	}
	if($("mensagem").value == "")
	{
		alert("O campo mensagem é obrigatório.");
		$("mensagem").focus();
		return false;
	}
	return true;
}
