// JavaScript Document
function ValidarBusca(f)
{
	if(f.busca.value.length < 3)
	{
		alert('O texto deve conter pelo menos 3 caracteres');
		return false;
	}
	return true
}

function ValidarContato(f)
{
	if(f.nome.value == '')
	{
		alert("Entre com seu nome completo");
		f.nome.focus();
		return false;
	}
	if(!ValidarEmail(f.email.value))
	{
		alert("Entre com um e-mail válido");
		f.email.focus();
		return false;
	}
	if(f.assunto.value == '')
	{
		alert("Entre com um assunto para a mensagem");
		f.assunto.focus();
		return false;
	}
	if(f.mensagem.value == '')
	{
		alert("Entre com uma mensagem, para o contato");
		f.mensagem.focus();
		return false;
	}
	return true;
}



function ValidarLogin(f)
{
	if(f.login.value.length < 3)
	{
		alert("Por favor, entre com seu login.");
		f.login.focus()
		return false;
	}
	
	if(f.senha.value.length < 3)
	{
		alert("Por favor, entre com sua senha.");
		f.senha.focus()
		return false;
	}
	return true;
}

function ValidarLoginComStatus(f,divLogin, divSenha)
{
	if(f.login.value.length < 3)
	{
		document.getElementById(divLogin).innerHTML = "*";
		alert("Por favor, entre com seu login.");
		f.login.focus()
		return false;
	}
	
	if(f.senha.value.length < 3)
	{
		document.getElementById(divSenha).innerHTML = "*";
		document.getElementById(divLogin).innerHTML = "";
		alert("Por favor, entre com sua senha.");
		f.senha.focus()
		return false;
	}
	return true;
}


// JavaScript Document
function ValidarCampoTexto(s)
{
	if(s.length < 2)
		return false
	return true
}

function ValidarCombo(combo)
{
	if(combo.options[combo.selectedIndex].value == "")
		return false;
	else
		return true;
}

function ValidarCPF(s)
{ 
	var i; 
	s = s.replace(".","");
	s = s.replace(".","");
	s = s.replace("-","");
	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; 
}

function ValidarEmail(email)
{
	if (email == "")
		return false

	var invalidChars = " /\;:'"
	var badchar

	for(i=0;i < invalidChars.length;i++)
	{
		badChar = invalidChars.charAt(i)
		if (email.indexOf(badChar,0) > -1)
			return false
	}
	atPos = email.indexOf("@",1)

	if (atPos == -1)
		return false

	if (email.indexOf("@",atPos+1) > -1)
		return false
	periodPos = email.indexOf(".",atPos)

	if (periodPos == -1)
		return false

	if (periodPos+3 > email.length)
		return false
		
	return true
}

//Função para exibir/ocultar a camada
function toggleMenu(currMenu)
{
	if(document.getElementById)
	{
		thisMenu = document.getElementById(currMenu).style
		
		if(thisMenu.display == "block")
				thisMenu.display = "none"
		else
			thisMenu.display = "block"
		return false
	}
	else
		return true
}


// Verifica se a data apresentada ou no uma data válida
function IsDate(day, month, year) {
	//IsDate(29, 2, 2005)
	//IsDate(29, 2, 2004)
	var date = new Date();
	var blnRet = false;
	var blnDay;
	var blnMonth;
	var blnYear;

	date.setFullYear(year, month -1, day);

	blnDay   = (date.getDate()      == day);
	blnMonth = (date.getMonth()     == month -1);
	blnYear  = (date.getFullYear()  == year);

	if (blnDay && blnMonth && blnYear)
	blnRet = true;

	return blnRet;
}



function ProtegerSelecao()
{
	alert('Todos os Direitos Resevados 2008');
	return false;
}

/*
function ProtegerCodigo()
{
	if (event.button==2||event.button==3)
   		alert('Todos os Direitos Resevados 2008');
}

function rejeitaTecla(oEvent){    
//by Micox - elmicox.blogspot.com - www.ievolutionweb.com
    var cod_tecla=62; //tecla que quer bloquear

    //filtrando o evento
    var oEvent = oEvent ? oEvent : window.event;
    var tecla = (oEvent.keyCode) ? oEvent.keyCode : oEvent.which;
    
    if(oEvent.type=="keydown" && navigator.appName.indexOf('Internet Explorer')<0 ){
        alert("alert 1");
		//se for keydown e não for o IE, vazarei pois o keypress já foi executado
        return false;
    }
    
    if (typeof(oEvent.keyCode)=='number' && oEvent.keyCode == cod_tecla){
        if (typeof(oEvent.preventDefault)=='function'){
			alert("alert 2");
            oEvent.preventDefault();
        } else {
			alert("3");
            oEvent.returnValue = false;
            oEvent.keyCode = 0;
        }
    }
    return false;
}
document.onkeypress = rejeitaTecla; //Pro Opereta e FF. O keydown nao tem preventDefault no OP.
document.onkeydown = rejeitaTecla; //Pro IE. O IE 6 não executa funcoes no keypress.

*/

/*
--->INÍCIO
//FUNÇÃO QUE DESABILITA O BOTÃO DIREITO DO MOUSE
function click() 
{
	if (event.button==2||event.button==3) 
	{
		oncontextmenu='return false';
	}
}
document.onmousedown=click
document.oncontextmenu = new Function("alert('Todos os Direitos Reservados!');return false;")
FINAL<---
*/

/*
--->INÍCIO
//FUNÇÃO QUE DESABILITA A SELEÇÃO DE TEXTOS NO SITE
function disableSelection(target){
if (typeof target.onselectstart!="undefined") //IE route
target.onselectstart=function(){return false}
else if (typeof target.style.MozUserSelect!="undefined") //Firefox route
target.style.MozUserSelect="none"
else //All other route (ie: Opera)
target.onmousedown=function(){return false}
target.style.cursor = "default"
}
//window.sidebar=disableSelection(document.body);

//document.onmousedown=ProtegerCodigo;
//document.onselectstart=ProtegerSelecao;
FINAL<----
*/
