//NOVO MODELO DE AJAX
// UTILIZASEMPRE  O ATUAL
function Ajax(){
	if (window.XMLHttpRequest) {
		this.xmlhttp = new XMLHttpRequest();
		// branch for IE/Windows ActiveX version
	} else{
		this.xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
	}
}

Ajax.prototype.processarGeral=function(url,path,objto){
	  if(xmlhttp.readyState != 2 && this.readyState != 3) {
			this.xmlhttp.open('POST', path ,false);
			this.xmlhttp.setRequestHeader('Method',"POST " + " HTTP/1.1");
			this.xmlhttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
			this.xmlhttp.send(url);
		}
		
		if(objto) this.show(objto);
	}
  
Ajax.prototype.show=function(obj){
			if (this.xmlhttp.readyState == 4 && this.xmlhttp.status == 200) {
			 var rcvdBox = document.getElementById(obj);
			 rcvdBox.style.display='block';
			 rcvdBox.innerHTML =  this.urldecode(this.xmlhttp.responseText) ;
	  }
	  
  }
  
Ajax.prototype.urldecode=  function (texto){
	texto=texto.replace(/\+/g," ");
	texto=unescape(texto);
	return texto;
}

Ajax.prototype.trim=function ( text ) {
	if(text==null) return null;
	return text.replace(/^[ \t]+|[ \t]+$/g, "");
}


<!--
// globals
var submeteuFormulario=0;
//*************** fim bloco anuncianantes/anuncios
function form1_validator(theform){
	nom=document.form1.nome.value;
	mat=document.form1.matricula.value;
	cpff=document.form1.cpf.value; 
	rg=document.form1.rg.value; 
	dat=document.form1.data_nasc.value;
	ddd=document.form1.ddd.value;
	tel=document.form1.telefone.value; 
	cel=document.form1.celular.value;
	end=document.form1.endereco.value; 
	cid=document.form1.cidade.value; 
	cep=document.form1.cep.value; 
	uf=document.form1.uf.value;
	
if(tel=='') tel=cel;
	
if(nom=='' || mat==''  || dat=='' ){
	alert("Informe os campos Nome aluno, Matrícula, Data Nascimento.");
	return false;
}
if(ddd=='' || tel==''){
	alert("Informe os campos DDD e telefone.");
	return false;
}

if(end=='' || cid==''  || cep==''  || uf==''  ){
	alert("Informe os campos Endereço, cidade, cep e UF.");
	return false;
}

//if(!cep){
//alert("Informe ao menos 08 caracteres para o CEP");
//return false;
//}
//return validacpf(cpff);

}

function validar_frmcadanunciante(){
	vuf=document.form1.uf.options[document.form1.uf.selectedIndex].value;
	cidade=document.form1.cidade.options[document.form1.cidade.selectedIndex].value;
	
	try{
		novcid=document.form1.newcidade.value;
	}catch(e){}
	
	v1=document.form1.nome.value;
	v2=document.form1.endereco.value;
	v3=document.form1.senha.value;
	v4=document.form1.telefone.value;
	v5=document.form1.email.value;
	//doc=document.form1.login.value;
	cep=document.form1.cep.value;
if(vuf==''){
	alert("Escolha o Estado de sua residência");
	return false;
}

if(cidade=='' && novcid=='' ){
alert("Escolha uma cidade ou caso não  haja digite  no campo nova cidade");
return false;
}
if(v1=='' || v4==''  || v3==''){
alert("Informe os campos Nome, telefone,  login e senha");
return false;
}
if(v3.length <4){
alert("Informe ao menos 04 caracteres para a senha");
return false;
}

}

function validar_frmcad2(){
	vuf=document.form1.uf.options[document.form1.uf.selectedIndex].value;
	cidade=document.form1.cidade.options[document.form1.cidade.selectedIndex].value;
	novcid=document.form1.novacidade.value;
	v1=document.form1.nome.value;
	v2=document.form1.endereco.value;
	v3=document.form1.senha.value;
	v4=document.form1.telefone.value;
	v5=document.form1.email.value;
	doc=document.form1.cpf.value;
	cep=document.form1.cep.value;
	dtnasc=document.form1.datanascimento.value;
	tipo=document.form1.cathidden.value;
	slen=doc.length;

if(vuf==''){
alert("Escolha o Estado de sua residência");
return false;
}

if(cidade=='' && novcid=='' ){
alert("Escolha uma cidade ou caso não  haja digite  no campo nova cidade");
return false;
}

if(dtnasc=='' && tipo!=2 ){
alert("Informe a data de nascimento do Cliente");
return false;
}


if(v1=='' || v2==''  || v3=='' || v4=='' || cep==''){
alert("Informe os campos Nome, endereço, cep,  telefone, senha e email");
return false;
}
if(v3.length <4){
alert("Informe ao menos 04 caracteres para a senha");
return false;
}

if(cep.length <8){
alert("Informe ao menos 08 caracteres para o CEP");
return false;
}

if(slen >14){
		return validacgc(doc);
//true
}else{
	return validacpf(doc);
}

}

//*********************************************************************
//****************** Bloco de código para exibir a msgbo e mostra form
//*********************************************************************

function msgbox(str){
if(str) alert(str);
}


function dasabilitarenter() {
var tecla = event.keyCode;
if ((tecla == 13)) { 
return false;
}
return tecla;
}

// Código para o teclado 
function tecladown (digito){
	if (digito == ''){
		document.form.senha.value = '';
		return;	
	}
	var pass = document.form.senha.value;
	if (pass.length >= 8){
		return;
	}
	document.form.senha.value = document.form.senha.value + digito;
}
function teclaclick(tecla){
	return false;
}
function teclaup(tecla){
	tecladown(tecla);
}
// --

// -- Contador para objeto TextArea.
function limita(campo){
	var tamanho = document.form[campo].value.length;
	var tex=document.form[campo].value;
	if (tamanho>=1539) {
		document.form[campo].value=tex.substring(0,1539); 
	}
	return true;
}

function contacampo(campo, tamtxt) {
document.form[tamtxt].value =  1540-document.form[campo].value.length;
}
// --

function SetHelp(txt) { help.innerText = txt ; }





//*********************************************************************
//************ Bloco para formatar/mascaras dos campos *********
//*********************************************************************

function FormataDado(campo,tammax,pos,teclapres){
	var tecla = teclapres.keyCode;
	vr = document.form[campo].value;
	vr = vr.replace( "-", "" );
	vr = vr.replace( ".", "" );
	vr = vr.replace( "/", "" );
	tam = vr.length ;
	if (tam < tammax && tecla != 8){ tam = vr.length + 1 ; }
	if (tecla == 8 ){ tam = tam - 1 ; }
	if ( tecla == 8 || tecla == 88 || tecla >= 48 && tecla <= 57 || tecla >= 96 && tecla <= 105 ){
		if ( tam <= 2 ){
	 		document.form[campo].value = vr ;}
		if ( tam > pos && tam <= tammax ){
			document.form[campo].value = vr.substr( 0, tam - pos ) + '-' + vr.substr( tam - pos, tam );}
	}
	//alert("campo: " + document.form[campo+1].name);
	if ( !teclapres.shiftKey && tecla == 9 && document.form[campo+1].name == "senhaConta" && document.applets['tclJava'] ){
		//alert("aki 1");
			document.applets['tclJava'].setFocus();
	}
}

// formato moeda
function FormataValor(campo,tammax,teclapres) {
	var BACKSPACE= 8; 	var key;  	 var tecla; 
   	CheckTAB=true; 
  	if(navigator.appName.indexOf("Netscape")!= -1){ 
	  tecla= teclapres.which; 
	  }else{ 
	tecla= teclapres.keyCode; 
	  } 
	key = String.fromCharCode( tecla); 
	var strValidos = "0123456789" 
	if ( strValidos.indexOf( key ) == -1 )  { return false;} 	
	var tecla = teclapres.keyCode;
	vr = campo.value;
	vr = vr.replace( "/", "" );
	vr = vr.replace( "/", "" );
	vr = vr.replace( ",", "" );
	vr = vr.replace( ".", "" );
	vr = vr.replace( ".", "" );
	vr = vr.replace( ".", "" );
	vr = vr.replace( ".", "" );
	tam = vr.length;
	if (tam < tammax && tecla != 8){ tam = vr.length + 1 ; }
	if (tecla == 8 ){	tam = tam - 1 ; }		
	if ( tecla == 8 || tecla >= 48 && tecla <= 57 || tecla >= 96 && tecla <= 105 ){
		if ( tam <= 2 ){ 
	 		campo.value = vr ; }
	 	if ( (tam > 2) && (tam <= 5) ){
	 		campo.value = vr.substr( 0, tam - 2 ) + ',' + vr.substr( tam - 2, tam ) ; }
	 	if ( (tam >= 6) && (tam <= 8) ){
	 		campo.value = vr.substr( 0, tam - 5 ) + '.' + vr.substr( tam - 5, 3 ) + ',' + vr.substr( tam - 2, tam ) ; }
	 	if ( (tam >= 9) && (tam <= 11) ){
	 			campo.value = vr.substr( 0, tam - 8 ) + '.' + vr.substr( tam - 8, 3 ) + '.' + vr.substr( tam - 5, 3 ) + ',' + vr.substr( tam - 2, tam ) ; }
	 	if ( (tam >= 12) && (tam <= 14) ){
	 			campo.value = vr.substr( 0, tam - 11 ) + '.' + vr.substr( tam - 11, 3 ) + '.' + vr.substr( tam - 8, 3 ) + '.' + vr.substr( tam - 5, 3 ) + ',' + vr.substr( tam - 2, tam ) ; }
	 	if ( (tam >= 15) && (tam <= 17) ){
	 		campo.value = vr.substr( 0, tam - 14 ) + '.' + vr.substr( tam - 14, 3 ) + '.' + vr.substr( tam - 11, 3 ) + '.' + vr.substr( tam - 8, 3 ) + '.' + vr.substr( tam - 5, 3 ) + ',' + vr.substr( tam - 2, tam ) ;}
	}
		
}

// formato inteiro
function FormataInteiro(tform,campo,teclapres) {
	var BACKSPACE= 8; 	var key;  	 var tecla; 
   	CheckTAB=true; 
 if(navigator.appName.indexOf("Netscape")!= -1){ 
	  tecla= teclapres.which; 
	  }else{ 
	tecla= teclapres.keyCode; 
	  } 

	key = String.fromCharCode( tecla); 
	var strValidos = "0123456789" 

	if ( strValidos.indexOf( key ) == -1 )  { 
		 return false ;
		 } 
	var tecla = teclapres.keyCode;
	var vr = tform.value;
	vr = vr.replace( ".", "" );
	vr = vr.replace( "/", "" );
	vr = vr.replace( "/", "" );
	tform.value = vr;
}

//formatdo data dd/mm/yyyy
function FormataData(campo,teclapres) {
	var BACKSPACE= 8; 	var key;  	 var tecla; 
   	CheckTAB=true; 
 if(navigator.appName.indexOf("Netscape")!= -1){ 
	  tecla= teclapres.which; 
	  }else{ 
	tecla= teclapres.keyCode; 
	  } 
	key = String.fromCharCode( tecla); 
	var strValidos = "0123456789" 
	if ( strValidos.indexOf( key ) == -1 )  { 
		 return false ;
		 } 
	var tecla = teclapres.keyCode;
	vr = campo.value;
	vr = vr.replace( ".", "" );
	vr = vr.replace( "/", "" );
	vr = vr.replace( "/", "" );
	tam = vr.length + 1;
	if ( tecla != 9 && tecla != 8 ){
		if ( tam > 2 && tam < 5 )
			campo.value = vr.substr( 0, tam - 2  ) + '/' + vr.substr( tam - 2, tam );
		if ( tam >= 5 && tam <= 10 )
			campo.value = vr.substr( 0, 2 ) + '/' + vr.substr( 2, 2 ) + '/' + vr.substr( 4, 4 ); 
	}

}

//nao sei para que??
function FormataMesAno(Campo,teclapres) {
	var tecla = teclapres.keyCode;
	vr = document.form[Campo].value;
	vr = vr.replace( ".", "" );
	vr = vr.replace( "/", "" );
	vr = vr.replace( "/", "" );
	tam = vr.length + 1;
	if ( tecla != 9 && tecla != 8 ){
		if ( tam > 2 && tam < 7 )
			document.form[Campo].value = vr.substr( 0, 2 ) + '/' + vr.substr( 2, tam ); }
}

// formata hora
function FormataHora(campo,teclapres) {
	var BACKSPACE= 8; 	var key;  	 var tecla; 
   	CheckTAB=true; 
 if(navigator.appName.indexOf("Netscape")!= -1){ 
	  tecla= teclapres.which; 
	  }else{ 
	tecla= teclapres.keyCode; 
	  } 

	key = String.fromCharCode( tecla); 
	var strValidos = "0123456789" 

	if ( strValidos.indexOf( key ) == -1 )  { 
		 return false ;
		 } 
	var tecla = teclapres.keyCode;
	vr = campo.value;
	vr = vr.replace( ".", "" );
	vr = vr.replace( "/", "" );
	vr = vr.replace( "/", "" );
	tam = vr.length + 1;
	if ( tecla != 9 && tecla != 8 ){
		if ( tam > 2 && tam < 5 )
			campo.value = vr.substr( 0, 2 ) + ':' + vr.substr( 2, tam ); }
}

//nao lembro para que ????
function FormataPercentual(campo,tammax,teclapres) {
	var tecla = teclapres.keyCode;
	vr = document.form[campo].value;
	vr = vr.replace( "/", "" );
	vr = vr.replace( "/", "" );
	vr = vr.replace( ",", "" );
	vr = vr.replace( ".", "" );
	vr = vr.replace( ".", "" );
	vr = vr.replace( ".", "" );
	vr = vr.replace( ".", "" );
	tam = vr.length;
	if (tam < tammax && tecla != 8){ tam = vr.length + 1 ; }
	if (tecla == 8 ){	tam = tam - 1 ; }
	if ( tecla == 8 || tecla >= 48 && tecla <= 57 || tecla >= 96 && tecla <= 105 ){
		if ( tam <= 3 ){ 
	 		document.form[campo].value = vr ; }
	 	if ( (tam > 3) && (tam <= 6) ){
	 		document.form[campo].value = vr.substr( 0, tam - 3 ) + ',' + vr.substr( tam - 3, tam ) ; }
	}		
	
}

// formata  CPF
function FormataCpf(campo,tammax,teclapres) {
	var tecla = teclapres.keyCode;
	var vr =campo.value;
	vr = vr.replace( "/", "" );
	vr = vr.replace( "/", "" );
	vr = vr.replace( ",", "" );
	vr = vr.replace( ".", "" );
	vr = vr.replace( ".", "" );
	vr = vr.replace( ".", "" );
	vr = vr.replace( ".", "" );
	vr = vr.replace( "-", "" );
	vr = vr.replace( "-", "" );
	vr = vr.replace( "-", "" );
	vr = vr.replace( "-", "" );
	vr = vr.replace( "-", "" );
	tam = vr.length;

	if (tam < tammax && tecla != 8){ tam = vr.length + 1 ; }

	if (tecla == 8 ){	tam = tam - 1 ; }
		
	if ( tecla == 8 || tecla >= 48 && tecla <= 57 || tecla >= 96 && tecla <= 105 ){
		if ( tam <= 2 ){ 
	 campo.value = vr ; }
	 	if ( (tam > 2) && (tam <= 5) ){
	 		campo.value = vr.substr( 0, tam - 2 ) + '-' + vr.substr( tam - 2, tam ) ; }
	 	if ( (tam >= 6) && (tam <= 8) ){
	 	campo.value = vr.substr( 0, tam - 5 ) + '.' + vr.substr( tam - 5, 3 ) + '-' + vr.substr( tam - 2, tam ) ; }
	 	if ( (tam >= 9) && (tam <= 11) ){
	 	campo.value = vr.substr( 0, tam - 8 ) + '.' + vr.substr( tam - 8, 3 ) + '.' + vr.substr( tam - 5, 3 ) + '-' + vr.substr( tam - 2, tam ) ; }
	 	if ( (tam >= 12) && (tam <= 14) ){
	 	campo.value = vr.substr( 0, tam - 11 ) + '.' + vr.substr( tam - 11, 3 ) + '.' + vr.substr( tam - 8, 3 ) + '.' + vr.substr( tam - 5, 3 ) + '-' + vr.substr( tam - 2, tam ) ; }
	 	if ( (tam >= 15) && (tam <= 17) ){
	 	campo.value = vr.substr( 0, tam - 14 ) + '.' + vr.substr( tam - 14, 3 ) + '.' + vr.substr( tam - 11, 3 ) + '.' + vr.substr( tam - 8, 3 ) + '.' + vr.substr( tam - 5, 3 ) + '-' + vr.substr( tam - 2, tam ) ;}
	}		
}

function FormataTelefone(campo,tammax,teclapres) {
	var tecla = teclapres.keyCode;
	vr = document.form[campo].value;
	vr = vr.replace( "/", "" );
	vr = vr.replace( "/", "" );
	vr = vr.replace( ",", "" );
	vr = vr.replace( ".", "" );
	vr = vr.replace( ".", "" );
	vr = vr.replace( ".", "" );
	vr = vr.replace( ".", "" );
	vr = vr.replace( "-", "" );
	vr = vr.replace( "-", "" );
	vr = vr.replace( "-", "" );
	vr = vr.replace( "-", "" );
	vr = vr.replace( "-", "" );
	tam = vr.length;

	if (tam < tammax && tecla != 8){ tam = vr.length + 1 ; }

	if (tecla == 8 ){	tam = tam - 1 ; }
		
	if ( tecla == 8 || tecla >= 48 && tecla <= 57 || tecla >= 96 && tecla <= 105 ){
		if ( tam <= 2 ){ 
	 		document.form[campo].value = vr ; }
	 	if ( (tam > 4) ){
	 		document.form[campo].value = vr.substr( 0, tam - 4 ) + '-' + vr.substr( tam - 4, tam ) ; }
	}		
}

function FormataCep(campo,tammax,teclapres) {
	var tecla = teclapres.keyCode;
	vr = campo.value;
	vr = vr.replace( "/", "" );
	vr = vr.replace( "/", "" );
	vr = vr.replace( ",", "" );
	vr = vr.replace( ".", "" );
	vr = vr.replace( ".", "" );
	vr = vr.replace( ".", "" );
	vr = vr.replace( ".", "" );
	vr = vr.replace( "-", "" );
	vr = vr.replace( "-", "" );
	vr = vr.replace( "-", "" );
	vr = vr.replace( "-", "" );
	vr = vr.replace( "-", "" );
	tam = vr.length;

	if (tam < tammax && tecla != 8){ tam = vr.length + 1 ; }

	if (tecla == 8 ){	tam = tam - 1 ; }
		
	if ( tecla == 8 || tecla >= 48 && tecla <= 57 || tecla >= 96 && tecla <= 105 ){
		if ( tam <= 2 ){ 
	 		campo.value = vr ; }
	 	if ( (tam > 4) ){
	 		campo.value = vr.substr( 0, tam - 3 ) + '-' + vr.substr( tam - 3, tam ) ; }
	}		
}


//*********************************************************************
//************ Bloco para validacoes de dados *************************
//*********************************************************************

function validacgc(pcgc){
       // verifica o tamanho
 if (pcgc.length < 14 || pcgc.length > 16) {
  sim=false
  alert ("Tamanho Inválido de CNPJ")
  	return false;
  }
 else {
 	sim=true}
  if (sim )  // verifica se e numero
  {
  for (i=0;((i<=(pcgc.length-1))&& sim); i++)
  {
   val = pcgc.charAt(i)
       // alert (val)
   if
((val!="9")&&(val!="0")&&(val!="1")&&(val!="2")&&(val!="3")&&(val!="4") &&
(val!="5")&&(val!="6")&&(val!="7")&&(val!="8")) {sim=false}
   }
   if (sim)  // se for numero continua
   {
    m2 = 2
    soma1 = 0
    soma2 = 0
    for (i=11;i>=0;i--)
    {
     val = eval(pcgc.charAt(i))
       // alert ("Valor do Val: "+val)
     m1 = m2
  if (m2<9) { m2 = m2+1}
  else {m2 = 2}
  soma1 = soma1 + (val * m1)
  soma2 = soma2 + (val * m2)
    }  // fim do for de soma

  soma1 = soma1 % 11
  if (soma1 < 2) {  d1 = 0}
   else { d1 = 11- soma1}

     soma2 = (soma2 + (2 * d1)) % 11
  if (soma2 < 2) { d2 = 0}
   else { d2 = 11- soma2}
        // alert (d1)
       // alert (d2)
    if ((d1==pcgc.charAt(12)) && (d2==pcgc.charAt(13)))
	   { return true; }
   else alert("Valor inválido de CNPJ");
   return false;
   }
 }
 }
 

// validade CPF  (muito bom)
 function validacpf(pcpf)
 {

 if (pcpf.length != 11) {sim=false}
 else {sim=true}

  if (sim )  // valida o primeiro digito
  {
  for (i=0;((i<=(pcpf.length-1))&& sim); i++)
  {
   val = pcpf.charAt(i)
   if

 ((val!="9")&&(val!="0")&&(val!="1")&&(val!="2")&&(val!="3")&&(val!="4")

 &&    (val!="5")&&(val!="6")&&(val!="7")&&(val!="8")) {sim=false}
   }

   if (sim)
  {
    soma = 0
    for (i=0;i<=8;i++)
    {
     val = eval(pcpf.charAt(i))
     soma = soma + (val*(i+1))
    }

    resto = soma % 11
    if (resto>9) dig = resto -10
    else  dig = resto
    if (dig != eval(pcpf.charAt(9))) { sim=false }
   else   // valida o segundo digito
    {

     soma = 0
    for (i=0;i<=7;i++)
     {
     val = eval(pcpf.charAt(i+1))
      soma = soma + (val*(i+1))
    }

     soma = soma + (dig * 9)
    resto = soma % 11
     if (resto>9) dig = resto -10
     else  dig = resto
   if (dig != eval(pcpf.charAt(10))) { sim = false }
    else sim = true
   }
   }
  }

  if (sim) { return  true; }
  else
    alert("Valor invalido de CPF")
	return false;
 }
 

//*********************************************************************
//************ Bloco confirmar exclusoes     *************************
//*********************************************************************
function del(strid){
	if(confirm('Deseja realmente excluir este Aluno?\n\nObservação:\n Todos os dados relativos ao Aluno serão\n excluídos juntamente com o cadastro.')){
		 window.location='aluno_alteracao.php?ckk='+ strid ;
	}
}

function delet(strid){
	if(confirm('Deseja realmente excluir este registro\n\nObservação:\n Não será possível desfazer a ação.')){
		 window.location=strid ;
	}
}
//*********************************************************************
//************ Bloco funcoes do antigo webmanager***********************
//*********************************************************************
function disabilitar(val){
self.error=null;
if(val=='0' ){
	document.form1.newcidade.disabled=false;
}else{
	document.form1.newcidade.disabled=true;
}
}

function habcurso(){
val=document.form1.cargo.options[form1.cargo.selectedIndex].value;
if(val==0){
	document.form1.outrocargo.disabled=false;
	document.form1.outrocargo.focus();
}else{
	document.form1.outrocargo.disabled=true;
}

}

function habex(){
val=document.form1.empresa.options[form1.empresa.selectedIndex].value;
if(val==0){
	document.form1.outroemp.disabled=false;
	document.form1.outroemp.focus();
}else{
	document.form1.outroemp.disabled=true;
}
}


//*********************************************************************
//************ Bloco funcoes de formularios  *************************
//*********************************************************************

// essa function deverar ser a  function generica para abrir janelas popup !!!!!!
// deveremos sempre que possivel usá-la
function abrir_janela(valor,medidas) {
self.OnError=null;
window.open(valor,'Popup','toolbar=no,location=no,scrollbars=yes,status=no,menubar=no,resizable=no,' + medidas);
}

function CheckAllBox(theform,sze,compare) {
	try{
  var nobj=theform.elements.length ; 
  for (var i=0;i<nobj;i++) {
	 
	  if(theform.elements[i].type=='checkbox'){
		   
   		var x = theform.elements[i];
		   var cmp=(x.id) ? x.id : x.name;
			
			var parte=cmp.substring(0,sze);
		if (parte === compare) {
		    x.checked =(x.checked ) ? false: true;
		}
		if(i > nobj) break;
	 }
  }
	}catch(e){}
}



// abaixo estam as function que deveram ser mudadas  com o tempo
//sempre deveremos usar  functions genericas !!!!!!!!
function CheckAll() {
nobj=document.form2.elements.length ;
  for (var i=0;i<nobj;i++) {
   		var x = document.form2.elements[i];
		var cmp=x.name;
		parte=cmp.substring(0,3);
		if (parte == 'kil') {
		 x.checked = document.form2.selall.checked;
		}
		if(i > nobj) break;
	 }
}
function reload(){
document.form1.submit()
}
function open_win2(valor) {
   self.OnError=null;
	window.open("help.php#" + valor,'Help','scrollbars=yes,width=280,height=300');
}

function open_win(valor) {
   self.OnError=null;
	window.open("popup.php?codprod=" + valor,'Popup','scrollbars=yes,width=320,height=360');
}

function open_win2(valor) {
   self.OnError=null;
	window.open("help.php#" + valor,'Help','scrollbars=yes,width=280,height=300');
}

function start_form(){document.form1.submit();}

function vertabela(url){
window.open(url,"titulo",'toolbar=no,width=415,height=405,left=100,top=50,resizable=no');
}




function openwindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}


function authfile(valor,fp){ //para o gerenciador de conteudo
window.tt.location="inc_gerenciador_getfile.php?arkf=" + valor + "&fp="  + fp;
}

// function para  exibir/ocultar radios buttons
function setvisible(theform,val) {
self.onerror=null ;
nobj=theform.elements.length ;
  var x = theform.getElementsByTagName('div');
	for (var i=0;i<=x.length;i++)
	{
		try{
			if (x[i].id == 'visible' + val ){
				x[i].style.display = 'block';
			}else{
				x[i].style.display = 'none';
			}
		}catch(e){}
		if(i > x) break;
	}

}


function onError(){ return false; }

function montaExpand(obj,n) {
var str="<a href=\"javascript: mostrarObj('" + obj +"','" + n + "')\"><img id='arrow_expand" + n +  "' src='../images/img/setadown.gif' border='0'></a>";
document.write(str);
}
// function para  exibir/ocultar  div com scrolling ou outros forms objetos
function mostrarObj(obj,n) {
nobj=document.getElementById(obj);
try{sobj=document.getElementById("arrow_expand"+n);}catch(e){}
  if(nobj.style.display=='none'){
  	nobj.style.display ='block';
	try{sobj.src='../images/img/setaup.gif';}catch(e){}
  }else{
  	nobj.style.display ='none';
	try{sobj.src='../images/img/setadown.gif';}catch(e){}
 }
}

function aStatus() { 
var as = document.getElementsByTagName("a")
try{
    for(var i = 0; i < as.length; i++) { 
    as[i].onmouseover = function() { 
                        //window.status = this.title != '' ? this.title : this.innerHTML; 
                        window.status='WebManager Versão 2.0';
						return true; 
                        }
    as[i].onmouseout = function() { 
                       window.status ='WebManager Versão 2.0'
                       return true; 
                       }
    } 
}catch(e){}
}

function checkSubmeteuFormulario(cancel){
    if(cancel) return true;
	if(submeteuFormulario==1){
	  alert('O formulário já está sendo processado.!');
	  return false
	}else{
	 submeteuFormulario=1;
	 return true;
	}
}

try{
	Mouse = {};
	Mouse.doc = document;
	Mouse.MouseMoveHandler = function (e) {
		  e = e || window.event;
		  Mouse.x = (Mouse.doc.body.scrollLeft || 0) + e.clientX;
		  Mouse.y = (Mouse.doc.body.scrollTop || 0) + e.clientY;
		  Mouse.currentTarget = e.target || e.srcElement;
		  return true;
		};

	if (Mouse.doc.attachEvent)
	   Mouse.doc.attachEvent("onmousemove",Mouse.MouseMoveHandler);
	else if (Mouse.doc.addEventListener)
	   Mouse.doc.addEventListener("mousemove",Mouse.MouseMoveHandler,false);
}catch(e){}


	function urldecode(texto){
			//Desfaz o urlencode
			texto=texto.replace(/\+/g," ");
			texto=unescape(texto);
			return texto;
		}
/**
 * This array is used to remember mark status of rows in browse mode
 */
var marked_row = new Array;
var lastone;
/**
 * Sets/unsets the pointer and marker in browse mode
 *
 * @param   object    the table row
 * @param   interger  the row number
 * @param   string    the action calling this script (over, out or click)
 * @param   string    the default background color
 * @param   string    the color to use for mouseover
 * @param   string    the color to use for marking a row
 *
 * @return  boolean  whether pointer is set or not
 */
function setPointer(theRow, theRowNum, theAction, theDefaultColor, thePointerColor, theMarkColor)
{
    var theCells = null;
try{
    // 1. Pointer and mark feature are disabled or the browser can't get the
    //    row -> exits
    if ((thePointerColor == '' && theMarkColor == '')
        || typeof(theRow.style) == 'undefined') {
        return false;
    }

    // 2. Gets the current row and exits if the browser can't get it
    if (typeof(document.getElementsByTagName) != 'undefined') {
        theCells = theRow.getElementsByTagName('td');
    }
    else if (typeof(theRow.cells) != 'undefined') {
        theCells = theRow.cells;
    }
    else {
        return false;
    }

    // 3. Gets the current color...
    var rowCellsCnt  = theCells.length;
    var domDetect    = null;
    var currentColor = null;
    var newColor     = null;
    // 3.1 ... with DOM compatible browsers except Opera that does not return
    //         valid values with "getAttribute"
    if (typeof(window.opera) == 'undefined'
        && typeof(theCells[0].getAttribute) != 'undefined') {
        currentColor = theCells[0].getAttribute('bgcolor');
        domDetect    = true;
    }
    // 3.2 ... with other browsers
    else {
        currentColor = theCells[0].style.backgroundColor;
        domDetect    = false;
    } // end 3

    // 3.3 ... Opera changes colors set via HTML to rgb(r,g,b) format so fix it
    if (currentColor.indexOf("rgb") >= 0) 
    {
        var rgbStr = currentColor.slice(currentColor.indexOf('(') + 1,
                                     currentColor.indexOf(')'));
        var rgbValues = rgbStr.split(",");
        currentColor = "#";
        var hexChars = "0123456789ABCDEF";
        for (var i = 0; i < 3; i++)
        {
            var v = rgbValues[i].valueOf();
            currentColor += hexChars.charAt(v/16) + hexChars.charAt(v%16);
        }
    }

    // 4. Defines the new color
    // 4.1 Current color is the default one
    if (currentColor == ''
        || currentColor.toLowerCase() == theDefaultColor.toLowerCase()) {
        if (theAction == 'over' && thePointerColor != '') {
            newColor              = thePointerColor;
        }
        else if (theAction == 'click' && theMarkColor != '') {
            newColor              = theMarkColor;
            marked_row[theRowNum] = true;
            // Garvin: deactivated onclick marking of the checkbox because it's also executed
            // when an action (like edit/delete) on a single item is performed. Then the checkbox
            // would get deactived, even though we need it activated. Maybe there is a way
            // to detect if the row was clicked, and not an item therein...
            // document.getElementById('id_rows_to_delete' + theRowNum).checked = true;
        }
    }
    // 4.1.2 Current color is the pointer one
    else if (currentColor.toLowerCase() == thePointerColor.toLowerCase()
             && (typeof(marked_row[theRowNum]) == 'undefined' || !marked_row[theRowNum])) {
        if (theAction == 'out') {
            newColor              = theDefaultColor;
        }
        else if (theAction == 'click' && theMarkColor != '') {
            newColor              = theMarkColor;
           marked_row[theRowNum] = true;
            // document.getElementById('id_rows_to_delete' + theRowNum).checked = true;
        }
    }
    // 4.1.3 Current color is the marker one
    else if (currentColor.toLowerCase() == theMarkColor.toLowerCase()) {
        if (theAction == 'click') {
			 newColor              = (thePointerColor != '')
                                  ? thePointerColor
                                  : theDefaultColor;
								  
            marked_row[theRowNum] = (typeof(marked_row[theRowNum]) == 'undefined' || !marked_row[theRowNum])
                                  ? true
                                  : null;
            // document.getElementById('id_rows_to_delete' + theRowNum).checked = false;
        }
    } // end 4

    // 5. Sets the new color...
    if (newColor) {
        var c = null;
        // 5.1 ... with DOM compatible browsers except Opera
        if (domDetect) {
            for (c = 0; c < rowCellsCnt; c++) {
                theCells[c].setAttribute('bgcolor', newColor, 0);
            } // end for
        }
        // 5.2 ... with other browsers
        else {
            for (c = 0; c < rowCellsCnt; c++) {
                theCells[c].style.backgroundColor = newColor;
            }
        }
    } // end 5

    lastone=theRowNum;
    return true;
}catch(e){}

} // end of the 'setPointer()' function

-->
