$(document).ready(init);

var intervalo;
var items;
var contador=0;

var aleatorio;
var aleatorioVoluntarios;


function init(){
	
	var imagenes = $('.col_d.peque figure')
	var totalImagenes = $('.col_d.peque figure').length;
	
	var imagenesVoluntarios = new Array ();
	imagenesVoluntarios.push(imagenes[16], imagenes[16], imagenes[16], imagenes[31], imagenes[32], imagenes[33], imagenes[31], imagenes[32], imagenes[33], imagenes[16], imagenes[16], imagenes[16], imagenes[31], imagenes[31], imagenes[32], imagenes[32], imagenes[33], imagenes[31], imagenes[32], imagenes[33]);
	var totalImagenesVoluntarios = imagenesVoluntarios.length;

	//intervalo=setInterval(pasaTexto, 3000);//3 segundos
	
	/*for(var i=0; i<totalItems; i++){	
		$(items[i+1]).css("display", "none");
	}*/
	
	//para que cargue aleatoriamente las imagenes
	for(var i=0; i<totalImagenes; i++){	
		$(imagenes[i]).css("display", "none");
	}
	
	aleatorio = Math.round(Math.random()*totalImagenes-1);
	aleatorioVoluntarios = Math.round(Math.random()*totalImagenesVoluntarios-1);
	//$(imagenes[aleatorio]).css("display", "block");

	getPageName();
	if (getPageName() == 'fundacion.asp' || getPageName() == 'unete.asp' || getPageName() == 'casas.asp'){
		$(imagenes[aleatorio+1]).css("display", "block");
		$(imagenes[aleatorio+2]).css("display", "block");
		$(imagenes[aleatorio+3]).css("display", "block");
	}else if (getPageName() == 'voluntarios.asp'){
		$(imagenesVoluntarios[aleatorioVoluntarios+1]).css("display", "block");
	}else{
		$(imagenes[aleatorio+1]).css("display", "block");
	}
	
}

//funcion para coger la url de la cabecera
function getPageName(){
	var url = document.URL;
	var getVariables = url.indexOf('?');
	var posicionUltimaBarra = url.lastIndexOf("/");
	
	if(getVariables != -1) {
		var nombrePagina = url.substring(posicionUltimaBarra + "/".length , getVariables).toLowerCase();
		return nombrePagina;
	}else if(getVariables == -1){
		var nombrePagina = url.substring(posicionUltimaBarra + "/".length , url.length ).toLowerCase();
		return nombrePagina;
	}
}
	


/*function pasaTexto(){
	contador++;
	$(items[contador-1]).css("display", "block");
	$(items[contador-1]).siblings().css("display", "none");
	
	if (contador > totalItems){
		contador = 0;
	}
}*/

