// AJAX

// POG PARA BOTAO VOLTAR

var atual = '';
var style = '';
//FIM POG

var xmlhttp = getXmlHttpRequest();
var emTrabalho = false;
var emTrabalho2 = false;
function getXmlHttpRequest() {
	if (window.XMLHttpRequest) {
		return new XMLHttpRequest();
	} else if (window.ActiveXObject) {
		return new ActiveXObject("Microsoft.XMLHTTP");
	}
}

function alteraURL(url){
    if (!emTrabalho){ // testa se já não está executando uma ação
    	document.getElementById("carregando").style.display = '';
    	document.getElementById("conteudo").style.display = 'none';
    	xmlhttp.open("POST", url, true);
    	emTrabalho = true;
        xmlhttp.onreadystatechange = function(){
    		if (xmlhttp.readyState==4){
    			document.getElementById("conteudo").style.display = '';
                document.getElementById("conteudo").innerHTML = xmlhttp.responseText;
    			document.getElementById("carregando").style.display = 'none';
                emTrabalho = false;
    		}
    	}
    	xmlhttp.send(null);
    }
}

function alteraParte3(url,div,div2){
    if (!emTrabalho){ // testa se já não está executando uma ação
	    var parte = getXmlHttpRequest();
	    document.getElementById(div2).style.display = '';
	    document.getElementById(div).style.display = 'none';
		xmlhttp.open("POST", url, true);
		emTrabalho = true;
		xmlhttp.onreadystatechange = function(){
			if (xmlhttp.readyState == 4){
	    		document.getElementById(div2).style.display = 'none';
	    		document.getElementById(div).style.display = '';
	            document.getElementById(div).innerHTML = xmlhttp.responseText;
                emTrabalho = false;
			}
		}
		xmlhttp.send(null);
	}
}

function alteraParte(url,div,div2){
window.scrollTo(0,0)

    if (!emTrabalho){ // testa se já não está executando uma ação
	    document.getElementById(div2).style.display = '';
	    document.getElementById(div).style.display = 'none';
	    document.getElementById("pog").src = url;
		document.getElementById(div2).style.display = 'none';
		document.getElementById(div).style.display = '';
	}
}


function banner(qual){
	//alert(atual);
	atual = qual;
	alteraParte2('flash.php?banner='+qual+'.swf','Flash','loadFlash');
}

function cor(qual){
	document.getElementById('mudaCor').style.backgroundColor = qual;
//	alert(style); 
	style = "color: "+qual+";";
	
	if (document.getElementById('menu1')){
	 document.getElementById('menu1').style.color = qual;
	 }
	
}


function alteraParte2(url,div,div2){
//alert(atual);	
    if (!emTrabalho2){ // testa se já não está executando uma ação
	    var parte = getXmlHttpRequest();
	    document.getElementById(div2).style.display = '';
	    document.getElementById(div).style.display = 'none';
		parte.open("POST", url, true);
		emTrabalho2 = true;
		parte.onreadystatechange = function(){
			if (parte.readyState == 4){
	    		document.getElementById(div2).style.display = 'none';
	    		document.getElementById(div).style.display = '';
	            document.getElementById(div).innerHTML = parte.responseText;
                emTrabalho2 = false;
			}
		}
		parte.send(null);
	}
}

function validaForm(f){
    var enviar = false;
    for (var i = 0; i < f.elements.length; i++){
        var e = f.elements[i];
        if (e.id != ""){
            if (e.value == ''){
                enviar = false;
                alert("Preencha o campo "+e.id+".")
                e.focus();
                break;
            }else{
                enviar = true
            }
        }else{
            enviar = true
        }
    }
    return enviar;    
}


function sForm(f, verifica){
    if (verifica!="nao"){
        enviar = validaForm(f);
    }else{
        enviar = true;
    }
    if (enviar) {
  	 	document.getElementById("carregando").style.display = '';
    	document.getElementById("conteudo").style.display = 'none';
        var params = valoresForm(f);
        var form = getXmlHttpRequest();      
        form.open("POST", f.action, true);
        form.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=ISO-8859-1");
        form.setRequestHeader("Cache-Control", "post-check=0, pre-check=0");
        form.setRequestHeader("Pragma", "no-cache");
        form.send(params);
        form.onreadystatechange = function() {
            if (form.readyState == 4) {
                if (form.status == 200) {
                    var resultado = form.responseText;
                	document.getElementById("conteudo").innerHTML = resultado;
    				document.getElementById("conteudo").style.display = '';
    				document.getElementById("carregando").style.display = 'none';
                }
            }
        }
    }
}

function sForm(f, verifica,div1,div2){
    if (verifica!="nao"){
        enviar = validaForm(f);
    }else{
        enviar = true;
    }
    if (enviar) {
  	 	document.getElementById(div2).style.display = '';
    	document.getElementById(div1).style.display = 'none';
        var params = valoresForm(f);
        var form = getXmlHttpRequest();      
        form.open("POST", f.action, true);
        form.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=ISO-8859-1");
        form.setRequestHeader("Cache-Control", "post-check=0, pre-check=0");
        form.setRequestHeader("Pragma", "no-cache");
        form.send(params);
        form.onreadystatechange = function() {
            if (form.readyState == 4) {
                if (form.status == 200) {
                    var resultado = form.responseText;
                	document.getElementById(div1).innerHTML = resultado;
    				document.getElementById(div1).style.display = '';
    				document.getElementById(div2).style.display = 'none';
                }
            }
        }
    }
}

function sFormArq(f){
//    if (f.acao.value != "delete"){
//        enviar = validaForm(f);
//    }else{
//        enviar = true;
//    }
//    if (enviar) {
        document.getElementById('loadSite').style.display = '';
        document.getElementById('Site').style.display = 'none';
        f.submit();
        
//   }
}

function resetForm(f){
    f.reset();
}

function excluir(f,oque){
    input_box=confirm("Tem certeza que deseja excluir este "+oque+"?");
    if (input_box==true){
        f.acao.value = "delete";
        submitForm(f,"nao")
    }
}

function valoresForm(f) {
    form = f;
    var str = "";
    for(var i=0; i<form.elements.length; i++) {
        str += i==0 ? '' : '&';
        str += form.elements[i].name + '=' + form.elements[i].value;
    }
    return str;
}

// FIM AJAX


function somenteNumero(e){
    var tecla=(window.event)?event.keyCode:e.which;
    if((tecla > 47 && tecla < 58 || tecla == 0)) return true;
    else{
    if (tecla != 8) return false;
    else return true;
    }
}

function valorFloat(e){
    var tecla=(window.event)?event.keyCode:e.which;
    if((tecla > 47 && tecla < 58 || tecla == 0 || tecla == 46 || tecla == 44)) return true;
    else{
    if (tecla != 8) return false;
    else return true;
    }
}

function validaData(campo) {
    var reDate = /^((0[1-9]|[12]\d)\/(0[1-9]|1[0-2])|30\/(0[13-9]|1[0-2])|31\/(0[13578]|1[02]))\/\d{4}$/;
    if (!campo.value == ''){
        if (!reDate.test(campo.value)) {
          alert(campo.value + " é uma data inválida.");
          campo.value = '';
          campo.focus();
        }
    }
}

function validaQuantidade(campo) {
	if ((campo.value <= 0)&&(campo.value == '')) {
          alert("A quantidade deve ser maior que 0");
          campo.value = '';
          campo.focus();
    }
}

function validaValor(campo) {

	if ((campo.value <= 0)&&(campo.value == '')) {
	  alert("O valor deve ser maior que 0");
	  campo.value = '';
	  campo.focus();
	}

}


function formata(tipo,campo,tammax, teclapres) {
    var tecla = teclapres.keyCode;
    vr = campo.value;
    if (tipo == 'CPF') {
        vr = vr.replace( ".", "" );
        vr = vr.replace( ".", "" );
        vr = vr.replace( "-", "" );
        tam = vr.length ;
        if (tam > 3) {
            vr = vr.substr( 0, 3 ) + '.' +  vr.substr( 3, tam );
        }
        if (tam > 6) {
            vr = vr.substr( 0, 7 ) + '.' +  vr.substr( 7, tam );
        }
        if (tam > 9) {
            vr = vr.substr( 0, 11 ) + '-' +  vr.substr( 11, tam );
        }
        campo.value = vr;
	} else if (tipo == 'RG') {
        vr = vr.replace( ".", "" );
        vr = vr.replace( ".", "" );
        vr = vr.replace( "-", "" );
        tam = vr.length ;
        if (tam > 3) {
            vr = vr.substr( 0, 3 ) + '.' +  vr.substr( 3, tam );
        }
        if (tam > 6) {
            vr = vr.substr( 0, 7 ) + '.' +  vr.substr( 7, tam );
        }
        if (tam > 8) {
            vr = vr.substr( 0, 10 ) + '-' +  vr.substr( 10, tam );
        }
        campo.value = vr;
    } else if (tipo == 'CEP') {
        vr = vr.replace( "-", "" );
        tam = vr.length ;
        if (tam > 5) {
            vr = vr.substr( 0, 5 ) + '-' +  vr.substr( 5, tam );
        }
        campo.value = vr;
    } else if (tipo == 'DATA') {
        vr = vr.replace( "/", "" );
        vr = vr.replace( "/", "" );
        tam = vr.length ;
        if (tam > 2) {
            vr = vr.substr( 0, 2 ) + '/' +  vr.substr( 2, tam );
        }
        if (tam > 4) {
            vr = vr.substr( 0, 5 ) + '/' +  vr.substr( 5, tam );
        }
        campo.value = vr;
            
    }
}



function verificaSenha(){
	if (document.inserir.senha.value == document.inserir.senhar.value) 
		return true;
	else { 
		alert('Senhas não conferem!'); 
		return false; 
	}
}


function consisteTC1(f){
	var ok = true;
	var msg = '';
	var campo = '';
	
	var foto = f.foto.value;
	foto = foto.toUpperCase();
	if (foto.substr(foto.length - 3) != 'JPG'){ alert('A foto deve ter a extensão ".jpg"'); return false; }
	
	
	if (f.nome.value == ''){ ok = false; campo = (campo)?campo + ', Nome':'Nome'; }
	if (f.email.value == ''){ ok = false; campo = (campo)?campo + ', E-mail':'E-mail'; }
	if (f.sexo.value == ''){ ok = false; campo = (campo)?campo + ', Sexo':'Sexo'; }
	if ((f.dia.value == '')||(f.mes.value == '')||(f.ano.value == '')){ ok = false; campo = (campo)?campo + ', Data de Nascimento':'Data de Nascimento'; }
	if (f.estado_civil.value == ''){ ok = false; campo = (campo)?campo + ', Estado Civil':'Estado Civil'; }
	if (f.filhos.value == 's'){ 
		if (f.nr_filhos.value == ''){ ok = false; campo = (campo)?campo + ', N° Filhos':'N° Filhos'; }
	} else if (f.filhos.value == ''){ ok = false; campo = (campo)?campo + ', Possui Filhos':'Possui Filhos'; }
	if ((f.ddd_tel_fixo.value == '')||(f.nr_tel_fixo.value == '')){ ok = false; campo = (campo)?campo + ', Telefone Fixo':'Telefone Fixo'; }
	if (f.endereco.value == ''){ ok = false; campo = (campo)?campo + ', Endereço':'Endereço'; }
	if (f.numero.value == ''){ ok = false; campo = (campo)?campo + ', Número':'Número'; }
	if (f.bairro.value == ''){ ok = false; campo = (campo)?campo + ', Bairro':'Bairro'; }
	if (f.cep.value == ''){ ok = false; campo = (campo)?campo + ', CEP':'CEP'; }
	if (f.estado.value == ''){ ok = false; campo = (campo)?campo + ', Estado':'Estado'; }
	if (f.cidade){
		if (f.cidade.value == ''){ ok = false; campo = (campo)?campo + ', Cidade':'Cidade'; }
	} else ok = false;
	if (f.cpf.value == ''){ ok = false; campo = (campo)?campo + ', CPF':'CPF'; }
	if (f.rg.value == ''){ ok = false; campo = (campo)?campo + ', RG':'RG'; }
	if (f.titulo_eleitor.value == ''){ ok = false; campo = (campo)?campo + ', Título de Eleitor':'Título de Eleitor'; }
	if (f.possui_cnh.value == 's'){ 
		if (f.cnh.value == ''){ ok = false; campo = (campo)?campo + ', N° CNH':'N° CNH'; }
		if (f.categoria_cnh.value == ''){ ok = false; campo = (campo)?campo + ', Categoria CNH':'Categoria CNH'; }
		if (f.veiculo_proprio.value == ''){ ok = false; campo = (campo)?campo + ', Possui Veículo Próprio':'Possui Veículo Próprio'; }
	} else if (f.possui_cnh.value == ''){ ok = false; campo = (campo)?campo + ', Possui CNH':'Possui CNH'; }

	if (f.area_interesse.value == ''){ ok = false; campo = (campo)?campo + ', Área de Interesse':'Área de Interesse'; }
	
	if (ok == false) alert('Por favor, preencha todos os campos marcados com asterisco (*). Campos a serem preenchidos: ' + campo);
	
	campo = '';
	
	return ok;
}

function consisteTC2(f){
	var ok = true;
	var msg = '';
	var campo = '';

	if (f.graduacao.value == ''){ ok = false; campo = 'Graduação'; }
	if (f.nome_curso.disabled == false){ if (f.nome_curso.value == ''){ ok = false; campo = (campo)?campo + ', Nome do Curso':'Nome do Curso'; } }
	if (f.instituicao.value == ''){ ok = false; campo = (campo)?campo + ', Instituição de Ensino':'Instituição de Ensino'; }
	if (f.ano_curso.value == ''){ ok = false; campo = (campo)?campo + ', Ano / Semestre':'Ano / Semestre'; }

	if (ok == false) alert('Por favor, preencha todos os campos marcados com asterisco (*). Campos a serem preenchidos: ' + campo);

	campo = '';
	return ok;
}

function consisteTC3(f){
	var ok = true;
	var msg = '';
	var campo = '';
	
	if (f.nome.value == ''){ ok = false; campo = 'Nome'; }
	if (f.email.value == ''){ ok = false; campo = (campo)?campo + ', E-mail':'E-mail'; }
	if (f.msg.value == ''){ ok = false; campo = (campo)?campo + ', Mensagem':'Mensagem'; }
	
	if (ok == false) alert('Por favor, preencha todos os campos marcados com asterisco (*). Campos a serem preenchidos: ' + campo);
	
	campo = '';
	return ok;
}

function consisteContato(f){
	var ok = true;
	var msg = '';
	var campo = '';

	if (f.nome.value == ''){ ok = false;  campo = 'Nome'; }
	if (f.email.value == ''){ ok = false; campo = (campo)?campo + ', E-mail':'E-mail'; }
	if (f.voce_e.value == ''){ ok = false; campo = (campo)?campo + ', Você é':'Você é'; }
	if ((f.ddd_tel.value == '')||(f.nr_tel.value == '')){ ok = false; campo = (campo)?campo + ', Telefone':'Telefone'; }
	if (f.estado.value == ''){ ok = false; campo = (campo)?campo + ', Estado':'Estado'; }
	if (f.cidade){
		if (f.cidade.value == ''){ ok = false; campo = (campo)?campo + ', Cidade':'Cidade'; }
		if (f.cidade.value == 'São Paulo'){
			if (f.bairro.value == '') { ok = false; campo = (campo)?campo + ', Bairro':'Bairro'; }
		}
	} else ok = false;
	if (f.msg.value == ''){ ok = false; campo = (campo)?campo + ', Mensagem':'Mensagem'; }
	
	
	if (ok == false) alert('Por favor, preencha todos os campos marcados com asterisco (*). Campos a serem preenchidos: ' + campo);
	
	campo = '';
	return ok;
}

function consisteCad(f){
	var ok = true;
	var msg = '';
	var campo = '';

	if (f.cod_estado.value == ''){ ok = false; campo = (campo)?campo + ', Estado':'Estado'; }
	if (f.cod_cidade){
		if (f.cod_cidade.value == ''){ ok = false; campo = (campo)?campo + ', Cidade':'Cidade'; }
	} else ok = false;

	if (ok == false) alert('Por favor, preencha todos os campos marcados com asterisco (*). Campos a serem preenchidos: ' + campo);
	
	campo = '';
	return ok;
}

// Nome: ampliar                                                    *
// Finalidade: A1mplia imagem                                       *
function ampliar(img) {
    titre="Mix-Use Cosm&eacute;tica Profissional - - NOVO PORTAL MIX-USE - DESCUBRA...";
    w=open("",'image','width=250,height=250,toolbar=no,resizable=yes,scrolling=no,left=50, top=0');
    w.document.write("<HTML><HEAD><TITLE>"+titre+"</TITLE></HEAD>");
    w.document.write("<script language=javascript>function checksize() { if (document.images[0].complete) { window.resizeTo(document.images[0].width+27,document.images[0].height+60); window.focus();} else { setTimeout('checksize()',250) } }</"+"SCRIPT>");
    w.document.write("<BODY onload='checksize()' bgcolor=#F3F4F8  leftMargin=0 topMargin=0 marginwidth=0 marginheight=0 >");
    w.document.write("<TABLE width='100%' border='0' cellspacing='0' cellpadding='0' height='100%' onmouseover='this.style.cursor=\"pointer\"' onclick='window.close()'><TR>");
    w.document.write("<TD valign='middle' align='center'><IMG src='"+img+"' border=0 alt=''>");
    w.document.write("</TD></TR></TABLE>");
    w.document.write("</BODY></HTML>");
    w.document.close();
}

// Nome: maximiza                                                    *
// Finalidade: Maximizar uma janela                                  *
function maximiza(wndw){
  wndw.resizeTo(screen.availWidth, screen.availHeight);
  wndw.moveTo(0, 0);
}
// Nome: relatorio                                                   *
// Finalidade: Abrir uma nova janela maximizada                      *
function relatorio(url){
  var janela = window.open(url, "_blank", "toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=yes, copyhistory=no");
  maximiza(janela);
}

function openWindow(url,w,h,t,l){
  window.open(url, "_blank", "toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=yes, copyhistory=no, width="+w+" ,height="+h+" ,top="+t+" ,left="+l);
}

function check_cpf (numcpf)
{
	
	numcpf = numcpf.replace('.','');
	numcpf = numcpf.replace('.','');
	numcpf = numcpf.replace('-','');
	x = 0;
	soma = 0;
	dig1 = 0;
	dig2 = 0;
	texto = "";
	numcpf1="";
	len = numcpf.length; x = len -1;
	for (var i=0; i <= len - 3; i++) {
		y = numcpf.substring(i,i+1);
		soma = soma + ( y * x);
		x = x - 1;
		texto = texto + y;
	}
	dig1 = 11 - (soma % 11);
	if (dig1 == 10) dig1=0 ;
	if (dig1 == 11) dig1=0 ;
	numcpf1 = numcpf.substring(0,len - 2) + dig1 ;
	x = 11; soma=0;
	for (var i=0; i <= len - 2; i++) {
		soma = soma + (numcpf1.substring(i,i+1) * x);
		x = x - 1;
	}
	dig2= 11 - (soma % 11);
	if (dig2 == 10) dig2=0;
	if (dig2 == 11) dig2=0;
	if ((dig1 + "" + dig2) == numcpf.substring(len,len-2)) {
		return true;
	}
	alert ("Numero do CPF invalido !!!");
	return false;
}


function chekSenha(){
	
	f = document.salvar;
	
	if (f.senha.value == f.senhar.value){
		return true;
	} else {
		alert('Senhas não conferem.');
		return false;
	}
}


function startList() {

	if (document.all&&document.getElementById) {
		navRoot = document.getElementById("nav");
		for (i=0; i<navRoot.childNodes.length; i++) {
			node = navRoot.childNodes[i];
			if (node.nodeName=="LI") {
				node.onmouseover=function() {
					this.className+=" over";
				}
				node.onmouseout=function() {
					this.className=this.className.replace(" over", "");
					
				}
			}
		}
	}

}
//window.onload=startList;


function setUf(estado){
	document.getElementById('estado').value = estado;
	var tipo = document.getElementById('interesse').value;
	alteraParte3('ondeEncontrar2.php?pagina=2&cod_estado='+estado+'&tipo='+tipo,'cidId','cidIdCarregando');
}

/* - - - -  Função do Cabelo - - - - - - */
function buscaValores(codigo,ano){
	
	//document.getElementById("al").style.display = '';
	
	var xmlHttpReq = false;
	var self = this;
	// Mozilla/Safari
	if (window.XMLHttpRequest) {
		self.xmlHttpReq = new XMLHttpRequest();
	}
	// IE
	else if (window.ActiveXObject) {
		self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
	}
	
	self.xmlHttpReq.open('POST', 'vendedores_vendas.php', true);
	self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	self.xmlHttpReq.onreadystatechange = function() {
		if (self.xmlHttpReq.readyState == 4) {

			if (!document.getElementById('pogPlus')){
				alteraParte('vendedores_vendas.php?msg=Dados atualizados.','Site','loadSite');
			} else {

				top.document.getElementById('Site').innerHTML = document.getElementById('pogPlus').innerHTML;
	
				//alert(self.xmlHttpReq.responseText);
	
				var ar = self.xmlHttpReq.responseText.split('|');
				var obj = top.document.salvar;
				
				obj.v1.value = ar[0];
				if (ar[0] != ""){
					obj.v1.readOnly = true; 
				} else 
					obj.v1.readOnly = false;
				
				obj.v2.value = ar[1];
				if (ar[1] != ""){
					obj.v2.readOnly = true; 
				} else 
					obj.v2.readOnly = false;
	
				obj.v3.value = ar[2];
				if (ar[2] != ""){
					obj.v3.readOnly = true; 
				} else 
					obj.v3.readOnly = false;
	
				obj.v4.value = ar[3];
				if (ar[3] != ""){
					obj.v4.readOnly = true; 
				} else 
					obj.v4.readOnly = false;
	
				obj.v5.value = ar[4];
				if (ar[4] != ""){
					obj.v5.readOnly = true; 
				} else 
					obj.v5.readOnly = false;
	
				obj.v6.value = ar[5];
				if (ar[5] != ""){
					obj.v6.readOnly = true; 
				} else 
					obj.v6.readOnly = false;
	
				obj.v7.value = ar[6];
				if (ar[6] != ""){
					obj.v7.readOnly = true; 
				} else 
					obj.v7.readOnly = false;
	
				obj.v8.value = ar[7];
				if (ar[7] != ""){
					obj.v8.readOnly = true; 
				} else 
					obj.v8.readOnly = false;
				
				obj.v9.value = ar[8];
				if (ar[8] != ""){
					obj.v9.readOnly = true; 
				} else 
					obj.v9.readOnly = false;
	
				obj.v10.value = ar[9];
				if (ar[9] != ""){
					obj.v10.readOnly = true; 
				} else 
					obj.v10.readOnly = false;
	
				obj.v11.value = ar[10];
				if (ar[10] != ""){
					obj.v11.readOnly = true; 
				} else 
					obj.v11.readOnly = false;
				
				obj.v12.value = ar[11];
				if (ar[11] != ""){
					obj.v12.readOnly = true; 
				} else 
					obj.v12.readOnly = false;
				
				if (ar[12])
					obj.media.value = ar[12]; 
				//alert(ar[12].value);
	
				// -- Bloqueia oq estiver atrás da data limite
				var day = new Date()
				var anoAtual = day.getFullYear();
				var mes = day.getMonth();
				var dia = day.getDate();
				var hr = day.getHours()
				var diaLib = 9;
				
				
				if (anoAtual == ano){ // -- Bloqueia até o mes corrente
	
					if (dia > diaLib){
						for (i = 1; i <= mes; i++){
							top.document.getElementById('v'+i).readOnly = true;
						}
					} else if (dia < diaLib)	{
						for (i = 1; i < mes; i++){
							top.document.getElementById('v'+i).readOnly = true;
						}
					} else if (dia == diaLib) {
						if (hr >= 18){
							for (i = 1; i <= mes; i++){
								top.document.getElementById('v'+i).readOnly = true;
							}
						} else {
							for (i = 1; i < mes; i++){
								top.document.getElementById('v'+i).readOnly = true;
							}
						}	
					}				
					
				} else if (anoAtual > ano){ // -- Bloqueia tudo			

					obj.v1.readOnly = true;  
					obj.v2.readOnly = true;
					obj.v3.readOnly = true;
					obj.v4.readOnly = true;
					obj.v5.readOnly = true;
					obj.v6.readOnly = true;
					obj.v7.readOnly = true;
					obj.v8.readOnly = true;
					obj.v9.readOnly = true;
					obj.v10.readOnly = true;
					obj.v11.readOnly = true;

					if ((mes == 0) && (dia <= diaLib) && (hr < 18) && (ar[11] == "")){
						obj.v12.readOnly = false;
					} else
						obj.v12.readOnly = true;

				}
			}
		}
	}

	self.xmlHttpReq.send('pagina=2&codigo='+codigo+'&ano='+ano);
}

function formataMoeda(objTextBox, SeparadorMilesimo, SeparadorDecimal, e){
	
	if (objTextBox.readOnly == false){
	
	    var sep = 0;
	    var key = '';
	    var i = j = 0;
	    var len = len2 = 0;
	    var strCheck = '0123456789';
	    var aux = aux2 = '';
	    var whichCode = (window.Event) ? e.which : e.keyCode;    
	    // 13=enter, 8=backspace as demais retornam 0(zero)
	    // whichCode==0 faz com que seja possivel usar todas as teclas como delete, setas, etc    
	    if ((whichCode == 13) || (whichCode == 0) || (whichCode == 8))
	    	return true;
	    key = String.fromCharCode(whichCode); // Valor para o código da Chave
	 
	 
	    if (strCheck.indexOf(key) == -1) 
	    	return false; // Chave inválida
	    len = objTextBox.value.length;
	    for(i = 0; i < len; i++)
	        if ((objTextBox.value.charAt(i) != '0') && (objTextBox.value.charAt(i) != SeparadorDecimal)) 
	        	break;
	    aux = '';
	    for(; i < len; i++)
	        if (strCheck.indexOf(objTextBox.value.charAt(i))!=-1) 
	        	aux += objTextBox.value.charAt(i);
	    aux += key;
	    len = aux.length;
	    if (len == 0) 
	    	objTextBox.value = '';
	    if (len == 1) 
	    	objTextBox.value = '0'+ SeparadorDecimal + '0' + aux;
	    if (len == 2) 
	    	objTextBox.value = '0'+ SeparadorDecimal + aux;
	    if (len > 2) {
	        aux2 = '';
	        for (j = 0, i = len - 3; i >= 0; i--) {
	            if (j == 3) {
	                aux2 += SeparadorMilesimo;
	                j = 0;
	            }
	            aux2 += aux.charAt(i);
	            j++;
	        }
	        objTextBox.value = '';
	        len2 = aux2.length;
	        for (i = len2 - 1; i >= 0; i--)
	        	objTextBox.value += aux2.charAt(i);
	        objTextBox.value += SeparadorDecimal + aux.substr(len - 2, len);
	    }
	    return false;
	}
}