function addFav(){
    var url      = "http://www.saee.com.br";
    var title    = "SAEE ESTÁGIOS";
    if (window.sidebar) window.sidebar.addPanel(title, url,"");
    else if(window.opera && window.print){
        var mbm = document.createElement('a');
        mbm.setAttribute('rel','sidebar');
        mbm.setAttribute('href',url);
        mbm.setAttribute('title',title);
        mbm.click();
    }
    else if(document.all){window.external.AddFavorite(url, title);}
}

function MostraTipoDeficiencia ( v )  {

	if(v == 'S'){
		document.getElementById('TipoDeficiencia').style.display = "";
	}else{
		document.getElementById('TipoDeficiencia').style.display = 'none';
	}
}

function MostraAreaAtuacao( v ){

		document.getElementById('AreaAtuacao'+v).style.display = "";
	
}

function MostraExpProf( v ){

		document.getElementById('TRExpProf'+v).style.display = "";
	
}

function MostraAtividade( v ){

		document.getElementById('MostraAtividade'+v).style.display = "";
	
}


function MostraIdioma( v ){

		document.getElementById('MostraIdioma'+v).style.display = "";
	
}

function MostraHorario( v ){
		
		if(v != ''){
			if(v == 'Fixo'){
				document.getElementById('MostraHorarioVariavel').style.display = "none";
				document.getElementById('MostraHorarioFixo').style.display = "";
			}else{
				document.getElementById('MostraHorarioVariavel').style.display = "";
				document.getElementById('MostraHorarioFixo').style.display = "none";
			}
		}else{
			document.getElementById('MostraHorarioVariavel').style.display = "none";
			document.getElementById('MostraHorarioFixo').style.display = "none";
		}
	
}

function MostraHorarioMig( v ){
		
		if(v != ''){
			if(v == 'Fixo'){
				document.getElementById('MostraHorarioVariavelMig').style.display = "none";
				document.getElementById('MostraHorarioFixoMig').style.display = "";
			}else{
				document.getElementById('MostraHorarioVariavelMig').style.display = "";
				document.getElementById('MostraHorarioFixoMig').style.display = "none";
			}
		}else{
			document.getElementById('MostraHorarioVariavelMig').style.display = "none";
			document.getElementById('MostraHorarioFixoMig').style.display = "none";
		}
	
}

function MostraBeneficio( v ){
		
		if(v != ''){
			if(v == 'S'){
				document.getElementById('TRBeneficio').style.display = "";
			}else{
				document.getElementById('TRBeneficio').style.display = "none";
			}
		}else{
			document.getElementById('TRBeneficio').style.display = "none";	
		}
	
}

function MostraServico( v ){
		
		if(v != ''){
			if(v == "S"){
				document.getElementById('TRServicoQual').style.display = "";
			}else{
				document.getElementById('TRServicoQual').style.display = "none";
			}
		}else{
			document.getElementById('TRServicoQual').style.display = "none";	
		}
		
}

function MostraLogo( v ){
		
		if(v != ''){
			if(v == 'S'){
				document.getElementById('TRLogoADD').style.display = "";
			}else{
				document.getElementById('TRLogoADD').style.display = "none";
			}
		}else{
			document.getElementById('TRLogoADD').style.display = "none";	
		}
	
}

function MostraBtnNavegadores(){
	
	if(document.Form.Aceito.checked == false){
		document.getElementById("TRBtnOff").style.display = "";
		document.getElementById("TRBtnOn").style.display = "none";
	}else{
		document.getElementById("TRBtnOn").style.display = "";
		document.getElementById("TRBtnOff").style.display = "none";
	}

}


function MostraBtn(x){
						
	if(document.getElementById("Aceito").checked == true){
		document.getElementById("TRBtnOn").style.display = "";
		document.getElementById("TRBtnOff").style.display = "none";
	}else{
		document.getElementById("TRBtnOff").style.display = "";
		document.getElementById("TRBtnOn").style.display = "none";
	}

}

// Funcao para verificar Email e confirmacao de Email
function VerificaEmail(Email,EmailX) {
 
 Email = eval(Email);
 EmailX = eval(EmailX);

if (Email.value == "") {

	alert('Preencha o campo E-mail para continuar!');
	setTimeout("Email.focus();",250);
	return (false);
	
}else{
	
	if (Email.value != EmailX.value) {

	alert('A confirmação do E-mail, não coincide com o E-mail digitado!');
	EmailX.value = "";
	setTimeout("EmailX.focus();",250);
	return (false);
	
	}					
  }
  
  //valida_email(Email);
  
} // VerificaEmail

function VerificaEmailVaga(Email,Email2) {
	
 Email = eval(Email);
 Email2 = eval(Email2);

if (Email.value == "") {

	alert('Preencha o campo E-mail para continuar!');
	setTimeout("Email.focus();",250);
	return (false);
	
}else{
	
	if (Email.value != Email2.value) {

	alert('A confirmação do E-mail, não coincide com a E-mail digitado!');
	Email2.value = "";
	//setTimeout("Email2.focus();",250);
	return (false);
	
	}
  }
  
  valida_email(Email);
  
} // VerificaEmail
//----------------------------------------------------

function verificaevalidaemail(c,Email,Email2) {

//alert(c);
FormEmail = c;
Email = eval(Email);
Email2 = eval(Email2);

if (FormEmail.value == "") {
} else {
  prim = FormEmail.value.indexOf("@")
  if(prim < 2) {
  //alert("O e-mail informado não contem @.");
  //FormEmail.focus();
  setTimeout("FormEmail.focus();",250);
  //FormEmail.select();
  return false;
  }
  if(FormEmail.value.indexOf("@",prim + 1) != -1) {
  //alert("O e-mail informado parece não conter um PROVEDOR valido depois do @.");
  //FormEmail.focus();
  setTimeout("FormEmail.focus();",250);
  //FormEmail.select();
  return false;
  }
  if(FormEmail.value.indexOf(".") < 1) {
  //alert("O e-mail informado parece não conter um ponto (.) indicando seu provedor.");
  //FormEmail.focus();
  setTimeout("FormEmail.focus();",250);
  //FormEmail.select();
  return false;
  }
  if(FormEmail.value.indexOf(" ") != -1) {
  //alert("O e-mail informado parece não estar correto.");
  //FormEmail.focus();
  setTimeout("FormEmail.focus();",250);
  //FormEmail.select();
  return false;
  }
  if(FormEmail.value.indexOf("zipmeil.com") > 0) {
  //alert("O e-mail informado parece não estar correto.");
  //FormEmail.focus();
  setTimeout("FormEmail.focus();",250);
  //FormEmail.select();
  return false;
  }
  if(FormEmail.value.indexOf("hotmeil.com") > 0) {
  //alert("O e-mail informado parece não estar correto.");
  //FormEmail.focus();
  setTimeout("FormEmail.focus();",250);
  //FormEmail.select();
  return false;
  }
  if(FormEmail.value.indexOf(".@") > 0) {
  //alert("O valor inserido ( .@ ) iFormado parece não estar correto.");
  //FormEmail.focus();
  setTimeout("FormEmail.focus();",250);
  //FormEmail.select();
  return false;
  }
  if(FormEmail.value.indexOf("@.") > 0) {
  //alert("O e-mail informado parece não estar correto.");
  //FormEmail.focus();
  setTimeout("FormEmail.focus();",250);
  //FormEmail.select();
  return false;
  }
  if(FormEmail.value.indexOf(".com.br.") > 0) {
  //alert("O e-mail informado parece não estar correto.");
  //FormEmail.focus();
  setTimeout("FormEmail.focus();",250);
  //FormEmail.select();
  return false;
  }
  if(FormEmail.value.indexOf("/") > 0) {
 // alert("O e-mail informado parece não estar correto. Caracter ilegal ( / )");
  //FormEmail.focus();
  setTimeout("FormEmail.focus();",250);
  //FormEmail.select();
  return false;
  }
  if(FormEmail.value.indexOf("[") > 0) {
  //alert("O e-mail informado parece não estar correto. Caracter ilegal ( [ )");
  //FormEmail.focus();
  setTimeout("FormEmail.focus();",250);
  //FormEmail.select();
  return false;
  }
  if(FormEmail.value.indexOf("]") > 0) {
  //alert("O e-mail informado parece não estar correto. Caracter ilegal ( ] )");
  //FormEmail.focus();
  setTimeout("FormEmail.focus();",250);
  //FormEmail.select();
  return false;
  }
  if(FormEmail.value.indexOf("(") > 0) {
  //alert("O e-mail informado parece não estar correto. Caracter ilegal ( ( )");
  //FormEmail.focus();
  setTimeout("FormEmail.focus();",250);
  //FormEmail.select();
  return false;
  }
  if(FormEmail.value.indexOf(")") > 0) {
  //alert("O e-mail informado parece não estar correto. Caracter ilegal ( ) )");
  //FormEmail.focus();
  setTimeout("FormEmail.focus();",250);
  //FormEmail.select();
  return false;
  }
  if(FormEmail.value.indexOf("..") > 0) {
  //alert("O e-mail informado parece não estar correto. Caracter ilegal ( .. )");
  //FormEmail.focus();
  setTimeout("FormEmail.focus();",250);
  //FormEmail.select();
  return false;
  }
  if(FormEmail.value.indexOf("www") != -1) {
  //alert("O e-mail informado parece não estar correto. Caracter ilegal ( .www. )");
  //FormEmail.focus();
  setTimeout("FormEmail.focus();",250);
  //FormEmail.select();
  return false;
  }
}
  return true;
  
  if (Email.value != Email2.value) {

	alert('A confirmação do E-mail, não coincide com a E-mail digitado!');
	Email2.value = "";
	//setTimeout("Email2.focus();",250);
	return (false);
	
	}
  
}

function FormataMoeda(campo, separador_milhar, separador_decimal, tecla) {
	var sep = 0;
	var key = '';
	var i = j = 0;
	var len = len2 = 0;
	var strCheck = '0123456789';
	var aux = aux2 = '';
	var whichCode = (window.Event) ? tecla.which : tecla.keyCode;

	if (whichCode == 13) return true; // Tecla Enter
	if (whichCode == 8) return true; // Tecla Delete
	key = String.fromCharCode(whichCode); // Pegando o valor digitado
	if (strCheck.indexOf(key) == -1) return false; // Valor inválido (não inteiro)
	len = campo.value.length;
	for(i = 0; i < len; i++)
	if ((campo.value.charAt(i) != '0') && (campo.value.charAt(i) != separador_decimal)) break;
	aux = '';
	for(; i < len; i++)
	if (strCheck.indexOf(campo.value.charAt(i))!=-1) aux += campo.value.charAt(i);
	aux += key;
	len = aux.length;
	if (len == 0) campo.value = '';
	if (len == 1) campo.value = '0'+ separador_decimal + '0' + aux;
	if (len == 2) campo.value = '0'+ separador_decimal + aux;

	if (len > 2) {
		aux2 = '';

		for (j = 0, i = len - 3; i >= 0; i--) {
			if (j == 3) {
				aux2 += separador_milhar;
				j = 0;
			}
			aux2 += aux.charAt(i);
			j++;
		}

		campo.value = '';
		len2 = aux2.length;
		for (i = len2 - 1; i >= 0; i--)
		campo.value += aux2.charAt(i);
		campo.value += separador_decimal + aux.substr(len - 2, len);
	}

	return false;
}



// ------------------------------ FIM DE FUNCOES PARA AJAX --------------------------------------

 function MostraAba(Aba){
	
	if( Aba == 'De' ){
		document.getElementById('S').className = 'AbaMenor';
		document.getElementById('A').className = 'AbaMenor';
		document.getElementById('C').className = 'AbaMenor';
		document.getElementById('Do').className = 'AbaMenor';
	} else if ( Aba == 'S' ) {
		document.getElementById('De').className = 'AbaMenor';
		document.getElementById('A').className = 'AbaMenor';
		document.getElementById('C').className = 'AbaMenor';
		document.getElementById('Do').className = 'AbaMenor';
	} else if ( Aba == 'A' ) {
		document.getElementById('S').className = 'AbaMenor';
		document.getElementById('De').className = 'AbaMenor';
		document.getElementById('C').className = 'AbaMenor';
		document.getElementById('Do').className = 'AbaMenor';
	} else if ( Aba == 'C' ) {
		document.getElementById('S').className = 'AbaMenor';
		document.getElementById('A').className = 'AbaMenor';
		document.getElementById('De').className = 'AbaMenor';
		document.getElementById('Do').className = 'AbaMenor';
	} else if ( Aba == 'Do' ) {
		document.getElementById('S').className = 'AbaMenor';
		document.getElementById('A').className = 'AbaMenor';
		document.getElementById('C').className = 'AbaMenor';
		document.getElementById('De').className = 'AbaMenor';
	} else if ( Aba == 'EA' ) {
		document.getElementById('NE').className = 'AbaMenor';
		document.getElementById('A').className = 'AbaMenor';
		document.getElementById('C').className = 'AbaMenor';
		document.getElementById('De').className = 'AbaMenor';
	}

	
 }

 function MostraAbaEvento(Aba){
	 
	if( Aba == 'EA' ){
		document.getElementById('EA').className = 'AbaMaior';
		document.getElementById('EN').className = 'AbaMenor';
	} else if ( Aba == 'EN' ) {
		document.getElementById('EN').className = 'AbaMaior';
		document.getElementById('EA').className = 'AbaMenor';
	}

 }
 
 function MostraAbaBiblioteca(Aba){
	 
	if( Aba == 'EP' ){
		document.getElementById('EP').className = 'AbaMaior';
		document.getElementById('EA').className = 'AbaMenor';
		document.getElementById('EV').className = 'AbaMenor';
	} else if ( Aba == 'EV' ) {
		document.getElementById('EV').className = 'AbaMaior';
		document.getElementById('EA').className = 'AbaMenor';
		document.getElementById('EP').className = 'AbaMenor';
	} else if ( Aba == 'EA' ) {
		document.getElementById('EA').className = 'AbaMaior';
		document.getElementById('EP').className = 'AbaMenor';
		document.getElementById('EV').className = 'AbaMenor';
	}

 }


function SelectCheckAll(){ 
  
  for (i=0;i<document.Form.elements.length;i++) 
      if(document.Form.elements[i].type == "checkbox") 
		 document.Form.elements[i].checked=1;
}

function DesSelectCheckAll(){ 
  
  for (i=0;i<document.Form.elements.length;i++) 
      if(document.Form.elements[i].type == "checkbox") 
         document.Form.elements[i].checked=0;
		 document.Form.idMenuValores.value = "";
} 


function MaxLength(textAreaField, limit) {
	var ta = document.getElementById(textAreaField);
	
	if (ta.value.length >= limit) {
		ta.value = ta.value.substring(0, limit-1);
	}
}


function MontaDataNascimentoGravando() {
		
	dia = document.Form.DiaNascimento.value;
	mes = document.Form.MesNascimento.value;
	ano = document.Form.AnoNascimento.value;
	document.Form.DataNascimento.value = dia+'/'+mes+'/'+ano;
	ExecAjaxDestino('', 'Cadastrar_Curriculo_Gravar.asp?Campo=dtNascimento&Valor='+ dia+'/'+mes+'/'+ano, 0, 'gravarcampo' );
		
}

function MontaDataNascimentoSeguro() {
		
	dia = document.FormSeg.DiaNascimentoSeg.value;
	mes = document.FormSeg.MesNascimentoSeg.value;
	ano = document.FormSeg.AnoNascimentoSeg.value;
	document.FormSeg.DataNascimentoSeg.value = dia+'/'+mes+'/'+ano;
		
}

function MontaDataNascimentoMig() {
		
	dia = document.FormMig.DiaNascimentoMig.value;
	mes = document.FormMig.MesNascimentoMig.value;
	ano = document.FormMig.AnoNascimentoMig.value;
	document.FormMig.DataNascimentoMig.value = dia+'/'+mes+'/'+ano;
		
}


//Função de validação de CPF
function validaCPFCadastro(cpf) {
		 
		 if (cpf == "") {
		 
		 VarCpf = document.FormCadastro.CPF;
		 cpf = document.FormCadastro.CPF.value;
		 
		 
		 }else{
		 VarCpf = eval("document.FormCadastro."+cpf);
		 cpf = eval("document.FormCadastro."+cpf+".value");
		 
		 }
		 cpf = cpf.replace(".", "");
		 cpf = cpf.replace(".", "");
		 cpf = cpf.replace(".", ""); 
		 cpf = cpf.replace("-", ""); 
		 
		 erro = new String;
		 if ((cpf.length < 11) && (cpf != "")) erro += "Sao necessarios 11 digitos para verificacao do CPF! \n\n"; 
		 var nonNumbers = /\D/;
		 if (nonNumbers.test(cpf)) erro += "A verificacao de CPF suporta apenas numeros!"+ cpf+ " \n\n"; 
		 if (cpf == "00000000000" || cpf == "11111111111" || cpf == "22222222222" || cpf == "33333333333" || cpf == "44444444444" || cpf == "55555555555" || cpf == "66666666666" || cpf == "77777777777" || cpf == "88888888888" || cpf == "99999999999"){
				erro += "Numero de CPF invalido!"
	   }
	   var a = [];
	   var b = new Number;
	   var c = 11;
	   for (i=0; i<11; i++){
			  a[i] = cpf.charAt(i);
			  if (i < 9) b += (a[i] * --c);
	   }
	   if ((x = b % 11) < 2) { a[9] = 0 } else { a[9] = 11-x }
	   b = 0;
	   c = 11;
	   for (y=0; y<10; y++) b += (a[y] * c--); 
	   if ((x = b % 11) < 2) { a[10] = 0; } else { a[10] = 11-x; }
	   if ((cpf.charAt(9) != a[9]) || (cpf.charAt(10) != a[10])){
			   erro +="Digito verificador com problema!";
	   }
	   if (erro.length > 0){
			   alert(erro);
			   VarCpf.focus();
			   setTimeout("VarCpf.focus();",250);
			   return false;
			   
	   }
	return true;
	Maskcpf = cpf.substr(0, 3) + '.' + cpf.substr(3, 6) + '.' + cpf.substr(6, 9) + '-' + cpf.substr(9, 11);
	VarCpf.value = Maskcpf;
	
}
// ---------- funcao para adicionar itens ao carrinho de compras (bandeija) -------------------

function escreveMensagemAlerta(msg , w) {

	var htm  ;
	if (w == "") {
		w = 100; 
	}
	
	htm = "<table width='"+w+"' border='0' cellspacing='1' cellpadding='4' class='QuadroCinza'>";
	htm += "	  <tr>";
	htm += "		<td class='red12B' align='center' width='30'><img src='images/ico_alerta.gif'></td>";
	htm += "		<td class='red12B' align='left'>" + msg + " </td>";
	htm += "	  </tr>";
	htm += "</table>"	;
		
	return htm;

}
//------------------------------------------------
function ExibeMesagemProduto ( id , msg )  {

	parent.document.getElementById('MsgAlerta'+id).style.display = "";
	parent.document.getElementById('IndicarAmigo'+id).style.display = "";
	parent.document.getElementById('MsgAlerta'+id).innerHTML = escreveMensagemAlerta ( msg );
	
}
//------------------------------------------------
function ApagaMsgAlertaProduto(id) {
	document.getElementById('MsgAlerta'+id).style.display = "none";
	document.getElementById('IndicarAmigo'+id).style.display = "none";
}
//------------------------------------------------

function ExibeMesagem ( id , msg )  {

	parent.document.getElementById('MsgAlerta'+id).style.display = "";
	parent.document.getElementById('MsgAlerta'+id).innerHTML = escreveMensagemAlerta ( msg );
	
}
//------------------------------------------------
function ApagaMsgAlerta(id) {
	document.getElementById('MsgAlerta'+id).style.display = "none";
}
//------------------------------------------------

function graficoSeta(sn, tot) {

	//alert(parent.document.getElementById('count_indice').value +  ' # ' + sn + ' # <%=ubound(vetor_Ano) %>');
	monta_vetor_ano(parent.document.getElementById('count_indice').value , sn , tot  );
	//monta_vetor_ano('6|7|8' , sn , 4 )


}


function DesabilitaEnter(event){
//Internet Explorer
	if(window.event && window.event.keyCode == 13){
	return false;
	}
}

function MontaDataNas() {
		
	dia = document.Form.DiaNascimento.value;
	mes = document.Form.MesNascimento.value;
	ano = document.Form.AnoNascimento.value;
	document.Form.DataNascimento.value = dia+'/'+mes+'/'+ano;
		
}

//------------------------------------------------

function VerificaCarrinho(QtdEstoque,QtdSolicitada,Form,id){

	var Formulario = eval("document."+Form);

	if(QtdEstoque < QtdSolicitada){
	document.getElementById('MsgAlerta'+id).style.display = "";
	//alert('Quantidade indisponível');
	Formulario.Qtd.value = 1;
	document.getElementById('MsgAlerta'+id).style.display = "";
	document.getElementById('MsgAlerta'+id).innerHTML = escreveMensagemAlerta ( "Quantidade indisponível" );
	
	}
	
	if(QtdSolicitada = '' || QtdSolicitada == 0){
	alert('Por favor, insira a Quantidade igual ou superior a 1');
	Formulario.Qtd.value = 1;				
	}

}

function MostraTRLoop_vetor(lugar, vet_id, qtdTR) {


	//alert( vet_id );
	id = vet_id.split("|");

	if ( vet_id != "undefined" ) {
		for (i=1;i<=qtdTR;i++){
			parent.document.getElementById(lugar + i).style.display = "none";
			//alert( 'ocultar: ' + lugar + i +" Que esta em : " + parent.document.getElementById(lugar + i).style.display  );
		}
	
		for ( j = 0 ; j < id.length; j++ ) { 
			//alert( 'mostrar: ' + lugar + id[j]  );
			if ( parent.document.getElementById(lugar + id[j]) == "[object]" ) 
			parent.document.getElementById(lugar + id[j]).style.display = "";
	
		}
	}
}

function monta_vetor_ano( vet_id , s , s_qtr ) {
	var conta_indice ;
	id = vet_id.split("|");
	
	indice_Primeiro = 0 ;
	indice_Ultimo = id.length - 1 ;
	
	if ( s == '+' ) {
	
		ind_min = parseInt ( id[indice_Primeiro] )  + 1 ; 
		ind_max = parseInt ( id[indice_Ultimo] )  + 1 ; 

	} else {

		ind_min = parseInt ( id[indice_Primeiro] )  - 1 ; 
		ind_max = parseInt ( id[indice_Ultimo] )  - 1 ; 
	}

	// alert( ' = '+ind_min+ ' ; j  <= '+ ind_max ) ;
	for ( j = ind_min ; j <= ind_max ; j ++ ) {
		
		if ( j == ind_min ) {
		conta_indice = j ;
		} else { 
		conta_indice += '|' + j ;
		}
		
	}	
	parent.document.getElementById('count_indice').value = conta_indice ; 
	//alert(  conta_indice +' , '+ qtdTR );
	MostraTRLoop_vetor('ano_', conta_indice ,s_qtr )
}

//-------------------------------------------------
function RemoverImagem(id,tbl,Titulo,PaginaAtual){

		w = window.confirm('Deseja realmente excluir a imagem '+Titulo+' ?');
		
		if(w == true){
			location.href='UpLoadImagemRemover.asp?id='+id+'&tbl='+tbl+'&PaginaRetorno='+PaginaAtual+'';
		}else{
		
		}
}
//----------------------------------------------------
function MostraTR(lugar) {
	if(document.getElementById(lugar).style.display == "none"){
		document.getElementById(lugar).style.display = "";
	}else{
		document.getElementById(lugar).style.display = "none";
	}
}

function UploadEdicao(a,i,t,p,e){

	if (a == 'REM') {	
		w = window.confirm('Deseja realmente excluir a imagem?');
		if (w == true) {
			window.open('UpLoadImagemRemover.asp?id='+i+'&tbl='+t+'&PaginaRetorno='+p+'&Tipo='+e,'Mini','width=400 height=300');
		}
	} else {
		window.open('UpLoadImagem.asp?id='+i+'&tbl='+t+'&PaginaRetorno='+p+'&Tipo='+e,'Mini','width=600 height=410');
	}
}

function UploadArquivo(a,i,t,p){

	if (a == 'REM') {	
		w = window.confirm('Deseja realmente excluir o arquivo?');
		if (w == true) {
			window.open('UpLoadArquivoRemover.asp?id='+i+'&tbl='+t+'&PaginaRetorno='+p,'Mini','width=400 height=300');
		}
	} else {
		window.open('UpLoadArquivo.asp?id='+i+'&tbl='+t+'&PaginaRetorno='+p,'Mini','width=600 height=410');
	}
}


function GuardaCheckMenu(Valor,Checado){

	if (Checado == true)  {
	//--- Adicionando ---
		if (document.Form.idMenuValores.value == ""){
		sValue = Valor;
		}else{
		sValue = document.Form.idMenuValores.value +","+Valor;
		}
	
	}else {
	//--- Removendo ---
		var ArrayCampo = new String(document.Form.idMenuValores.value);
		var sValue = ""
		ArrayCampo = ArrayCampo.split(",");
		for (i=0;i<ArrayCampo.length;i++){
			
			if (parseInt(ArrayCampo[i]) != parseInt(Valor)) {
			
				if (sValue == ""){
				sValue  = ArrayCampo[i];
				}else{
				sValue = sValue + ","+ArrayCampo[i];
				}
			} //(ArrayCampo(i) != Valor)	
			
		}// for

	} //(Checado == true)
	document.Form.idMenuValores.value = sValue;
}



function GuardaCheckOpcaoGravar(Valor,Checado){

	//alert(Checado+', '+Valor)
	if (Checado == true)  {
	//--- Adicionando ---
		if (document.Form.idOpcaoGravarValores.value == ""){
		sValue = Valor;
		}else{
		sValue = document.Form.idOpcaoGravarValores.value +","+Valor;
		}
	
	}else {
	//--- Removendo ---
		var ArrayCampo = new String(document.Form.idOpcaoGravarValores.value);
		var sValue = ""
		ArrayCampo = ArrayCampo.split(",");
		for (i=0;i<ArrayCampo.length;i++){
			
			if (parseInt(ArrayCampo[i]) != parseInt(Valor)) {
			
				if (sValue == ""){
				sValue  = ArrayCampo[i];
				}else{
				sValue = sValue + ","+ArrayCampo[i];
				}
			} //(ArrayCampo(i) != Valor)	
			
		}// for

	} //(Checado == true)
	document.Form.idOpcaoGravarValores.value = sValue;
}


function VerificaTipoMenuAcesso(){

	//alert( document.Form.TipoMenuAcesso.value );

	if (document.Form.TipoMenuAcesso.value == 'Perfil') {
		document.getElementById("LinhaidPerfilAcesso").style.display = "block";
	}else if (document.Form.TipoMenuAcesso.value == 'Proprio')  {
		document.getElementById("LinhaidPerfilAcesso").style.display = "none";
	}


}


function MudaComboTipoMenu(){

	document.Form.TipoMenuAcesso.options[0].selected = true;
	document.Form.idPerfilAcesso.options[0].selected = true;
	VerificaTipoMenuAcesso();

}

function EnableCheckBoxGravar(valor, checado) {

	if (checado == true) {
	
		document.getElementById(valor).disabled = ""   
		
	}else {
	
		document.getElementById(valor).disabled = "disabled"   
	}

}


function TrocaCorSelecionada(id) {

	if (document.getElementById(id).className == 'CorMenuCheckedOff') {
	document.getElementById(id).className = 'CorMenuCheckedOn';
	}else{
	document.getElementById(id).className = 'CorMenuCheckedOff';
	}

}


function MostraInput(Linha) {

  var Linha = document.getElementById(Linha);
  var Campo = document.FormBusca.Filtro.value

  if (Campo == ''){
  Linha.style.display='none';
  }else {
  Linha.style.display='';
  }
}

function VerificaProdutoVazio(Qtd,Valor,ID){
			
	if ( Qtd == '' && document.getElementById("AddProdutoID"+ID).checked == true ) {
	document.getElementById('LinhaQtd'+ID).style.display = '';
	document.getElementById("ID"+ID).checked = false;	
	}else{
	document.getElementById('LinhaQtd'+ID).style.display = 'none';
	document.getElementById("ID"+ID).checked = true;
	}
	
	if ( Valor == '' && document.getElementById("ID"+ID).checked == true ) {
	document.getElementById('LinhaValor'+ID).style.display = '';
	document.getElementById("ID"+ID).checked = false;	
	}else{
	document.getElementById('LinhaValor'+ID).style.display = 'none';
	document.getElementById("ID"+ID).checked = true;
	
	}
		
}

function EnviaFormProduto(R){
 
  //R -> Retorno - Se = 1 então volta para Popup Produto
  //R -> Retorno - Se = 2 então Fecha Popup Produto
  //alert(R);
  
   if ( R == 1 ){
   document.FormProduto.Retorno.value = 1;
   }else{
   document.FormProduto.Retorno.value = 2;	      
   }
  
  return checkCampos('FormProduto','ID');
  
}


function MoedaVerifica(valor, c) {

  
  var ValorFormat = valor;
  var campo       = eval("document."+c);
  var campo = document.getElementById(c);
  LenValorFormat    = ValorFormat.length;
  VerifPagtoUsuario = LenValorFormat - 3;
  ValorIncorreto    = ValorFormat.charAt(VerifPagtoUsuario);
                        
  // a vigula NAO esta antes das 2 casas do centavos ?
     if (ValorIncorreto != "," && valor != '') {
     alert("O valor informado parece estar incorreto. \n Digite um valor no formato 0,00");
	
		campo.value = valor; //"0,00";
		//campo.focus();
		setTimeout("campo.focus();",250);

  //TrocoUsuario.value = "";
    return false;
    }
    FindPonto2 = ValorFormat.indexOf("..");

	if (FindPonto2 != -1 && valor != '') {
	alert("O valor informado parece estar incorreto. \n Não deve conter (..) \n Digite um valor no formato 0,00");
	//campo.value = "0.00";
	//campo.focus();  
	setTimeout("campo.focus();",250);
	}

}

//----------------------------------------------------

function MoedaAutoFormata(valor, c) {

  
  var ValorFormat = valor;
  var campo       = eval("document."+c);
  var campo = document.getElementById(c);
   
   //alert(campo.value.indexOf(","))
  if (campo.value.indexOf(",") == -1 ) {

		campo.value = valor + ",00";
	  
  }
}

//----------------------------------------------------

function MostraTRLoop(lugar, id, qtdTR) {
	
	for (i=1;i<=qtdTR;i++){
	//alert(lugar + i);
	document.getElementById(lugar + i).style.display = "none";
	}
	document.getElementById(lugar + id).style.display = "";
}

function AbrePaginaSwf(url) {
	dominio = document.domain;
	
	if (dominio.indexOf('varosoft') >= 0 ) {
	subVar = "/clientes/sbcm/web";
	}else{
	subVar = "";	
	}
	location.href = "http://" + dominio + subVar + "/"+ url
}


function OcultaTR() { 
document.getElementById("CorpoClinicoView").style.display = "none";
}

function MostraTRcontrole(lugar, controle) {
	
	if(controle == 1 ){
		document.getElementById(lugar).style.display = "";
	}else{
		document.getElementById(lugar).style.display = "none";
	}
}

//------------------------------------------
//Limita Caractere para Textarea Resumo
function LimitaCaractere(qtd){
    limite = qtd;
    myTextArea = document.forms[0].Resumo;

    if (myTextArea.value.length > limite) {
        myTextArea.value = myTextArea.value.substr(0, (myTextArea.value.length - (myTextArea.value.length - limite)));
    }
}

//------------------------------------------
function TrocaTR(div1, div2) {

if(document.getElementById(div1).style.display == "none"){
		document.getElementById(div1).style.display = "";
		document.getElementById(div2).style.display = "none";
	}else{
		document.getElementById(div1).style.display = "none";
		document.getElementById(div2).style.display = "";
	}
}
// ------------------------------ FIM DE FUNCOES PARA AJAX --------------------------------------
function UploadImagem(a,i,t,p){

	if (a == 'REM') {	
		w = window.confirm('Deseja realmente excluir a imagem?');
		if (w == true) {
			window.open('UpLoadImagemRemover.asp?id='+i+'&tbl='+t+'&PaginaRetorno='+p,'Mini','width=400 height=300');
		}
	} else {
		window.open('UpLoadImagem.asp?id='+i+'&tbl='+t+'&PaginaRetorno='+p+'&acao='+a,'Mini','width=600 height=410');
	}
}

function UploadVideo(a,i,t,p){

	if (a == 'REM') {	
		w = window.confirm('Deseja realmente excluir a Video?');
		if (w == true) {
			window.open('UpLoadVideoRem.asp?id='+i+'&tbl='+t+'&PaginaRetorno='+p,'Mini','width=100 height=100');
		}
	} else {
		window.open('UpLoadVideo.asp?id='+i+'&tbl='+t+'&PaginaRetorno='+p,'Mini','width=600 height=410');
	}
}



/*---------------------------------------------*/
// funcao somente ponto
	function SomenteNumeroPonto(e,punct)
	{		
		if (document.all){var evt=event.keyCode;}
		else{var evt = e.charCode;}
		var min_key = (punct?43:47);
		if ((evt <20) || (evt >min_key && evt<58) || (evt==46)){return true;}
		return false;
	}



/*---------------------------------------------*/
function tabAutomatico(cO,mL,cD){
var cD   = eval("document."+cD);

	if ( cO == mL ) {
		 cD.focus();   
	}
}


/*---------------------------------------------*/
function tabForcado(fr,field,e){

  if (document.all){
  var evt = event.keyCode;
  }else{
  var evt = e.charCode;  
  }
  
  if (evt==9){
	var cmp = eval("document."+fr+"."+field);
	cmp.focus();   
  }
}




function PaginaManutencao() {
	alert('Desculpe, Página em Desenvolvimento!');
	}
	
function Bloqueia(e) {
	if (window.event) {
		var X = window.event.keyCode;
		var Ctrl = window.event.ctrlKey;
		if (Ctrl && X == 78 || X == 116 || X == 122) {
			window.event.keyCode = 8;
			if (window.event.keyCode == 8) {
				window.event.cancelBubble = true;
			    window.event.returnValue = false;
			    return false;
			}
		}
	}
	else {
		var X = e.which;
		if (X == 110) return(false);
	}	

	if (navigator.appName == 'Netscape') {
	  window.captureEvents(Event.KEYPRESS);
	  window.onkeypress = Bloqueia;
	}
}


//Funcao para Exlcuir Registros 
function ExcluirRegistro(id,Item, tbl,PaginaRetorno, PaginaOrigem ) {
	
	var confirmacao = window.confirm('Deseja Realmente excluir '+Item+' ?');
	
		if(tbl == 'Site'){
		
			var confirmacao = window.confirm('Todos os arquivos serão apagados ! \n Deseja continuar ?');
			
					if (confirmacao == true) { 
						if (PaginaOrigem != undefined) {
						document.location.href = PaginaOrigem+'?id='+id
						}else{	
						document.location.href = 'ExcluirRegistro.asp?Id='+id+'&tbl='+tbl+'&PaginaRetorno='+PaginaRetorno;
						}
					}
			
		}else{
		
		/*-------------------------------------------------------------------------------------------------------------*/
		
			if (confirmacao == true) { 
				if (PaginaOrigem != undefined) {
				document.location.href = PaginaOrigem+'?id='+id
				}else{	
				document.location.href = 'ExcluirRegistro.asp?Id='+id+'&tbl='+tbl+'&PaginaRetorno='+PaginaRetorno;
				}
			}
		}

}

function ExcluirRegistroForm(id,Item, tbl,PaginaRetorno ) {


var confirmacao = window.confirm('Deseja Realmente excluir '+Item+' ?');
	if (confirmacao == true) {
		document.location.href = 'ExcluirRegistroFormulario.asp?Id='+id+'&tbl='+tbl+'&PaginaRetorno='+PaginaRetorno;
	}


}


//Funcao Logoff
function Logoff() {
	var confirmacao = window.confirm('Deseja realmente Sair ?');
	if (confirmacao == true) { 
	document.location.href = 'logoff.asp';	
    }
	else{	
   	document.location.href='#';
  }
}

function Opener(url) { 
  opener.location.href=url;
  window.close();
}

function EnviaFormPopup(f,a, w,h){
/*
	f -> form
	a -> Ação ( open / close )
	w -> largura
	h -> altura
*/	


	var form = eval("document."+f);

	if (a == "open") {
		window.open('','Mini','width='+w+', height='+h);
		
	}else if (a == "close") {
		window.close;
	}
	form.submit();
}
//-----------------------------------------------------------------------------------------------------------------
function LimparCampoMoeda(valor, validos) { 
// retira caracteres invalidos da string 
	var result = ""; 
	var aux; 
	for (var i=0; i < valor.length; i++) { 
		aux = validos.indexOf(valor.substring(i, i+1)); 
		if (aux>=0) { 
			result += aux; 
		} 
	} 
	return result; 
} 
//-----------------------------------------------------------------------------------------------------------------

function FormataCampoMoeda(campo,tammax,teclapres,decimal) { 
var tecla = teclapres.keyCode; 
vr = LimparCampoMoeda(campo.value,"0123456789"); 
tam = vr.length; 
dec=decimal 

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 <= dec ) 	{ 
		campo.value = vr ; 
		} 
		
		if ( (tam > dec) && (tam <= 5) )	{ 
			campo.value = vr.substr( 0, tam - 2 ) + "," + vr.substr( tam - dec, tam ) ; 
			} 
		if ( (tam >= 6) && (tam <= 8) ){ 
			campo.value = vr.substr( 0, tam - 5 ) + "." + vr.substr( tam - 5, 3 ) + "," + vr.substr( tam - dec, 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 - dec, 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 - dec, 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 ) ;
			} 
		
	}  //	if ( tecla == 8 || tecla >= 48 && tecla <= 57 || tecla >= 96 && tecla <= 105 ) { 

}  //FormataCampoMoeda
//----------------------------------------------------------------------------------


function txtBoxFormat(objeto, sMask, evtKeyPress) 
{
	var i, nCount, sValue, fldLen, mskLen,bolMask, sCod, nTecla;


	if(document.all) { // Internet Explorer
	    nTecla = evtKeyPress.keyCode;
	} else if(document.layers) { // Nestcape
	    nTecla = evtKeyPress.which;
	} else {
	    nTecla = evtKeyPress.which;
	    if (nTecla == 8) {
	        return true;
	    }
	}

  sValue = objeto.value;

  // Limpa todos os caracteres de formatação que
  // já estiverem no campo.
  sValue = sValue.toString().replace( "-", "" );
  sValue = sValue.toString().replace( "-", "" );
  sValue = sValue.toString().replace( ".", "" );
  sValue = sValue.toString().replace( ".", "" );
  sValue = sValue.toString().replace( "/", "" );
  sValue = sValue.toString().replace( "/", "" );
  sValue = sValue.toString().replace( ":", "" );
  sValue = sValue.toString().replace( ":", "" );
  sValue = sValue.toString().replace( "(", "" );
  sValue = sValue.toString().replace( "(", "" );
  sValue = sValue.toString().replace( ")", "" );
  sValue = sValue.toString().replace( ")", "" );
  sValue = sValue.toString().replace( " ", "" );
  sValue = sValue.toString().replace( " ", "" );
  fldLen = sValue.length;
  mskLen = sMask.length;

  i = 0;
  nCount = 0;
  sCod = "";
  mskLen = fldLen;

  while (i <= mskLen) {
    bolMask = ((sMask.charAt(i) == "-") || (sMask.charAt(i) == ".") || (sMask.charAt(i) == "/") || (sMask.charAt(i) == ":"))
    bolMask = bolMask || ((sMask.charAt(i) == "(") || (sMask.charAt(i) == ")") || (sMask.charAt(i) == " "))

    if (bolMask) {
      sCod += sMask.charAt(i);
      mskLen++; }
    else {
      sCod += sValue.charAt(nCount);
      nCount++;
    }

    i++;
  }

  objeto.value = sCod;

  if (nTecla != 8) { // backspace
    if (sMask.charAt(i-1) == "9") { // apenas números...
      return ((nTecla > 47) && (nTecla < 58)); }
    else { // qualquer caracter...
      return true;
    }
  }
  else {
    return true;
  }
}

//Função de validação de CPF
function validaCPFVaga(cpf) {
		 
		 if (cpf == "") {
		 
		 VarCpf = document.Form.CPF;
		 cpf = document.Form.CPF.value;
		 
		 }else{
		 VarCpf = eval("document.Form."+cpf);
		 cpf = eval("document.Form."+cpf+".value");
		 ExecAjaxDestino('', 'Cadastrar_Curriculo_Gravar.asp?Campo=CPF&Valor='+ cpf, 0, 'gravarcampo' );
		 }
		 cpf = cpf.replace(".", "");
		 cpf = cpf.replace(".", "");
		 cpf = cpf.replace(".", ""); 
		 cpf = cpf.replace("-", ""); 
		 
		 erro = new String;
		 if ((cpf.length < 11) && (cpf != "")) erro += "Sao necessarios 11 digitos para verificacao do CPF! \n\n"; 
		 var nonNumbers = /\D/;
		 if (nonNumbers.test(cpf)) erro += "A verificacao de CPF suporta apenas numeros!"+ cpf+ " \n\n"; 
		 if (cpf == "00000000000" || cpf == "11111111111" || cpf == "22222222222" || cpf == "33333333333" || cpf == "44444444444" || cpf == "55555555555" || cpf == "66666666666" || cpf == "77777777777" || cpf == "88888888888" || cpf == "99999999999"){
				erro += "Numero de CPF invalido!"
	   }
	   var a = [];
	   var b = new Number;
	   var c = 11;
	   for (i=0; i<11; i++){
			  a[i] = cpf.charAt(i);
			  if (i < 9) b += (a[i] * --c);
	   }
	   if ((x = b % 11) < 2) { a[9] = 0 } else { a[9] = 11-x }
	   b = 0;
	   c = 11;
	   for (y=0; y<10; y++) b += (a[y] * c--); 
	   if ((x = b % 11) < 2) { a[10] = 0; } else { a[10] = 11-x; }
	   if ((cpf.charAt(9) != a[9]) || (cpf.charAt(10) != a[10])){
			   erro +="Digito verificador com problema!";
	   }
	   if (erro.length > 0){
			   alert(erro);
			   setTimeout("VarCpf.focus()",250);
			   return false;
			   
	   }
	
	if (cpf != ""){
	cpf = cpf.replace(".", "");
	cpf = cpf.replace(".", "");
	cpf = cpf.replace(".", "");
    cpf = cpf.replace("-", ""); 
	Maskcpf = cpf.substr(0, 3) + '.' + cpf.substr(3, 3) + '.' + cpf.substr(6, 3) + '-' + cpf.substr(9, 2);
	VarCpf.value = Maskcpf;
	}
	return true;
	
	
	
	
}
//Função de validação de CPF
function validaCPF(cpf) {
		 
		 if (cpf == "") {
		 
		 VarCpf = document.Form.CPF;
		 cpf = document.Form.CPF.value;
		 
		 
		 }else{
		 VarCpf = eval("document.Form."+cpf);
		 cpf = eval("document.Form."+cpf+".value");
		 
		 }
		 cpf = cpf.replace(".", "");
		 cpf = cpf.replace(".", "");
		 cpf = cpf.replace(".", ""); 
		 cpf = cpf.replace("-", ""); 
		 
		 erro = new String;
		 if ((cpf.length < 11) && (cpf != "")) erro += "Sao necessarios 11 digitos para verificacao do CPF! \n\n"; 
		 var nonNumbers = /\D/;
		 if (nonNumbers.test(cpf)) erro += "A verificacao de CPF suporta apenas numeros!"+ cpf+ " \n\n"; 
		 if (cpf == "00000000000" || cpf == "11111111111" || cpf == "22222222222" || cpf == "33333333333" || cpf == "44444444444" || cpf == "55555555555" || cpf == "66666666666" || cpf == "77777777777" || cpf == "88888888888" || cpf == "99999999999"){
				erro += "Numero de CPF invalido!"
	   }
	   var a = [];
	   var b = new Number;
	   var c = 11;
	   for (i=0; i<11; i++){
			  a[i] = cpf.charAt(i);
			  if (i < 9) b += (a[i] * --c);
	   }
	   if ((x = b % 11) < 2) { a[9] = 0 } else { a[9] = 11-x }
	   b = 0;
	   c = 11;
	   for (y=0; y<10; y++) b += (a[y] * c--); 
	   if ((x = b % 11) < 2) { a[10] = 0; } else { a[10] = 11-x; }
	   if ((cpf.charAt(9) != a[9]) || (cpf.charAt(10) != a[10])){
			   erro +="Digito verificador com problema!";
	   }
	   if (erro.length > 0){
			   alert(erro);
			   //VarCpf.focus();
			   setTimeout("VarCpf.focus();",250);
			   return false;
			   
	   }
	return true;
	Maskcpf = cpf.substr(0, 3) + '.' + cpf.substr(3, 6) + '.' + cpf.substr(6, 9) + '-' + cpf.substr(9, 11);
	VarCpf.value = Maskcpf;
	
}

//Função de validação de CPF
function validaCPFSeg(cpf) {
		 
		 if (cpf == "") {
		 
		 VarCpf = document.FormSeg.CPF;
		 cpf = document.FormSeg.CPF.value;
		 
		 }else{
		 VarCpf = eval("document.FormSeg."+cpf);
		 cpf = eval("document.FormSeg."+cpf+".value");
		 //ExecAjaxDestino('', 'Cadastrar_Curriculo_Gravar.asp?Campo=CPF&Valor='+ cpf, 0, 'gravarcampo' );
		 }
		 cpf = cpf.replace(".", "");
		 cpf = cpf.replace(".", "");
		 cpf = cpf.replace(".", ""); 
		 cpf = cpf.replace("-", ""); 
		 
		 erro = new String;
		 if ((cpf.length < 11) && (cpf != "")) erro += "Sao necessarios 11 digitos para verificacao do CPF! \n\n"; 
		 var nonNumbers = /\D/;
		 if (nonNumbers.test(cpf)) erro += "A verificacao de CPF suporta apenas numeros!"+ cpf+ " \n\n"; 
		 if (cpf == "00000000000" || cpf == "11111111111" || cpf == "22222222222" || cpf == "33333333333" || cpf == "44444444444" || cpf == "55555555555" || cpf == "66666666666" || cpf == "77777777777" || cpf == "88888888888" || cpf == "99999999999"){
				erro += "Numero de CPF invalido!"
	   }
	   var a = [];
	   var b = new Number;
	   var c = 11;
	   for (i=0; i<11; i++){
			  a[i] = cpf.charAt(i);
			  if (i < 9) b += (a[i] * --c);
	   }
	   if ((x = b % 11) < 2) { a[9] = 0 } else { a[9] = 11-x }
	   b = 0;
	   c = 11;
	   for (y=0; y<10; y++) b += (a[y] * c--); 
	   if ((x = b % 11) < 2) { a[10] = 0; } else { a[10] = 11-x; }
	   if ((cpf.charAt(9) != a[9]) || (cpf.charAt(10) != a[10])){
			   erro +="Digito verificador com problema!";
	   }
	   if (erro.length > 0){
			   alert(erro);
			   setTimeout("VarCpf.focus()",250);
			   return false;
			   
	   }
	
	if (cpf != ""){
	cpf = cpf.replace(".", "");
	cpf = cpf.replace(".", "");
	cpf = cpf.replace(".", "");
    cpf = cpf.replace("-", ""); 
	Maskcpf = cpf.substr(0, 3) + '.' + cpf.substr(3, 3) + '.' + cpf.substr(6, 3) + '-' + cpf.substr(9, 2);
	VarCpf.value = Maskcpf;
	}
	return true;	
	
}
//Função de validação de CPF


//Função de validação de CPF
function validaCPFMig(cpf) {
		 
		 if (cpf == "") {
		 
		 VarCpf = document.FormMig.CPF;
		 cpf = document.FormMig.CPF.value;
		 
		 }else{
		 VarCpf = eval("document.FormMig."+cpf);
		 cpf = eval("document.FormMig."+cpf+".value");
		 //ExecAjaxDestino('', 'Cadastrar_Curriculo_Gravar.asp?Campo=CPF&Valor='+ cpf, 0, 'gravarcampo' );
		 }
		 cpf = cpf.replace(".", "");
		 cpf = cpf.replace(".", "");
		 cpf = cpf.replace(".", ""); 
		 cpf = cpf.replace("-", ""); 
		 
		 erro = new String;
		 if ((cpf.length < 11) && (cpf != "")) erro += "Sao necessarios 11 digitos para verificacao do CPF! \n\n"; 
		 var nonNumbers = /\D/;
		 if (nonNumbers.test(cpf)) erro += "A verificacao de CPF suporta apenas numeros!"+ cpf+ " \n\n"; 
		 if (cpf == "00000000000" || cpf == "11111111111" || cpf == "22222222222" || cpf == "33333333333" || cpf == "44444444444" || cpf == "55555555555" || cpf == "66666666666" || cpf == "77777777777" || cpf == "88888888888" || cpf == "99999999999"){
				erro += "Numero de CPF invalido!"
	   }
	   var a = [];
	   var b = new Number;
	   var c = 11;
	   for (i=0; i<11; i++){
			  a[i] = cpf.charAt(i);
			  if (i < 9) b += (a[i] * --c);
	   }
	   if ((x = b % 11) < 2) { a[9] = 0 } else { a[9] = 11-x }
	   b = 0;
	   c = 11;
	   for (y=0; y<10; y++) b += (a[y] * c--); 
	   if ((x = b % 11) < 2) { a[10] = 0; } else { a[10] = 11-x; }
	   if ((cpf.charAt(9) != a[9]) || (cpf.charAt(10) != a[10])){
			   erro +="Digito verificador com problema!";
	   }
	   if (erro.length > 0){
			   alert(erro);
			   setTimeout("VarCpf.focus()",250);
			   return false;
			   
	   }
	
	if (cpf != ""){
	cpf = cpf.replace(".", "");
	cpf = cpf.replace(".", "");
	cpf = cpf.replace(".", "");
    cpf = cpf.replace("-", ""); 
	Maskcpf = cpf.substr(0, 3) + '.' + cpf.substr(3, 3) + '.' + cpf.substr(6, 3) + '-' + cpf.substr(9, 2);
	VarCpf.value = Maskcpf;
	}
	return true;
		
}
//Função de validação de CPF


// funcao somente numeros
function SomenteNumeros(e,punct)
	{		
		if (document.all){var evt=event.keyCode;}
		else{var evt = e.charCode;}
		var min_key = (punct?43:47);
		if (evt <20 || (evt >min_key && evt<58)){return true;}
		return false;
	}
	
//------------- Email CORRETO ---------------

function valida_email(c) {

//alert(c);
FormEmail = c;

if (FormEmail.value == "") {
} else {
  prim = FormEmail.value.indexOf("@")
  if(prim < 2) {
  alert("O e-mail informado não contem @.");
  //FormEmail.focus();
  setTimeout("FormEmail.focus();",250);
  //FormEmail.select();
  return false;
  }
  if(FormEmail.value.indexOf("@",prim + 1) != -1) {
  alert("O e-mail informado parece não conter um PROVEDOR valido depois do @.");
  //FormEmail.focus();
  setTimeout("FormEmail.focus();",250);
  //FormEmail.select();
  return false;
  }
  if(FormEmail.value.indexOf(".") < 1) {
  alert("O e-mail informado parece não conter um ponto (.) indicando seu provedor.");
  //FormEmail.focus();
  setTimeout("FormEmail.focus();",250);
  //FormEmail.select();
  return false;
  }
  if(FormEmail.value.indexOf(" ") != -1) {
  alert("O e-mail informado parece não estar correto.");
  //FormEmail.focus();
  setTimeout("FormEmail.focus();",250);
  //FormEmail.select();
  return false;
  }
  if(FormEmail.value.indexOf("zipmeil.com") > 0) {
  alert("O e-mail informado parece não estar correto.");
  //FormEmail.focus();
  setTimeout("FormEmail.focus();",250);
  //FormEmail.select();
  return false;
  }
  if(FormEmail.value.indexOf("hotmeil.com") > 0) {
  alert("O e-mail informado parece não estar correto.");
  //FormEmail.focus();
  setTimeout("FormEmail.focus();",250);
  //FormEmail.select();
  return false;
  }
  if(FormEmail.value.indexOf(".@") > 0) {
  alert("O valor inserido ( .@ ) iFormado parece não estar correto.");
  //FormEmail.focus();
  setTimeout("FormEmail.focus();",250);
  //FormEmail.select();
  return false;
  }
  if(FormEmail.value.indexOf("@.") > 0) {
  alert("O e-mail informado parece não estar correto.");
  //FormEmail.focus();
  setTimeout("FormEmail.focus();",250);
  //FormEmail.select();
  return false;
  }
  if(FormEmail.value.indexOf(".com.br.") > 0) {
  alert("O e-mail informado parece não estar correto.");
  //FormEmail.focus();
  setTimeout("FormEmail.focus();",250);
  //FormEmail.select();
  return false;
  }
  if(FormEmail.value.indexOf("/") > 0) {
  alert("O e-mail informado parece não estar correto. Caracter ilegal ( / )");
  //FormEmail.focus();
  setTimeout("FormEmail.focus();",250);
  //FormEmail.select();
  return false;
  }
  if(FormEmail.value.indexOf("[") > 0) {
  alert("O e-mail informado parece não estar correto. Caracter ilegal ( [ )");
  //FormEmail.focus();
  setTimeout("FormEmail.focus();",250);
  //FormEmail.select();
  return false;
  }
  if(FormEmail.value.indexOf("]") > 0) {
  alert("O e-mail informado parece não estar correto. Caracter ilegal ( ] )");
  //FormEmail.focus();
  setTimeout("FormEmail.focus();",250);
  //FormEmail.select();
  return false;
  }
  if(FormEmail.value.indexOf("(") > 0) {
  alert("O e-mail informado parece não estar correto. Caracter ilegal ( ( )");
  //FormEmail.focus();
  setTimeout("FormEmail.focus();",250);
  //FormEmail.select();
  return false;
  }
  if(FormEmail.value.indexOf(")") > 0) {
  alert("O e-mail informado parece não estar correto. Caracter ilegal ( ) )");
  //FormEmail.focus();
  setTimeout("FormEmail.focus();",250);
  //FormEmail.select();
  return false;
  }
  if(FormEmail.value.indexOf("..") > 0) {
  alert("O e-mail informado parece não estar correto. Caracter ilegal ( .. )");
  //FormEmail.focus();
  setTimeout("FormEmail.focus();",250);
  //FormEmail.select();
  return false;
  }
  if(FormEmail.value.indexOf("www") != -1) {
  alert("O e-mail informado parece não estar correto. Caracter ilegal ( .www. )");
  //FormEmail.focus();
  setTimeout("FormEmail.focus();",250);
  //FormEmail.select();
  return false;
  }
}
  return true;
  
  
}



function CaractereIlegal (e,punct)	{		

  if (document.all){
  var evt=event.keyCode;
  }else{
  var evt = e.charCode;}
  if (evt==39){
  return false;
  }
  return true;
}




// VERIFICA CAMPOS EM BRANCO
function checkCampos(form,valor){

	var frm = eval("document."+form);
	
	var ValorCampo = valor;
	
	var ArrayCampo = new String(ValorCampo) 
	
	ArrayCampo = ArrayCampo.split(",");

	var nomedocampo = ArrayCampo;
	var descricao = ArrayCampo;

	var msgAlert = "Por favor complete os seguintes Campos:\n\n";
	var msg = msgAlert.length;
	
	for (var i = 0; i < nomedocampo.length; i++){
		var objetos = frm.elements[nomedocampo[i]];
		var Ly = "Linha" + nomedocampo[i];
		var ExibeIcone = null;
	
		//alert(Ly);
		document.getElementById(Ly).style.display = "none";
		if (objetos){
			switch(objetos.type){
			case "select-one":
				if (objetos.selectedIndex == -1 || 
					objetos.options[objetos.selectedIndex].text == "" || objetos.value == ""){
					msgAlert += " - " + descricao[i] + "\n";
					document.getElementById(Ly).style.display = "";
				}
				break;
			case "select-multiple":
				if (objetos.selectedIndex == -1){
					msgAlert += " - " + descricao[i] + "\n";
					document.getElementById(Ly).style.display = "";
				}
				break;

			case "text":
			case "textarea":
			case "password":
			
				if (objetos.value == "" || objetos.value == null ){
					msgAlert += " - " + descricao[i] + "\n";
					document.getElementById(Ly).style.display = "";
				}
				break;
			default:
			}
			if (objetos.type == undefined){
				var blnchecked = false;
				for (var j = 0; j < objetos.length; j++){
					if (objetos[j].checked){
						blnchecked = true;
					}
				}
				if (!blnchecked){
					msgAlert += " - " + descricao[i] + "\n";
					document.getElementById(Ly).style.display = "";
				}
			}
		}
	}

	if (msgAlert.length == msg){
		//alert('Todos os Campos estão Preenchidos!');
		frm.submit();
		return true;
	}else{
		alert('Confira o formulário, existe campo em branco!');
		return false;
	}
	
} //checkCampos

// VERIFICA CAMPOS EM BRANCO
function checkCamposLateral(form,valor){

	var frm = eval("document."+form);
	
	var ValorCampo = valor;
	
	var ArrayCampo = new String(ValorCampo) 
	
	ArrayCampo = ArrayCampo.split(",");

	var nomedocampo = ArrayCampo;
	var descricao = ArrayCampo;

	var msgAlert = "Por favor complete os seguintes Campos:\n\n";
	var msg = msgAlert.length;
	
	for (var i = 0; i < nomedocampo.length; i++){
		var objetos = frm.elements[nomedocampo[i]];
		var Ly = "Linha" + nomedocampo[i];
		var ExibeIcone = null;
	
		//alert(Ly);
		document.getElementById(Ly).style.display = "none";
		if (objetos){
			switch(objetos.type){
			case "select-one":
				if (objetos.selectedIndex == -1 || 
					objetos.options[objetos.selectedIndex].text == "" || objetos.value == ""){
					msgAlert += " - " + descricao[i] + "\n";
					//document.getElementById(Ly).style.display = "";
				}
				break;
			case "select-multiple":
				if (objetos.selectedIndex == -1){
					msgAlert += " - " + descricao[i] + "\n";
					//document.getElementById(Ly).style.display = "";
				}
				break;

			case "text":
			case "textarea":
			case "password":
			
				if (objetos.value == "" || objetos.value == null ){
					msgAlert += " - " + descricao[i] + "\n";
					//document.getElementById(Ly).style.display = "";
				}
				break;
			default:
			}
			if (objetos.type == undefined){
				var blnchecked = false;
				for (var j = 0; j < objetos.length; j++){
					if (objetos[j].checked){
						blnchecked = true;
					}
				}
				if (!blnchecked){
					msgAlert += " - " + descricao[i] + "\n";
					//document.getElementById(Ly).style.display = "";
				}
			}
		}
	}

	if (msgAlert.length == msg){
		frm.submit();
		return true;
	}else{
		alert('Todos os campos são obrigatórios!');
		//alert('Confira o formulário, existe campo em branco!');
		return false;
	}
	
} //checkCampos
									
//----------------------------------------------------------------------------------
function checkCamposValida(form,valor){

	var frm = eval("document."+form);
	
	var ValorCampo = valor;
	
	var ArrayCampo = new String(ValorCampo) 
	
	ArrayCampo = ArrayCampo.split(",");

	var nomedocampo = ArrayCampo;
	var descricao = ArrayCampo;

	var msgAlert = "Por favor complete os seguintes Campos:\n\n";
	var msg = msgAlert.length;
	
	for (var i = 0; i < nomedocampo.length; i++){
		var objetos = frm.elements[nomedocampo[i]];
		var Ly = "Linha" + nomedocampo[i];
	
		//alert(Ly);
		document.getElementById(Ly).style.display = "none";
		if (objetos){
			switch(objetos.type){
			case "select-one":
				if (objetos.selectedIndex == -1 || 
					objetos.options[objetos.selectedIndex].text == "" || objetos.value == ""){
					msgAlert += " - " + descricao[i] + "\n";
					document.getElementById(Ly).style.display = "";
					
				}
				break;
			case "select-multiple":
				if (objetos.selectedIndex == -1){
					msgAlert += " - " + descricao[i] + "\n";
					document.getElementById(Ly).style.display = "";
				}
				break;

			case "text":
			case "textarea":
			case "password":
				if (objetos.value == "" || objetos.value == null ){
					msgAlert += " - " + descricao[i] + "\n";
					document.getElementById(Ly).style.display = "";
				}
				break;
			default:
			}
			if (objetos.type == undefined){
				var blnchecked = false;
				for (var j = 0; j < objetos.length; j++){
					if (objetos[j].checked){
						blnchecked = true;
					}
				}
				if (!blnchecked){
					msgAlert += " - " + descricao[i] + "\n";
					document.getElementById(Ly).style.display = "";
				}
			}
		}
	}

	if (msgAlert.length == msg){
		//alert('Todos os Campos estão Preenchidos!');
		return true;
	}else{
		//alert(msgAlert);
		return false;
	}
	
} //checkCampos
//-------------------------------------------------------------------

// Funcao para verificar Senha e confirmacao de Senha
function ValidaSenha(Senha,SenhaX) {
	
	Senha = eval(Senha)
	SenhaX = eval(SenhaX)

if (Senha.value == "") {

	alert('Preencha o campo Senha para continuar!');
	//Senha.focus();
	//setTimeout(Senha+".focus();",250);
	//return (false);
	
}else{
	
	if (Senha.value != SenhaX.value) {

	alert('A confirmação da senha, não coincide com a senha digitada');
	SenhaX.value = "";

	Senha.value = "";
	//setTimeout(Senha+".focus();",250);
	//return (false);
	}					
  }
} // ValidaSenha

function AlertaOper() {
	alert('Por favor, clique em Salvar e selecione esta opção Novamente.');
}
//----------------------------------------------------------------------------------
function AbreImagem(img, w, h) {
	window.open ("Visualizar_imagem.asp?ImagemNome="+img,"","width="+w+", height="+h+", scrollbars=no, resizable=no");
}
//----------------------------------------------------------------------------------
function MostraTRimg(linha,imagem, img1, img2) {

	var linha = document.getElementById(linha);
    var urlImg = '../images/';
	  if (linha.style.display=='none') {
		   linha.style.display='';
	       if(imagem != null) 
		   	 imagem.src= urlImg +img2+'.gif';
	  } else {
		   linha.style.display='none';
	       if(imagem != null) 
		     imagem.src= urlImg +img1+'.gif';
      }

}
//----------------------------------------------------------------------------------
function MostraDiv( Ly, y){
var Ly
	if (y==1) { 
			void(document.all[Ly].style.visibility='visible');
	} else {
			void(document.all[Ly].style.visibility='hidden')
	}
}
//----------------------------------------------------------------------------------
function ExibeImagem(campo,img) { 
	img.src = campo.value;
}

function TipoCampo(x){
	
		//alert(x);
	
		document.getElementById("TRheading").style.display = "none";
		document.getElementById("TRtext").style.display = "none";
		document.getElementById("TRpassword").style.display = "none";
		document.getElementById("TRtextarea").style.display = "none";
		document.getElementById("TRhidden").style.display = "none";
		document.getElementById("TRselect").style.display = "none";
		document.getElementById("TRcheckbox").style.display = "none";
		document.getElementById("TRradio").style.display = "none";
		document.getElementById("TRdata").style.display = "none";
		
	if (x != ''){
		document.getElementById("TR"+x).style.display = "";		
	}
}

