﻿
function over(id) {

   document.getElementById(id).style.background='url(./images/txtboxOver.gif)';
   document.getElementById(id).style.color='#405CBE';
}

function out(id) {
    document.getElementById(id).style.background='url(./images/txtbox.gif)';
    document.getElementById(id).style.color='#000000';
}



function overCinza(id) {
   document.getElementById(id).style.background='url(./images/fdocinzaOver.jpg)';
   document.getElementById(id).style.color='#347AAF';   
}

function outCinza(id) {
    document.getElementById(id).style.background='url(./images/fdocinza.jpg)';
    document.getElementById(id).style.color='#000000';
}

function overbtnCinza(id) {
    document.getElementById(id).style.background='url(./images/fdobtazulOver.jpg)';
}

function outbtnCinza(id) {
    document.getElementById(id).style.background='url(./images/fdobtazul.jpg)';
}

function overbtn(id) {
    document.getElementById(id).style.background='url(./images/buttonOver.gif)';
}

function outbtn(id) {
    document.getElementById(id).style.background='url(./images/button.gif)';
}

function acao(a) {    if(document.getElementById('ctl00_ContentPlaceHolder1_rbtnFisica').checked==true)     {        return mascara(event,a,'###.###.###-##');    }    else if(document.getElementById('ctl00_ContentPlaceHolder1_rbtnJuridica').checked==true)    {        return mascara(event,a,'##.###.###/####-##');    }}

function porc(a)
{
    return mascara(event,a,'##,##');
}

function mascara(e,src,mask) {   if(window.event)    {       _TXT = e.keyCode;    }    else if(e.which)    {       _TXT = e.which;    }   if(_TXT > 47 && _TXT < 58)    {      var i = src.value.length;       var saida = mask.substring(0,1);       var texto = mask.substring(i);      if(texto.substring(0,1) != saida)       {           src.value += texto.substring(0,1);       }          return true;   }       else         {           if (_TXT != 8)           {              return false;           }           else           {              return true;           }     }}
function SomenteNumero(e)
{
    var tecla=(window.event)?event.keyCode:e.which;
    if((tecla > 47 && tecla < 58)) return true;
    else
    {
        if (tecla != 8) return false;
        else return true;
    }
}

function SomenteNumeroPonto(e)
{
    var tecla=(window.event)?event.keyCode:e.which;
    if((tecla > 47 && tecla < 58 || tecla == 46)) return true;
    else
    {
        if (tecla != 8) return false;
        else return true;
    }
}

function mascaraNumero(fld, milSep, decSep, e) {    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);    if (strCheck.indexOf(key) == -1)         return false;    len = fld.value.length;    for(i = 0; i < len; i++)        if ((fld.value.charAt(i) != '0') && (fld.value.charAt(i) != decSep)) break;    aux = '';    for(; i < len; i++)        if (strCheck.indexOf(fld.value.charAt(i))!=-1)            aux += fld.value.charAt(i);    aux += key;    len = aux.length;    if (len == 0)         fld.value = '';    if (len == 1)         fld.value = '0'+ decSep + '0' + aux;    if (len == 2)         fld.value = '0'+ decSep + aux;    if (len > 2)     {        aux2 = '';        for (j = 0, i = len - 3; i >= 0; i--)         {            if (j == 3)             {                aux2 += milSep;                j = 0;            }            aux2 += aux.charAt(i);            j++;        }        fld.value = '';        len2 = aux2.length;        for (i = len2 - 1; i >= 0; i--)            fld.value += aux2.charAt(i);        fld.value += decSep + aux.substr(len - 2, len);    }    return false;}var wd

  function parseelement(thisone)
  {    
   wd="w"
   var tempnum=thisone.value
   for (i=0;i<tempnum.length;i++)
   {
    if (tempnum.charAt(i)==",")
    {
     wd="d"
     break
    }
   }
   if (wd=="w")
    thisone.value=tempnum+",00"
   else
   {
    if (tempnum.charAt(tempnum.length-2)==",")
    {
     thisone.value=tempnum+"0"
    }
    else if (tempnum.charAt(tempnum.length-1)==",")
    {
     thisone.value=tempnum+"00"
    }
   }
  }

function mascaraS(o,f){
    v_obj=o
    v_fun=f
    setTimeout("execmascara()",1)
}

function execmascara(){
    v_obj.value=v_fun(v_obj.value)
}

function telefone(v){
    v=v.replace(/\D/g,"")                 //Remove tudo o que não é dígito
    v=v.replace(/^(\d\d)(\d)/g,"($1) $2") //Coloca parênteses em volta dos dois primeiros dígitos
    v=v.replace(/(\d{4})(\d)/,"$1-$2")    //Coloca hífen entre o quarto e o quinto dígitos
    return v
}


    function currencyFormat(fld) {
      
    milSep = '.';
    decSep = ',';
     
    var key = '';
    var i = j = len = len2 = 0;
    var strCheck = '0123456789';//+decSep
    var aux = aux2 = '';
    len = fld.value.length;
    for(; i < len; i++)    
    if ((fld.value.charAt(i) != '0') && (fld.value.charAt(i) != decSep)) break;
    aux = '';
    for(;i < len; i++)
 if (strCheck.indexOf(fld.value.charAt(i))!=-1) aux += fld.value.charAt(i);
 aux += key;
 len = aux.length;
 if (len > 3){
     aux2 = '';
     for (j = 0, i = len - 3; i >= 0; i--) {
   if (j == 3) {
       aux2 += milSep;
       j = 0;
   }
   aux2 += aux.charAt(i);
   j++;
     }
     fld.value = '';
     len2 = aux2.length;      
     for (i = len2 - 1; i >= 0; i--){
   fld.value += aux2.charAt(i);
     }
     fld.value += decSep + aux.substr(len - 2, len);
 }
    }    

