/* 

   | --------------------------------------------- | 
   | Script Desenvolvido por Luiz Fabiano          |
   | João Pessoa, 14 de Agosto de 2006             |
   | E-mail: contato@luizfabianooliviera.com.br    |
   | site: http://www.luizfabianooliveira.com.br   | 
   | Fone: (0xx83) 8808-0002                       |
   | --------------------------------------------- |
   
*/

function abreJanela(url)
{
	var janela = '_blank';
	var larg   = 450;
	var alt    = 562;
	var scroll = 'yes';
	var pos1   = 100;
	var pos2   = 200;
	window.open(url,janela,"toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars="+scroll+",resizable=no,copyhistory=no,top="+pos1+",left="+pos2+",screenY="+pos1+",screenX="+pos2+",width="+larg+",height="+alt);
}

function acao (url, i) {
    
    document.forms[i].action=url;
    document.forms[i].submit();
}

function remover (url, i) {
    var confirma = confirm("Deseja Realmente Apagar?");

	if (confirma == true) {
	    alert("Remoção efetuada com sucesso");
		document.forms[i].action=url;
	    document.forms[i].submit();
	}
}

function formataValor(cur,len)
{
   n='__0123456789';
   d=cur.value;
   l=d.length;
   r='';
   if (l > 0)
   {
    z=d.substr(0,l-1);
    s='';
    a=2;
    for (i=0; i < l; i++)
    {
        c=d.charAt(i);
        if (n.indexOf(c) > a)
        {
            a=1;
            s+=c;
        };
    };
    l=s.length;
    t=len-1;
    if (l > t)
    {
        l=t;
        s=s.substr(0,t);
    };
    if (l > 2)
    {
        r=s.substr(0,l-2)+','+s.substr(l-2,2);
    }
    else
    {
        if (l == 2)
        {
            r='0,'+s;
        }
        else
        {
            if (l == 1)
            {
                r='0,0'+s;
            };
        };
    };
    if (r == '')
    {
        r='0,00';
    }
    else
    {
        l=r.length;
        if (l > 6)
        {
            j=l%3;
            w=r.substr(0,j);
            wa=r.substr(j,l-j-6);
            wb=r.substr(l-6,6);
            if (j > 0)
            {
                w+='.';
            };
            k=(l-j)/3-2;
            for (i=0; i < k; i++)
            {
                w+=wa.substr(i*3,3)+'.';
            };
            r=w+wb;
        };
    };
   };
   if (r.length <= len)
   {
    cur.value=r;
   }
   else
   {
    cur.value=z;
   };
   return 'ok';
}; 



/* -- mostrar - INICIO -- */

function Mostrar(div)
{
	  if (document.getElementById(div).style.display == 'none')
	  {
		  document.getElementById(div).style.display = 'block';
	  }else{
		  document.getElementById(div).style.display = 'none';
	  }
 
}
/* -- mostrar - FIM -- */
