
function validFilter(myForm){
	if (myForm.filter[myForm.filter.selectedIndex].value == '' ){
		alert('Selecione uma palavra-chave');
		myForm.filter.focus();
		return false;
	}
	
	if (myForm.search_by_keywords){
		if (myForm.filter[myForm.filter.selectedIndex].value == "all"){
			myForm.search_by_keywords.value = "any";
		}
		else{
			myForm.search_by_keywords.value = myForm.filter[myForm.filter.selectedIndex].value;
		}
	}
}


//BOM VERIFICADOR DE EMAIL
function emailCheck (emailStr) {
  var checkTLD=0;
  var knownDomsPat=/^(com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum)$/;
  var emailPat=/^(.+)@(.+)$/;
  var specialChars="\\(\\)><@,;:\\\\\\\"\\.\\[\\]";
  var validChars="\[^\\s" + specialChars + "\]";
  var quotedUser="(\"[^\"]*\")";
  var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/;
  var atom=validChars + '+';
  var word="(" + atom + "|" + quotedUser + ")";
  var userPat=new RegExp("^" + word + "(\\." + word + ")*$");
  var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$");
  var matchArray=emailStr.match(emailPat);
 
  if (matchArray==null)
  {
    alert("Por favor, verifique novamente o email digitado.");
    return false;
  }
  var user=matchArray[1];
  var domain=matchArray[2];

  for (i=0; i<user.length; i++)
  {
    if (user.charCodeAt(i)>127)
    {
      alert("O nome de usuário de email contém caracteres inválidos.");
      return false;
    }
  }
 
  for (i=0; i<domain.length; i++)
  {
    if (domain.charCodeAt(i)>127)
    {
      alert("O nome do domínio do email contém caracteres inválidos.");
      return false;
    }
  }

  if (user.match(userPat)==null)
  {
    alert("Por favor, verifique o nome de usuário de email.");
    return false;
  }

  var IPArray=domain.match(ipDomainPat);
  if (IPArray!=null)
  {
    for (var i=1;i<=4;i++)
    {
      if (IPArray[i]>255) {
        alert("Por favor, verifique o ip de destino.");
        return false;
      }
    }
  return true;
  }

  var atomPat=new RegExp("^" + atom + "$");
  var domArr=domain.split(".");
  var len=domArr.length;
  for (i=0;i<len;i++)
  {
    if (domArr[i].search(atomPat)==-1)
    {
      alert("Por favor, verifique o nome do domínio do email.");
      return false;
    }
  }

  if (len<2) {
    alert("Por favor, verifique o email digitado.");
  return false;
  }
 
  return true;
}




function postForm(myForm){
	//TRATAMENTO PADRAO
	if (myForm.name.value == ''){
		alert("Preencha o campo 'Nome'.");
		myForm.name.focus();
		return false;
	}
	
	if (myForm.email.value == ''){
		alert("Preencha o campo 'E-mail'");
		myForm.email.focus();
		return false;
	}
	
	if (!emailCheck(myForm.email.value)){
		myForm.email.focus();
		return false;
	}
	
	if (myForm.ocupation.value == ''){
		alert("Preencha o campo 'Profissão'.");
		myForm.ocupation.focus();
		return false;
	}
	if (myForm.actarea[myForm.actarea.selectedIndex].value == ''){
		alert("Selecione a área de atuação.");
		myForm.actarea.focus();
		return false;
	}
	
	G_hasClickedCheckbox = false;
	
	for(x=0; x < myForm.length; x++){
		if (myForm.elements[x].type == 'checkbox'){
			if (myForm.elements[x].checked == true){
				G_hasClickedCheckbox = true;
			}
		}
	}
	
	if (G_hasClickedCheckbox == false){
		alert("Informe seu setor de atuação.");
		return false;
	}
	
	
	if (myForm.password.value == ''){
		alert("Preencha o campo 'Senha'.");
		myForm.password.focus();
		return false;
	}
	
	if (myForm.confir_password.value == ''){
		alert("Preencha o campo 'Confirmar Senha'.");
		myForm.confir_password.focus();
		return false;
	}
	
	//TRATAMENTO ESPECIAL
	if (myForm.password.value != myForm.confir_password.value){
		alert("Os valores do campos 'Senha' e 'Confirmar senha' devem ser iguais.");
		myForm.confir_password.focus();
		return false;
	}
	
	
	return true;;
}

function postContactForm(myForm){
	if (myForm.nome.value == ''){
		alert("Preencha o campo 'Nome'.");
		myForm.nome.focus();
		return false;
	}
	
	if (myForm.email.value == ''){
		alert("Preencha o campo 'E-mail'");
		myForm.email.focus();
		return false;
	}
	
	if (!emailCheck(myForm.email.value)){
		myForm.email.focus();
		return false;
	}
	
	if (myForm.assunto.value == ''){
		alert("Preencha o campo 'Assunto'.");
		myForm.assunto.focus();
		return false;
	}
	
	if (myForm.mensagem.value == ''){
		alert("Preencha o campo 'Mensagem'.");
		myForm.mensagem.focus();
		return false;
	}
	
	
	return true;;
}


function showCSS(pathURL){
	var browserName = new String(navigator.appName);
	var browserVersion = new String(navigator.appVersion)
	
	if (browserVersion.indexOf('MSIE') != -1){
		if (browserVersion.indexOf('MSIE 6.0') != -1) {
			document.write('<link href="'+pathURL+'css/geral.css" rel="stylesheet" type="text/css" />');
		}
		else{
			document.write('<link href="'+pathURL+'css/geral_ie7.css" rel="stylesheet" type="text/css" />');
		}
	}
	else{
		if (browserName.indexOf('Netscape') != -1){
			document.write('<link href="'+pathURL+'css/geral_ff.css" rel="stylesheet" type="text/css" />');
		}
		else{
			document.write('<link href="'+pathURL+'css/geral_opera.css" rel="stylesheet" type="text/css" />');
		}
	}
	
	return ;
}



//Specify affected tags. Add or remove from list:
var tgs = new Array('div');

//Specify spectrum of different font sizes:
var szs = new Array( '8px','9px','10px','11px','12px','13px','14px','15px','16px','17px' );
var startSz = 2; 

function ts( trgt,inc ) {
if (!document.getElementById) return
var d = document,cEl = null,sz = startSz,i,j,cTags;

sz += inc;
if ( sz < 0 ) sz = 0;
if ( sz > 9 ) sz = 9;
startSz = sz;

if ( !( cEl = d.getElementById( trgt ) ) ) cEl = d.getElementsByTagName( trgt )[ 0 ];

cEl.style.fontSize = szs[ sz ];

for ( i = 0; i < tgs.length; i++ ) {
cTags = cEl.getElementsByTagName( tgs[ i ] );
for ( j = 0; j < cTags.length; j++ ) cTags[ j ].style.fontSize = szs[ sz ];
}
}
