
// JavaScript Document

function openajax() /* Cria a Funcao*/
{
	var ajax; /* Defini a Variável */
	try
	{
		ajax = new XMLHttpRequest(); /* Tenta Instanciar o Objeto */
	}
	catch(ee)
	{
		try
		{
			ajax = new ActiveXObject("Msxm12.XMLHTTP"); /* Se Nao Conseguiu o Anterior Tenta esse*/
		}
		catch(e)
		{
			try
			{
				ajax = new ActiveXObject("Microsoft.XMLHTTP"); /* E o memso se repete aqui*/
			}
			catch(E)
			{
				ajax = false; /* Se nao conseguiu em Nenhum retorna False pois o Navegador Usado nao Suporta Ajax*/
			}
		}
	}
	return ajax; /* Retorna um Boleano*/
}


function ajax_js(){ 
        var scripts = document.getElementById('scripts');
        if(scripts){
				var corpo = window.document.getElementsByTagName('body')[0]; 
				var js = window.document.createElement('script'); 
				js.text = scripts.innerHTML;
				js.type = 'text/javascript';
				corpo.appendChild(js);    
        }
}

function Mudar_imagem() {	
	document.getElementById("im").src = "imagens/img.php?largura=250&altura=30&caracteres=6&chave="+Math.random();
}

function Checamail(campo) {
	if (campo.value != "") {
		arr_nome = campo.value.split('@');
		nome = arr_nome[0];
		divResposta = document.getElementById("ckemail");
		var ajax = openajax();
		ajax.open("GET","checa_email.php?nome="+nome,true);
		ajax.onreadystatechange = function()
		{
			if (ajax.readyState < 4)		
			{
				
			}
			if (ajax.readyState == 4)
			{
				if (ajax.status == 200)
				
				{
					divResposta.innerHTML = ajax.responseText;
				}
			}
		}
		ajax.send(null);
	}
}

function tab(e) {
	if (document.all){
		var evt=e.keyCode;
		if (evt == 13) {
			e.keyCode = 9;
		}
	}else{
		var evt = e.which;
		if (evt == 13) {
			e.which = 9;
		}
	}
}

function so_num(e) {
    if (document.all){
	var evt=event.keyCode;
}else{
	var evt = e.which;} 
    if (evt >47 && evt<58){return true;} 
    if (evt < 20) {return true;}
	return false; 
}
//-----------------Só numeros 2---------------------
function num_fone(e) {
    if (document.all){
	var evt=event.keyCode;
}else{
	var evt = e.which;} 
    if (evt >47 && evt<58){return true;} 
    if (evt < 20) {return true;}
	return false; 
}

//-----------------Só letras email---------------------
function let_email(e) {
    if (document.all){
	var evt=event.keyCode;
}else{
	var evt = e.which;} 
    if (evt >47 && evt<58){return true;}
	if (evt >64 && evt<91){return true;}
	if (evt >96 && evt<123){return true;}
	if (evt ==95){return true;}
	if (evt ==46){return true;} 
    if (evt < 20) {return true;}
	return false; 
}

//-----------------Só letras e números---------------------
function let_num(e) {
    if (document.all){
	var evt=event.keyCode;
}else{
	var evt = e.which;} 
    if (evt >47 && evt<58){return true;}
	if (evt >96 && evt<123){return true;}
    if (evt < 20) {return true;}
	return false; 
}

//-----------------------------------------------
//Máscaras para determinados campos
//-----------------------------------------------

//------------Máscara de data-------------------//
var data = 0;
function mask_data(vdata) {
if (data < vdata.value.length) {
	if (vdata.value.length == 2) {
		vdata.value = vdata.value + '/';
	}
	if (vdata.value.length == 5) {
		vdata.value = vdata.value + '/';
	}
	
}
data = vdata.value.length;
}


