		function gerarDataLocal(){
        	var obj = document.getElementById('Local');
        	var string = "<table>";
        	var br = "";
        	for( x = 0 ; x < obj.length ; x++ ){
        		string += "<tr><td class='titulo'>" + obj.options[x].text + ":&nbsp;</td><td class='descricao'> de&nbsp;<input type='text' style='width: 120px;' class='data' name='data-de-"+obj.options[x].value+"' id='data-de-"+obj.options[x].value+"'/> <img src='../imagens/calendario.gif' id='botao-de-"+obj.options[x].value+"'> &nbsp;&nbsp; até&nbsp;<input type='text' style='width: 120px;' class='data' name='data-ate-"+obj.options[x].value+"' id='data-ate-"+obj.options[x].value+"' /> <img src='../imagens/calendario.gif' id='botao-ate-"+obj.options[x].value+"'></td></tr>";
        	}
        	string += "</table>";
        	
        	document.getElementById('datas_locais').innerHTML = string;
        	
        	for( x = 0 ; x < obj.length ; x++ ){
        		var cal = new Zapatec.Calendar.setup({
				showsTime      : true,//mostrar hora ou não
				range          : [1900.01, 2999.12],//data inicial e final
				singleClick    : true,//selecionar data com um único click
				inputField     : "data-de-"+obj.options[x].value,//nome do campo que irá receber a data
				button         : "botao-de-"+obj.options[x].value,//botão que irá chamar a função da data
				ifFormat       : "%d/%m/%Y %H:%M"//formata que irá ser mostrado
				});
				
				var cal = new Zapatec.Calendar.setup({
				showsTime      : true,//mostrar hora ou não
				range          : [1900.01, 2999.12],//data inicial e final
				singleClick    : true,//selecionar data com um único click
				inputField     : "data-ate-"+obj.options[x].value,//nome do campo que irá receber a data
				button         : "botao-ate-"+obj.options[x].value ,//botão que irá chamar a função da data
				ifFormat       : "%d/%m/%Y %H:%M"//formata que irá ser mostrado
				});
        	}

        }

		function somenteNumerico(obj, e, excecoes){		
			
			if(excecoes == undefined)
				excecoes = '';
				
			var strcheck = '0123456789'+excecoes;
			var key = '';
			
			var whichCode = (window.Event) ? e.which : e.keyCode;
			
			//var whichCode = (window.event) ? window.event.keyCode : e.keyCode;
			
			if ( (whichCode == 13) || (whichCode==0) )return true;  // Enter
			
			key = String.fromCharCode(whichCode);
					
			if ( strcheck.indexOf(key) != -1 || (whichCode == 8) ){
				document.getElementById(obj.id).innerHTML = obj.value;
			}else{
				return false;
			}	
		}
	
		

		function ajaxPadrao(formulario, metodo, url, layer) {
			objAjax = new AjaxObject(metodo, url);
			objAjax.addAllRequestObjects(document.forms[formulario]);
			objAjax.setLoadingFunction(loading);
			objAjax.setCallBackFunction(callBackPadrao, new Array(layer));
			objAjax.load();
		}
		
		function ajaxPadraoCadastros(formulario, metodo, url, layer) {
			objAjax = new AjaxObject(metodo, url);
			objAjax.addAllRequestObjects(document.forms[formulario]);
			objAjax.setLoadingFunction(loading);
			objAjax.setCallBackFunction(callBackDetailCadastros2, new Array(layer));
			objAjax.load();
		}
		
		function ajaxPadrao2(formulario, metodo, url, layer) {
			objAjax = new AjaxObject(metodo, url);
			objAjax.setLoadingFunction(loading);
			objAjax.setCallBackFunction(callBackPadrao, new Array(layer));
			objAjax.load();
		}
		
	   /*
		*	FUNÇÃO PARA EXIBIR DIV
		*/
		function showMenu(div){
			/*
			if(div != 'menuCadastros')
			document.getElementById('menuCadastros').style.display="none";
			if(div != 'menuCadastroTipos')
			document.getElementById('menuCadastroTipos').style.display="none";
			if(div != 'menuGerencial')
			document.getElementById('menuGerencial').style.display="none";
			*/
			if(document.getElementById(div).style.display=="none"){
				document.getElementById(div).style.display="block";
			}else{
				document.getElementById(div).style.display="none";	
			}
		}


		
		function alterarRate(resposta, idLivro) {
			if (resposta) {
				document.getElementById("estrela" + idLivro).innerHTML = "<span class=titulo>" + resposta + "</span>";
			}
		}
		
		function trocaNota(div, nota){
			notas = new Array("Péssimo", "Ruim", "Regular", "Bom", "Muito bom", "Excelente");
			document.getElementById("nota" + div).innerHTML = "<span class=titulo>" + nota + "</span>";
			document.getElementById("texto" + div).innerHTML = "<span class=titulo>" + notas[nota] + "</span>"; 
		}
		
		function ajaxPadraoUniqueCadastros(valor, metodo, url,layer, idsCalendarios) {
			objAjax = new AjaxObject(metodo, url);
			objAjax.addRequestValue('key',valor);
			objAjax.setCallBackFunction(callBackDetailCadastros, new Array(layer,idsCalendarios));
			objAjax.setExceptionFunction(exceptionPadrao);
			objAjax.load();
			
		}
		
		function callBackDetailCadastros(response, layerName, idsCalendarios) {
			document.getElementById(layerName).style.display = 'block';
			document.getElementById(layerName).innerHTML = response;
			var vetor = idsCalendarios.split(",");
			for (valor in vetor){
				//alert(vetor[valor]);
				var primeira = vetor[valor].substring(0,1);
				primeira = primeira.toUpperCase();
				
				var idBotao='botao'+primeira+vetor[valor].substring(1)
				
				var cal = new Zapatec.Calendar.setup({
				showsTime      : false,//mostrar hora ou não
				range          : [1900.01, 2999.12],//data inicial e final
				singleClick    : true,//selecionar data com um único click
				inputField     : vetor[valor],//nome do campo que irá receber a data
				button         : idBotao,//botão que irá chamar a função da data
				ifFormat       : "%d/%m/%Y"//formata que irá ser mostrado
				});
			}
			
			
		}
		
		function ajaxPadraoUnique(valor, metodo, url,layer) {
			objAjax = new AjaxObject(metodo, url);
			objAjax.addRequestValue('key',valor);
			objAjax.setCallBackFunction(callBackPadrao, new Array(layer));
			objAjax.setExceptionFunction(exceptionPadrao);
			objAjax.load();
		}
		
		function exceptionPadrao(cod, status) {
			alert(cod + ": " + status);
		}
		
		function move(s1, s2) {
	      i = s1.selectedIndex;
	      if ( i != -1 ) {
	        if ( s1.options[i].selected ) {
	            for ( j = 0; j < s2.options.length; j++ ) {
	              if ( s2.options[j].value == s1.options[i].value ) break;
	              if ( s2.options[j].text > s1.options[i].text ) {
	                for ( z = s2.options.length; z > j ; z-- ) {
	                  s2.options[z] = new Option(s2.options[z-1].text, s2.options[z-1].value, false, false);
	                }
	                break;
	              }
	            }
	            s2.options[j] = new Option(s1.options[i].text, s1.options[i].value, false, true);
	            s1.options[i] = null;
	        }
	      }
	    }
		function moveall(s1, s2) {
		
			total =  s1.options.length;
		
			soma = s2.options.length;
	
			rodar = total+soma;
		
			for ( x = soma,y=0; x < rodar; x++,y++) {
		 	 s2.options[x] = new Option(s1.options[y].text, s1.options[y].value, false, false);
			}
			s1.innerHTML = "";
		}
		
		function FormataCpf(campo,tammax,teclapres) {
			 var tecla = teclapres.keyCode;
			  
			 vr = event.srcElement.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 ){ 
			    event.srcElement.value = vr ; }
			   if ( (tam > 2) && (tam <= 5) ){
			    event.srcElement.value = vr.substr( 0, tam - 2 ) + '-' + vr.substr( tam - 2, tam ) ; }
			   if ( (tam >= 6) && (tam <= 8) ){
			    event.srcElement.value = vr.substr( 0, tam - 5 ) + '.' + vr.substr( tam - 5, 3 ) + '-' + vr.substr( tam - 2, tam ) ; }
			   if ( (tam >= 9) && (tam <= 11) ){
			    event.srcElement.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) ){
			    event.srcElement.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) ){
			    event.srcElement.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 callBackDetail(response, layerName, campo, botao) {
			document.getElementById(layerName).style.display = 'block';
			document.getElementById(layerName).innerHTML = response;
			var cal = new Zapatec.Calendar.setup({
			showsTime      : false,//mostrar hora ou não
			range          : [1900.01, 2999.12],//data inicial e final
			singleClick    : true,//selecionar data com um único click
			inputField     : campo,//nome do campo que irá receber a data
			button         : botao,//botão que irá chamar a função da data
			ifFormat       : "%d/%m/%Y"//formata que irá ser mostrado
			});
			
		}
		
		function callBackPadrao(response, layerName) {
			document.getElementById(layerName).innerHTML = response;
		}


		// Função padrao de ajax para formularios
		function ajaxPadraoForm(formulario, metodo, url) {
			objAjax = new AjaxObject(metodo, url);
			objAjax.addAllRequestObjects(document.forms[formulario]);
			objAjax.setCallBackFunction(callBackAlert, new Array());
			objAjax.load();
		}
		
		function ajaxPadraoFormUnique(valor, metodo, url) {
			objAjax = new AjaxObject(metodo, url);
			objAjax.addRequestValue('key',valor);
			objAjax.setCallBackFunction(callBackAlert, new Array());
			objAjax.setExceptionFunction(exceptionPadrao);
			objAjax.load();
		}
		
		function verificarDataDisponivel(data){
			if(confirm('Deseja definir o prazo para o dia '+data)){
				document.getElementById('prazo').value = data;
			}else{
	 			document.getElementById('prazo').value = '';
	 		}
		}
		

		function loading(){
				layerName = this.callBackArguments[0];
				
				document.getElementById(layerName).innerHTML = "<font face=verdana size=3><div align=center><b>Carregando...</b></div></font>";	
		}

// Função padrão de Callback
		
		function callBackAlert(response) {
			eval(response);
		}

function MM_reloadPage(init) {  //reloads the window if Nav4 resized

if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {

document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}

else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();

}

MM_reloadPage(true);

function MM_findObj(n, d) { //v4.01

var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {

d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}

if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];

for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);

if(!x && d.getElementById) x=d.getElementById(n); return x;

}

function MM_showHideLayers() { //v6.0

var i,p,v,obj,args=MM_showHideLayers.arguments;

for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];

if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }

obj.visibility=v; }

}



function MM_swapImgRestore() { //v3.0

var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;

}

function MM_preloadImages() { //v3.0

var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();

var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)

if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}

}

function MM_swapImage() { //v3.0

var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)

if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}

}

function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}

function carregarCalendario(mes, ano , base) { 
    req = null; 
	url = base+'/calendario/carregar/' + mes + '/' + ano;
    document.getElementById('calendario').innerHTML = calendarioCarregando();
 	
    // Procura por um objeto nativo (Mozilla) 
    if (window.XMLHttpRequest) { 
        req = new XMLHttpRequest(); 
        req.onreadystatechange = processReqChange; 
        req.open("GET", url, true); 
        req.send(null); 
    // Procura por uma versão ActiveX (IE) 
    } else if (window.ActiveXObject) {
        req = new ActiveXObject("Microsoft.XMLHTTP"); 
        if (req) { 
            req.onreadystatechange = processReqChange; 
            req.open("GET", url, true); 
            req.send(); 
        } 
    } 
} 

function processReqChange() { 
    // apenas quando o estado for "completado" 
    if (req.readyState == 4) { 
        // apenas se o servidor retornar "OK" 
        if (req.status == 200) { 
            // procura pela div id="calendario" e insere o conteudo 
            // retornado nela, como texto HTML 
            document.getElementById('calendario').innerHTML = req.responseText; 
        } else { 
            alert("Problemas para carregar o calendário!\nTente novamente mais tarde."); 
        } 
    } 
} 

function carregarCalendarioMesAno() {
	document.getElementById('calendario_mes_ano').innerHTML = ' ' + meses[mes] + ' ' + ano + ' '; 
}

function iniciarCalendario(iDia, iMes, iAno , base) {
	meses = new Array('', 'Janeiro',  'Fevereiro', 'Março', 'Abril', 'Maio', 'Junho',
					  'Julho', 'Agosto', 'Setembro', 'Outubro', 'Novembro', 'Dezembro');
	dia = iDia;
	mes = iMes;
	ano = iAno;
	carregarCalendarioMesAno(mes, ano);
	carregarCalendario(mes, ano , base);
}
function trocarCalendario(valor,base) {
	// se o novo mes até 12 (jan = 1, dez = 12)
	if ((mes + valor) <= 12) {
		if (mes + valor > 0) {
			mes += valor;
		// se o novo mês for menor que zero
		} else {
			mes = 12;
			ano -= 1;
		}
	// se o novo mês passar de 12 (1 a 12)
	} else {
		mes = 1;
		ano += 1;
	}
	carregarCalendario(mes, ano , base);
	carregarCalendarioMesAno(mes, ano);
}
var meses, data, mes, ano;

function calendarioCarregando() {
	return '<table border="0"><tr><td width="168" align="center" valign="middle" height="115">\n'+
'	 <table width="150"  border="0" cellspacing="0" cellpadding="0">\n' +
'	  <tr>\n' +
'		<td colspan="3" align="right" background="imagens/topo_div_bg.gif"><table width="100%" cellpadding="0" cellspacing="0">\n' +
'			<tr><td><img src="imagens/topo_div_canto.gif"></td><td><img src="imagens/topo_div_resto.gif"></td></tr></table></td>\n' +
'	  </tr>\n' +
'	  <tr>\n' +
'		<td bgcolor=cccccc width="1"></td>\n' +
'		<td background="imagens/bg_div.jpg" height="18" align="right" nowrap class="texto_destaque">\n' +
'			<b> Carregando ... &nbsp; </b></td>\n' +
'		<td bgcolor="#cccccc" width="1"></td>\n' +
'	  </tr>\n' +
'	 </table></td></tr></table>\n';
}


function showDiv(valor){

		oDiv0 = document.getElementById("tipo0");
		oDiv1 = document.getElementById("tipo1");
	
		if (valor=='0')
		{
			oDiv0.style.display = "block";
			oDiv1.style.display = "none";
		}
		if (valor=='1')
		{
			oDiv1.style.display = "block";
			oDiv0.style.display = "none";
		}

}

function move(s1, s2) {
      i = s1.selectedIndex;
      if ( i != -1 ) {
        if ( s1.options[i].selected ) {
            for ( j = 0; j < s2.options.length; j++ ) {
              if ( s2.options[j].value == s1.options[i].value ) break;
              if ( s2.options[j].text > s1.options[i].text ) {
                for ( z = s2.options.length; z > j ; z-- ) {
                  s2.options[z] = new Option(s2.options[z-1].text, s2.options[z-1].value, false, false);
                }
                break;
              }
            }
            s2.options[j] = new Option(s1.options[i].text, s1.options[i].value, false, true);
            s1.options[i] = null;
        }
      }
    }


function setSelectOptions(the_form, the_select, do_check)
{
	var selects = the_select.split(",");
	
	for (pos in selects){

	    var selectObject = document.forms[the_form].elements[selects[pos]];
	    var selectCount  = selectObject.length;
	
	    for (var i = 0; i < selectCount; i++) {
	        selectObject.options[i].selected = do_check;
	    } // end for
    
    }

    return true;
}
	

function passamouse(src,cor,sentido){

  if (sentido == "entra") {

    if(!src.contains(event.fromElement)){

      src.style.cursor='hand';src.bgColor=cor;

    }

  }

  if (sentido == "sai") {

    if(!src.contains(event.toElement)){

      src.style.cursor='default';src.bgColor=cor;

    }

  }

}



function cliquemouse(src){

  if(event.srcElement.tagName=='TD'){

    src.children.tags('A')[0].click();

  }

}

function submeter(acao,arquivo_url) {

	

	switch (acao) {

	case 0: //Atualizar



           	document.edicao.action = arquivo_url;

		break;



	case 1: //Excluir

		if (!confirm('Deseja excluir o(s) item(ns) selecionado(s) ?')) return(false);

		document.edicao.action = arquivo_url;

		break;



	case 2: //Imprimir

		document.edicao.action = arquivo_url;

		break;

	}



	document.edicao.submit();

	return(true);

}



function currencyFormat(fld, milSep, decSep, e) {
	
	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;

	if (whichCode == 13) return true;  // Enter
	
	key = String.fromCharCode(whichCode);  // Get key value from key code
	
	if (strCheck.indexOf(key) == -1) return false;  // Not a valid key
	
	len = fld.value.length;
	
	for(i = 0; i < len; i++)
	
	if ((fld.value.charAt(i) != '0') && (fld.value.charAt(i) != decSep)) break;
	
	aux = '';

	for(; i < len; i++)

		if (strCheck.indexOf(fld.value.charAt(i))!=-1) aux += fld.value.charAt(i);

	aux += key;

	len = aux.length;

	if (len == 0) fld.value = '';
	
	if (len == 1) fld.value = '0'+ decSep + '0' + aux;
	
	if (len == 2) fld.value = '0'+ decSep + aux;
	
	if (len > 0) {

		aux2 = '';
		
		for (j = 0, i = len - 3; i >= 0; i--) {
		
			if (j == 3) {
			
				aux2 += milSep;
				
				j = 0;
			
			}
		
			aux2 += aux.charAt(i);
			
			j++;
			
		}
		
		fld.value = '';
		
		len2 = aux2.length;
		
		for (i = len2 - 1; i >= 0; i--)
		
		fld.value += aux2.charAt(i);
		
		fld.value += decSep + aux.substr(len - 2, len);
	
	}

return false;

}


function mascara(mascara,objeto) {
	if (objeto.value.length >= mascara.length){
		objeto.value = objeto.value.substring(0,objeto.value.length-1);
		return true;
	}
	var itemMascara	= '';
	var itemValue	= '';
	itemMascara = mascara.charAt(objeto.value.length);
	if (itemMascara !== '0') {
		objeto.value += itemMascara;
	}
}

function formata(campo,tecla){
	valor = campo.value;
	tam = valor.length;
	if(tecla!=8 && tecla!=46 && tecla!=45){
		if(valor.length==3)
			campo.value += ".";
		if(valor.length==7)
			campo.value += ".";
		if(valor.length==11)
			campo.value += "-";
	}
}

function ValidarCNPJ(ObjCnpj){
	
    var cnpj = ObjCnpj.value;
    var valida = new Array(6,5,4,3,2,9,8,7,6,5,4,3,2);
    var dig1= new Number;
    var dig2= new Number;
    
    exp = /\.|\-|\//g
    cnpj = cnpj.toString().replace( exp, "" );
    var digito = new Number(eval(cnpj.charAt(12)+cnpj.charAt(13)));
        
    for(i = 0; i<valida.length; i++){
        dig1 += (i>0? (cnpj.charAt(i-1)*valida[i]):0);    
        dig2 += cnpj.charAt(i)*valida[i];    
    }
    dig1 = (((dig1%11)<2)? 0:(11-(dig1%11)));
    dig2 = (((dig2%11)<2)? 0:(11-(dig2%11)));
    
    if(((dig1*10)+dig2) != digito){   
        alert('CNPJ Invalido!');
    	return false;
    }
    return true;
        
}

function FormataCNPJ(Campo, teclapres){
	var tecla = teclapres.keyCode;
	
	var vr = new String(Campo.value);
	vr = vr.replace(".", "");
	vr = vr.replace(".", "");
	vr = vr.replace("/", "");
	vr = vr.replace("-", "");

	tam = vr.length + 1 ;

	
	if (tecla != 9 && tecla != 8){
		if (tam > 2 && tam < 6)
			Campo.value = vr.substr(0, 2) + '.' + vr.substr(2, tam);
		if (tam >= 6 && tam < 9)
			Campo.value = vr.substr(0,2) + '.' + vr.substr(2,3) + '.' + vr.substr(5,tam-5);
		if (tam >= 9 && tam < 13)
			Campo.value = vr.substr(0,2) + '.' + vr.substr(2,3) + '.' + vr.substr(5,3) + '/' + vr.substr(8,tam-8);
		if (tam >= 13 && tam < 15)
			Campo.value = vr.substr(0,2) + '.' + vr.substr(2,3) + '.' + vr.substr(5,3) + '/' + vr.substr(8,4)+ '-' + vr.substr(12,tam-12);
		}
}

function abre(foto){

    parent.window.open('../recibo.php?V1='+foto,foto+'fotos','scrolling:no,scrollbars=0');



}


function MM_openBrWindow(theURL,winName,features) { //v2.0

  window.open(theURL,winName,features);

}

function abrePopup(pagina, configuracoes){
window.open(pagina, "CECON", configuracoes);
}

function sonumeros(s,campo,formulario) { 
	for (vlcont = 0 ; vlcont <= 12 ; vlcont++) {
		if (s.charAt(vlcont) == "") {
			var vlPosAtual = vlcont-1;
			break;
		}
	}

	var vlChar = s.charAt(vlPosAtual);
	var vaAux1 = ((vlChar >= "0") && (vlChar <= "9"));

	if(!vaAux1) {
		var vlNewChar = "";
		for (vlcont = 0 ; vlcont <= vlPosAtual ; vlcont++) {
			if (vlcont != vlPosAtual) {
				vlNewChar = vlNewChar + s.charAt(vlcont);
			}
		}

		eval("document." + formulario + "." + campo + ".value = vlNewChar");
		return false;
	}
	return true;
}

	// determinando as imagens
	arrayImagens = new Array();
	arrayImagens[0] = new Image();
	arrayImagens[0].src = "imagens/m.gif";
	arrayImagens[1] = new Image();
	arrayImagens[1].src = "imagens/p.gif";
	function exibirRespostas(imagem,layer) {
		// caso não ache o layer passado, retorna sem dar erro de script
		if (!(objeto = document.getElementById(layer))) return;
		// checando se o layer está visivel
		if (objeto.style.visibility == "hidden") {
			objeto.style.visibility = "inherit";
			objeto.style.position = "relative";
			objeto.outerHTML = objeto.outerHTML;
			imagem.src = arrayImagens[0].src;
			imagem.alt = "Ocultar as respostas a este comentário";
		} else {
			for (x=0;x<objeto.children.tags("DIV").length;x++) {
				if (objeto.children.tags("DIV")[x].style.visibility=="visible") {
					alert(objeto.children.tags("DIV")[x].id);
				}
			}
			objeto.style.visibility = "hidden";
			objeto.style.position = "absolute";
			imagem.src = arrayImagens[1].src;
			imagem.alt = "Expandir as respostas deste comentário";
		}
	}



function Verifica_campo_CPF(campo) {
var CPF = campo.value; // Recebe o valor digitado no campo

CPF = CPF.replace( ".", "" );
CPF = CPF.replace( ".", "" );
CPF = CPF.replace( "-", "" );

// Aqui começa a checagem do CPF
var POSICAO, I, SOMA, DV, DV_INFORMADO;
var DIGITO = new Array(10);
DV_INFORMADO = CPF.substr(9, 2); // Retira os dois últimos dígitos do número informado

// Desemembra o número do CPF na array DIGITO
for (I=0; I<=8; I++) {
  DIGITO[I] = CPF.substr( I, 1);
}

// Calcula o valor do 10º dígito da verificação
POSICAO = 10;
SOMA = 0;
   for (I=0; I<=8; I++) {
      SOMA = SOMA + DIGITO[I] * POSICAO;
      POSICAO = POSICAO - 1;
   }
DIGITO[9] = SOMA % 11;
   if (DIGITO[9] < 2) {
        DIGITO[9] = 0;
}
   else{
       DIGITO[9] = 11 - DIGITO[9];
}

// Calcula o valor do 11º dígito da verificação
POSICAO = 11;
SOMA = 0;
   for (I=0; I<=9; I++) {
      SOMA = SOMA + DIGITO[I] * POSICAO;
      POSICAO = POSICAO - 1;
   }
DIGITO[10] = SOMA % 11;
   if (DIGITO[10] < 2) {
        DIGITO[10] = 0;
   }
   else {
        DIGITO[10] = 11 - DIGITO[10];
   }

// Verifica se os valores dos dígitos verificadores conferem
DV = DIGITO[9] * 10 + DIGITO[10];
   
   if (CPF.length != 11 || CPF == "00000000000" || CPF == "11111111111" ||
           CPF == "22222222222" || CPF == "33333333333" || CPF == "44444444444" ||
           CPF == "55555555555" || CPF == "66666666666" || CPF == "77777777777" ||
           CPF == "88888888888" || CPF == "99999999999"){
	         alert('O CPF digitado é inválido!');
      campo.focus();

           return false;
   }
   if (DV != DV_INFORMADO) {
      alert('O CPF digitado é inválido!');
      campo.focus();
      return false;
   } 
}

function excluirArquivo(titulo){
	if(confirm('Deseja realmente excluir o arquivo '+titulo+' ?'))
		return true;
	else
		return false;
}


function imagemLoading(base,layer){
	document.getElementById(layer).innerHTML = "<img src='"+base+"/imagens/ajax-loader.gif'>";
}
function testeImagem(base,layer){
	document.getElementById(layer).innerHTML = "teste";
	//document.getElementById(layer).innerHTML = "<table width='100%' height='100%' border=0><tr><td valign=top align=center><img src='"+base+"/imagens/ajax-loader.gif'></td></tr></table>";
}

