

var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-20943533-44']);
_gaq.push(['_trackPageview']);

(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();

function dtAtual(){

	momentoAtual = new Date() 
    hora = momentoAtual.getHours() 
    minuto = momentoAtual.getMinutes() 
    segundo = momentoAtual.getSeconds() 

	if(hora <= 9) hora = '0' + hora;
	if(minuto <= 9) minuto = '0' + minuto;
	if(segundo <= 9) segundo = '0' + segundo;
	
    horaImprimivel = hora + " : " + minuto + " : " + segundo
	
	document.getElementById('clock').innerHTML =  horaImprimivel;
	
	setTimeout("dtAtual()", 1000);
}

function local(code){
	
	if(parent.document.getElementById('menu_menu'))
		var io = parent.document.getElementById('menu_menu');
	else
		var io = false;
	
	if(io.contentWindow){
		
		if(io.contentWindow.document.getElementById('local')){
			if(io.contentWindow.document.getElementById('local').innerHTML){
				io.contentWindow.document.getElementById('local').innerHTML = 'Você está em: ' + code;
			}
		}
	
	
	} else if(io.contentDocument){
		
		if(io.contentDocument.document.getElementById('local')){
			if(io.contentDocument.document.getElementById('local').innerHTML){
				io.contentDocument.document.getElementById('local').innerHTML = 'Você está em: ' + code;
			}
		}
	}
	
}

function popUp(url, nome, width, height, params){
	window.open(url, nome, 'width=' + width + ',height=' + height + ',scrollbars=yes,menubar=no' + params);
}

function UpPop(url, nome){
	window.open(url, nome, 'fullscreen=yes,scrollbars=no');
}

function isCheck(obj, url){		
	if(obj.checked)
		location.href = url;		
}

function gtURL(str){
	location.href=str;
}

function mostraDIV(div){
	document.getElementById(div).style.display='block';
}

function escondeDIV(div){
	document.getElementById(div).style.display='none';
}

function setCampo(obj, valor){
	document.getElementById(obj).value=valor;
}

function check(obj){
document.getElementById(obj).checked=true; 
}

function abre_print(id, valor){
	
	var url = '';
	
	switch(valor){
		case 1:
			url = '../relatorios/rel_contrato.php?id=' + id;
			window.top.open('url');
			break
		case 2:
			url = '../relatorios/rel_procuracao.php?id=' + id;
			window.top.open('url');
			break
		case 3:
			url = '../relatorios/rel_notifica_extra_judicial_financia.php?id=' + id;
			window.top.open('url');
			break
		case 4:
			url = '../relatorios/rel_notifica_extra_judicial_leasing.php?id=' + id;
			window.top.open('url');
			break	
		case 5:
			url = '../relatorios/rel_nota_promissoria.php?id=' + id;
			window.top.open('url');
			break	
		case 6:
			url = '../relatorios/rel_contrato.php?id=' + id;
			window.top.open('url');
			break	
	}
}

function checkByParent(aId, aChecked){
    var collection = document.getElementById(aId).getElementsByTagName('INPUT');
    for (var x=0; x<collection.length; x++) {
        if (collection[x].type.toUpperCase()=='CHECKBOX')
            collection[x].checked = aChecked;
    }
}

function FormataValor(id,tammax,teclapres) {

if(window.event)	
	var tecla = teclapres.keyCode;
else if(teclapres.which)
	var tecla = teclapres.which;

	vr = document.getElementById(id).value;
	vr = vr.toString().replace( "/", "" );
	vr = vr.toString().replace( "/", "" );
	vr = vr.toString().replace( ",", "" );
	vr = vr.toString().replace( ".", "" );
	vr = vr.toString().replace( ".", "" );
	vr = vr.toString().replace( ".", "" );
	vr = vr.toString().replace( ".", "" );
	tam = vr.length;

	if (tam < tammax && tecla != 8){ tam = vr.length + 1; }

	if (tecla == 8 ){ tam = tam - 1; }
	
	if ( tecla == 8 || tecla >= 48 && tecla <= 57 || tecla >= 96 && tecla <= 105 ){
	
	if ( tam <= 2 ){
		document.getElementById(id).value = vr; }
	
	if ( (tam > 2) && (tam <= 5) ){
		document.getElementById(id).value = vr.substr( 0, tam - 2 ) + ',' + vr.substr( tam - 2, tam ); }
	
	if ( (tam >= 6) && (tam <= 8) ){
		document.getElementById(id).value = vr.substr( 0, tam - 5 ) + '.' + vr.substr( tam - 5, 3 ) + ',' + vr.substr( tam - 2, tam ); }
	
	if ( (tam >= 9) && (tam <= 11) ){
		document.getElementById(id).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) ){
		document.getElementById(id).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) ){
		document.getElementById(id).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 mensagem(id){
	var name =confirm("Deseja Informar uma Nova Data  para o Vencimento?.");
	
	if (name==true){
		 location.href = 'form_datavencimento.php?id='+id;
	}	else 	{
		 location.href = 'form_serv_calculado.php?id='+id;
	}
	 
	return false;
}

// funções que controla  a Validação do Calculo 
function upcalc(id)
{	
	location.href = '../funcoes/atualiza_calculo.php?st=at&id='+id;
}

function dlcalc(id)
{
	location.href = '../funcoes/deleta_calculo.php?st=dl&id='+id;
}

function upcalc_normal(id)
{
	location.href = '../funcoes/atualiza_calculonormal.php?st=at&id='+id;
}
function dlcalc_normal(id)
{
	location.href = '../funcoes/deleta_calculonormal.php?st=dl&id='+id;
}
