$(document).ready(function()  {
   $("#telefone").mask("(99) 9999-9999");
});
function agenda(top, left, id) {
	$('#agenda').css({ top:top, left:left });
	$('#horario').hide();
	$('#marca').hide();
	$('#agenda').show();
	$('#id').val(id);
}
function AJAXmudadata(mes, ano, id) {
	$('#horarios').hide();
	id = $('#id').val();
	$.post('inc/calendario.php',{
		 mes: mes,
		 ano: ano,
		 id: id
	},function(response){
		$('#agenda').html(response);
	});
}
function isMail(mailField){
  strMail = mailField;
  var re = new RegExp;
  re = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
  var arr = re.exec(strMail);
  if (arr == null)
    return(false);
  else
    return(true);
}
function validaFormulario() {
	if (document.getElementById('nome').value == "") {
		alert('Preencha o campo nome corretamente!');
		document.getElementById('nome').focus();
		return false;
	}
	if (document.getElementById('email').value == "") {
		alert('Preencha o campo e-mail corretamente!');
		document.getElementById('email').focus();
		return false;
	}
	else {
		if (!isMail(document.getElementById('email').value)) {
			alert('Preencha o campo e-mail com um e-mail válido!');
			document.getElementById('email').focus();
			return false;
		}
	}
	if (document.getElementById('mensagem').value == "") {
		alert('Preencha o campo mensagem corretamente!');
		document.getElementById('mensagem').focus();
		return false;
	}
	return true;
}

function AJAXcidade() {
	$("#cidade_load").html("<img src='../images/load.gif'>");
	$.post('ajax/AJAX_cidades.php',{
		 estado: $('#estado').val()
	},function(response){
		$("#cidade_load").html("");
		$('#cidade_ajax').html(response);
	});
}