//Step 2: Define a "callback" function to process the data returned by the Ajax request:
function processGetPost3(){
var myajax=ajaxpack.ajaxobj;
var myfiletype=ajaxpack.filetype;
if (myajax.readyState == 4){ //if request of file completed
	if (myajax.status==200 || window.location.href.indexOf("http")==-1){ //if request was successful or running script locally
		if (myfiletype=="txt")
		//alert(myajax.responseText)
			if(myajax.responseText == "sucesso"){
				document.getElementById('inscricoesForm').innerHTML = "<div style='width: 270px; height:160px; color: #AF221B; padding-top: 80px; font-size: 12px; font-weight: bold; text-align:center;'>Formul&aacute;rio enviado com sucesso!<br><br>Aguarde que em breve estaremos entrando em contato com voc&ecirc;!</div>";	
			}
			if(myajax.responseText == "campo"){
				document.getElementById('mensagemerro').innerHTML = "<div style='color: #AF221B; width: 270px; padding: 2px; margin-top: 5px; text-align: center; font-size:10px;'>Os campos Nome, Cidade e mais um a sua escolha s&atilde;o obrigat&oacute;rios!</div>";
			}
			if(myajax.responseText == "ddd"){
				document.getElementById('mensagemerro').innerHTML = "<div style='color: #AF221B; width: 270px; padding: 2px; margin-top: 5px; text-align: center; font-size:10px;'>Voc&ecirc; precisa digitar o DDD do telefone!</div>";
			}
			if(myajax.responseText == "variavel"){
				document.getElementById('mensagemerro').innerHTML = "<div style='color: #AF221B; width: 270px; padding: 2px; margin-top: 5px; text-align: center; font-size:10px;'>Erro no formulario - Vari&aacute;vel de seguran&ccedil;a inv&aacute;lida</div>";
			}
			if(myajax.responseText == "timer"){
				document.getElementById('mensagemerro').innerHTML = "<div style='color: #AF221B; width: 270px; padding: 2px; margin-top: 5px; text-align: center; font-size:10px;'>Sua &uacute;ltima mensagem est&aacute; sendo processada. Aguarde mais alguns segundos para enviar outra.</div>";
			}	
			else
		//alert(myajax.responseXML)
		//document.getElementById('panelSerAluno').innerHTML = "<div style='width: 250px; height:75px; padding-top: 45px; color: white; font-size: 12px; font-weight: bold; text-align:center;'>Formul&aacute;rio enviado com sucesso!<br><br>Aguarde que muito em breve estaremos entrando em contato com voc&ecirc;</div>";	
		//document.getElementById('mensagemerro').innerHTML = "";	
			var nada;
		}
	}
}

function createpoststring3(){
var inscricao_curso=document.getElementById("curso").options[document.getElementById("curso").selectedIndex].value;
var inscricao_nome=document.getElementById("nome").value;
var inscricao_cidade=document.getElementById("cidade").value;
var inscricao_email=document.getElementById("email").value;
var inscricao_ddd=document.getElementById("ddd").value;
var inscricao_fone=document.getElementById("fone").value;
var inscricao_sec=document.getElementById("inscricoesForm").sec.value
var poststr3 = "nome=" + encodeURI(inscricao_nome) + "&sec=" + encodeURI(inscricao_sec) + "&email=" + encodeURI(inscricao_email) + "&cidade=" + encodeURI(inscricao_cidade) + "&ddd=" + encodeURI(inscricao_ddd) + "&fone=" + encodeURI(inscricao_fone) + "&curso=" + encodeURI(inscricao_curso);
return poststr3;
}

//Step 3: Invoke the Ajax routine method to make the desired Ajax request.
function inscricao(){
	var inscricoesForm = document.getElementById("inscricoesForm");
	var SS = Spry.Widget.Form.validate(inscricoesForm);
	if (SS == true) {
		var poststr3=createpoststring3(); //Get contents to post and create query string first
		ajaxpack.postAjaxRequest("inscricoes_form.php", poststr3, processGetPost3, "txt");
	}
}