<!--
function doSubmitBusqueda() {
//	if( (document.forms[0].elements["etapaEducativa"].selectedIndex==0) &&
//	    (document.forms[0].elements["areaEducativa"].selectedIndex==0) &&
//	    (document.forms[0].elements["tipusMaterial"].selectedIndex==0) &&
//	    (document.forms[0].elements["coleccio"].selectedIndex==0) &&
//	    (document.forms[0].elements["cicle"].selectedIndex==0) ) {
		
//		alert("Al menys un dels desplegables ha d'estar informat per poder fer la cerca.");
//		return
//	}
	
	if(document.forms[0].elements["etapaEducativa"].value=="infantil") {
		document.location.href="http://www.text-lagalera.cat:9521/escolar/catalegs/TAM_TAM_DESPLEGABLE.pdf";
                 //document.location.href="http://www.grec.net/home/escolar/infantil/hinfantil.htm";
		return;
	}
	
	document.forms[0].action = "listadoLibros.jsp";
	document.forms[0].submit();	   
}

function doSubmitEnlaces() {
	document.forms[0].action = "enlaces.jsp";
	document.forms[0].submit();	   
	
}

function goToLibro(id, theUrl) {
	document.forms[0].elements["idLibro"].value = id;
	document.forms[0].action = theUrl;
	document.forms[0].submit();	   
	
}

function reloadCiclo(combo) {
	
	if(combo.selectedIndex==0) {
//Neutro: habilitamos el combo de ciclo
		document.forms[0].elements["cicle"].disabled=false;
		document.forms[0].elements["areaEducativa"].disabled=false;
		document.forms[0].elements["tipusMaterial"].disabled=false;
		document.forms[0].elements["coleccio"].disabled=false;
		
		oldArea = document.forms[0].elements["areaEducativa"].value;
		deleteCombo("areaEducativa");
		insertRowsCombo("areaEducativa", arrayNeutra[0], oldArea);
		
		oldTipus = document.forms[0].elements["tipusMaterial"].value;
		deleteCombo("tipusMaterial");
		insertRowsCombo("tipusMaterial", arrayNeutra[1], oldTipus);
		
		oldColeccio = document.forms[0].elements["coleccio"].value;
		deleteCombo("coleccio");
		insertRowsCombo("coleccio", arrayNeutra[2], oldColeccio);
		
		oldCicle = document.forms[0].elements["cicle"].value;
		deleteCombo("cicle");
		insertRowsCombo("cicle", arrayNeutra[3], oldCicle);
		
	}
	if(combo.selectedIndex==1) {
//Infantil: deshabilitamos todos los combos
		document.forms[0].elements["areaEducativa"].selectedIndex=0;
		document.forms[0].elements["areaEducativa"].disabled=true;
		document.forms[0].elements["tipusMaterial"].selectedIndex=0;
		document.forms[0].elements["tipusMaterial"].disabled=true;
		document.forms[0].elements["coleccio"].selectedIndex=0;
		document.forms[0].elements["coleccio"].disabled=true;
	}
	if(combo.selectedIndex==2) {
//Primaria: cargamos combos con info de primaria
		document.forms[0].elements["cicle"].disabled=false;
		document.forms[0].elements["areaEducativa"].disabled=false;
		document.forms[0].elements["tipusMaterial"].disabled=false;
		document.forms[0].elements["coleccio"].disabled=false;
		
		oldArea = document.forms[0].elements["areaEducativa"].value;
		deleteCombo("areaEducativa");
		insertRowsCombo("areaEducativa", arrayPrimaria[0], oldArea);
		
		oldTipus = document.forms[0].elements["tipusMaterial"].value;
		deleteCombo("tipusMaterial");
		insertRowsCombo("tipusMaterial", arrayPrimaria[1], oldTipus);
		
		oldColeccio = document.forms[0].elements["coleccio"].value;
		deleteCombo("coleccio");
		insertRowsCombo("coleccio", arrayPrimaria[2], oldColeccio);
		
		oldCicle = document.forms[0].elements["cicle"].value;
		deleteCombo("cicle");
		insertRowsCombo("cicle", arrayPrimaria[3], oldCicle);
				
	}
	if(combo.selectedIndex==3) {
//ESO: cargamos combos con info de ESO
		document.forms[0].elements["areaEducativa"].disabled=false;
		document.forms[0].elements["tipusMaterial"].disabled=false;
		document.forms[0].elements["coleccio"].disabled=false;
		
		oldArea = document.forms[0].elements["areaEducativa"].value;
		deleteCombo("areaEducativa");
		insertRowsCombo("areaEducativa", arrayESO[0], oldArea);
		
		oldTipus = document.forms[0].elements["tipusMaterial"].value;
		deleteCombo("tipusMaterial");
		insertRowsCombo("tipusMaterial", arrayESO[1], oldTipus);
		
		oldColeccio = document.forms[0].elements["coleccio"].value;
		deleteCombo("coleccio");
		insertRowsCombo("coleccio", arrayESO[2], oldColeccio);
		
		oldCicle = document.forms[0].elements["cicle"].value;
		deleteCombo("cicle");
		insertRowsCombo("cicle", arrayESO[3], oldCicle);
		
	}
	if(combo.selectedIndex==4) {
//Bachillerato: cargamos combos con info de Bachillerato
		document.forms[0].elements["areaEducativa"].disabled=false;
		document.forms[0].elements["tipusMaterial"].disabled=false;
		document.forms[0].elements["coleccio"].disabled=false;
		
		oldArea = document.forms[0].elements["areaEducativa"].value;
		deleteCombo("areaEducativa");
		insertRowsCombo("areaEducativa", arrayBatxillerat[0], oldArea);
		
		oldTipus = document.forms[0].elements["tipusMaterial"].value;
		deleteCombo("tipusMaterial");
		insertRowsCombo("tipusMaterial", arrayBatxillerat[1], oldTipus);
		
		oldColeccio = document.forms[0].elements["coleccio"].value;
		deleteCombo("coleccio");
		insertRowsCombo("coleccio", arrayBatxillerat[2], oldColeccio);
		
		oldCicle = document.forms[0].elements["cicle"].value;
		deleteCombo("cicle");
		insertRowsCombo("cicle", arrayBatxillerat[3], oldCicle);
		
	}
	calculaComboCiclo();
}

function calculaComboCiclo() {
	auxCombo = document.forms[0].elements["etapaEducativa"];
	if((auxCombo.selectedIndex==0)||(auxCombo.selectedIndex==2)) {
		document.forms[0].elements["cicle"].disabled=false;
	} else {	
		document.forms[0].elements["cicle"].selectedIndex=0;
		document.forms[0].elements["cicle"].disabled=true;
	}
}

function obtenerHTML(oldValue, theList) {
	var str="";
	for(i=0;i<theList.length;i++) {
		str += "<option value='" + theList[i];
		if(oldValue==theList[i])
			str += "' selected>";
		else 
			str += "'>";
		str += theList[i] + "</option>";
	}
}


function deleteCombo(comboName) {
	var theCombo = document.forms[0].elements[comboName];
	while(theCombo.length>1) {
		theCombo.remove(theCombo.length - 1);
	}
	theCombo.size=1;
}

function insertRowsCombo(comboName, strArray, value) {
	if((strArray==null)||(strArray=="")||(strArray.length<=0))
		return;
	var theCombo = document.forms[0].elements[comboName];
	var theArray = strArray.split("::");
	for(i=0;i<theArray.length;i++) {
		if(value==theArray[i])
			theCombo[i+1] = new Option(theArray[i],theArray[i],true);
		else
			theCombo[i+1] = new Option(theArray[i],theArray[i]);
	}
}

//-->