﻿function popAssistencia(url){
    window.open(url , '_blank', 'width=530,height=500,left=50,top=50,scrollbars=yes,resizable=no,menubar=no,toolbar=no');
}

function popAmigo(url){
    window.open('../pop-up/pop_amigo.aspx?destino='+ url, '_blank', 'width=525,height=450,left=50,top=50,scrollbars=no,resizable=no,menubar=no,toolbar=no');
}

function impressao(){
	popimpressao = window.open('', '_blank', 'width=730,height=500,left=0,top=0,scrollbars=yes,resizable=no,menubar=no,toolbar=no');
	var d, s ;
	d = new Date();
	s =  d.getDate()+ ".";
	s += (d.getMonth() + 1) + ".";
	s += d.getFullYear();


	with (popimpressao.document) {
		write('<html><head><title>Imprime</title></head>');
		//write('<link rel="stylesheet" href="../_css/default.css" type="text/css">');
		write('<link href="../_css/print.css" rel="stylesheet" type="text/css">');
		write('<body>');
		//write('<div style="background:#E4E4E4;padding:12px 40px">');
		//write('<img src="../../img/logo_impressao.gif" width="144" height="46" alt="">');
		//write('</div>');
		write('<div style="width:670px;margin:10px 0 0 20px" class="texto_preto" >');
		//write(document.getElementById("areaTopo").innerHTML.replace("100%","720").replace("50%","350").replace("50%",""));
		//write('<div style="height: 1px; width: 690px; background-color:#CCC; display: block;" class="MT10 MB10"><!-- --></div>');
		//alert(document.getElementById("conteudo").innerHTML)
		write(document.getElementById("conteudo").innerHTML.replace("bt_hotsite","pix"));
		//write(document.getElementById("conteudo").innerHTML.replace("texto_2","texto_preto").replace("texto_4","texto_preto").replace("texto_4","texto_preto").replace("texto_5","texto_preto"));
		write('</div>');
		write('<table cellpadding="0" cellspacing="0" border="0" width="670" style="margin:0 0 0 10px;border-top:solid 1px #CCC;"><tr><td class="texto_preto T11">&nbsp;&nbsp;&nbsp;&nbsp;<em>Data: ' + s + '<br>&nbsp;&nbsp;&nbsp;&nbsp;http://www.cfl.com.br/</em></td></tr></table>');
		write('<br></body></html>');
		close();
		}
        popimpressao.print();
}


   function lembraSenha(){
    
        $("#areaLembraSenha").fadeIn("slow");

    } 



 function exibeMSG(msg){
	//alert(msg);
	$("#textoMSG").innerHTML = msg;
	$("#areaMsg").slideDown("slow");
	setTimeout("escondeMSG()",5000)

  }

  function escondeMSG(){
	
	$("#areaMsg").fadeOut("slow");

  }



     // máscara de campos
    // uso: onkeypress="return formata(this, '###.###.###-##', event)"
    function FormataCampo(campo,evt,mask){
		 if(document.all) { // Internet Explorer
			key = evt.keyCode; }
			else{ // Nestcape
			   key = evt.which;
			 }

		if (key == 8) {
		return true;
		}

		 string = campo.value;  
		 i = string.length;

		 if (i < mask.length) {
		  if (mask.charAt(i) == '#') {
			   return (key > 47 && key < 58);
			  } else {
			   if (mask.charAt(i) == '!') {  return true;  }
		   for (c = i; c < mask.length; c++) {
				 if (mask.charAt(c) != '#' && mask.charAt(c) != '!')
				 campo.value = campo.value + mask.charAt(c);
			  else if (mask.charAt(c) == '!'){
						return true;
			   } else {
				 return (key > 47 && key < 58);
				  }
			   }
			}
		  } else return false;
    }


    //Adiciona todos os caracteres que podem ser usados como máscara
    function OrganizaCasa(Campo,arrpos,teclapres_key,strtext){
    if (((arrpos == "/") || (arrpos == ".") || (arrpos == ",") || (arrpos == ":") || (arrpos == " ") || (arrpos == "-")) && !(teclapres_key == 9)){
     separador = arrpos
     masktext = strtext + separador
     Campo.value = masktext
    }
    }
    function DetonaEvent(Campo,strtext){
    event.returnValue = false
    if (strtext != "") {
     Campo.value = strtext
    }
    }

	function limpaCampo(fild, limpa){
		DateValue = fild.value;
		if(DateValue==limpa){
			fild.value = "";
			DateValue = "";

		}
	}

    function check_date(field){
        var checkstr = "0123456789";
        var DateField = field;
        var Datevalue = "";
        var DateTemp = "";
        var seperator = "/";
        var day;
        var month;
        var year;
        var leap = 0;
        var err = 0;
        var i;
		var strDataMsg = "";

        err = 0;
        DateValue = DateField.value;
		
		
		//DateValue = DateValue.replace('dd/mm/aaaa','');

		//alert(DateValue.charAt(2));

		if (DateValue.charAt(2) != "/" || DateValue.charAt(5) != "/")
		{
			 err = 18;
			 strDataMsg = "Verifique o formato da data.";	
		}
		
		if(DateValue.length < 10){
			 err = 40;
			 strDataMsg = "A data informada é inválida.";	
		}

       /* Delete all chars except 0..9 */
       for (i = 0; i < DateValue.length; i++) {
          if (checkstr.indexOf(DateValue.substr(i,1)) >= 0) {
             DateTemp = DateTemp + DateValue.substr(i,1);
          }
       }
       DateValue = DateTemp;
       /* Always change date to 8 digits - string*/
       /* if year is entered as 2-digit / always assume 20xx */
       if (DateValue.length == 6) {
          DateValue = DateValue.substr(0,4) + '20' + DateValue.substr(4,2); }
       if (DateValue.length != 8) {
          err = 19;
		  strDataMsg = "A data informada é inválida.";		  
		}

       /* Validation of day*/
       day = DateValue.substr(0,2);
	   //alert(day);
       if ((day < 1) || (day > 31)) {
         err = 22;
		 strDataMsg = "o dia informado é inválido.";
       }		

		/* Validation of month*/
       month = DateValue.substr(2,2);
       if ((month < 1) || (month > 12)) {
          err = 21;
		  strDataMsg = "O mês informado é inválido.";
       }

       /* year is wrong if year = 0000 */
       year = DateValue.substr(4,4);
       if (year == 0) {
          err = 20;
		  strDataMsg = "O ano informado é inválido.";
       }

       /* Validation leap-year / february / day */
       if ((year % 4 == 0) || (year % 100 == 0) || (year % 400 == 0)) {
          leap = 1;
       }
       if ((month == 2) && (leap == 1) && (day > 29)) {
          err = 23;
		  strDataMsg = "O mês informado possui no máximo 29 dias.";
       }
       if ((month == 2) && (leap != 1) && (day > 28)) {
          err = 24;
		  strDataMsg = "O mês informado possui no máximo 28 dias.";
       }
       /* Validation of other months */
       if ((day > 31) && ((month == "01") || (month == "03") || (month == "05") || (month == "07") || (month == "08") || (month == "10") || (month == "12"))) {
          err = 25;
		  strDataMsg = "O mês informado possui no máximo 31 dias.";
       }
       if ((day > 30) && ((month == "04") || (month == "06") || (month == "09") || (month == "11"))) {
          err = 26;
		  strDataMsg = "O mês informado possui no máximo 30 dias.";
       }
       /* if 00 ist entered, no error, deleting the entry */
       if ((day == 0) && (month == 0) && (year == 00)) {
          err = 0; day = ""; month = ""; year = ""; seperator = "";
       }
       /* if no error, write the completed date to Input-Field (e.g. 13.12.2001) */
       if (err == 0) {
          //DateField.value = day + seperator + month + seperator + year;
          return true;
       }
       else {
          alert(strDataMsg);
		  DateField.value="";
          DateField.select();
          DateField.focus();
          return false;
       }
    }


	function Organiza_Casa(Campo,arrpos,teclapres_key,strtext){
        if (((arrpos == "/") || (arrpos == ".") || (arrpos == ",") || (arrpos == ":") || (arrpos == " ") || (arrpos == "-")) && !(teclapres_key == 9)){
            separador = arrpos
            masktext = strtext + separador
            Campo.value = masktext
        }
    }
    
    function mascara(o,f)
    {
        v_obj=o
        v_fun=f
        setTimeout("execmascara()",1)
    }
    
    function execmascara()
    {
        v_obj.value=v_fun(v_obj.value)
    }

    
    function soNumeros(v){
        v = v.replace(/\D/g,"")
        return v;
    }
    
    // *********************** paginacao *************************
var arrImg=[];
var idImagem = 0;

function PaginaConteudo(op){
	var totalImagens = arrImg.length-1;
	var conteudo = "";
    
    //$("#conteudo").fadeOut("fast");
	document.getElementById("conteudo").style.display = "none";
    
	if(op == 'p'){
		if(idImagem < arrImg.length-1){
			idImagem++;
			conteudo = document.getElementById("conteudoHdd_"+ arrImg[idImagem]).innerHTML;
			document.getElementById("conteudo").innerHTML = conteudo;

		}
	}else{
		if(idImagem>1){
			idImagem--;
			conteudo = document.getElementById("conteudoHdd_"+ arrImg[idImagem]).innerHTML;
			document.getElementById("conteudo").innerHTML = conteudo;
		
		}
	}
	$("#conteudo").fadeIn(450);
	document.getElementById("conteudo").style.display = "block";
	
    try
     {
	    //botão anteriores
	    if (idImagem <= 1)
	    {
		    document.getElementById("butPaginaImgA").style.display = "none";
		    document.getElementById("butPaginaImgA2").style.display = "block";
	    }else{
		    document.getElementById("butPaginaImgA").style.display = "block";
		    document.getElementById("butPaginaImgA2").style.display = "none";
	    }

	    //botão proximas
	    if (idImagem >= totalImagens)
	    {
		    document.getElementById("butPaginaImgP").style.display = "none";
	    }else{
		    document.getElementById("butPaginaImgP").style.display = "block";
	    }
    	
	    document.getElementById("textoPaginacao").innerHTML = arrImg[idImagem] +" de "+ document.getElementById("ctl00_main_hddTotal").value;
	}catch(err)
      {
      //Handle errors here
      }

	//document.getElementById("imagemTotal").innerHTML = "Exibindo de "+ idImagem + " a "+ totalImagens;
}

function abreFoto(id){
    document.getElementById("fotoGrande").src = "../arquivos/imagens/galeriaimagem/"+id+"gra.jpg";
}

function manipulaDivPasseio(idDiv){
    if (eval('document.getElementById(\'' + idDiv + '\').style.display == \'none\''))
        eval('document.getElementById(\'' + idDiv + '\').style.display = \'block\';');
    else
        eval('document.getElementById(\'' + idDiv + '\').style.display = \'none\';');
}
