var domain = document.domain;
if (domain == '192.168.0.200') domain += '/dev/adote.org.br';
else if (domain == 'www.magicwebdesign.com.br') domain += '/dev/adote';
else domain = 'www.adote.org.br';

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_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_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 validaemail(email) {
  var objRegExp  = /^([\w-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([\w-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/i;
  return objRegExp.test(email);
}

function envia(param) {
  if (param == 1) {
    if (document.f1.nome.value.length < 3) {
      alert("Preencha o campo NOME!");
      document.f1.nome.focus();
    }
    else {
      if (!validaemail(document.f1.emai.value)) {
        alert("Preencha o campo E-MAIL!");
              document.f1.emai.focus();
      }
      else {
        document.f1.submit();
      }
    }
  }
  else if (param == 2) {
    if (!validaemail(document.f2.emai.value)) {
      alert("Preencha o campo E-MAIL!");
      document.f2.emai.focus();
    }
    else {
      document.f2.submit();
    }
  }
  else if ( param == 3 ) {
    if (document.f1.nome.value.length < 3) {
        alert("Preencha o campo CONTATO!");
        document.f1.nome.focus();
    }
    else if (!validaemail(document.f1.emai.value)) {
        alert("Preencha o campo E-MAIL!");
        document.f1.emai.focus();
    }
    else if ( ! validaCPF( document.f1.cpf.value ) )
    {
        alert("Preencha corretamente o campo CPF!");
        document.f1.cpf.focus();
    }
    else if ( ! validaCNPJ( document.f1.cnpj.value ) )
    {
        alert("Preencha corretamente o campo CNPJ!");
        document.f1.cnpj.focus();
    }
    else if ( document.f1.mensagem.value.length < 3 ){
        alert("Preencha o campo MENSAGEM!");
        document.f1.mensagem.focus();
    } else {
        document.f1.submit();
    }
  } 
  else if ( param == 4 ) {
    if (document.f2.nome.value.length < 3) {
        alert("Preencha o campo CONTATO!");
        document.f2.nome.focus();
    }
    else if (!validaemail(document.f2.emai_juridica.value)) {
        alert("Preencha o campo E-MAIL!");
        document.f2.emai_juridica.focus();
    }
     else {
        document.f2.submit();
    }
  }
  
}

function abre_popup(foto) {
  window.open('foto.htm?'+foto,'imagem','width=100, height=100, status=no');
}

var res = screen.height;
	if (res <= 600)
	{
		document.write('<style type="text/css">#geral{min-height:91%;_height:91%;}<\/style>')
	}
	else if ( res == 768 )
	{
		document.write('<style type="text/css">#geral{min-height:92%;_height:92%;}<\/style>')
	}
	else if ( res == 864 )
	{
		document.write('<style type="text/css">#geral{min-height:93%;_height:93%;}<\/style>')
	}
	else if ( res == 1024 )
	{
		document.write('<style type="text/css">#geral{min-height:95%;_height:95%;}<\/style>')
	}
	else if ( res == 1200 )
	{
		document.write('<style type="text/css">#geral{min-height:96%;_height:96%;}<\/style>')
	}
	else
	{
		document.write('<style type="text/css">#geral{min-height:97%;_height:97%;}<\/style>')
	}

/*
    COMO USAR
    EX: onkeypress="return Mascaras ( event, 'FONE', 'nome_id' );"
*/
function Mascaras ( e, formato, objeto )
{
    var key;

    if ( window.event ) keyPressed = window.event.keyCode; // IE hack
    else keyPressed = e.which; // <B>standard method</B>

    if ( keyPressed >= 48 && keyPressed <= 57 )
    {
        var campo = document.getElementById(objeto);
        
        /*
            DATA
            FORMATO: 00/00/0000
        */
        if ( formato == 'DATA' )
        {
            separador = '/'; 
            conjunto1 = 2;
            conjunto2 = 5;
            if ( campo.value.length == conjunto1 )
                campo.value = campo.value + separador;
            
            if ( campo.value.length == conjunto2 )
                campo.value = campo.value + separador;
            
            return true;
        }
        
        /*
            HORA
            FORMATO: 00:00
        */
        if (formato == 'HORA')
        {
            separador = ':';
            conjunto1 = 2;
            if ( campo.value.length == conjunto1 )
                campo.value = campo.value + separador;
            
            return true;
        }
        
        /*
            CEP
            FORMATO: 00000-000
        */
        if (formato == 'CEP')
        {
            separador = '-';
            conjunto1 = 5;
            if (    campo.value.length == conjunto1 )
                campo.value = campo.value + separador;
            
            return true;
        } 
        
        /*
            CPF
            FORMATO: 000.000.000-00
        */
        if (formato == 'CPF')
        {
            separador = '.';
            separador1 = '-';
            conjunto1 = 3;
            conjunto2 = 7;
            conjunto3 = 11;
            if ( campo.value.length == conjunto1 )
                campo.value = campo.value + separador;

            if ( campo.value.length == conjunto2 )
                campo.value = campo.value + separador;

            if ( campo.value.length == conjunto3 )
                campo.value = campo.value + separador1;
            
            return true;
        }
        
        /*
            CNPJ
            FORMATO: 00.000.000/0000-00
        */
        if (formato == 'CNPJ')
        {
            separador1 = '.';
            separador2 = '/';
            separador3 = '-';
            conjunto1 = 2;
            conjunto2 = 6;
            conjunto3 = 10;
            conjunto4 = 15;
            if ( campo.value.length == conjunto1 )
                campo.value = campo.value + separador1;
            
            if ( campo.value.length == conjunto2 )
                campo.value = campo.value + separador1;
            
            if ( campo.value.length == conjunto3 )
                campo.value = campo.value + separador2;
            
            if ( campo.value.length == conjunto4 )
                campo.value = campo.value + separador3;
            
            return true;
        }
        
        /*
            FONE
            FORMATO: (00) 0000-0000
        */
        if ( formato == 'FONE' )
        {
            separador1 = '(';
            separador2 = ') ';
            separador3 = '-';
            conjunto1 = 0;
            conjunto2 = 3;
            conjunto3 = 9;
            if ( campo.value.length == conjunto1 )
                campo.value = campo.value + separador1;
            
            if ( campo.value.length == conjunto2 )
                campo.value = campo.value + separador2;
            
            if ( campo.value.length == conjunto3 )
                campo.value = campo.value + separador3;
            
            return true;
        }
        
        /*
            FONE2
            FORMATO: 0000-0000
        */
        if ( formato == 'FONESIMPLES' )
        {
            separador1 = '-';
            conjunto1 = 4;
            if ( campo.value.length == conjunto1 )
                campo.value = campo.value + separador1;
            
            return true;
        }
    }
    else if ( keyPressed == 8 || keyPressed == 13 || keyPressed == 0 )
        return true;
    else
        return false;
}

/*
    COMO USAR
    EX: onkeypress="return TextoSimples ( event );"
*/
function TextoSimples ( e )
{
    if ( window.event ) keyPressed = window.event.keyCode; // IE hack
    else keyPressed = e.which; // <B>standard method</B>

    if ( keyPressed == 8 || keyPressed == 95  || keyPressed == 13  || keyPressed == 0 ) return true;
    else if ( ( keyPressed >= 48 && keyPressed <= 57 ) || (keyPressed > 96 && keyPressed < 123) || keyPressed == 95 ) return true;
    else if ( ( keyPressed > 191 && keyPressed < 221 ) || ( keyPressed > 223 && keyPressed < 253 ) ) return true;
    
    return false;
}

/*
    COMO USAR
    EX: onkeypress="return Numeros ( event );"

function Numeros ( e )
{
    if ( window.event ) keyPressed = window.event.keyCode; // IE hack
    else keyPressed = e.which; // <B>standard method</B>
    
    if ( keyPressed == 8 || keyPressed == 13 || keyPressed == 0 ) return true;
    else if ( keyPressed >= 48 && keyPressed <= 57 ) return true;
              
    return false;
}

/*calculo meld*/
function calculaMELD(){
		creatina = document.meldform.creatina.value.replace(',','.');
		bilirrubina = document.meldform.bilirrubina.value.replace(',','.');
		inr = document.meldform.inr.value.replace(',','.');

		if (document.meldform.dialise.checked==true) creatina=4;
		if (creatina<1) creatina=1;
		if (bilirrubina<1) bilirrubina=1;
		if (inr<1) inr=1;
		if (creatina>4) creatina=4;

		meld = Math.round(10*(0.957*Math.log(creatina) + 0.378*Math.log(bilirrubina) + 1.120*Math.log(inr) + 0.643));
	
		return meld;
	}
	
	function isNumber(v){
		v = v.replace(',','.')
		return !isNaN(v);
	}

	function checkformMELD(){
		ok = true;
		
		if (!isNumber(document.meldform.creatina.value)|| document.meldform.creatina.value == "" ) ok=false;
		if (!isNumber(document.meldform.bilirrubina.value) || document.meldform.bilirrubina.value == "" ) ok=false;		
		if (!isNumber(document.meldform.inr.value)|| document.meldform.inr.value == "" ) ok=false;				
		
		return ok;
	}

	
	function MELD(){

		if (checkformMELD()){
			MELDvalue=calculaMELD();
			str = 'MELD = ' + MELDvalue;			
		}
		else{
			str = 'Um ou mais campos não foram preenchidos corretamente.';
		}

		document.getElementById('win').style.top = '100px';
		document.getElementById('win').style.display = '';
		document.getElementById('result').innerHTML	= str;	
		return true;
	}

	function fechar(){
		document.getElementById('win').style.display='none';
	}
/*calcula peld*/

var altura = new Array(73);
		var peso = new Array(73);	
		var alturaf = new Array(73);
		var pesof = new Array(73);	
		
		altura[0] = 46.0200;
		altura[1] = 55.8000;
		altura[2] = 62.4000;
		altura[3] = 67.0200;
		altura[4] = 70.7000;
		altura[5] = 73.7000;
		altura[6] = 76.3200;
		altura[7] = 78.6400;
		altura[8] = 79.2400;
		altura[9] = 81.3800;
		altura[10] = 83.3600;
		altura[11] = 85.3600;
		altura[12] = 87.2800;
		altura[13] = 89.1400;
		altura[14] = 91.0000;
		altura[15] = 92.6800;
		altura[16] = 94.3800;
		altura[17] = 96.0800;
		altura[18] = 97.7200;
		altura[19] = 99.2600;
		altura[20] = 100.7000;
		altura[21] = 102.1600;
		altura[22] = 103.6200;
		altura[23] = 105.0000;
		altura[24] = 106.3800;
		altura[25] = 107.6600;
		altura[26] = 109.0400;
		altura[27] = 110.2200;
		altura[28] = 111.5000;
		altura[29] = 112.6800;
		altura[30] = 113.9600;
		altura[31] = 115.1400;
		altura[32] = 116.3000;
		altura[33] = 117.4600;
		altura[34] = 118.6000;
		altura[35] = 119.7200;
		altura[36] = 120.8400;
		altura[37] = 121.9600;
		altura[38] = 123.0400;
		altura[39] = 124.1200;
		altura[40] = 125.2800;
		altura[41] = 126.4000;
		altura[42] = 127.5200;
		altura[43] = 128.7200;
		altura[44] = 129.8800;
		altura[45] = 131.0200;
		altura[46] = 132.2400;
		altura[47] = 133.4200;
		altura[48] = 134.6800;
		altura[49] = 135.8600;
		altura[50] = 137.1600;
		altura[51] = 138.5800;
		altura[52] = 139.9400;
		altura[53] = 141.3600;
		altura[54] = 142.8800;
		altura[55] = 144.3600;
		altura[56] = 145.9800;
		altura[57] = 147.6800;
		altura[58] = 149.4000;
		altura[59] = 151.1200;
		altura[60] = 152.8800;
		altura[61] = 154.6000;
		altura[62] = 156.2400;
		altura[63] = 157.7800;
		altura[64] = 159.1200;
		altura[65] = 160.4200;
		altura[66] = 161.5800;
		altura[67] = 162.4600;
		altura[68] = 163.0600;
		altura[69] = 163.4600;
		altura[70] = 163.6600;
		altura[71] = 163.7200;
		altura[72] = 163.6000;
	
		peso[0] = 2.4800;
		peso[1] = 4.1000;
		peso[2] = 5.8400;
		peso[3] = 7.2600;
		peso[4] = 8.1600;
		peso[5] = 8.7200;
		peso[6] = 9.1400;
		peso[7] = 9.4800;
		peso[8] = 9.6400;
		peso[9] = 10.1000;
		peso[10] = 10.5800;
		peso[11] = 11.0800;
		peso[12] = 11.4000;
		peso[13] = 11.8200;
		peso[14] = 12.1600;
		peso[15] = 12.5200;
		peso[16] = 12.9000;
		peso[17] = 13.2800;
		peso[18] = 13.6800;
		peso[19] = 14.0600;
		peso[20] = 14.4600;
		peso[21] = 14.8600;
		peso[22] = 15.2600;
		peso[23] = 15.6600;
		peso[24] = 16.0400;
		peso[25] = 16.4000;
		peso[26] = 16.7600;
		peso[27] = 17.2200;
		peso[28] = 17.6400;
		peso[29] = 17.9400;
		peso[30] = 18.3200;
		peso[31] = 18.7800;
		peso[32] = 19.1000;
		peso[33] = 19.5000;
		peso[34] = 19.8600;
		peso[35] = 20.2000;
		peso[36] = 20.5200;
		peso[37] = 20.9000;
		peso[38] = 21.2800;
		peso[39] = 21.7400;
		peso[40] = 22.1000;
		peso[41] = 22.6400;
		peso[42] = 23.0800;
		peso[43] = 23.6000;
		peso[44] = 24.1400;
		peso[45] = 24.7800;
		peso[46] = 25.4000;
		peso[47] = 26.0600;
		peso[48] = 26.8200;
		peso[49] = 27.5800;
		peso[50] = 28.4600;
		peso[51] = 29.3800;
		peso[52] = 30.4000;
		peso[53] = 31.4400;
		peso[54] = 32.5200;
		peso[55] = 33.7200;
		peso[56] = 34.9400;
		peso[57] = 36.1800;
		peso[58] = 37.4400;
		peso[59] = 38.6200;
		peso[60] = 39.9400;
		peso[61] = 41.1600;
		peso[62] = 42.4000;
		peso[63] = 43.5400;
		peso[64] = 44.7200;
		peso[65] = 45.8000;
		peso[66] = 46.8000;
		peso[67] = 47.7200;
		peso[68] = 48.5400;
		peso[69] = 49.2800;
		peso[70] = 49.9400;
		peso[71] = 50.4800;
		peso[72] = 50.9400;
	
		alturaf[0] = 45.5600;
		alturaf[1] = 54.5200;
		alturaf[2] = 60.6200;
		alturaf[3] = 64.9400;
		alturaf[4] = 68.6200;
		alturaf[5] = 71.9000;
		alturaf[6] = 74.7600;
		alturaf[7] = 77.4400;
		alturaf[8] = 78.0000;
		alturaf[9] = 80.2800;
		alturaf[10] = 82.4200;
		alturaf[11] = 84.5200;
		alturaf[12] = 86.4800;
		alturaf[13] = 88.3200;
		alturaf[14] = 90.1200;
		alturaf[15] = 91.9000;
		alturaf[16] = 93.5600;
		alturaf[17] = 95.1000;
		alturaf[18] = 96.6000;
		alturaf[19] = 98.1000;
		alturaf[20] = 99.5800;
		alturaf[21] = 100.9400;
		alturaf[22] = 102.2800;
		alturaf[23] = 103.5200;
		alturaf[24] = 104.7600;
		alturaf[25] = 106.0800;
		alturaf[26] = 107.2000;
		alturaf[27] = 108.4000;
		alturaf[28] = 109.6200;
		alturaf[29] = 110.8400;
		alturaf[30] = 111.9600;
		alturaf[31] = 113.0800;
		alturaf[32] = 114.3200;
		alturaf[33] = 115.4600;
		alturaf[34] = 116.7200;
		alturaf[35] = 118.0000;
		alturaf[36] = 119.1800;
		alturaf[37] = 120.4800;
		alturaf[38] = 121.8200;
		alturaf[39] = 123.2600;
		alturaf[40] = 124.6400;
		alturaf[41] = 126.1400;
		alturaf[42] = 127.6600;
		alturaf[43] = 129.2200;
		alturaf[44] = 130.9200;
		alturaf[45] = 132.6400;
		alturaf[46] = 134.4000;
		alturaf[47] = 136.1800;
		alturaf[48] = 137.8600;
		alturaf[49] = 139.5400;
		alturaf[50] = 141.1200;
		alturaf[51] = 142.5000;
		alturaf[52] = 143.7400;
		alturaf[53] = 144.8600;
		alturaf[54] = 145.6600;
		alturaf[55] = 146.4600;
		alturaf[56] = 147.0200;
		alturaf[57] = 147.4000;
		alturaf[58] = 147.7600;
		alturaf[59] = 148.0400;
		alturaf[60] = 148.3200;
		alturaf[61] = 148.5200;
		alturaf[62] = 148.6400;
		alturaf[63] = 148.7600;
		alturaf[64] = 149.0800;
		alturaf[65] = 149.4000;
		alturaf[66] = 149.6600;
		alturaf[67] = 150.0200;
		alturaf[68] = 150.3000;
		alturaf[69] = 150.7200;
		alturaf[70] = 151.1200;
		alturaf[71] = 151.5000;
		alturaf[72] = 151.7800;
	
		pesof[0] = 2.2000;
		pesof[1] = 3.9200;
		pesof[2] = 5.4600;
		pesof[3] = 6.6600;
		pesof[4] = 7.4000;
		pesof[5] = 7.9600;
		pesof[6] = 8.4600;
		pesof[7] = 8.9800;
		pesof[8] = 9.4600;
		pesof[9] = 9.8800;
		pesof[10] = 10.3200;
		pesof[11] = 10.7800;
		pesof[12] = 11.1400;
		pesof[13] = 11.5200;
		pesof[14] = 11.9200;
		pesof[15] = 12.2000;
		pesof[16] = 12.6000;
		pesof[17] = 12.8800;
		pesof[18] = 13.1800;
		pesof[19] = 13.4600;
		pesof[20] = 13.8400;
		pesof[21] = 14.1000;
		pesof[22] = 14.4400;
		pesof[23] = 14.6800;
		pesof[24] = 14.9800;
		pesof[25] = 15.2800;
		pesof[26] = 15.6400;
		pesof[27] = 15.9800;
		pesof[28] = 16.3000;
		pesof[29] = 16.6800;
		pesof[30] = 17.1200;
		pesof[31] = 17.4400;
		pesof[32] = 17.8400;
		pesof[33] = 18.3200;
		pesof[34] = 18.7800;
		pesof[35] = 19.2400;
		pesof[36] = 19.7600;
		pesof[37] = 20.2000;
		pesof[38] = 20.8200;
		pesof[39] = 21.3400;
		pesof[40] = 21.8600;
		pesof[41] = 22.4800;
		pesof[42] = 23.1200;
		pesof[43] = 23.7600;
		pesof[44] = 24.5000;
		pesof[45] = 25.1800;
		pesof[46] = 25.8600;
		pesof[47] = 26.6600;
		pesof[48] = 27.4000;
		pesof[49] = 28.2600;
		pesof[50] = 29.0200;
		pesof[51] = 29.9600;
		pesof[52] = 30.8000;
		pesof[53] = 31.6800;
		pesof[54] = 32.5800;
		pesof[55] = 33.4000;
		pesof[56] = 34.2600;
		pesof[57] = 35.0400;
		pesof[58] = 35.8800;
		pesof[59] = 36.6200;
		pesof[60] = 37.4000;
		pesof[61] = 38.1200;
		pesof[62] = 38.7600;
		pesof[63] = 39.3400;
		pesof[64] = 39.8600;
		pesof[65] = 40.3000;
		pesof[66] = 40.6600;
		pesof[67] = 41.0600;
		pesof[68] = 41.3600;
		pesof[69] = 41.5600;
		pesof[70] = 41.7800;
		pesof[71] = 41.9800;
		pesof[72] = 42.0800;	

	
	function calculaPELD(){
		albumina = document.peldform.albumina.value.replace(',','.');
		bilirrubina = document.peldform.bilirrubina.value.replace(',','.');
		inr = document.peldform.inr.value.replace(',','.');
				
		idade = document.peldform.idade.value;
		peso_inf = document.peldform.peso.value;
		altura_inf = document.peldform.altura.value;
	
		sexo = 'masculino';
		if (document.peldform.sexo[1].checked) sexo='feminino';
		
		i = Math.floor(idade / 3);
		
		if (i>72) i=72;
		
		deficit = false;
		if (sexo=='masculino')
			if ((altura_inf<=altura[i]) || (peso_inf<=peso[i])) deficit=true;
		else
			if ((altura_inf<=alturaf[i]) || (peso_inf<=pesof[i])) deficit=true;				
		
		if (albumina<1) albumina=1;
		if (bilirrubina<1) bilirrubina=1;

		peld = 0.378*Math.log(bilirrubina) + 1.857*Math.log(inr) - 0.687*Math.log(albumina);
		
		if (idade<=24) peld = peld + 0.436;
		if (deficit) peld = peld + 0.667;
		
		peld = Math.round(10*peld);
				
		return peld;
	}
	
	function isNumber(v){
		v = v.replace(',','.')
		return !isNaN(v);
	}

	function checkformPELD(){
		ok = true;
		
		if (!document.peldform.sexo[1].checked && !document.peldform.sexo[0].checked) ok=false;
		if (!isNumber(document.peldform.albumina.value)) ok=false;
		if (!isNumber(document.peldform.bilirrubina.value)) ok=false;		
		if (!isNumber(document.peldform.inr.value)) ok=false;				
		if (!isNumber(document.peldform.idade.value)) ok=false;	
		if (!isNumber(document.peldform.peso.value)) ok=false;
		if (!isNumber(document.peldform.altura.value)) ok=false;
		
		return ok;
	}

	function PELD(){

		if (checkformPELD()){
			PELDvalue=calculaPELD();
			str = 'PELD = ' + PELDvalue;	
		}
		else{
			str = 'Um ou mais campos não foram preenchidos corretamente.';
		}

		document.getElementById('win').style.top = '150px';
		document.getElementById('win').style.display = '';
		document.getElementById('result').innerHTML	= str;	
		return true;
	}
	
	function fechar(){
		document.getElementById('win').style.display='none';
	}

/* Mascaras */
formataCampo = function ( tecla, obj, tipo ) {
  var key;
  var keyNum;
  if ( navigator.userAgent.indexOf( "MSIE" ) > 0 ) key = tecla.keyCode;
  if ( navigator.userAgent.indexOf( "Gecko" ) > 0 ) key = tecla.which;
  if ( ( key == 8 ) || ( key == 0 ) ) return true;
  keyNum = key;
  key = String.fromCharCode(key);

  if ( tipo == 'numero' || tipo == 'dotnum' )
    var erNum = /[0-9\,\.]/i;
  else if ( tipo == 'minifone' )
    var erNum = /[0-9\-]/i;
  else
    var erNum = /[0-9]/i;

  if (erNum.test(key)) {
    /**** MINI FONE ****/
    if (tipo == 'minifone') {
      if ( key == '-' )
      {
        if ( strpos ( obj.value, '-') !== false )
          return false;
        else
        {
          obj.value += "-";
          return false;
        }
      }
      return true; }
      
    /**** NÚMERO ****/
    if (tipo == 'numero') {
      if ( key == "," || key == "." )
      {
        if ( strpos ( obj.value, ',') !== false )
          return false;
        else
        {
          obj.value += ",";
          return false;
        }
      }
      return true; }
      
    /**** NÚMERO COM SEPARADOR ESTILO PONTO "." ****/
    if (tipo == 'dotnum') {
      if ( key == "." || key == "," )
      {
        if ( strpos ( obj.value, '.') !== false )
          return false;
        else
        {
          obj.value += ".";
          return false;
        }
      }
      return true; }
      
    /**** CEP ****/
    if (tipo == 'cep') {
      if (obj.value.length == 4) { obj.value = obj.value + key + '-'; return false; }
      else return true;

    /**** CPF ****/
    } else if (tipo == 'cpf') {   
      if ((obj.value.length == 2) || (obj.value.length == 6)) { obj.value = obj.value + key + '.'; return false; }
      else if (obj.value.length == 10) { obj.value = obj.value + key + '-'; return false; }
      else if (obj.value.length > 13) { return false }
      else return true;

    /**** Fone ****/
    } else if (tipo == 'fone') {
      if ((obj.value.length == 0)) { obj.value = '(' + key ; return false; }
      else if (obj.value.length == 2) { obj.value = obj.value + key + ') '; return false; }
      else if (obj.value.length == 8) { obj.value = obj.value + key + '-'; return false; }
      else return true;


    /**** Fone2 ****/
    } else if (tipo == 'fone2') {
      if ((obj.value.length == 0)) { obj.value = '(' + key ; return false; }
      else if (obj.value.length == 2) { obj.value = obj.value + key + ') '; return false; }
      else if (obj.value.length == 8) { obj.value = obj.value + key + '-'; return false; }
      else return true;

    /**** CNPJ ****/
    } else if (tipo == 'cnpj') {
      if ((obj.value.length == 1) || (obj.value.length == 5)) { obj.value = obj.value + key + '.'; return false; }
      else if (obj.value.length == 9) { obj.value = obj.value + key + '/'; return false; }
      else if (obj.value.length == 14) { obj.value = obj.value + key + '-'; return false; }
      else return true;

    /**** MOEDA ****/
    } else if (tipo == 'moeda') {
        
        objTextBox = obj ;
        SeparadorMilesimo = '' ;
        SeparadorDecimal = '.' ;
        e = tecla ;
            //-----------------------------------------------------
            //Funcao: MascaraMoeda
            //Autor: Gabriel Fróes
            //-----------------------------------------------------
            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;
            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;        
        
    /**** DATA ****/
    } else if (tipo == 'data') {
      if ((obj.value.length == 1) || (obj.value.length == 4)) { obj.value = obj.value + key + '/'; return false; }
      else return true;

    /**** HORA ****/
    } else if (tipo == 'hora') {
      if (obj.value.length == 1) { obj.value = obj.value + key + ':'; return false; }
      else return true;

    } else { return false; }
  } else if ( keyNum == 13 ) {
    return true;
  }
  else return false;
}
/*
	GALERIA DE FOTOS PREMIAÇÃO ADOTE
*/
var div = new Array();
div[0] = 's1';
div[1] = 's2';
div[2] = 's3';
div[3] = 's4';
div[4] = 's5';
var qtde = 5;
			
function abreFotoGaleria(galer_id, foto,imagemOriginal)
{
 var regex = new RegExp(foto + '$');
 if (!$('img#galeria_foto').attr('src').match(regex)) {
 $('img#galeria_foto')
 .fadeOut('slow', function() {
 $('span#loading-animation').show();
 var oSrc = this.src, img = null;
 img = $(document.createElement('img'))
 .load(function(){
 $('img#galeria_foto')
 .attr({
 src: this.src,
 oSrc: oSrc,
 alt: foto,
 title: foto
 })
 .fadeIn('slow');
  if(imagemOriginal!="")
  {
  	document.getElementById('linkBaixarImagem').href=_HTTP_PATH_+"baixarImagem.php?imagem="+imagemOriginal;
  	$('div#baixarImagem').show();
  }
  else
  {
  	$('div#baixarImagem').hide();
  }

 $('span#loading-animation').hide()
 })
 .attr('src', ( _HTTP_PATH_ || "") + "img/galeria/" + galer_id + "/" + foto)
 });
 }

}
function show(layer) {
  for (i=0; i<qtde; i++) {
    if (i==layer) {
	  document.getElementById(div[i]).style.display = 'block';
	} else {
	  document.getElementById(div[i]).style.display = 'none';
	}
  }
}

function abre (obj)
{
	var div = document.getElementById(obj);
	
	if(div.style.display=="")
	{
		div.style.display = "none";
	} else {
		$(".esconde_div").hide();
		div.style.display = "";
	}
}