// _________________________________________________________________________________________ // || Código JAVASCRIPT Desenvolvido por CoringaDesign.com - Todos os Direitos Reservados || // || ----------------------------------------------------------------------------------- || // || Tecnologia utilizada: PHP, MySQL, JavaScript Assíncrono (AJAX) || // || Direitos de Uso : Soltege Soluções em Informática || // || Distribuição : Soltege Soluções em Informática, FCDL-MG, CoringaDesign || // || ----------------------------------------------------------------------------------- || // || CoringadeDesign - A Qualidade em Seu Site - www.coringadesign.com || // || contato:rodrigo@coringadesign.com || // ||_____________________________________________________________________________________|| try{ xmlhttp = new XMLHttpRequest();// Mozilla, Safari, Firefox, etc... try { if (xmlhttp.overrideMimeType) { //Se possível, ignora cabecalho usado pelo servidor e forca o padrao "text/xml". Alguns navegadores exigem esse padrao e pode dar erro se o servidor nao utilizar ele xmlhttp.overrideMimeType('text/xml'); } } catch (e1) { } }catch(e2){ try{ xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");// Internet Explorer }catch(e3){ try{ xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");// Internet Explorer }catch(e4){ //tratamento para alguma outra forma de implementar XMLHTTP xmlhttp = false; } } } if (!xmlhttp){ //Nao conseguiu instanciar o objeto xmlhttp para fazer as solicitacoes alert("Erro no AJAX. Seu navegador não dá suporte ao AJAX. Recomendamos usar o Internet Explorer para Windows"); } ///////////////////////////////////////////////////////////// // Função Automatiza AJAX //////////////////////////////////////////////////////////// function getxmlhttp(){ var xmlhttp = false; try { xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try { xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); } catch (E) { xmlhttp = false; } } if (!xmlhttp && typeof XMLHttpRequest !='undefined') { xmlhttp = new XMLHttpRequest(); } return xmlhttp; } ////////////////////////////////////////////////////////////////////////////////////////////////// function processajax (obj, serverPage){ xmlhttp = getxmlhttp(); xmlhttp.open("GET", serverPage); xmlhttp.setRequestHeader("If-Modified-Since", "Thu, 1 Jan 1970 00:00:00 GMT"); xmlhttp.setRequestHeader("Cache-Control", "no-cache"); xmlhttp.onreadystatechange = function(){ if (xmlhttp.readyState == 4 && xmlhttp.status == 200) { // coloca o valor no objeto requisitado texto=unescape(xmlhttp.responseText.replace(/\+/g," ")); document.getElementById(obj).innerHTML=texto; // executa scripts extraiScript(texto); document.getElementById(obj).innerHTML = xmlhttp.responseText; } } xmlhttp.send(null); } ////////////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////// function extraiScript(texto){ // inicializa o inicio >< var ini = 0; // loop enquanto achar um script while (ini!=-1){ // procura uma tag de script ini = texto.indexOf('=0){ // define o inicio para depois do fechamento dessa tag ini = texto.indexOf('>', ini) + 1; // procura o final do script var fim = texto.indexOf('', ini); // extrai apenas o script codigo = texto.substring(ini,fim); // executa o script //eval(codigo); novo = document.createElement("script") novo.text = codigo; document.body.appendChild(novo); } } } /////////////////////////////////////////////// //Funções do Formulario de Cadastro //Necessita de Spry /////////////////////////////////////////////// some = function(){ setTimeout("apagadiv()",5000); } apagadiv = function(){ document.getElementById('result').innerHTML =''; } visu = function(valor){ if(valor=='cpf'){ document.getElementById('bcpf').style.display = 'block'; document.getElementById('bcnpj').style.display = 'none'; }else{ document.getElementById('bcpf').style.display = 'none'; document.getElementById('bcnpj').style.display = 'block'; } document.getElementById('tcpf').value =''; document.getElementById('tcnpj').value =''; setTimeout("document.getElementById('result_cnpj').innerHTML=''",300); } vdoc = function(valor,tipo){ if(valor!=''){ local = '/classes/forms/scripts/confirmcnpj.php?mode='+tipo+'&valor='+valor; processajax('result_cnpj',local); } } vercep = function(valor){ document.getElementById('endereco').value = 'Aguarde... verificando CEP'; if(valor!=''){ local = '/classes/forms/scripts/ceps.php?cep='+valor; processajax('result_cnpj',local); } } selcidade = function(valor){ document.getElementById('divcity').innerHTML = ''; local = '/classes/forms/scripts/selcidade.php?idref='+valor; processajax('divcity',local); } vermail =function(valor){ local = '/classes/forms/scripts/vermail.php?email='+valor; processajax('result_mail',local); } ///////////// FIM DO FORMULARIO DE CADASTRO ////////////////////// ////////////////////////////////////// function getPosicaoElemento(elemID){ var offsetTrail = document.getElementById(elemID); var offsetLeft = 0; var offsetTop = 0; while (offsetTrail) { offsetLeft += offsetTrail.offsetLeft; offsetTop += offsetTrail.offsetTop; offsetTrail = offsetTrail.offsetParent; } if (navigator.userAgent.indexOf("Mac") != -1 && typeof document.body.leftMargin != "undefined") { offsetLeft += document.body.leftMargin; offsetTop += document.body.topMargin; } return {left:offsetLeft, top:offsetTop}; } showalert = function(valor, pai){ var altura = document.getElementById(pai).offsetHeight+'px'; var left = getPosicaoElemento(pai).left+'px'; var top = getPosicaoElemento(pai).top+'px'; if(top<100){ top = 354; } document.getElementById('divalert').align = 'center'; document.getElementById('divalert').style.background='#999'; document.getElementById('divalert').style.width=document.getElementById(pai).style.width; document.getElementById('divalert').style.position='absolute'; document.getElementById('divalert').style.top=top; document.getElementById('divalert').style.height=altura; document.getElementById('divalert').style.left=left; document.getElementById('divalert').style.filter='alpha(opacity=76)'; document.getElementById('divalert').style.opacity='0.76'; document.getElementById('divalert').style.MozOpacity='0.76'; document.getElementById('divalert').style.textAlign='center'; document.getElementById('divalert').style.fontSize='18px'; document.getElementById('divalert').style.fontWeight='bold'; document.getElementById('divalert').style.color='#FFF'; document.getElementById('divalert').innerHTML = valor; document.getElementById('divalert').style.display = 'block'; document.getElementById('divalert').style.overflow = 'hidden'; } removealert = function(){ var div_rem = document.getElementById('divalert'); var conteudo = document.getElementById('pbody'); div_rem.style.display = 'none'; document.getElementById('submit').disabled = false; } alteralert = function(valor){ document.getElementById('divalert').innerHTML = '
'+ valor+'
'; document.getElementById('divalert').style.background = '#FFF'; } //////////////////////////////////////// loading = function(valor, local){ document.getElementById('submit').disabled = 'true'; showalert('
Aguarde... salvando '+valor+'
',local); } /////////////////////////////////////// errodb = function(valor){ document.getElementById('divalert').innerHTML ='
'+ valor+'
'; setTimeout("removealert()",3000); } /////////////////////////////////////// addEvent = function(o, e, f, s){ var r = o[r = "_" + (e = "on" + e)] = o[r] || (o[e] ? [[o[e], o]] : []), a, c, d; r[r.length] = [f, s || o], o[e] = function(e){ try{ (e = e || event).preventDefault || (e.preventDefault = function(){e.returnValue = false;}); e.stopPropagation || (e.stopPropagation = function(){e.cancelBubble = true;}); e.target || (e.target = e.srcElement || null); e.key = (e.which + 1 || e.keyCode + 1) - 1 || 0; }catch(f){} for(d = 1, f = r.length; f; r[--f] && (a = r[f][0], o = r[f][1], a.call ? c = a.call(o, e) : (o._ = a, c = o._(e), o._ = null), d &= c !== false)); return e = null, !!d; } }; removeEvent = function(o, e, f, s){ for(var i = (e = o["_on" + e] || []).length; i;) if(e[--i] && e[i][0] == f && (s || o) == e[i][1]) return delete e[i]; return false; }; //Exemplo de Uso /* verificacliente = function(){ local = '/scripts/verifica_cliente.php?data='+document.getElementById('cnpj').value+'|'+document.getElementById('razaosocial').value; setTimeout("processajax('dados',local)",1000); } var dados = document.getElementById('numero'); addEvent(dados, "focus", function( e ) { verificacliente();return false; }); */