// JavaScript Document
function avalia_form_login()
{
	var login=document.form1.login.value;
	var senha=document.form1.senha.value;
	if(login=="")
	{
		alert("Digite seu E-mail");
		//document.getElementById("login").focus();
		return false;		
	}
	if(login.indexOf("@")==-1 || login.indexOf(".")==-1)
	{
		alert("E-mail Incorreto");
		//document.getElementById("login").focus();
		return false;
	}
	if(senha=="")
	{
		alert("Digite sua senha");
		//document.getElementById("senha").focus();
		return false;
	}
}
function avalia_minilogin()
{
	var login=document.frmninilogin.loginmini.value;
	var senha=document.frmninilogin.senhamini.value;
	if(login=="")
	{
		alert("Digite seu E-mail");
		//document.getElementById("login").focus();
		return false;		
	}
	if(login.indexOf("@")==-1 || login.indexOf(".")==-1)
	{
		alert("E-mail Incorreto");
		//document.getElementById("login").focus();
		return false;
	}
	if(senha=="")
	{
		alert("Digite sua senha");
		//document.getElementById("senha").focus();
		return false;
	}
}

function validaEmail(email)
{
	if(email=="")
	{
		return false;
	}
	else
	{
		if(email.indexOf("@")==-1 || email.indexOf(".")==-1)
		{
			return false;
		}
		else
		{
				return true;
		}
	}
}

function validaCNPJ(CNPJ) 
{
	erro = new String;
	if (CNPJ.length < 18) 
		erro += "É necessario preencher corretamente o número do CNPJ! ";
	if ((CNPJ.charAt(2) != ".") || (CNPJ.charAt(6) != ".") || (CNPJ.charAt(10) != "/") || (CNPJ.charAt(15) != "-"))
	{
		if (erro.length == 0) 
			erro += "É necessário preencher corretamente o número do CNPJ! ";
	}
	//substituir os caracteres que não são números
	if(document.layers && parseInt(navigator.appVersion) == 4)
	{
		x = CNPJ.substring(0,2);
		x += CNPJ. substring (3,6);
		x += CNPJ. substring (7,10);
		x += CNPJ. substring (11,15);
		x += CNPJ. substring (16,18);
		CNPJ = x;
	} 
	else 
	{
		CNPJ = CNPJ. replace (".","");
		CNPJ = CNPJ. replace (".","");
		CNPJ = CNPJ. replace ("-","");
		CNPJ = CNPJ. replace ("/","");
	}
	var nonNumbers = /\D/;
	if (nonNumbers.test(CNPJ)) 
		erro += "A verificação de CNPJ suporta apenas números! ";
	
	var a = [];
	var b = new Number;
	var c = [6,5,4,3,2,9,8,7,6,5,4,3,2];
	for (i=0; i<12; i++)
	{
		a[i] = CNPJ.charAt(i);
		b += a[i] * c[i+1];
	}
	if ((x = b % 11) < 2) 
	{ 
		a[12] = 0 ;
	} 
	else 
	{ 
		a[12] = 11-x; 
	}
	b = 0;
	for (y=0; y<13; y++) 
	{
		b += (a[y] * c[y]);
	}
	if ((x = b % 11) < 2) 
	{ 
		a[13] = 0; 
	} 
	else 
	{ 
		a[13] = 11-x;
	}
	if ((CNPJ.charAt(12) != a[12]) || (CNPJ.charAt(13) != a[13]))
	{
		erro +="Dígito verificador com problema!";
	}
	if (erro.length > 0)
	{
		return false;
	} 
	else 
	{
		return true;
	}
}

function validaData(data)
{
	//verifica se os caracters de separação são "/" 
	a=data.substr(2,1);
	b=data.substr(5,1);
	dia=data.substring(0,2);
	mes=data.substring(3,5);
	ano=data.substring(6,10);
	if(dia>31 || dia<0 || isNaN(dia))
	{
		return false;
	}
	else
	{
		if(mes > 12 || mes < 0 || isNaN(mes))
		{
			return false
		}
		else
		{
			if(ano<1800 || isNaN(ano))
			{
				return false;
			}
			else
			{
				if(a!="/" || b!="/")
				{
					return false;
				}
				else
				{
					return true;
				}
			}
		}
	}
}

function popup(URL, w, h, m) 
{
	if(w==undefined){
		w=650;
	}
	if(h==undefined){
		h=500;
	}
	if(m==undefined){
		m=0;
	}
	day = new Date();
	id = day.getTime();
	eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar="+ m +",resizable=0,width="+ w +",height="+ h +",left=0,top=0');");
}

// Por não ter tempo de alterar coloquei essas função da macromedia aqui pois tem muitas paginas que usam essa função
function MM_openBrWindow(theURL,winName,features) 
{ 
  window.open(theURL,winName,features);
}


/*
function numberFormat(valor)
{
	// alert(valor);
	if(!isNaN(valor))
	{
		var tamanho_str;
		var tamanho;
		tamanho_str=toString(valor);
		tamanho=tamanho_str.length;
		alert(tamanho);
		for(a=0; a<tamanho; a++)
		{
			if(tamanho_str.charAt(a)==".")
			{
				if(tamanho_str.charAt(++a)!="" && tamanho_str.charAt(a+2)!="")
				{
					retorno=tamanho_str.substring(0, (a+2));
					return (retorno);
				}
				else
				{
					if(tamanho_str.charAt(++a)!="" && tamanho_str.charAt(a+2)=="")
					{
						retorno=tamanho_str.substring(0, ++a);
						retorno=retorno+"0";
						return (retorno);
					}
					else
					{
						if(tamanho_str.charAt(++a)=="" && tamanho_str.charAt(a+2)=="")
						{
							retorno=tamanho_str.substring(0, a);
							retorno=retorno+"00";
							return (retorno);
						}
					}
				}
			}
		}
	}
	else
	{
		return (NaN);
	}
	
}
*/

