function ObtenerDatos(datos,divID) { 
	var obj = document.getElementById(divID); 
	var peticion = false; 
	if (window.XMLHttpRequest) { 
    	peticion = new XMLHttpRequest(); 
    } else if (window.ActiveXObject) { 
        peticion = new ActiveXObject("Microsoft.XMLHTTP"); 
	}
	if(peticion) { 
		var url=datos;
     	peticion.open("GET", url);   //
     	peticion.onreadystatechange = function()  { 
        	if (peticion.readyState == 4) { 
         		obj.innerHTML = peticion.responseText	;
		   	} 
     	} 
		peticion.send(null); 
	}
	
}

function MostrarFilas(Fila) { 
var elementos = document.getElementsByName(Fila); 
    for (i = 0; i< elementos.length; i++) { 
        if(navigator.appName.indexOf("Microsoft") > -1){ 
               var visible = 'block'; 
        } else { 
               var visible = 'table-row'; 
        } 
elementos[i].style.display = visible; 
        } 
} 
  
function OcultarFilas(Fila) { 
    var elementos = document.getElementsByName(Fila); 
    for (k = 0; k< elementos.length; k++) { 
         elementos[k].style.display = "none"; 
    } 
}  

function ValidarRecurso(f){
	if (f.titulo.value == "" && f.editorial.value=="" && f.autor.value==""){
		alert("Tienes que rellenar al menos uno de los campos");
		return false;
	}
	return true;
}

function ValidarValInscripciones(f){

	if(f.codigo.value==""){
		alert("Rellene el código");
		return false;
	}
	
	return true;
}

function ValidarInscripciones(f){

	if(f.id_actividad.value==""){
		alert("Seleccione una actividad");
		return false;
	}
	if(f.nombre_persona.value==""){
		alert("Rellene su nombre");
		return false;
	}
	if(f.apellidos.value==""){
		alert("Rellene los apellidos");
		return false;
	}
	if(f.nif.value==""){
		alert("Rellene el nif");
		return false;
	}
	if(f.telefono.value==""){
		alert("Rellene el teléfono");
		return false;
	}
	if(f.email.value==""){
		alert("Rellene el correo electrónico");
		return false;
	}
	if(f.domicilio.value==""){
		alert("Rellene el domicilio");
		return false;
	}
	if(f.c_postal_persona.value==""){
		alert("Rellene el código postal");
		return false;
	}
	if(f.localidad.value==""){
		alert("Rellene la localidad");
		return false;
	}
	if(f.provincia.value==""){
		alert("Rellene la provincia");
		return false;
	}
	if(f.nombre_centro.value==""){
		alert("Rellene el nombre del Centro");
		return false;
	}
	if(f.tipo_centro.value==""){
		alert("Rellene el tipo del Centro");
		return false;
	}
	if(f.nivel.value==""){
		alert("Rellene el nivel que imparte");
		return false;
	}
if(f.area.value==""){
		alert("Rellene el Area/Materia/Especialidad");
		return false;
	}
if(f.anos_exp.value==""){
		alert("Rellene los años de experiencia");
		return false;
	}
if(f.situacion.value==""){
		alert("Rellene la situación administrativa");
		return false;
	}
	if(f.email.value==""){
		alert("Rellene el correo electrónico");
		return false;
	}else{
		var str=f.email.value
		var filter=/^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/
		if (filter.test(str))
			testresults=true
		else{
			alert("El E-mail no es correcto")
			return false;
		}
	}
	return true;
}

function validarmail(f){
	if(f.nombre.value==""){
		alert("Rellene su nombre");
		return false;
	}
	if(f.email.value==""){
		alert("Rellene el E-mail");
		return false;
	}else{
		var str=f.email.value
		var filter=/^(\w+(?:\.\w+)*)@((?:\w+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
		if (filter.test(str))
			testresults=true
		else{
			alert("El E-mail no es correcto")
			return false;
		}
	}
	if(f.asunto.value==""){
		alert("Rellene el asunto");
		return false;
	}
	if(f.texto.value==""){
		alert("Rellene la consulta");
		return false;
	}

}

function ValidarSolucitud(f){
	
	if(f.nombre_material.value==""){
		alert("Rellene el nombre del recurso");
		return false;
	}
	if(f.nombre_solicitante.value==""){
		alert("Rellene el nombre del solicitante");
		return false;
	}
	if(f.centro.value==""){
		alert("Rellene el centro de destino");
		return false;
	}
	return true;
}

function ValidarBusqueda(f){
	if(f.busqueda.value==""){
		alert("Rellene el campo de busqueda");
		return false;
	}
	return true;
}

function ValidarEncuesta(f){
	if(f.id_respuesta.value==""){
		alert("Selecciona una respuesta");
		return false;
	}
	return true;
}

//////////Codigo galeria fotografica/////////////

function ObtenerDatosGaleria(divID,id,pos) { 
	var imagen = document.getElementById("id_imagen");

	if(pos!="no"){
		imagen.value=pos;
	}
	var obj = document.getElementById(divID); 
	var peticion = false; 
	if (window.XMLHttpRequest) { 
    	peticion = new XMLHttpRequest(); 
    } else if (window.ActiveXObject) { 
        peticion = new ActiveXObject("Microsoft.XMLHTTP"); 
	}
	if(peticion) { 
		var url='galeria_auxiliar.php?id=' + id;
     	peticion.open("GET", url);   //
     	peticion.onreadystatechange = function()  { 
        	if (peticion.readyState == 4) { 
         		obj.innerHTML = peticion.responseText;
		   	} 
     	} 
		peticion.send(null); 
	}
}

function bucle(){
	var imagen = document.getElementById("id_imagen");
	
	if(imagen.value<9){
		imagen.value=eval(imagen.value + "+ 1");
	} else {
		imagen.value=0;
	}
	aux=imagen.value;
	return aux;
}

var matriz=new Array(9);

function MoverFoto() { 
	var cadena=document.getElementById("sw");
	var aux2;
	var aux=cadena.value;
	
	for(i=0;i<10;i++){
		if(aux.substr(0,1)!=""){
			if(aux.substr(2,1)!="" && aux.substr(2,1)!="-"){
				matriz[i]=aux.substr(0,3);
				aux=aux.substr(4);
			}else{
				if(aux.substr(1,1)!="" && aux.substr(1,1)!="-"){
					matriz[i]=aux.substr(0,2);
					aux=aux.substr(3);
				}else{
					matriz[i]=aux.substr(0,1);
					aux=aux.substr(2);
				}
			}			
		}else{
			matriz[i]="";
		}
	}
if(matriz[2]!=""){
		setInterval("aux2=bucle();if(eval(matriz[aux2]!='')){ObtenerDatosGaleria('foto', eval(matriz[aux2]),'no');}else{ObtenerDatosGaleria('foto', eval(matriz[0]),'0');}",4000);
}
}

//////////Fin codigo galeria fotografica/////////////
