function GotoInternetBanking(){ 
			var name_element = document.getElementById('clientes_txt');
			if(Validar(name_element))
			{
				pageTracker._trackPageview('/virtual/bancoeletronico/login');
				str = 'https://wwws.bdmg.mg.gov.br/?cpfcnpj=' + name_element.value;
				location.href = str;
			}
			else
			{
				name_element.value = 'Sua Identifica\u00E7\u00E3o (Exclusivo para clientes)';
			}
		}
		
// Validação de CPF e CNPJ
function valida_CPFCNPJ(oSrc,args){
	if (args.Value.length == 14){
		valida_CPF(oSrc,args);
	}else if(args.Value.length != 14){
		valida_CNPJ(oSrc, args);
	}else{
		return args.IsValid = false;
	}
}


function validaEmail(mail){
	var er = new RegExp(/^[A-Za-z0-9_\-\.]+@[A-Za-z0-9_\-\.]{2,}\.[A-Za-z0-9]{2,}(\.[A-Za-z0-9])?/);
	if(typeof(mail) == "string"){
		if(er.test(mail)){ return true; }
	}else if(typeof(mail) == "object"){
		if(er.test(mail.value)){ 
					return true; 
				}
	}else{
		return false;
	}
}


//Created / Generates the captcha function    
    function DrawCaptcha()
    {

        var a = Math.ceil(Math.random() * 10)+ '';
        var b = Math.ceil(Math.random() * 10)+ '';       
        var c = Math.ceil(Math.random() * 10)+ '';  
        var d = Math.ceil(Math.random() * 10)+ '';          
        var code = a + ' ' + b + ' ' + ' ' + c + ' ' + d;

        document.getElementById("txtCaptcha").value = code;
		
    }

    // Validate the Entered input aganist the generated security code function   
    function ValidCaptcha(){
        var str1 = removeSpaces(document.getElementById('txtCaptcha').value);
        var str2 = removeSpaces(document.getElementById('txtInput').value);
        if (str1 == str2) return true;        
        return false;
        
    }

    // Remove the spaces from the entered and generated code
    function removeSpaces(string)
    {
        return string.split(' ').join('');
    }


function trim(str){return str.replace(/^\s+|\s+$/g,"");}

function validaCPF(cpf){
	cpf = cpf.replace("-","");
	cpf = cpf.replace(".","");
	cpf = cpf.replace(".","");

	//Verifica se o CPF possui 11 caracteres e se os dígitos verificadores são válidos.
	if (cpf.length != 11 || cpf == "00000000000" || cpf == "11111111111" || cpf == "22222222222" || cpf == "33333333333" || cpf == "44444444444" || cpf == "55555555555" || cpf == "66666666666" || cpf == "77777777777" || cpf == "88888888888" || cpf == "99999999999") return false;
				add = 0;
				for (i=0; i < 9; i ++)
					add += parseInt(cpf.charAt(i)) * (10 - i);
				rev = 11 - (add % 11);
				if (rev == 10 || rev == 11)
					rev = 0;
				if (rev != parseInt(cpf.charAt(9)))
					return false;
				add = 0;
				for (i = 0; i < 10; i ++)
					add += parseInt(cpf.charAt(i)) * (11 - i);
				rev = 11 - (add % 11);
				if (rev == 10 || rev == 11)
					rev = 0;
				if (rev != parseInt(cpf.charAt(10)))
					return false;
				//CPF Válido:
				return true;
}

//Validação de CPF
function valida_CPF(oSrc,args){

s = args.Value.replace("-","");
s = s.replace(".","");
s = s.replace(".","");

//args.isValid = (s >= 3);
//document.write(oSrc.Value + ',' + args.Value);

if (isNaN(s)) {
return args.IsValid = false;
}

var i;
var c = s.substr(0,9);
var dv = s.substr(9,2);
var d1 = 0;
for (i = 0; i < 9; i++) {
	d1 += c.charAt(i)*(10-i);
}

if (d1 == 0){
	return args.IsValid = false;
}

d1 = 11 - (d1 % 11);
if (d1 > 9) d1 = 0;
if (dv.charAt(0) != d1) {
return args.IsValid = false;
}

d1 *= 2;
for (i = 0; i < 9; i++) {
	d1 += c.charAt(i)*(11-i);
}

d1 = 11 - (d1 % 11);
if (d1 > 9) d1 = 0;
if (dv.charAt(1) != d1) {
	return args.IsValid = false;
}

return args.IsValid = true;
}

//Validação de CNPJ
function valida_CNPJ(oSrc, args){

//s = args.Value;

s = args.Value.replace("-","");
s = s.replace(".","");
s = s.replace(".","");
s = s.replace("/","");

if (isNaN(s)) {
return args.IsValid = false;
}
var i;
var c = s.substr(0,12);
var dv = s.substr(12,2);
var d1 = 0;

for (i = 0; i <12; i++){
	d1 += c.charAt(11-i)*(2+(i % 8));
}

if (d1 == 0)
return args.IsValid = false;

d1 = 11 - (d1 % 11);

if (d1 > 9) d1 = 0;
if (dv.charAt(0) != d1){
return args.IsValid = false;
}

d1 *= 2;

for (i = 0; i < 12; i++){
	d1 += c.charAt(11-i)*(2+((i+1) % 8));
}

d1 = 11 - (d1 % 11);

if (d1 > 9)
d1 = 0;

if (dv.charAt(1) != d1){
return args.IsValid = false;
}
return args.IsValid = true;
}


function Validar(theCPF)
{
  
  if (theCPF.value == "")
  {
    alert("CPF/CNPJ inv\u00E1lido. É necessário informar o CPF ou CNPJ");
    theCPF.focus();
    return (false);
  }
  if (((theCPF.value.length == 11) && (theCPF.value == 11111111111) || (theCPF.value == 22222222222) || (theCPF.value == 33333333333) || (theCPF.value == 44444444444) || (theCPF.value == 55555555555) || (theCPF.value == 66666666666) || (theCPF.value == 77777777777) || (theCPF.value == 88888888888) || (theCPF.value == 99999999999) || (theCPF.value == 00000000000)))
  {
    alert("CPF/CNPJ inv\u00E1lido.");
    theCPF.focus();
    return (false);
  }


  if (!((theCPF.value.length == 11) || (theCPF.value.length == 14)))
  {
    alert("CPF/CNPJ inv\u00E1lido.");
    theCPF.focus();
    return (false);
  }

  var checkOK = "0123456789";
  var checkStr = theCPF.value;
  var allValid = true;
  var allNum = "";
  for (i = 0;  i < checkStr.length;  i++)
  {
    ch = checkStr.charAt(i);
    for (j = 0;  j < checkOK.length;  j++)
      if (ch == checkOK.charAt(j))
        break;
    if (j == checkOK.length)
    {
      allValid = false;
      break;
    }
    allNum += ch;
  }
  if (!allValid)
  {
    alert("Favor preencher somente com dígitos o campo CPF/CNPJ.");
    theCPF.focus();
    return (false);
  }

  var chkVal = allNum;
  var prsVal = parseFloat(allNum);
  if (chkVal != "" && !(prsVal > "0"))
  {
    alert("CPF zerado !");
    theCPF.focus();
    return (false);
  }

if (theCPF.value.length == 11)
{
  var tot = 0;

  for (i = 2;  i <= 10;  i++)
    tot += i * parseInt(checkStr.charAt(10 - i));

  if ((tot * 10 % 11 % 10) != parseInt(checkStr.charAt(9)))
  {
    alert("CPF/CNPJ inv\u00E1lido.");
    theCPF.focus();
    return (false);
  }
  
  tot = 0;
  
  for (i = 2;  i <= 11;  i++)
    tot += i * parseInt(checkStr.charAt(11 - i));

  if ((tot * 10 % 11 % 10) != parseInt(checkStr.charAt(10)))
  {
    alert("CPF/CNPJ inv\u00E1lido.");
    theCPF.focus();
    return (false);
  }
}
else
{
  var tot  = 0;
  var peso = 2;
  
  for (i = 0;  i <= 11;  i++)
  {
    tot += peso * parseInt(checkStr.charAt(11 - i));
    peso++;
    if (peso == 10)
    {
        peso = 2;
    }
  }

  if ((tot * 10 % 11 % 10) != parseInt(checkStr.charAt(12)))
  {
    alert("CPF/CNPJ inv\u00E1lido.");
    theCPF.focus();
    return (false);
  }
  
  tot  = 0;
  peso = 2;
  
  for (i = 0;  i <= 12;  i++)
  {
    tot += peso * parseInt(checkStr.charAt(12 - i));
    peso++;
    if (peso == 10)
    {
        peso = 2;
    }
  }

  if ((tot * 10 % 11 % 10) != parseInt(checkStr.charAt(13)))
  {
    alert("CPF/CNPJ inv\u00E1lido.");
    theCPF.focus();
    return (false);
  }
}
  return(true);
} 


$(document).ready(function() {
	
	var box_login = $("#login-instituicao-parceira");
	
	$('div#global div#conteudo h3.ms-standardheader span.subtit-h2-home').removeClass('subtit-h2-home');
	
	$('#lista_financiamentos li:eq(2)').addClass("noborder");
	$('#lista_financiamentos li:eq(5)').addClass("noborder");
	$('#lista_financiamentos li:eq(8)').addClass("noborder");
	$('#lista_financiamentos li:eq(11)').addClass("noborder");
	$('#lista_financiamentos li:eq(14)').addClass("noborder");
	$('#lista_financiamentos li:last').addClass("noborder");
					
	$("#mn_parceira a").click(function() {
	//	if ( $(box_login).is(":visible") ) {
	//		$("#mn_parceira").removeClass("ativo");
	//		$(box_login).fadeOut("fast");
	//	} else {
	//		$("#mn_parceira").addClass("ativo");
	//		$(box_login).fadeIn("fast");
	//	}
	//	return false;
	});
	
	var box_login_auto = $("#login-auto-atendimento");
	
	$("#mn_autoatendimento a").click(function() {
		/*if ( $(box_login_auto).is(":visible") ) {
			$("#mn_autoatendimento a").removeClass("ativo");
			$(box_login_auto).fadeOut("fast");
		} else {
			$("#mn_autoatendimento a").addClass("ativo");
			$(box_login_auto).fadeIn("fast");
		}*/
		location.href="https://wwws.bdmg.mg.gov.br";
		return false;
	});
	
	$("#casodesucesso ul li").mouseover(function() {
		$(".casosover").hide();
		$(this).children("div").show();
	});
	
	$(".casosover").mouseout(function() {
		$(this).hide();
	});
			

	//mostra esconde pagina diferenciais
	$(".conteudo-abre-fecha").hide();
	$(".titulos-eventos").click(function() {
		var $content = $(this).next();
		if ($content.is(':visible')) {
			$content.slideUp("slow");
		} else {
			$content.slideDown("slow");
		}
	});	
		
	
	/*
	$("ul#submenu li ul").hide();
	$("ul#submenu > li > a").click(function() {
		var submenu = $(this).parent().children("ul");
		if ( $(submenu).is(":visible") ) {
			$(submenu).slideUp("normal");
		} else {
			$(submenu).slideDown("normal");
		}
		//return false;
	});
	
	$("ul#submenu li.aberto-por-padrao ul").show();
	*/
	
	// abas
    // oculta todas as abas
    $('div.contaba').hide();
    // mostra somente  a primeira aba
    $('div.contaba:first').show();
    // seta a primeira aba como selecionada (na lista de abas)
    $('#abasC a:first').addClass('ativo');
	 
    // quando clicar no link de uma aba
    $('#abasC a').click(function(){
    	// oculta todas as abas
    	$('div.contaba').hide();
    	// tira a seleção da aba atual
    	$('#abasC a').removeClass('ativo');
   	 	//$('#abas a').addClass('inativo');
	 
    	// adiciona a classe selected na selecionada atualmente
    	$(this).addClass('ativo');
    	// mostra a aba clicada
    	$($(this).attr('href')).show();
    	// pra nao ir para o link
    	return false;
    })


});


