// Eliseusb.com 'n Metaora.com.br
// Creative Tecnology
// http://www.minimodetalhe.com.br
// web@metaora.com.br
// Copyright eliseusb.com/metaora.com.br/approved partners

// FUNÇÕES ESTÁTICAS PARA TROCAR MAPAS DA HOME
function mparceiro(){
	document.getElementById('setaX').style.marginTop='34px';
	document.getElementById('mp01').style.zIndex='876';
	document.getElementById('mp02').style.zIndex='866';
	document.getElementById('mp03').style.zIndex='856';
}
function mestagiario(){
	document.getElementById('setaX').style.marginTop='140px';
	document.getElementById('mp01').style.zIndex='866';
	document.getElementById('mp02').style.zIndex='876';
	document.getElementById('mp03').style.zIndex='856';
}
function mescritorio(){
	document.getElementById('setaX').style.marginTop='247px';
	document.getElementById('mp01').style.zIndex='866';
	document.getElementById('mp02').style.zIndex='856';
	document.getElementById('mp03').style.zIndex='876';
}

// ESSA É TRETA, NÃO IMPRIME O LINK NO CÓDIGO, SÓ NO FRONT-END PRO USUÁRIO, AMENIZA SPAM UHUU
usuario="contato"
dominio="advogadosparceiros.com.br"
conector="@"
function dar_correio(){
   return usuario + conector + dominio
} function eliseusbPontoCom(){
   document.write("<a title='Contato via e-mail' href='mailto:" + dar_correio() + "?subject=Contato pelo site'>" + dar_correio() + "</a>")
} // A TRETA ACABA AQUI


//---> Formatação genérica telefone. eliseu@
function Formata_Telefone(objeto,tammax,teclapres)
{
	var tecla = teclapres.keyCode;
	vr = objeto.value;
	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 <= 4 ) { 
			objeto.value = vr ;
		}
		if ( (tam > 4) && (tam <= 8) ) {
			objeto.value = vr.substr(0,tam-4) + '-' + vr.substr( tam - 4, tam ) ;
		}
		if ( (tam >= 9) && (tam <= 10) ) {
			objeto.value = '(' + vr.substr(0,2) + ') ' + vr.substr(2,tam-6) + '-' + vr.substr(tam-4,tam) ;			
		}
	}		
}

//---> Cria máscaras personalizadas ao critério do desenvolvedor, ex: formatar_mascara(this, '####-####'). eliseu@
function formatar_mascara(src, mascara) {
	var campo = src.value.length;
	var saida = mascara.substring(0,1);
	var texto = mascara.substring(campo);
	if(texto.substring(0,1) != saida) {
		src.value += texto.substring(0,1);
	}
}

//---> Encerra tecla enter dentro de formulário. eliseu@
function para(){
if(navigator.appName == 'Microsoft Internet Explorer') {
			if(event.keyCode=="13"){
			event.keyCode=0;
			return false;
		}
	}
else {
	if(navigator.appName == 'Netscape') {
			if(event.wich=="13"){
			event.wich=0;
			return false;
		}
	}
	}
}

//---> Máscaras genéricas. jonatas@
function Mascara(tipo, campo, teclaPress) {
        if (window.event)
        {
                var tecla = teclaPress.keyCode;
        } else {
                tecla = teclaPress.which;
        }
 
        var s = new String(campo.value);
        // Remove todos os caracteres à seguir: ( ) / - . e espaço, para tratar a string denovo.
        s = s.replace(/(\.|\(|\)|\/|\-| )+/g,'');
 
        tam = s.length + 1;
 
        if ( tecla != 9 && tecla != 8 ) {
                switch (tipo)
                {
                case 'CPF' :
                        if (tam > 3 && tam < 7)
                                campo.value = s.substr(0,3) + '.' + s.substr(3, tam);
                        if (tam >= 7 && tam < 10)
                                campo.value = s.substr(0,3) + '.' + s.substr(3,3) + '.' + s.substr(6,tam-6);
                        if (tam >= 10 && tam < 12)
                                campo.value = s.substr(0,3) + '.' + s.substr(3,3) + '.' + s.substr(6,3) + '-' + s.substr(9,tam-9);
                break;
 
                case 'CNPJ' :
 
                        if (tam > 2 && tam < 6)
                                campo.value = s.substr(0,2) + '.' + s.substr(2, tam);
                        if (tam >= 6 && tam < 9)
                                campo.value = s.substr(0,2) + '.' + s.substr(2,3) + '.' + s.substr(5,tam-5);
                        if (tam >= 9 && tam < 13)
                                campo.value = s.substr(0,2) + '.' + s.substr(2,3) + '.' + s.substr(5,3) + '/' + s.substr(8,tam-8);
                        if (tam >= 13 && tam < 15)
                                campo.value = s.substr(0,2) + '.' + s.substr(2,3) + '.' + s.substr(5,3) + '/' + s.substr(8,4)+ '-' + s.substr(12,tam-12);
                break;
 
                case 'TEL' :
                        if (tam > 2 && tam < 4)
                                campo.value = '(' + s.substr(0,2) + ') ' + s.substr(2,tam);
                        if (tam >= 7 && tam < 11)
                                campo.value = '(' + s.substr(0,2) + ') ' + s.substr(2,4) + '-' + s.substr(6,tam-6);
                break;
 
                case 'DATA' :
                        if (tam > 2 && tam < 4)
                                campo.value = s.substr(0,2) + '/' + s.substr(2, tam);
                        if (tam > 4 && tam < 11)
                                campo.value = s.substr(0,2) + '/' + s.substr(2,2) + '/' + s.substr(4,tam-4);
                break;
				
				case 'HORA' :
                        if (tam > 2 && tam < 4)
                                campo.value = s.substr(0,2) + ':' + s.substr(2, tam);
                break;
                
                case 'CEP' :
                        if (tam > 5 && tam < 7)
                                campo.value = s.substr(0,5) + '-' + s.substr(5, tam);
                break;
                }
        }
}

//---> SOMENTE CARACTERES NUMÉRICOS. jonatas@
function digitos(event){
        if (window.event) {
                // IE
                key = event.keyCode;
        } else if ( event.which ) {
                // NAVEGADORES ANTIGOS
                key = event.which;
        }
        if ( key != 8 || key != 13 || key < 48 || key > 57 )
                return ( ( ( key > 47 ) && ( key < 58 ) ) || ( key == 8 ) || ( key == 13 ) );
        return true;
}

//---> ADICIONAR AOS FAVORITOS CROSSBROWSER. eliseu@

// ALTERA TAMANHO DA FONTE. google@
function changethefont(changeinsize) {
	var sizevalue=document.getElementById('story').style.fontSize;
	var currentsize=parseInt(sizevalue);
	if (!currentsize) {
		currentsize=12;
	}
	var newsize=currentsize+changeinsize;
	if (!newsize) {
		newsize=0;
	}
	if (newsize < 7) {
		newsize=7;
	}
	if (newsize > 16){
		newsize=16;
	}
	if (document.all) {
	   if (document.getElementById('story')) {
	   		document.getElementById('story').style.fontSize=newsize+"px";
	   }
	   if (document.getElementById('pre')) {
	   		document.getElementById('pre').style.fontSize=newsize+"px";
	   }
	} else if(document.getElementById) {
	   if (document.getElementById('story')) {
	   		document.getElementById('story').style.fontSize=newsize+"px";
	   }
	   if (document.getElementById('pre')) {
	   		document.getElementById('pre').style.fontSize=newsize+"px";
	   }
	} 
}

function toggle(id){
	document.getElementById(id).style.display = (document.getElementById(id).style.display == 'block') ? 'none' : 'block';
}

function readytoroll() {
		
}
function changethefontRestaurar() {
	document.getElementById('story').style.fontSize='13px';
}

function cxMensagem(mensagem) {
	(function($){
	$.prompt(''+ mensagem +'',{ buttons:{ Fechar:1},prefix:'colsJqi'}).children('#colsJqi');
	})(jQuery); /*Declara-se jQuery para resolver BUG quando utilizada junto a outras bibliotecas */
}

/*Formatacao moeda - Jonatas*/
function FormataValor(id,tammax,teclapres) {
    
        if(window.event) { // Internet Explorer
         var tecla = teclapres.keyCode; }
        else if(teclapres.which) { // Nestcape / firefox
         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 ClickHereToPrint(){
	try{
		var oIframe = document.getElementById('ifrmPrint');
		var oContent = document.getElementById('divToPrint').innerHTML;
		var oDoc = (oIframe.contentWindow || oIframe.contentDocument);
		if (oDoc.document) oDoc = oDoc.document;
		oDoc.write("<head><title>title</title>");
		oDoc.write("</head><body onload='this.focus(); this.print();'>");
		oDoc.write(oContent + "</body>");
		oDoc.close();
		}
		catch(e){
		self.print();
	}
}

function printDivxx(id, pg) {
	var oPrint, oJan;
	oPrint = window.document.getElementById(id).innerHTML;
	oJan = window.open(pg);
	oJan.document.write(oPrint);
	oJan.window.print();
       oJan.document.close();
       oJan.focus();
}

function cxMensagem(mensagem) {
	(function($){
	$.prompt(''+ mensagem +'',{ buttons:{ Fechar:1},prefix:'colsJqi'}).children('#colsJqi');
	})(jQuery);
}

