function popblank(pag)
{
	window.open(pag,'_blank','');
}
var urlInst="http://institucional.bradesco.com.br/";
function popup(url,w,h,s) {var oW=window.open(url,'popup','width='+w+',height='+h+',directories=0,location=0,menubar=0,resizable=0,scrollbars='+s+',status=0,toolbar=0,marginleft=0,margintop=0,left='+(((screen.availWidth-w)/2)+-10)+',top='+(((screen.height-h)/2)+-10));return false;}
function pop_solicitacao(host) {
	var url = host;
	var w = '400';
	var h = '414';
	var s = '0';
	if (typeof(host ) !="undefined")
	var oW=window.open(url,'popup','width='+w+',height='+h+',directories=0,location=0,menubar=0,resizable=0,scrollbars='+s+',status=0,toolbar=0,marginleft=0,margintop=0,left='+(((screen.availWidth-w)/2)+-10)+',top='+(((screen.height-h)/2)+-10)
	);
}
function pop_agencia(host) {
	var url = 'consultaAgencia.aspx';
	var w = '400';
	var h = '414';
	var s = '0';
	if (typeof(host ) !="undefined")
		url = host+url;
	var oW=window.open(url,'popup','width='+w+',height='+h+',directories=0,location=0,menubar=0,resizable=0,scrollbars='+s+',status=0,toolbar=0,marginleft=0,margintop=0,left='+(((screen.availWidth-w)/2)+-10)+',top='+(((screen.height-h)/2)+-10)
	);
}
function AbreRede(pag)
{
	switch (pag) 
	{
		case 1:
		{
			local=urlInst+'RedeAtendimento/Index_Pesquisa.asp?pesquisa=Agencia&titulo=Agências';
			break;
		}
		case 2:
		{
			local=urlInst+'RedeAtendimento/Index_Pesquisa.asp?pesquisa=BancoPostal&titulo=Banco Postal';
			break;
		}
		case 3:
		{
			local=urlInst+'RedeAtendimento/Index_Pesquisa.asp?pesquisa=Bdn&titulo=Bradesco Dia&amp;Noite';
			break;
		}
		case 4:
		{
			local=urlInst+'RedeAtendimento/Index_Pesquisa.asp?pesquisa=ChequeExpresso&titulo=Cheque Expresso';
			break;
		}
		case 5:
		{
			local=urlInst+'RedeAtendimento/Index_Pesquisa.asp?pesquisa=Correspondente&titulo=Correspondente Bancário';
			break;
		}
		case 6:
		{
			local=urlInst+'RedeAtendimento/Index_Pesquisa.asp?pesquisa=DriveThru&titulo=Drive Thru';
			break;
		}
		case 7:
		{
			local=urlInst+'RedeAtendimento/Index_Pesquisa.asp?pesquisa=Estrutura&titulo=Estrutura de Atendimento';
			break;
		}
		case 8:
		{
			local=urlInst+'/NetRedeAtendimento/site/content/fone/default.aspx?h=3';
			break;
		}
		case 9:
		{
			local=urlInst+'RedeAtendimento/Index_Pesquisa.asp?pesquisa=WebPoint&titulo=Web Point';
			break;
		}
		default:
			local='/site/content/redirect/redeatend.html';
	}
	
	window.open(local,'_blank','width=790,height=505,top=90,left=50,toolbar=no,copyhistory=no,status=no,menubar=no,scrollbars=1,resizable=no,top=0,left=0');
}
function iecompattest(){return(document.compatMode && document.compatMode!="BackCompat")?document.documentElement:document.body}
function ExibeOcultaComoUsar(op){
	var dsoctop=document.all?iecompattest().scrollTop:pageYOffset;
	document.getElementById("boxComoUsar").style.top=dsoctop+"px";
	if(op=="none"){
		timeC=setTimeout("defVisib('"+op+"')",50);
	}
	else{
		if(typeof(timeC)!='undefined'){
			clearTimeout(timeC);
		}
		defVisib(op);
	}
}
function defVisib(op){
	document.getElementById("boxComoUsar").style.display=op;
}
function AbreRede2(pag)
{
	switch(pag){
		case 0:{local=urlInst+'NetRedeAtendimento/site/content/agencia/default.aspx?h=1';break;}
		case 1:{local=urlInst+'NetRedeAtendimento/site/content/maquina/default.aspx?h=2';break;}
		case 2:{local=urlInst+'NetRedeAtendimento/site/content/fone/default.aspx?h=3';break;}
		case 3:{local=urlInst+'NetRedeAtendimento/site/content/cheque/default.aspx?h=4';break;}
		case 4:{local=urlInst+'NetRedeAtendimento/site/content/drive/default.aspx?h=5';break;}
		case 5:{local=urlInst+'NetRedeAtendimento/site/content/banco/default.aspx?h=6';break;}
		case 6:{local=urlInst+'NetRedeAtendimento/site/content/cambio/default.aspx?h=7';break;}
		case 7:{local=urlInst+'NetRedeAtendimento/site/content/nikkei/default.aspx?h=8';break;}
		case 8:{local=urlInst+'NetRedeAtendimento/site/content/deficientes/default.aspx?h=9';break;}
		default:local=urlInst+'RedeAtendimento/Index_Menu.asp';
	}
	window.open(local,'_blank','width=995,height=505,top=90,left=50,toolbar=no,copyhistory=no,status=no,menubar=no,scrollbars=yes,resizable=no,top=0,left=0');
}
function exibeS(id){
	var doc = document.getElementById(id);
	doc.style.display = "block";
}
function escondeS(id){
	var doc = document.getElementById(id);
	doc.style.display = "none";
}
function exibe(id){
	var doc = document.getElementById(id);
	var op = document.getElementById("opM_"+id);
	op.style.fontWeight = "bold";
	op.style.color = "#F00000";
	doc.style.display = "block";
	hideselect();
}
function esconde(id){
	var doc = document.getElementById(id);
	var op = document.getElementById("opM_"+id);
	op.style.fontWeight = "normal";
	op.style.color = "#000000";
	doc.style.display = "none";
	showselect();
}
function hideselect(){
    var selec = document.getElementsByTagName('SELECT');
    for(var no=0;no<selec.length;no++){
    	selec[no].style.visibility = "hidden";
    }
}
function showselect(){
    var selec = document.getElementsByTagName('SELECT');
    for(var no=0;no<selec.length;no++){
    	selec[no].style.visibility = "";
    }
}
function estilo(est,idest){
	document.getElementById(""+idest+"").className=est;
}
var temp;
function abrediv(id){	
	if(temp != undefined){
		if( document.getElementById("div_"+id).style.display == "none"){
			document.getElementById("blt_"+temp).src = "./SitePJ/img/blt_mais.gif";
			document.getElementById("lnk_"+temp).style.fontWeight = "normal";
			document.getElementById("div_"+temp).style.display = "none";
			document.getElementById("blt_"+id).src = "./SitePJ/img/blt_menos.gif";
			document.getElementById("lnk_"+id).style.fontWeight = "bold";
			document.getElementById("div_"+id).style.display = "block";
			temp = id;
		}
		else{
			document.getElementById("blt_"+id).src = "./SitePJ/img/blt_mais.gif";
			document.getElementById("lnk_"+id).style.fontWeight = "normal";
			document.getElementById("div_"+id).style.display = "none";
			temp = id;
		}
	}
	else{
		document.getElementById("blt_"+id).src = "./SitePJ/img/blt_menos.gif";
		document.getElementById("lnk_"+id).style.fontWeight = "bold";
		document.getElementById("div_"+id).style.display = "block";
		temp = id;
	}
}
function frmcomb()
{
		var URL = document.form1.institucional.options[document.form1.institucional.selectedIndex].value;
		x=document.form1.institucional.selectedIndex;
		if (x!=0)
        	{
		    window.open (URL,"_self")
		}
}
function chama_url(target,selObj,restore)
{
    x=selObj.selectedIndex;
    if (x!=0)
        {
           eval(target+".location='http://www.bradesco.com.br"+selObj.options[selObj.selectedIndex].value+"'");
           if (restore) selObj.selectedIndex=0;
        }
}
function MM_jumpMenu(targ,selObj,restore){ 
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}
function soNumeros(e){
     var key;
     var keychar;

     if (window.event) {
        key = window.event.keyCode;
     } else if (e) {
        key = e.which;
     } else {
        return true;
     }	

     keychar = String.fromCharCode(key);

     if ((key==null) || (key==0) || (key==8) ||
          (key==9) || (key==13) || (key==27) ) {
        return true;
     } else if ((("0123456789").indexOf(keychar) > -1)) {
        return true;     
     } else {
        return false;
     }
}
function FormataCampo(Campo,teclapres,mascara, sai) {

	if (sai == "S" && consistente == "N") {
		if (obrigatorio == "N" && Campo.value.length > 0) {
			obrig_fixo = "S";
			Consist(Campo.maxLength, Campo);
			obrig_fixo = "N";
		}
		if (obrigatorio == "S" || Campo.value.length > 0) {
			if (sai == "S") {
				if (Campo.value.length != mascara.length) {
					alert('O campo precisa estar neste formato:\n\n       '+ mascara);
					Campo.value = "";
				}
				erro = "S";
				return false;
			}
		}
	}
	if (sai == "S" && obrigatorio == "N" && Campo.value.length > 0) {
		obrig_fixo = "S";
		Consist(Campo.maxLength, Campo);
		obrig_fixo = "N";
		if (consistente == "N") {
			alert('O campo precisa estar neste formato:\n\n       '+ mascara);
		}
	}
	strtext = Campo.value;
	tamtext = strtext.length;
	tammask = mascara.length;
	arrmask = new Array(tammask);
	for (var i = 0 ; i < tammask; i++) {
		arrmask[i] = mascara.slice(i,i+1)
	} 

	if (((((arrmask[tamtext] == "#") || (arrmask[tamtext] == "9"))) || (((arrmask[tamtext+1] != "#") || (arrmask[tamtext+1] != "9"))))) {
		if ((teclapres.keyCode >= 35 && teclapres.keyCode <= 40)||(teclapres.keyCode >= 48 && teclapres.keyCode <= 57)||(teclapres.keyCode >= 96 && teclapres.keyCode <= 105)||(teclapres.keyCode == 8)||(teclapres.keyCode == 9) ||(teclapres.keyCode == 46) ||(teclapres.keyCode == 13)||(teclapres.keyCode == 16)){
			Organiza_Casa(Campo,arrmask[tamtext],teclapres.keyCode,strtext)		
		} else {
			Detona_Event(Campo,strtext)
		}
	} else {
		if ((arrmask[tamtext] == "A")) {
			charupper = event.valueOf()
			Detona_Event(Campo,strtext)
			masktext = strtext + charupper 
			Campo.value = masktext
		}
	}
}
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;
   for (i = 0; i < DateValue.length; i++) {
	  if (checkstr.indexOf(DateValue.substr(i,1)) >= 0) {
		 DateTemp = DateTemp + DateValue.substr(i,1);
	  }
   }
   DateValue = DateTemp;
   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";		  
	}

   year = DateValue.substr(4,4);
   if (year == 0) {
	  err = 20;
	  strDataMsg = "O ano informado é inválido";
   }
   month = DateValue.substr(2,2);
   if ((month < 1) || (month > 12)) {
	  err = 21;
	  strDataMsg = "O mês informado é inválido";
   }

   day = DateValue.substr(0,2);
   if (day < 1) {
	 err = 22;
	 strDataMsg = "O dia informado é inválido";
   }

   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";
   }
   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 ((day == 0) && (month == 0) && (year == 00)) {
	  err = 0; day = ""; month = ""; year = ""; seperator = "";
   }
   
   if (err == 0) {
	  return '';
   } else {
	  return strDataMsg;
   }
}
function Organiza_Casa(Campo,arrpos,teclapres_key,strtext){
	if (((arrpos == "/") || (arrpos == ".") || (arrpos == ",") || (arrpos == ":") || (arrpos == " ") || (arrpos == "-")) && !(teclapres_key == 8)){
		separador = arrpos
		masktext = strtext + separador
		Campo.value = masktext
	}
}
function Detona_Event(Campo,strtext){
	event.returnValue = false
	if (strtext != "") {
		Campo.value = strtext
	}
}
function FCTempoReal(Campo)	{

	if (((event.keyCode) > 47) && ((event.keyCode) < 58)) {
		NumDig = Campo.value;
		TamDig = NumDig.length;
		Contador = 0;
		if (TamDig > 1) {

			numer = "";
			for (i = TamDig; (i >= 0); i--) {
				if ((parseInt(NumDig.substr(i,1))>=0) && (parseInt(NumDig.substr(i, 1))<=9)) {
					Contador++;
					if ((Contador == 2) && ((TamDig -i) < 4)) {
						numer = ","+numer;
						Contador = 0;
					} else if (Contador == 3) {
						numer = "."+numer;
						Contador = 0;
					}
					numer = NumDig.substr(i, 1)+numer;
				} 
			}
			Campo.value = numer;
		}

		return true;

	} else {

		return false;
	}
}
function formataValor(campo,tammax,teclapres,f) {

	var tecla = teclapres.keyCode;
	vr = f[campo].value;
	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 ){ 
	 		f[campo].value = vr ; }
	 	if ( (tam > 2) && (tam <= 5) ){
	 		f[campo].value = vr.substr( 0, tam - 2 ) + ',' + vr.substr( tam - 2, tam ) ; }
	 	if ( (tam >= 6) && (tam <= 8) ){
	 		f[campo].value = vr.substr( 0, tam - 5 ) + '.' + vr.substr( tam - 5, 3 ) + ',' + vr.substr( tam - 2, tam ) ; }
	 	if ( (tam >= 9) && (tam <= 11) ){
	 		f[campo].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) ){
	 		f[campo].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) ){
	 		f[campo].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 keyNumber(e) {
	var ie = (document.all)?true:false;

	var strValid = "1234567890" + String.fromCharCode(8) + String.fromCharCode(13); 
	
	if (ie) {
		var Key = String.fromCharCode(window.event.keyCode);
		event.cancelBubble = true;
	} else {
		var Key = String.fromCharCode(e.which);
	}

	var ret = (strValid.indexOf(Key) != -1)
	
	if (ie) {
		event.returnValue = ret;
	} else {
		return ret;
	}
}
function GetCommaDelimiter(nCountryCode)
{
       var sRet='';
       switch (nCountryCode)
       {
            case 3:   
                     sRet = '';
                     break;
            case 2:   
                     sRet = '.';
                     break;
            default:
                     sRet = ',';
                     break;
        }
      return sRet;
}
function GetDecimalDelimiter(nCountryCode)
{
       var sRet='';
       switch (nCountryCode)
       {
            case 3:                 
                     sRet = ',';
                     break;
            
            case 2:
                     sRet = ',';
                     break;
            default:
                     sRet = '.';
                     break;
 
        }
      return sRet;
}
function FormatClean(num) {
     var sVal='';
     var nVal = num.length;
     var sChar='';
     
   try
   {
       for(i=0;i<nVal;i++)
      {
         sChar = num.charAt(i);
         nChar = sChar.charCodeAt(0);
         if ((nChar >=48) && (nChar <=57))  { 
			 sVal += num.charAt(i);   
		 }
      }
   }
    catch (exception) { AlertError("Format Clean",e); } 

    return sVal;
}
function FormatCurrency(num,nCountryCode) {
        var sVal='';
        var minus='';
        var Decimal='';

		Decimal = GetDecimalDelimiter(nCountryCode);

		if (num.toString().lastIndexOf("-") == 0) { 
			minus='-'; 
		}

		if (num.toString().lastIndexOf(Decimal) < 0) { 
			num = num + '00'; 			
		}
		if (num.toString().lastIndexOf(Decimal) > -1) { 
			arrNum	= num.toString().split(Decimal);
			mil		= arrNum[0];
			cen		= arrNum[1];

			if (cen.toString().length == 0) { cen = cen + '00'; }
			if (cen.toString().length == 1) { cen = cen + '0'; }

			num = mil +'.'+ cen;
		}
		num = FormatClean(num);

       		sVal = minus + FormatDollar(num,GetCommaDelimiter(nCountryCode)) + GetDecimalDelimiter(nCountryCode) + FormatCents(num); 
		return sVal;		
}
function FormatCurrency_2(num,nCountryCode) {
        var sVal='';
        var minus='';
        var Decimal='';

		Decimal = GetDecimalDelimiter(nCountryCode);
		if (num.toString().lastIndexOf("-") == 0) { 
			minus='-'; 
		}

		if (num.toString().lastIndexOf(".") < 0) { 
			num = num + '00'; 			
		}
		if (num.toString().lastIndexOf(".") > -1) { 
			arrNum	= num.toString().split(".");
			mil		= arrNum[0];
			cen		= arrNum[1];

			if (cen.toString().length == 0) { cen = cen + '00'; }
			if (cen.toString().length == 1) { cen = cen + '0'; }

			num = mil +'.'+ cen;
		}
		num = FormatClean(num);
	        sVal = minus + FormatDollar(num,GetCommaDelimiter(nCountryCode)) + GetDecimalDelimiter(nCountryCode) + FormatCents(num); 
		return sVal;		
}
function FormatNumber(num,nCountryCode)
{       
        var sVal='';
        var minus='';
        var CommaDelimiter='';

        try 
       {

           CommaDelimiter = GetCommaDelimiter(nCountryCode);

           if (num.toString().lastIndexOf("-") == 0) { minus='-'; }

           num = FormatClean(num);

           num = parseFloat(num);

           var samount = new String(num);
             
           for (var i = 0; i < Math.floor((samount.length-(1+i))/3); i++)
          {
             samount = samount.substring(0,samount.length-(4*i+3)) + CommaDelimiter + samount.substring(samount.length-(4*i+3));
          }

        }
        catch (exception) { AlertError("Format Number",e); }
        return minus + samount;
}
function FormatCents(amount)
{
     var cents = '';
      try
      {
           amount = parseFloat(amount);
           var samount = new String(amount);

           if (samount.length == 0) { return '00'; }
           if (samount.length == 1) { return '0' + samount; }
           if (samount.length == 2) { return samount; }
         
           cents =  samount.substring(samount.length -2,samount.length);
          
      }
      catch (exception) { AlertError("Format Cents",e); }
      return cents;
}
function FormatDollar(amount,CommaDelimiter)
{
   try 
   {
        amount = parseFloat(amount);
        var samount = new String(amount);
        if (samount.length < 3) { return 0; }  
        samount =  samount.substring(0,samount.length -2);
        for (var i = 0; i < Math.floor((samount.length-(1+i))/3); i++)
        {
           samount = samount.substring(0,samount.length-(4*i+3)) + CommaDelimiter + samount.substring(samount.length-(4*i+3));
        }

   }
   catch (exception) { AlertError("Format Comma",e); }
   return samount;
}
function checkData(year,month,day){
	var checkstr = "0123456789";
	var leap = 0;
	var i;
	var strDataMsg = "";
	data = new Date();
	ano = data.getFullYear();
	mes = data.getMonth();
	dia = data.getDate();

	if (year > ano || (year == ano && (month == (mes+1) && day > dia)) || (year == ano && (month > (mes+1)))) {
		strDataMsg = strDataMsg + "Data inválida.\n";
		return strDataMsg;
	}

	if (year == '') {
		strDataMsg = strDataMsg + "Preencha o Ano de Nascimento.\n";
	} else if (year == 0 || year.length < 4 || year > ano) {
		strDataMsg = strDataMsg + "O Ano informado é inválido.\n";
	}
	if (month == '') {
		strDataMsg = strDataMsg + "Preencha o Mês do Nascimento.\n";
	} else  if ((month < 1) || (month > 12)) {
	    strDataMsg = strDataMsg + "O Mês informado é inválido.\n";
    }
	if (day == ''){
		strDataMsg = strDataMsg + "Preencha o Dia do Nascimento.\n";	
	} else if (day < 1 || day > 31) {
		strDataMsg = strDataMsg + "O Dia informado é inválido.\n";
    }

   if ((year % 4 == 0) || (year % 100 == 0) || (year % 400 == 0)) {
	  leap = 1;
   }
   if ((month == 2) && (leap == 1) && (day > 29)) {
	  strDataMsg = strDataMsg + "O Mês informado possui no máximo 29 dias.\n";
   }
   if ((month == 2) && (leap != 1) && (day > 28)) {
	  strDataMsg = strDataMsg + "O Mês informado possui no máximo 28 dias.\n";
   }
   /* Validation of other months */
   if ((day > 31) && ((month == "01") || (month == "03") || (month == "05") || (month == "07") || (month == "08") || (month == "10") || (month == "12"))) {
	  strDataMsg = strDataMsg + "O Mês informado possui no máximo 31 dias.\n";
   }
   if ((day > 30) && ((month == "04") || (month == "06") || (month == "09") || (month == "11"))) {
	  strDataMsg = strDataMsg + "O Mês informado possui no máximo 30 dias.\n";
   }
  return strDataMsg;
}
String.prototype.trim = function() {
   return this.replace(/(^\s*)|(\s*$)/g, "");
}
function validaCNPJ(CNPJ) {
		 erro = new String;
		 erro = '';
		 if (CNPJ =='00.000.000/0000-00'){
			 erro += "É necessario preencher corretamente o número do CNPJ!\n ";
			 return erro;
		 }
		 if (CNPJ.length < 18) erro += "É necessario preencher corretamente o número do CNPJ!\n "; 
		 if ((CNPJ.charAt(2) != ".") || (CNPJ.charAt(6) != ".") || (CNPJ.charAt(10) != "/") || (CNPJ.charAt(15) != "-")){
		 if (erro.length == 0) erro += "É necessário preencher corretamente o número do CNPJ!\n ";
		 }
	   if(document.layers && parseInt(navigator.appVersion) == 4){
			   x = CNPJ.substring(0,2);
			   x += CNPJ. substring (3,6);
			   x += CNPJ. substring (7,10);
			   x += CNPJ. substring (11,15);
			   x += CNPJ. substring (16,18);
			   CNPJ = x; 
	   } else {
			   CNPJ = CNPJ. replace (".","");
			   CNPJ = CNPJ. replace (".","");
			   CNPJ = CNPJ. replace ("-","");
			   CNPJ = CNPJ. replace ("/","");
	   }
	   var nonNumbers = /\D/;
	   if (nonNumbers.test(CNPJ)) erro += "A verificação de CNPJ suporta apenas números!\n "; 
	   var a = [];
	   var b = new Number;
	   var c = [6,5,4,3,2,9,8,7,6,5,4,3,2];
	   for (i=0; i<12; i++){
			   a[i] = CNPJ.charAt(i);
			   b += a[i] * c[i+1];
	}
	   if ((x = b % 11) < 2) { a[12] = 0 } else { a[12] = 11-x }
	   b = 0;
	   for (y=0; y<13; y++) {
			   b += (a[y] * c[y]); 
	   }
	   if ((x = b % 11) < 2) { a[13] = 0; } else { a[13] = 11-x; }
	   if ((CNPJ.charAt(12) != a[12]) || (CNPJ.charAt(13) != a[13])){
			   erro +="Dígito verificador do CNPJ com problema!\n";
	   }
	   if (erro.length > 0){
			   return erro;
	   } 
	   return '';
}
function soMoney(tammax){
	event.srcElement.maxLength=tammax;
	if (event.srcElement.value.length+1>tammax) { 
		event.KeyCode=0;
	}
	if ( (event.keyCode >= 48) && (event.keyCode <= 57 ) || (event.keyCode == 44)) {
		if (event.keyCode == 44){
			if (event.srcElement.value.indexOf(",") > -1) {			
				event.keyCode = 0
				return false
			}
		}
		return true
	} else {
		if (event.keyCode != 8){
			 event.keyCode = 0
			 return false
		 }
	}
}
function isValidCPFCGC(sText) {
	var flgStatus;
	flgStatus = true;
	sText = new String(sText).toString();
	
	re = /[\.\/-]/g; 
	sText = sText.replace(re,"");		

	if(sText.length == 11) {
		
		for(i=0;((i<=(sText.length-1))&& flgStatus); i++) {
		val = sText.charAt(i);

			if((val!="9")&&(val!="0")&&(val!="1")&&(val!="2")&&(val!="3")&&(val!="4") &&
			(val!="5")&&(val!="6")&&(val!="7")&&(val!="8")) {
				flgStatus = false;
			}
		}
		if(flgStatus) {
			soma = 0;
			for(i=0;i<=8;i++) {
				val = eval(sText.charAt(i));
				soma = soma + (val*(i+1));
			}
			resto = soma % 11;
			if(resto>9) {
				dig = resto-10;
			} else {
				dig = resto;
			}
			if(dig != eval(sText.charAt(9))) {
				flgStatus = false;
			} else {
				soma = 0;
				for(i=0;i<=7;i++) {
					val = eval(sText.charAt(i+1));
					soma = soma + (val*(i+1));
				}
				soma = soma + (dig * 9);
				resto = soma % 11;
				if(resto>9) {
					dig = resto-10;
				} else {
					dig = resto;
				}
				if (dig != eval(sText.charAt(10))) {
					flgStatus = false;
				}
			}	
		}
	} else if(sText.length == 14) {
		for(i=0;((i<=(sText.length-1))&& flgStatus); i++) {
			val = sText.charAt(i);

			if((val!="9")&&(val!="0")&&(val!="1")&&(val!="2")&&(val!="3")&&(val!="4") &&
			(val!="5")&&(val!="6")&&(val!="7")&&(val!="8")) {
				flgStatus = false;
			}
		}
		if(flgStatus) {
			m2 = 2;
			soma1 = 0;
			soma2 = 0;
			for(i=11;i>=0;i--) {
				val = eval(sText.charAt(i));
				m1 = m2;
				if (m2<9) {
					m2 = m2+1;
				} else {
					m2 = 2;
				}
				soma1 = soma1 + (val * m1);
				soma2 = soma2 + (val * m2);
			}  

			soma1 = soma1 % 11;
			if (soma1 < 2) {
				d1 = 0;
			} else {
				d1 = 11-soma1;
			}

			soma2 = (soma2 + (2 * d1)) % 11;
			if (soma2 < 2) {
				d2 = 0;
			} else {
				d2 = 11-soma2;
			}
			if (!((d1==sText.charAt(12)) && (d2==sText.charAt(13)))) {
				flgStatus = false;
			}
		}
	} else {
		
		flgStatus = false;
	}

	return(flgStatus);
}
function openLink(comboName) {    
    var combo = document.getElementById(comboName)
    
    if (typeof(combo) != "undefined") {
        if(combo.options[combo.selectedIndex].value !="") 
	{
		if(
			((combo.options[combo.selectedIndex].value) == "inc/controller.aspx?siteId=3&urlId=1") || 
			((combo.options[combo.selectedIndex].value) == "inc/controller.aspx?siteId=38&urlId=1")|| 
			((combo.options[combo.selectedIndex].value) == "http://www.bradescocartoes.com.br/conteudo/simulador/simulador.aspx?paramPag=SimuladorPJ")||
			((combo.options[combo.selectedIndex].value) == "http://simulador.bmf.com.br?paramPag=investimentos_futuros")
		)
		{window.open(combo.options[combo.selectedIndex].value,"_blank");}
		else
		{window.location.href= (combo.options[combo.selectedIndex].value);}
	} 
    }
}
function grafico() {
    var combo = document.getElementById('indiceGrafico');
    var indice = combo.options[combo.selectedIndex].value;
    if (indice!="")
	    window.open('http://www.bradescori.com.br/site/content/popup/grafico_intraday.asp?indice=' + indice,'pop','width=273,height=351','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no');
}
function VerificaDecimal(v,n){
	var total = v; var nCampo = n;
	if (total != '') {
		var virgula = total.indexOf(",");
		
		if (virgula == -1) {
				eval('document.forms[0].total'+nCampo).value = total+',00';
		}
		else {
			var depois_virgula = total.split(',')
			if (depois_virgula[1].length >= 3 || depois_virgula[1].length == 0){
				alert('Utilize apenas duas casas decimais no campo Valor Total!');
				eval('document.forms[0].total'+nCampo).focus();
				return false;							
			}
			else {
				if (depois_virgula[1].length == 1) {
					eval('document.forms[0].total'+nCampo).value = total+'0';
				}
			}
		}
	}
}
function DFonlyThisChars(n,l,o,e){if(window.event)key=window.event.keyCode;else if(e)key=e.which;else return true;S=(o)?o:'';if(n)S+='0123456789';if(l)S+='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';if(key==null||key==0||key==8||key==9||key==13||key==27)return true;else if(S.indexOf(String.fromCharCode(key))!=-1)return true;else return false;}
function capitalgiro() {
    var form = document.forms[0];
    var str_erro = "";
    if (form.CNPJ.value == "") {
        str_erro += "Informar o seu CNPJ.\n";
    } else if (!isValidCPFCGC(form.CNPJ.value)) {
        str_erro += "Informar um CNPJ válido.\n";
    }
    
    if (form.ValorBem.value == "") {
        str_erro += "Informar o valor.\n";
    }
    
    if (str_erro != "") {
        alert("Para prosseguir com a simulação é necessário:\n\n"+str_erro);                
    } else {
        location.href="../solucoes/simulador_capital_giro.aspx?cnpj="+escape(form.CNPJ.value)+"&valorbem="+escape(form.ValorBem.value);
    }
}
function popup(url,w,h,s) {
    var oW=window.open(url,'popup','width='+w+',height='+h+',directories=0,location=0,menubar=0,resizable=0,scrollbars='+s+',status=0,toolbar=0,marginleft=0,margintop=0,left=0,top=0');

}
		var urlBradesco="http://www.bradesco.com.br/";
		var urlInst="http://institucional.bradesco.com.br/";
		function AbreRede(pag)
		{
			switch(pag){
			case 0:{local=urlInst+'NetRedeAtendimento/site/content/agencia/default.aspx?h=1';break;}
			default:local=urlInst+'RedeAtendimento/Index_Menu.asp';}
			window.open(local,'_blank','width=795,height=505,top=90,left=50,toolbar=no,copyhistory=no,status=no,menubar=no,scrollbars=yes,resizable=no,top=0,left=0');
		}
		function col_rh(){popup('../redirect/politica_rh.html',480,400,0)}
		function col_quali(){popup('/static_files/PJ/pdf/politica_qualidade.pdf',1000,800,0)}
		function popup(url,w,h,s){var oW=window.open(url,'popup','width='+w+',height='+h+',directories=0,location=0,menubar=0,resizable=1,scrollbars='+s+',status=0,toolbar=0,marginleft=0,margintop=0,left=0,top=0');}	
		function col_op(){window.open('http://www.bradescopj.com.br/static_files/PJ/redirect/opor_carreira.html')}