/*
 * Created by: Ramon <ramon.silva@realweb.com.br>
 * data:06/2009
*/
$(function(){

	$("#tel").mask("(99)9999-9999");
	
	$("#btCadatrar").click(function(){
		
		if($("#senha").val() == $("#confSenha").val()) {
			var valida = validaForm();
			if(valida[0] == false){
				if(valida[1] == -1) {
					showModalBox({msg:"Por favor, preencha todos os campos!"});
				} else {
					var id = $(valida[1]).attr("id");
					showModalBox({msg:$("#"+id+"_msg").val()});
				}
			} else { //validou
				
				loadImg($("#cadastro"));
				$.ajax({
					 type: "GET",
					 url: "js/rpc/RPC_account.php",
					 data: "func=newAccount&"+montaQueryURL(),
					 success: function(ret) {
							loadImg($("#cadastro"), 2);
							if($.trim(ret) != '1'){
								showModalBox({msg:ret});
							} else {//Se o cadastro ocorreu ok, mostra a mensagem!
								$(".contentFormHome").load("content/usuarioOk.php");
							}
					 }
				});	
			}
		} else {
			showModalBox({msg:"Senha e confirmação não conferem"});
		}
	});
});
