function amf2005_BecameCurrency(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';
};

// Função somente para tecla de números e backspace (das idades)
function desabilitateclas()
{
	var tecla = event.keyCode;
	if ((tecla >= 0 && tecla <= 7)||(tecla >= 9 && tecla <= 12)||(tecla >= 14 && tecla <= 43)||(tecla >= 58 && tecla <= 127))
	{ return false; }
	return tecla;
}
// Muda o focus do telefone
function muda_focus(a,b)
{
	if(a.length==2)
		b.focus();
}
// Função mascara de FONE
function mascaraFONE(objeto)
{
	campo = eval (objeto);
	separacao1 = '-';
	conjunto1 = 4;
	conjunto2 = 9;
	if (desabilitateclas())
	{
			if (campo.value.length < (conjunto2))
			{
			  if (campo.value.length == conjunto1)
					campo.value = campo.value + separacao1;
			}
	}
	else
		event.returnValue = false;
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function favoritos() {
var name=confirm("A Agência Giga Convida você a incluir nosso site em seus Favoritos!")
if (name==true)
{
	var url      = "http://www.agenciagiga.com.br";
    var title    = "Agência Giga- Desenvolvimento Web - Central de Vendas e Promoções !";
    if (window.sidebar) window.sidebar.addPanel(title, url,"");
    else if(window.opera && window.print){
        var mbm = document.createElement('a');
        mbm.setAttribute('rel','sidebar');
        mbm.setAttribute('href',url);
        mbm.setAttribute('title',title);
        mbm.click();
    }
    else if(document.all){window.external.AddFavorite(url, title);}
}
}

function menu(obj)
{
	a=document.getElementById(obj);

	if(a.style.display=="none")
	{
		a.style.display="block";
	}
	else
	{
		a.style.display="none";
	}
}

function full2(link,nome_janela) 
{
	largura = screen.width - 25;
	altura = screen.height - 70;
	
	if (link != '')
		window.open(link,''+nome_janela+'','width='+largura+',height='+altura+',top=5,left=4,screenX=0,screenY=0,status=no,scrollbars=yes,toolbar=no,resizable=no,maximized=no,menubar=no,location=no');
}

function copiar(texto)
{
	texto=document.getElementById(texto);
	texto.select();
	var cop = texto.createTextRange();
	cop.execCommand("Copy");
}

