function submitContato() {
	$('submit').className = "dsbl";
	$('submit').disabled = true;
	var params = "nome=" + escape(url_encode($('in_nome').value)) +
					"&email=" + escape(url_encode($('in_email').value)) +
					"&assunto=" + escape(url_encode($('in_assunto').value)) +
					"&mensagem=" + escape(url_encode($('in_msg').value)) +
					"&enviar=1";
	var url = "function/ac-contato.php";
	var ajax = new Ajax.Request(url, {method:'post', parameters:params, asynchronous:true,
					onComplete:function(t) {
						eval("var retorno = " + t.responseText);
						if (retorno.err_nome)
							adicionaConteudo(retorno.err_nome, "err_nome");
						else
							$('err_nome').innerHTML = "";
						if (retorno.err_email)
							adicionaConteudo(retorno.err_email, "err_email");
						else
							$('err_email').innerHTML = "";
						if (retorno.err_assunto)
							adicionaConteudo(retorno.err_assunto, "err_assunto");
						else
							$('err_assunto').innerHTML = "";
						if (retorno.err_msg)
							adicionaConteudo(retorno.err_msg, "err_msg");
						else
							$('err_msg').innerHTML = "";
						if (retorno.err_envio)
							adicionaConteudo(retorno.err_envio, "err_envio");
						else
							$('err_envio').innerHTML = "";
						
						$('submit').className = "";
						$('submit').disabled = false;
						if (retorno.msg_sucesso) {
							var objSucesso = document.createElement("p");
							objSucesso.setAttribute('id','msg_sucesso');
							$("frm_contato").appendChild(objSucesso);
							adicionaConteudo(retorno.msg_sucesso, "msg_sucesso");
							if (retorno.msg_sucesso.search(/sucesso/i) != -1)
								$("frm_contato").reset();
						}
						else
							$('msg_sucesso').innerHTML = "";
			}});
}
function adicionaConteudo(cont, id_layer) {
	$(id_layer).innerHTML = decodeText(cont);
}
// url_encode version 1.0 
function url_encode(str) { 
    var hex_chars = "0123456789ABCDEF"; 
    var noEncode = /^([a-zA-Z0-9\_\-\.])$/; 
    var n, strCode, hex1, hex2, strEncode = ""; 

    for(n = 0; n < str.length; n++) { 
        if (noEncode.test(str.charAt(n))) { 
            strEncode += str.charAt(n); 
        } else { 
            strCode = str.charCodeAt(n); 
            hex1 = hex_chars.charAt(Math.floor(strCode / 16)); 
            hex2 = hex_chars.charAt(strCode % 16); 
            strEncode += "%" + (hex1 + hex2); 
        } 
    } 
    return strEncode; 
} 

// url_decode version 1.0 
function url_decode(str) { 
    var n, strCode, strDecode = ""; 

    for (n = 0; n < str.length; n++) { 
        if (str.charAt(n) == "%") { 
            strCode = str.charAt(n + 1) + str.charAt(n + 2); 
            strDecode += String.fromCharCode(parseInt(strCode, 16)); 
            n += 2; 
        } else { 
            strDecode += str.charAt(n); 
        } 
    } 
    return strDecode; 
}

function decodeText(txt) {
	txt = txt.replace(/\+/g," ");
	return unescape(txt);
}

window.onload = function() {
	if ($('mapa-swf')) {
		var FO = { movie:"swf/mapa.swf", width:"480", height:"270", majorversion:"6", build:"0", wmode:"transparent" };
		UFO.create(FO, 'mapa-swf');
	}
}