////////////abre janela
function abre(url,window_width,window_height){
		var window_top = (screen.height-window_height)/2;
		var window_left = (screen.width-window_width)/2;
		window.open(url,"net","top="+window_top+",left="+window_left+",width="+window_width+",height="+window_height+", maximized=no, toolbar=no, location=no, status=no, menubar=no, scrollbars=no, scrolling=no, resizebled=no");	
	}
//////////login
function extraiScript(texto){
var ini, pos_src, fim, codigo;
    var objScript = null;
    ini = texto.indexOf('<script', 0)
    while (ini!=-1){
        var objScript = document.createElement("script");
        //Busca se tem algum src a partir do inicio do script
        pos_src = texto.indexOf(' src', ini)
        ini = texto.indexOf('>', ini) + 1;

        //Verifica se este e um bloco de script ou include para um arquivo de scripts
        if (pos_src < ini && pos_src >=0){//Se encontrou um "src" dentro da tag script, esta e um include de um arquivo script
            //Marca como sendo o inicio do nome do arquivo para depois do src
            ini = pos_src + 4;
            //Procura pelo ponto do nome da extencao do arquivo e marca para depois dele
            fim = texto.indexOf('.', ini)+4;
            //Pega o nome do arquivo
            codigo = texto.substring(ini,fim);
            //Elimina do nome do arquivo os caracteres que possam ter sido pegos por engano
            codigo = codigo.replace("=","").replace(" ","").replace("\"","").replace("\"","").replace("\'","").replace("\'","").replace(">","");
            // Adiciona o arquivo de script ao objeto que sera adicionado ao documento
            objScript.src = codigo;
        }else{//Se nao encontrou um "src" dentro da tag script, esta e um bloco de codigo script
            // Procura o final do script
            fim = texto.indexOf('</script>', ini);
            // Extrai apenas o script
            codigo = texto.substring(ini,fim);
            // Adiciona o bloco de script ao objeto que sera adicionado ao documento
            objScript.text = codigo;
        }

        //Adiciona o script ao documento
        document.body.appendChild(objScript);
        // Procura a proxima tag de <script
        ini = texto.indexOf('<script', fim);

        //Limpa o objeto de script
        objScript = null;
    }
}

var xmlHttp

function login()
{ 
xmlHttp=GetXmlHttpObject()
if (xmlHttp==null)
{
alert ("Browser does not support HTTP Request")
return
} 
var usuario = unescape(document.getElementById("usuario").value);
var senha = unescape(document.getElementById("senha").value);

var url="process_login.asp?usuario="+usuario+"&senha="+senha
xmlHttp.onreadystatechange=stateChanged 
xmlHttp.open("GET",url,true)
xmlHttp.send(null)
}

function stateChanged() 
{
if (xmlHttp.readyState==4){
texto=unescape(xmlHttp.responseText.replace(/\+/g," "));
document.getElementById("r").innerHTML=texto;
// executa scripts
extraiScript(texto);
}
} 

function GetXmlHttpObject()
{ 
var objXMLHttp=null
if (window.XMLHttpRequest)
{
objXMLHttp=new XMLHttpRequest()
}
else if (window.ActiveXObject)
{
objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP")
}
return objXMLHttp
}
function openAjax() { 
var Ajax; 
try {Ajax = new XMLHttpRequest();
}catch(ee) { 
try {Ajax = new ActiveXObject("Msxml2.XMLHTTP");
}catch(e) { 
try {Ajax = new ActiveXObject("Microsoft.XMLHTTP");
}catch(e) {Ajax = false; 
} 
} 
} 
return Ajax; 
} 

function aj(id,url) { 
if(document.getElementById) { 
var exibeResultado = document.getElementById(id); 
var Ajax = openAjax();
Ajax.open("GET", url, true);
Ajax.onreadystatechange = function() 
{ 
//if(Ajax.readyState == 1) {
//exibeResultado.innerHTML = "<div id='loading'><img src='images/aguarde.gif' width='110' height='34' alt=''/></div>"; 
//} 
if(Ajax.readyState == 4) {
if(Ajax.status == 200) { 
var resultado = unescape(Ajax.responseText.replace(/\+/g," "));
exibeResultado.innerHTML = resultado;
// executa scripts
extraiScript(resultado);
} 
else { 
exibeResultado.innerHTML = "Erro: "+resultado; 
} 
} 
} 
Ajax.send(null);
} 
}
function openAjax() { 
var Ajax; 
try {Ajax = new XMLHttpRequest();
}catch(ee) { 
try {Ajax = new ActiveXObject("Msxml2.XMLHTTP");
}catch(e) { 
try {Ajax = new ActiveXObject("Microsoft.XMLHTTP");
}catch(e) {Ajax = false; 
} 
} 
} 
return Ajax; 
}


/////////
function aj_combo(div,url,id1,id2) { 
if(document.getElementById) { 
var exibeResultado = document.getElementById(div); 
var Ajax = openAjax();
url = url+'?id1='+id1+'&id2='+id2;
Ajax.open("GET", url, true);
Ajax.onreadystatechange = function() 
{ 
if(Ajax.readyState == 1) {
exibeResultado.innerHTML = "Aguarde..."; 
} 
if(Ajax.readyState == 4) {
if(Ajax.status == 200) { 
var resultado = unescape(Ajax.responseText.replace(/\+/g," "));
exibeResultado.innerHTML = resultado;
// executa scripts
extraiScript(resultado);
} 
else { 
exibeResultado.innerHTML = "Erro: "+resultado; 
} 
} 
} 
Ajax.send(null);
} 
}
function openAjax() { 
var Ajax; 
try {Ajax = new XMLHttpRequest();
}catch(ee) { 
try {Ajax = new ActiveXObject("Msxml2.XMLHTTP");
}catch(e) { 
try {Ajax = new ActiveXObject("Microsoft.XMLHTTP");
}catch(e) {Ajax = false; 
} 
} 
} 
return Ajax; 
}


//////////////////////////////////////
function adicionar(url){
		window_height = 200
		window_width = 260
		var window_top = (screen.height-window_height)/2;
		var window_left = (screen.width-window_width)/2;
		window.open(url,"net","top="+window_top+",left="+window_left+",width="+window_width+",height="+window_height+", maximized=no, toolbar=no, location=no, status=no, menubar=no, scrollbars=no, scrolling=no, resizebled=no");	
	}
function alterar(opt,url,window_width,window_height) {
	var opt = document.getElementById(opt).value;
	if (opt == ''){
		alert('Favor selecionar o registro.');
	}else{
	var window_top = (screen.height-window_height)/2;
	var window_left = (screen.width-window_width)/2;
	window.open(url+"&id="+opt,"net","top="+window_top+",left="+window_left+",width="+window_width+",height="+window_height+", maximized=no, toolbar=no, location=no, status=no, menubar=no, scrollbars=no, scrolling=no, resizebled=no");	
}
}
function adicionarCF(forn) {
	var cat = document.getElementById("f_todas_cat").value;
	if (cat == 'Selecione'){
		alert('Favor selecionar a categoria.');
	}else{
		aj('cf','adicionarCF.asp?id='+cat+'&idforn='+forn);
	}
}
function adicionarPF(forn) {
	var pl = document.getElementById("f_todos_pl").value;
	if (pl == 'Selecione'){
		alert('Favor selecionar o plano.');
	}else{
		aj('pf','adicionarPF.asp?id='+pl+'&idpl='+forn);
	}
}
function excluir(id,modo,id2){
	if (id == 0){
		if (modo == 'p_cat'){
			alert('Favor selecionar a categoria.');
		}else if (modo == 'p_gr'){
			alert('Favor selecionar o grupo.');
		}else{
			alert('Favor selecionar o registro.');
		}
		
	}else{
		if (confirm("Confirma a exclusão do registro?")==true){
			if (modo == 'cf'){
				aj('cf','excluir.asp?id='+id+'&modo='+modo+'&id2='+id2);
			}else if (modo == 'pf'){
				aj('pf','excluir.asp?id='+id+'&modo='+modo+'&id2='+id2);
			}else{
				aj('del','excluir.asp?id='+id+'&modo='+modo+'&id2='+id2);
			}
		}
	}
}

/////////////habilitar enter
function enter(tipo) {
var tecla = event.keyCode;
if ((tecla == 13)) { 
	if (tipo = 'logar'){
	login();
	}
}
return tecla;
}

////////////////////////////////////////////////
function TudoIgual(field) {
  var str = field.value, primeiro='';
  for(i = 0; i < str.length; i++)
    if (str.charAt(i)>='0' && str.charAt(i)<='9')
      if (primeiro=='') primeiro = str.charAt(i);
      else if (str.charAt(i) != primeiro) return 0;
  return 1;
}
function Trim(s)
{
 if (s.length == 0)
  return s;

 if (s.length == 1 && s.value == ' ')
  return '';

 var i=0;

 while ( i < s.length && s.substring(i,i+1) == ' ') i++;

 var f = s.length - 1;

 while ( f >= 0 && s.substr(f,f+1) == ' ') f--;

 s = s.substr(i,f+1);

 return s;
}

function Guardar_CPF_CGC(field) {

  document.form1.f_doc.value = Trim(field.value);

}

function Verifica_CPF_CGC(field) {

  var cpf='', cgc='', digito='', digitoc='', temp='', k=0; i=0, j=0, soma=0, mt=0, dg='';

  field.value = Trim(field.value);
  
  // Compara o CNPJ_CPF antigo com o CNPJ_CPF novo
  
//  if(Trim(document.frmPedido.FormFederalTaxID.value) != field.value) {
//  		
//		document.frmPedido.FormNICHandle.value = "true";		
//		document.frmPedido.FormNICPassword.value = "";	
//		document.frmPedido.PasswordRequired.value = "0";	
//		
//		document.frmPedido.NICHandleRequested.value = "0";	
//		document.frmPedido.FormNICHandle.disabled = false;		
//		document.frmPedido.FormNICPassword.disabled = false;		
//		document.frmPedido.FormRegistrant.checked = true;
//
// }
  
  
//  if (field.value.substring(0,2) == '00') {
//        field.value = field.value.substring(1, field.value.length)
//  }

  // Limpa os espacos da variavel
  if (field.value == ' ' || field.value == '  ' || field.value == ''){
	return false;
  } 
  else {
       cpf = field.value;
  }
  if (cpf.length == 19) {
     cpf = cpf.substring(1, cpf.length)
  }
  
  for (i = 0;i < cpf.length; i++) {
	k = i + 1;
	if (isNaN(cpf.substring(i,k))== false){
          temp = temp + cpf.substring(i,k);  	
	}
  }

 if (((cpf.length > 13) && (cpf.length < 19)) && (isNaN(cpf.substring(3,4))==false)){ 
  cgc = temp.substring(0,12);
  digito = temp.substring(12,14);
  mult = '543298765432';
  for (j = 1; j <= 2; j++) {
    soma = 0;
    for (i = 0; i <= 11; i++) {
      k = i + 1;
      soma += parseInt((cgc.substring(i,k)) * (mult.substring(i,k)));
    }
    if (j == 2){
	soma = soma + (2 * digitoc);
    }
    digitoc = ((soma * 10) % 11);
    if (digitoc == 10){
	digitoc = 0;
    }
    dg +=digitoc;
    mult = '654329876543';
  }
  if (dg != digito || TudoIgual(field)) {
    alert('O CPF/CNPJ informado não é válido!');
    field.value = '';
    field.focus();
    return false;
  } 
  else {
    field.value=temp.substring(0,2)+'.'+temp.substring(2,5)+'.'+temp.substring(5,8)+'/'+temp.substring(8,12)+'-'+temp.substring(12,14);
    return true;
  }
 }
 else {
  if (cpf.length < 11) {
	alert( 'Informação inválida.');
	field.value = '';
	field.focus();
	return false;
  }
  if (cpf.length >= 11) {
      
      cpf = temp.substring(0,9);
	digito = temp.substring(9,11);
	for (j = 1; j <= 2; j++) {
	  soma = 0;
	  mt = 2;
	  for (i = 8 + j; i >= 1; i--) {
	    soma += parseInt(cpf.charAt(i-1),10) * mt;
	    mt++;
	  }
	  dg = 11 - (soma % 11);
	  if (dg > 9) {dg = 0};
	  cpf += dg;
	}

	if (digito != cpf.substring(9,11) || TudoIgual(field)) {
	  alert('O CPF/CNPJ informado não é válido!');
	  field.value = '';
	  field.focus();
	  return false;
	  } 
	else {
	  field.value=cpf.substring(0,3)+'.'+cpf.substring(3,6)+'.'+cpf.substring(6,9)+'-'+cpf.substring(9,11);
	  return true;
	}
    }
  } // fim if (cpf.length < 15)

}
<!-- Begin
var isNN = (navigator.appName.indexOf("Netscape")!=-1);
function autoTab(input,len, e) {
var keyCode = (isNN) ? e.which : e.keyCode; 
var filter = (isNN) ? [0,8,9] : [0,8,9,16,17,18,37,38,39,40,46];
if(input.value.length >= len && !containsElement(filter,keyCode)) {
input.value = input.value.slice(0, len);
input.form[(getIndex(input)+1) % input.form.length].focus();
}
function containsElement(arr, ele) {
var found = false, index = 0;
while(!found && index < arr.length)
if(arr[index] == ele)
found = true;
else
index++;
return found;
}
function getIndex(input) {
var index = -1, i = 0, found = false;
while (i < input.form.length && index == -1)
if (input.form[i] == input)index = i;
else i++;
return index;
}
return true;
}
//  End -->
/////////////filtro emails newsletter
<!--
function combo(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}
//-->