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 menu(obj)
{
	a=document.getElementById(obj);

	if(a.style.display=="none")
	{
		a.style.display="block";
	}
	else
	{
		a.style.display="none";
	}
}

function favoritos() {
	var name=confirm("Portais da Mulher Convida você a incluir nosso site em seus Favoritos!")
	if (name==true)
	{
		var url      = "http://www.portaisdamulher.com.br";
		var title    = "Portais da Mulher - O Portal da Mulher Inteligente !";
		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 conta_regressiva(obj,n,obj2)
{
	var tam = 0;
	var valor = 0;
	tam=obj.value.length;
	valor=n-tam;
	obj2.value=valor;
}

function valida_login(a)
{
	if(a.usuario.value == "")
	{
		alert("Por favor, informe seu login");
		a.usuario.focus();
		return false;
	}else{
		re=/^[A-Za-z0-9_.-]+@([A-Za-z0-9_.-]+\.)+[A-Za-z]{2,4}$/i;
		if(!re.test(a.usuario.value)){
			alert('O login parece não estar correto. Verifique se está no padrão (email@dominio.com.br)');
			a.usuario.focus();
			return false;
		}
	}
	if(a.senha.value == "")
	{
		alert("Por favor, informe sua senha");
		a.senha.focus();
		return false;
	}
}

function valida_reenvio(a)
{
	if(a.usuario.value == "")
	{
		alert("Por favor, informe seu login");
		a.usuario.focus();
		return false;
	}else{
		re=/^[A-Za-z0-9_.-]+@([A-Za-z0-9_.-]+\.)+[A-Za-z]{2,4}$/i;
		if(!re.test(a.usuario.value)){
			alert('O login parece não estar correto. Verifique se está no padrão (email@dominio.com.br)');
			a.usuario.focus();
			return false;
		}
	}
}

function linha(id,acao)
{
	var linha = id;
	var cor = '#fff';
	var novacor = '#e0e0e0';
	if(acao=='over')
	{
		linha.style.background  = novacor;
	}else{
		linha.style.background  = cor;
	}
}
