function checkNumber(field, e)
{
  if(e.keyCode == 13)
  		x=0;		
  else if(e.keyCode <= 45 || e.keyCode > 57)
        e.returnValue = false;
}


function CheckDigits(field,e)
{
   var tecla = e.KeyCode;

   if(tecla == null || tecla == 'undefined')
      tecla = e.charCode;

    if(tecla == 13)
    {
       x=0;
    }  
    //aceita a letra 'x'
     if(document.all)
     {
         if(e.keyCode != 88 && e.keyCode != 120)
         {
           if(e.keyCode <= 45 || e.keyCode > 57)
           {
             e.returnValue = false;
           }
         }  
     }
     else
     {
        if(tecla != 88 && tecla != 120)
        {
            if((tecla <= 45 || tecla > 57)&&(tecla != 0))
            {
                e.returnValue = false;
                return false;
            }
        } 
     } 
 }
 
 
 //Verifica os dígitos e verifica se o banco é HSBC
function verifyDigitCont2(field,fieldBank,e)
{
     var bank = fieldBank.options[fieldBank.selectedIndex].value;
     var tecla = e.KeyCode;

   if(tecla == null || tecla == 'undefined')

      tecla = e.charCode;
    if(tecla == 13)
    {
       x=0;
    }  
    //aceita a letra 'x'

     if(document.all)
     {
         if (bank != "399" && bank != "41")
           if (field.value.length > 0)
             e.returnValue = false;
         
         if(e.keyCode != 88 && e.keyCode != 120)
         {
   
           if(e.keyCode <= 45 || e.keyCode > 57)
           {
             e.returnValue = false;
           }

         }  
     }

     else
     {
       if (bank != "399" && bank != "41")
         if (field.value.length > 0)
          {
           if(tecla != 0)
           {
             e.returnValue = false;
             return false;
           }
          }
          
        if(tecla != 88 && tecla != 120)
        {
            if((tecla <= 45 || tecla > 57)&&(tecla != 0))
            {
              e.returnValue = false;
              return false;
            }
        } 
     } 

}
 

function CheckDecimalSeparator(field, e)
{

    var code = e.charCode;
   if ((code == null)||(code=="undefined"))
    code = e.keyCode;
   if(code  == 13)
        x=0;	
    
    else if ((code != 0) && (code!=44) && (code!=46) && (code  <= 47 || code  > 57))
    {
        e.returnValue = false; 
        return false;
    }
    return true; 
}





    function visible()
    {       
        if($('divAdd').style.display == "none")
        {
            $('divAdd').style.display = "block";
            $('box_quote_seta').src = "../im/bt_setaup.gif";
            $('box_quote_label').innerHTML = "Clique para compactar";
        }
        else
        {
            $('divAdd').style.display = "none";
            $('box_quote_seta').src = "../im/bt_setadw.gif";
            $('box_quote_label').innerHTML = "Clique para detalhes";
        }
    }
   
    function responder(opt)
    {
    var obj = 'div_resp_' + opt;
    if($(obj).style.display == "none")
    {
            $(obj).style.display = "block";
            }
            else
            {   $(obj).style.display = "none";
                   
            }
    }
    function showAndHideDatasTitular(indice)
    {
        var field = "ctl00_ContentMid_checkConjunta" + indice;
        var tr = "trDadosTitular" + indice;
        var cpf = "ctl00_ContentMid_txtCPF"+ indice;
        var nome = "ctl00_ContentMid_txtNome" +indice;
        var holder = "ctl00_ContentMid_checkHolderAccount_" +indice;
        
        if(document.getElementById(field).checked)
        {
            document.getElementById(tr).style.display = "block";
        }
        else
        {
            document.getElementById(tr).style.display = "none";
            document.getElementById(cpf).value="";
            document.getElementById(nome).value="";
            document.getElementById(holder).checked=false;
        } 
    }
    
    function showAndHideDigitAgency(indice)
    {
   
        var name  = "ctl00_ContentMid_ddlBanco" + indice;
        var field = document.getElementById(name);
        var td = "tdDigitoAgencia"+ indice;
        var td2 = "divDigitoConta"+ indice;
        var txtDigitAccount = "ctl00_ContentMid_txtDigito" + indice;
       
        selectField = document.getElementById(name).selectedIndex;
        
        if (field.options[selectField].value != "1")
        {
            document.getElementById(td).style.display = "none";
            document.getElementById("ctl00_ContentMid_txtDigitoAgencia" + indice).value = "";
        }
        else
        {
            document.getElementById(td).style.display = "block";
        }      
      
        if (field.options[selectField].value == "477"  || field.options[selectField].value == "745" || field.options[selectField].value == "752")
        {
           document.getElementById(td2).style.display = "none";
           document.getElementById(txtDigitAccount).value = "";
        }
        else
        {
          document.getElementById(td2).style.display = "block";
        }
    }
       

 function showAlert()
 {
    var obj = $('alertbox');
    obj.style.display = "";
    obj.style.height = screen.height - 180;
    obj.style.width = document.body.clientWidth + 10;
}
 function showAlert2()
 {
    var obj = $('alertbox_email');
    obj.style.display = "";    
}
 function closeBox2()
 {
    var obj = $('alertbox_login');
    obj.style.display = "none";
    
    var obj2 = $('alertbox_contato');
    obj2.style.display = "block";    
}
function closeBox()
{
    var obj = $('alertbox');
    obj.style.display = "none";
}

  function autoComplete (field, select, property, forcematch) {
	    var Ativos = new Array();
        Ativos.push("ACES3");
	    Ativos.push("ACES4");
	    Ativos.push("Acesita");
	    Ativos.push("AES Tiete");
	    Ativos.push("GETI3");
	    Ativos.push("GETI4");
	    Ativos.push("BARDELLA");
	    Ativos.push("BDLL3");
	    Ativos.push("BDLL4");
	    Ativos.push("DSUL3");
	    Ativos.push("EMBRATEL PAR");
	    Ativos.push("EBTP3");
	    Ativos.push("EBTP4");
	    Ativos.push("GLOBEX");
	    Ativos.push("GLOB3");
	    Ativos.push("GOAU4");
	    Ativos.push("ITSA4");
	    Ativos.push("PTIP4");
	    Ativos.push("TMAR5");
	    Ativos.push("USIN5");
	    Ativos.push("VALE3");
	    Ativos.push("Vale Rio Doce");
	    Ativos.push("GLOB4");
	    Ativos.push("IBOV");
	    Ativos.push("Bovespa");	    
	    Ativos.push("Indice Bovespa");	
        Ativos.push("ITAUBANCO");
        Ativos.push("CELESC");
        Ativos.push("CLSC3");
        Ativos.push("CLSC5");
        Ativos.push("ITAU3");
        Ativos.push("ITAU4");
	    Ativos.push("PETR4");
	    Ativos.push("TELB4");	    
	    Ativos.push("Petrobras ON");
	    Ativos.push("Petrobras PN");
	    var found = false;	    
	    for (var i = 0; i < Ativos.length; i++) {
	        if (Ativos[i].toUpperCase().indexOf(field.value.toUpperCase()) == 0) {
		        found=true; break;
		    }
	    }	    
	    if (field.createTextRange) {
		    if (forcematch && !found) {
			    field.value=field.value.substring(0,field.value.length-1); 
			    return;
			}
		    var cursorKeys ="8;46;37;38;39;40;33;34;35;36;45;";
		    if (cursorKeys.indexOf(event.keyCode+";") == -1) {
			    var r1 = field.createTextRange();
			    var oldValue = r1.text;
			    var newValue = found ? Ativos[i] : oldValue;
			    if (newValue != field.value) {
				    field.value = newValue;
				    var rNew = field.createTextRange();
				    rNew.moveStart('character', oldValue.length) ;
				    rNew.select();
				}
			}
		}
	}

//Pop-up Envie para um amigo
function envieAmigo(){
	janela=window.open("../../common/envieAmigoHelp.aspx","","width=377,height=399,scrollbars=no");
	//interceptacao de erro na abertura da janela
	text = "Desative seu bloqueador de pop-ups!";
	if(janela == null) { alert(text); return; }
	//fim
}
function envieAmigoGW(){
	janela=window.open("../../common/envieAmigo.aspx","","width=377,height=399,scrollbars=no");
	//interceptacao de erro na abertura da janela
	text = "Desative seu bloqueador de pop-ups!";
	if(janela == null) { alert(text); return; }
	//fim
}
//Janela Gráfico Apligraf
var grafico;
function OpenGraficoApligraf(symbol)
{
	try
	{
		if (grafico.closed)
			grafico = null;
	}	
	catch (err)
	{
		grafico = null;
	}

	
    if (grafico == null)
    {
        var largura = screen.width-100;
        var altura = screen.height-200;
        grafico = window.open('https://secure.apligraf.com.br/webfeed/win/graficos001.php?ativo=ibov&estudo=ifr&popup=sim&ativo=' + symbol,'grafico','width=' + largura + ',height=' + altura + ',status=1,left=50,top=100,resizable=1');
    }
    else
    {
       grafico.location = 'https://secure.apligraf.com.br/webfeed/win/graficos001.php?ativo=ibov&estudo=ifr&popup=sim&ativo=' + symbol;
       grafico.focus();
    }
}



