/*function cargaRuedaImg(imagen,div){
	var obj = document.getElementById(div); 
	var peticion = false; 
	if (window.XMLHttpRequest) { 
    	peticion = new XMLHttpRequest(); 
    } else if (window.ActiveXObject) { 
        peticion = new ActiveXObject("Microsoft.XMLHTTP"); 
	}
	if(peticion) { 
		var url=imagen;
     	peticion.open("GET", url);   //
     	peticion.onreadystatechange = function()  {
		if(peticion.readyState == 1){
			$(div).startWaiting('images/loading.gif');
		}
			if (peticion.readyState == 4) { 
				$(div).stopWaiting();
         		obj.innerHTML = peticion.responseText;
		   	} 
     	} 
		peticion.send(null); 
	}
} 
*/

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 menu_visible(opcion,img){
	var capa=document.getElementById(opcion);
	var imagen=document.getElementById(img);
	if(capa.style.display == 'none'){
		 if(navigator.appName.indexOf("Microsoft") > -1){ 
               var visible = 'block'; 
        }else{ 
               var visible = 'table-row'; 
        } 
		capa.style.display = visible; 
		imagen.style.backgroundImage = "url('images/flecha_arriba.png')";
	}else{
		capa.style.display = "none"; 
		imagen.style.backgroundImage = "url('images/flecha_abajo.png')";
	}
}

function menu_visible2(opcion){
	var capa=document.getElementById(opcion);
	capa.style.visibility='visible';
}

function menu_invisible(opcion){
	var capa=document.getElementById(opcion);

	capa.style.visibility='hidden';
}

function cambio_color_negro(celda,enlace_id){
	var obj=document.getElementById(celda);
	var enlace=document.getElementById(enlace_id);
	obj.style.backgroundColor='#252525';
	enlace.style.color="#C6F500";
}
function cambio_color_verde(celda,enlace_id){
	var obj=document.getElementById(celda);
	var enlace=document.getElementById(enlace_id);
	obj.style.backgroundColor='#C6F500';
	enlace.style.color="#252525";
}
function cambio_color_negro2(enlace_id){
	var enlace=document.getElementById(enlace_id);
	enlace.style.color="#C6F500";
}
function cambio_color_verde2(enlace_id){
	var enlace=document.getElementById(enlace_id);
	enlace.style.color="#FFFFFF";
}

function iluminar_linea(linea){
	var obj = document.getElementsByName(linea); 
    for (i = 0; i< obj.length; i++) { 
		obj[i].style.backgroundColor='#669900';
		obj[i].style.color='#FFFFFF';
	}
}

function no_iluminar_linea(linea){
	var obj = document.getElementsByName(linea); 
    for (i = 0; i< obj.length; i++) { 
		obj[i].style.backgroundColor='#FFFFFF';
		obj[i].style.color='#000000';
	}
}


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 == 1) { 
				obj.innerHTML="<img src='images/cargando.jpg' alt=cargando width='601' height='447'>";
		   	}*/
			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 validarmail(f){
	var aux=f.cod_uno.value.toUpperCase();
	if(aux==f.cod_dos.value && f.cod_uno.value!="" && f.cod_dos.value!=""){
		if(!f.proteccion.checked){
			alert("Debes leer y aceptar las condiciones de la Ley de Protección de Datos");
			return false;
		}
		return true;
	}else{
		alert("Rellene el codigo de la imagen");
		return false;
	}
	
}

function validar_pedido(f){
	var aux=f.cliente.value;
	if(aux==""){
		alert("Debes validarte primero para poder continuar con el proceso de compra");
		return false;
	}else{
		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/////////////
