function mudaBusca(opcao){
   if(opcao != "0"){
	   if(opcao.value == "busca_google" || opcao == "busca_google"){
		  document.getElementById("busca_portal").style.display = "none";
		  document.getElementById("busca_arquivo").style.display = "none";
		  document.getElementById("busca_google").style.display = "";
	   }else if(opcao.value == "busca_portal" || opcao == "busca_portal"){
		  document.getElementById("busca_google").style.display = "none";
		  document.getElementById("busca_arquivo").style.display = "none";
		  document.getElementById("busca_portal").style.display = "";
	   }else if(opcao.value == "busca_arquivo"  || opcao == "busca_arquivo"){
		  document.getElementById("busca_portal").style.display = "none";
		  document.getElementById("busca_google").style.display = "none";
		  document.getElementById("busca_arquivo").style.display = "";
	   }
   }else{
	  document.getElementById("busca_portal").style.display = "none";
	  document.getElementById("busca_arquivo").style.display = "none";
	  document.getElementById("busca_google").style.display = "";
   }
}

function mudaBuscaData(opcao){
   if(opcao != "0"){
	   if(opcao.value == "periodo"){
		  document.getElementById("data").style.display = "none";
		  document.getElementById("periodo").style.display = "";
		  document.form1.de.value="";
	   }else if(opcao.value == "dia"){
		  document.getElementById("data").style.display = "";
		  document.getElementById("periodo").style.display = "none";
		  document.form1.dex.value="";
		  document.form1.ds.value="";
	   }else if(opcao.value == "todos"){
		  document.getElementById("data").style.display = "none";
		  document.getElementById("periodo").style.display = "none";
		  document.form1.de.value="";
		  document.form1.dex.value="";
		  document.form1.ds.value="";
	   }
   }else{
	  document.getElementById("data").style.display = "none";
	  document.getElementById("periodo").style.display = "none";
   }
}
function executarBusca(form){

	var texto_alerta = "";
	var texto_erro = "";

	if(form.tipo_busca.value == 0){
		if(form.q.value == 0){
			texto_alerta = texto_alerta+"\n - Palavra-chave";
		}
		if(form.c.value == 0){
			texto_alerta = texto_alerta+"\n - Canal";
		}
		if(form.f.value == 'todos'){
			texto_alerta = texto_alerta+"\n - Filtro";
		}else{
			if(form.f.value == 'periodo'){
				if(form.dex.value == ""){
					texto_alerta = texto_alerta+"\n - Data de início";
				} else {
				  if(!dataValida(form.dex.value,form.dex)){
					texto_erro = texto_erro+"\n - Data de início";
				  } 
				}
				if(form.ds.value == ""){
					texto_alerta = texto_alerta+"\n - Data de término";
				} else {
				  if(!dataValida(form.ds.value,form.ds)){
					texto_erro = texto_erro+"\n - Data de término";
				  } 
				}
			}
			if(form.f.value == 'dia'){
				if(form.de.value == ""){
				 texto_alerta = texto_alerta+"\n - Data";
				} else {
				  if(!dataValida(form.de.value,form.de)){
					  texto_erro = texto_erro+"\n - Data";
				  } 
				}
			}
		}
	}
	if(form.tipo_busca.value == 2){
		if(form.de.value == ""){
		 texto_alerta = texto_alerta+"\n - Data";
		} else {
		  if(!dataValida(form.de.value,form.de)){
			  texto_erro = texto_erro+"\n - Data";
		  } 
		}
	}
	if(form.tipo_busca.value == 1){
		if(form.q.value == 0){
			texto_alerta = texto_alerta+"\n - Palavra-chave";
		}
	}
	if(texto_alerta == ""){
		if(texto_erro!=""){
			alert("Campos incorretos :\n"+texto_erro);
			return;
		} else{	 
			if(form.tipo_busca.value == 1){
				form.method = "GET";
				form.action = "http://www.google.com/u/atarde";
			}else{
				form.method = "POST";
				form.action = "/busca/busca.jsp?efetuar=1";
			}
			form.submit();
		}
	}else{
		if(texto_erro!=""){
			alert("Campos obrigatórios :"+texto_alerta+"\n\nCampos incorretos :"+texto_erro);
			return;
		}
		else{
			alert("Campos obrigatórios :\n"+texto_alerta);		 
			return;
		}
	} 
}