hoje = new Date()
        dia = hoje.getDate()
        mes = hoje.getMonth()
        ano = hoje.getFullYear() 
        if (dia < 10)
                dia = "0" + dia
        if (ano < 2000)
                ano = "20" + ano
        function CriaArray (n) {
        this.length = n }
          NomeMes = new CriaArray(12)
			NomeMes[0] = "Janeiro"
			NomeMes[1] = "Fevereiro"
			NomeMes[2] = "Mar&ccedil;o"
			NomeMes[3] = "Abril"
			NomeMes[4] = "Maio"
			NomeMes[5] = "Junho"
			NomeMes[6] = "Julho"
			NomeMes[7] = "Agosto"
			NomeMes[8] = "Setembro"
			NomeMes[9] = "Outubro"
			NomeMes[10] = "Novembro"
			NomeMes[11] = "Dezembro"
function escreveData()
{
 document.write (dia + " de " + NomeMes[mes] + " de " + ano)
}

function avaliaLogin()
{
	var doc = document.frmLogin;
		
	if(doc.login.value == "")
	{
		alert("Informe o email");
		doc.login.focus();
		document.getElementById("login").style.border='solid 2px #ff0000';
		return false;
	}
	
	if(doc.senha.value == "")
	{
		alert("Informe a senha");
		doc.senha.focus();
		document.getElementById("senha").style.border='solid 2px #ff0000';
		return false;
	}
}

function avaliaLoginPedido()
{
	var doc = document.frmLoginPedido;
		
	if(doc.cpf.value == "")
	{
		alert("Informe o cpf");
		doc.cpf.focus();
		document.getElementById("cpf").style.border='solid 2px #ff0000';
		document.getElementById("cpf").style.background='#EEEEEE';
		return false;
	}
	
	if(doc.pedido.value == "")
	{
		alert("Informe o numero do pedido");
		doc.pedido.focus();
		document.getElementById("pedido").style.border='solid 2px #ff0000';
		document.getElementById("pedido").style.background='#EEEEEE';
		return false;
	}
}

function avaliaNews()
{
	var doc = document.newsletter;
		
	if(!validaEmail(doc.email.value))
	{
		alert("Informe um email válido");
		doc.email.focus();
		document.getElementById("email").style.border='solid 2px #ff0000';
		document.getElementById("email").style.background='#EEEEEE';
		return false;
	}
}

function avaliaContato()
{
	var doc = document.frmContato;
	var ddd = 2;
	var telefone = 8;
	
	if(doc.nome_contato.value == "")
	{
		alert("Informe o nome de contato");
		doc.nome_contato.focus();
		document.getElementById("nome_contato").style.border='solid 2px #ff0000';
		document.getElementById("nome_contato").style.background='#EEEEEE';
		return false;
	}
	
	if(!validaEmail(doc.email_contato.value))
	{
		alert("Informe um email válido");
		doc.email_contato.focus();
		document.getElementById("email_contato").style.border='solid 2px #ff0000';
		document.getElementById("email_contato").style.background='#EEEEEE';
		return false;
	}
	
	if(doc.ddd.value.length < ddd || isNaN(doc.ddd.value))
	{
		alert("Informe o DDD da sua região");
		doc.ddd.focus();
		document.getElementById("ddd").style.border='solid 2px #ff0000';
		document.getElementById("ddd").style.background='#EEEEEE';
		return false;
	}
	
	if(doc.telefone.value.length < telefone || isNaN(doc.telefone.value))
	{
		alert("Informe o telefone");
		doc.telefone.focus();
		document.getElementById("telefone").style.border='solid 2px #ff0000';
		document.getElementById("telefone").style.background='#EEEEEE';
		return false;
	}
	
	if(doc.codigoimg.value == "")
	{
		alert("Digite o código de segurança");
		doc.codigoimg.focus();
		document.getElementById("codigoimg").style.border='solid 2px #ff0000';
		document.getElementById("codigoimg").style.background='#EEEEEE';
		return false;
	}
}

function avaliaSolicite()
{
	var doc = document.frmSolicite;
	var ddd = 2;
	var telefone = 8;
	
	if(doc.nome.value == "")
	{
		alert("Informe o nome de contato");
		doc.nome.focus();
		document.getElementById("nome").style.border='solid 2px #ff0000';
		document.getElementById("nome").style.background='#EEEEEE';
		return false;
	}
	if(!validaEmail(doc.email.value))
	{
		alert("Informe um email válido");
		doc.email.focus();
		document.getElementById("email").style.border='solid 2px #ff0000';
		document.getElementById("email").style.background='#EEEEEE';
		return false;
	}
	if(doc.ddd.value.length < ddd)
	{
		alert("Informe o DDD da sua região");
		doc.ddd.focus();
		document.getElementById("ddd").style.border='solid 2px #ff0000';
		document.getElementById("ddd").style.background='#EEEEEE';
		return false;
	}
	
	if(doc.telefone.value.length < telefone)
	{
		alert("Informe o telefone");
		doc.telefone.focus();
		document.getElementById("telefone").style.border='solid 2px #ff0000';
		document.getElementById("telefone").style.background='#EEEEEE';
		return false;
	}
}

function avaliaIndique()
{
	var doc = document.frmIndique;
	
	if(doc.nome.value == "")
	{
		alert("Informe o nome de contato");
		doc.nome.focus();
		document.getElementById("nome").style.border='solid 2px #ff0000';
		document.getElementById("nome").style.background='#EEEEEE';
		return false;
	}
	if(!validaEmail(doc.email.value))
	{
		alert("Informe um email válido");
		doc.email.focus();
		document.getElementById("email").style.border='solid 2px #ff0000';
		document.getElementById("email").style.background='#EEEEEE';
		return false;
	}
	if(doc.nome_destinatario.value == "")
	{
		alert("Informe o nome de contato");
		doc.nome_destinatario.focus();
		document.getElementById("nome_destinatario").style.border='solid 2px #ff0000';
		document.getElementById("nome_destinatario").style.background='#EEEEEE';
		return false;
	}
	if(!validaEmail(doc.email_destinatario.value))
	{
		alert("Informe um email válido");
		doc.email_destinatario.focus();
		document.getElementById("email_destinatario").style.border='solid 2px #ff0000';
		document.getElementById("email_destinatario").style.background='#EEEEEE';
		return false;
	}
}

function mudacor(ref,cor)
{
  ref.style.backgroundColor=cor;
}

function tirarBorda(nome_campo)
{
	document.getElementById(nome_campo).style.border="solid 1px #999";
}

function Limpar(valor, validos) 
{
	// retira caracteres invalidos da string
	var result = "";
	var aux;
	for (var i=0; i < valor.length; i++)
	{
		aux = validos.indexOf(valor.substring(i, i+1));
		if (aux>=0)
		{
			result += aux;
		}
	}
	return result;
}

function Numero(par_tecla)
{
     var var_tecla = par_tecla.keyCode ? par_tecla.keyCode : par_tecla.which;
     /* Tecla Backspace */
     if (var_tecla == 8)
          {return true;}
	 /* Tecla Tab */
     if (var_tecla == 9)
          {return true;}
	 /* Tecla Left */
     if (var_tecla == 37)
          {return true;}
	 /* Tecla Right */
     if (var_tecla == 39)
          {return true;}
	 /* Tecla Delete */
     if (var_tecla == 46)
          {return true;}
	
	 /* Teclas Numéricas */
     if (var_tecla > 47 && var_tecla < 58) 
          {return true;}
     
     return false;
}

function somente_txt(par_tecla)
{
     var var_tecla = par_tecla.keyCode ? par_tecla.keyCode : par_tecla.which;
     /* Tecla Backspace */
     if (var_tecla == 8)
          {return true;}
	 /* Tecla Tab */
     if (var_tecla == 9)
          {return true;}
	 /* Tecla Space */
     if (var_tecla == 32)
          {return true;}
     /* Tecla Left */
     if (var_tecla == 37)
          {return true;}
	 /* Tecla Right */
     if (var_tecla == 39)
          {return true;}
	 /* Tecla Delete */
     if (var_tecla == 46)
          {return true;}
     /* Teclas a-z e A-Z */
     if ((var_tecla > 64 && var_tecla < 91) || (var_tecla > 96 && var_tecla < 123))
          {return true;}
     /* Teclas acentuadas e cidilha */
     if ((var_tecla > 191 && var_tecla < 221) || (var_tecla > 223 && var_tecla < 253))
          {return true;}
          
     return false;
}

//Formata número tipo moeda usando o evento onKeyDown

function Formata(campo,tammax,teclapres,decimal) 
{
	var tecla = teclapres.keyCode;
	vr = Limpar(campo.value,"0123456789");
	tam = vr.length;
	dec=decimal
	
	if (tam < tammax && tecla != 8){ tam = vr.length + 1 ; }
	
	if (tecla == 8 ){ tam = tam - 1 ; }
	
	if ( tecla == 8 || tecla >= 48 && tecla <= 57 || tecla >= 96 && tecla <= 105 )
	{
		if ( tam <= dec ){ campo.value = vr ; }
		if ( (tam > dec) && (tam <= 5) ){
		campo.value = vr.substr( 0, tam - 2 ) + "," + vr.substr( tam - dec, tam ) ; }
		if ( (tam >= 6) && (tam <= 8) ){
		campo.value = vr.substr( 0, tam - 5 ) + "." + vr.substr( tam - 5, 3 ) + "," + vr.substr( tam - dec, tam ) ; }
		if ( (tam >= 9) && (tam <= 11) ){
		campo.value = vr.substr( 0, tam - 8 ) + "." + vr.substr( tam - 8, 3 ) + "." + vr.substr( tam - 5, 3 ) + "," + vr.substr( tam - dec, tam ) ; }
		if ( (tam >= 12) && (tam <= 14) ){
		campo.value = vr.substr( 0, tam - 11 ) + "." + vr.substr( tam - 11, 3 ) + "." + vr.substr( tam - 8, 3 ) + "." + vr.substr( tam - 5, 3 ) + "," + vr.substr( tam - dec, tam ) ; }
		if ( (tam >= 15) && (tam <= 17) ){
		campo.value = vr.substr( 0, tam - 14 ) + "." + vr.substr( tam - 14, 3 ) + "." + vr.substr( tam - 11, 3 ) + "." + vr.substr( tam - 8, 3 ) + "." + vr.substr( tam - 5, 3 ) + "," + vr.substr( tam - 2, tam ) ; }
	} 
}


function FormataCEP(evt) 
{
	vr = (navigator.appName == 'Netscape') ?evt.target.value : evt.srcElement.value;
	if(vr.length == 5) vr = vr+"-";
	return vr;
}


//Limita caracteres em text area 

function Caracteres(objeto){
        var limite = 500;
        
        tamanho = objeto.value.length;
        if (tamanho>limite) {
  objeto.value = objeto.value.substring(0,limite);
  alert(erro);
        } else {
  document.getElementById('restantes').innerHTML = (limite-objeto.value.length);
        }
}

function validaEmail(mailField){
	var re = new RegExp;
	re = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	var arr = re.exec(mailField);
	if (arr == null){
		return false
	}
	else{
		return true
	}
}

function FormataDATA(evt) 
{
	vr = (navigator.appName == 'Netscape') ?evt.target.value : evt.srcElement.value;
	if(vr.length == 2) vr = vr+"/";
	if(vr.length == 5) vr = vr+"/";
	return vr;
}

function changeAssinale(tipo)
{
	if(tipo == "1")
	{
		document.getElementById("tb_assinale").style.display = "block";
		document.getElementById("tb_assinale").style.display = "none";
	}
	else if(tipo == "2")
	{
		document.getElementById("tb_assinale").style.display = "none";
		document.getElementById("tb_assinale").style.display = "block";
	}
	else
	{
		alert("Tipo Incorreto");
	}

}

//Limita caracteres em text area 

function Caracteres(objeto){
        var limite = 500;
        
        tamanho = objeto.value.length;
        if (tamanho>limite) {
  objeto.value = objeto.value.substring(0,limite);
  alert(erro);
        } else {
  document.getElementById('restantes').innerHTML = (limite-objeto.value.length);
        }
}

function validaCPF(s)	{
	var i;
	//s = limpa_string(s);
	if (s.length != 11) {
		return false
	}
	var c = s.substr(0,9);
	var dv = s.substr(9,2);
	var d1 = 0;
	for (i = 0; i < 9; i++)
	{
		d1 += c.charAt(i)*(10-i);
	}
        if (d1 == 0) return false;
	d1 = 11 - (d1 % 11);
	if (d1 > 9) d1 = 0;
	if (dv.charAt(0) != d1)
	{
		return false;
	}

	d1 *= 2;
	for (i = 0; i < 9; i++)
	{
		d1 += c.charAt(i)*(11-i);
	}
	d1 = 11 - (d1 % 11);
	if (d1 > 9) d1 = 0;
	if (dv.charAt(1) != d1)
	{
		return false;
	}
        return true;
}


