/*** PRODUZIDO POR ON-LINE PRODUÇÕES - Cláudio PG Júnior - Copyright © 2007 ***/
/*$(document).ready(function(){
    $("#modalPopup").click(function(){
	    $("#modalPopup").slideDown();
	});
});*/

function showModalPopup() {
	$("#modalPopup").slideDown(1000);
	$('#modalPopup').css('display', 'block');
};

function hideModalPopup() {
	$("#modalPopup").slideUp(200);
    showForm();
};

function showForm() {
    $("#modalForm").slideDown(1000);
    $("#modalForm").css('display', 'block');
};
function hideForm() {
	$("#modalForm").slideUp(200);
};

function getData(obj) {
	var postStr = "";
	var erros = "";
	var ctaLoop = 0;
	//$("<div><p>Hello</p></div>").appendTo("body")
	$("*:input").each(function() {
		// VERIFICA SE CADA CAMPO FOI PREENCHIDO
		// IGNORA O BOTÃO E CONCATENA OS CAMPOS
		if (this.name != 'inEnviar' && this.name != 'isearch' && this.name != 'enviar') {
			if (this.value.length == 0) {
				alert("Todos os campos sao obrigatorios!");
				return false;
			}
		}

		if (postStr == "") {
			postStr = this.name + "=" + this.value;
		} else {
			postStr = postStr + "&" + this.name + "=" + this.value;
		}
		ctaLoop++;

		// VERIFICA E-MAIL
		if (this.name == "inEmail") {
			if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(this.value)) {
				return (true);
			}
				this.focus();
				alert("Digite um e-mail valido!")
				return false;
		}
	});
	if (ctaLoop == 7) {
        $("#btn").append("<br>Aguarde...");
		$.ajax({
			timeout: 20000,
			type: "get",
			url: "verify.asp",
			data: postStr,
			success: function(msg) {
				if (msg == "erro") {
					alert("Erro no cadastro, por favor tente novamente mais tarde.");
				} else {
					$("ul").fadeOut("slow",function() {
						$("#myform")[0].reset();
						$("#modalForm").append("<br /><p>Seu cadastro foi realizado com sucesso.<br>Para obter maiores informa&ccedil;&otilde;es<br>ligue: (17) 3224-7600</p><p><a href='#' onclick='javascript:hideForm();'>Fechar</a></p>");
						return (true);
					});
				}
			}
		});
	}
}