function atomzForm(oForm) {
	var areas, autor, s
	s = ""
	s += oForm.query.value + " "
//	if (!oForm.query.value || oForm.query.value == " ") {s = "* "}
	var a = oForm.area
	if (a[0].checked == false) {
		for (i = 1; i < a.length; i++) {
			if (a[i].checked) {s += "keys:\"" + a[i].value + "\" "}
		}
	}
	var m = oForm.medio;
	var m_cant = 0;
	for (i = 1; i < m.length; i++) {//contar cuántos medios se seleccionan
		if (m[i].checked) {m_cant++;}
	}
//	alert(m_cant);
	for (i = 1; i < m.length; i++) {// el medio debe ser distinto "Todos" (index=0), que no tiene valor
		if (m[i].checked) {
			if (m_cant < 2) {s += "+"} //hay menos de 2 medios, entonces obligatorio que aparezca en ese medio
			s += "keys:\"" + m[i].value + "\" "
		}
	}

	if (oForm.autor.value) { //el input autor está vacio
		s += "+keys:\"" + oForm.autor.value + "\" ";
	} else { //input autor vacio -> buscar en select autores
		if(oForm.autores.value) { //se ha seleccionado
			s += "+keys:\"" + oForm.autores.value + "\" ";
		}
	}

	document.getElementById("realForm")["sp-date-range"].value = oForm["date-range"].value;
	document.getElementById("realForm")["sp-q"].value = s;
//	document.all.realForm.enviar.focus();
	document.getElementById("realForm").submit();
	return false;
}
function markAllAreas(oForm) {
	var a = oForm.area	
	if (a[0].checked == true) {
		for (i=1; i < a.length; i++) {
			a[i].checked = true;
		}
	}

}
function markArea(oForm, oChk) {
	//marca los checkboxes
	// si está habilitada la opcion "todas las areas" antes desmarca todos
	var a = oForm.area
	var c = oChk
	if (a[0].checked == true) {
		a[0].checked = false;
		clearArea(oForm, true);
		c.checked = true;
	}
	function marcarPrimero (){
		//marca la opcion todos, si todos están marcados
		var algunoNoMarcado = false;
		for (i=1; i < a.length; i++) {
			if (a[i].checked == false) {algunoNoMarcado = true}
		}
		if (algunoNoMarcado == false) {a[0].checked = true;}
	}
	//marcarPrimero();

}

function clearArea(oForm, bTodos) {
	var a = oForm.area
	if (bTodos) 	{
//		alert("desmarcar todos");
		for (i=1; i < a.length; i++) {
			a[i].checked = false;
		}
	}
	else	{
//		alert("desmarcar solo el primero")
		a[0].checked = false;
	}
}

function clearMedio(oForm, bTodos) {
	var m = oForm.medio
	if (bTodos) 	{
//		alert("desmarcar todos");
		for (i=1; i < m.length; i++) {
			m[i].checked = false;
		}
	}
	else	{
//		alert("desmarcar solo el primero")
		m[0].checked = false;
	}
}
