/* ---------------------------------------------------
			         QUIENES SOMOS
------------------------------------------------------*/
function cargarTextoQuienesSomos(id) {
	cargarPagina("quienesSomosCargarTexto.php?id="+id,"divTextoQuienesSomos",'','',true,'fadeIn');
}

/* ---------------------------------------------------
			          CAMPOBOSCO
------------------------------------------------------*/
function cargarTextoCampoBosco(id,funcionFinCarga) {
	cargarPagina("campoBoscoCargarTexto.php?id="+id,"divTextoCampoBosco",funcionFinCarga,'',true,'fadeIn');
}

function cargarFotoCampoBosco(nombre) {
	cargarPagina("campoBosco2011Fotos.php?nombre="+nombre,"divFotosCampoBosco",'','',true,'fadeIn');
}

function TerminoCargaCampoBosco2011(nombre) {
	cargarFotoCampoBosco('Lema');
}

/* ---------------------------------------------------
			         MENSAJES
------------------------------------------------------*/
function cargarMensajes(pagina) {
	cargarPagina("mensajesLista.php?pagina="+pagina,"divMensajes",'','',true,'');	
}

function nuevoMensaje() {
	var pagina = 0;
	if (document.getElementById('paginaActual') != null) {
		pagina = document.getElementById('paginaActual').value;
	}
	cargarPagina("mensajesNuevo.php?pagina="+pagina,"divMensajes",'','',true,'');
}

function cancelarNuevoMensaje() {
	var pagina = 0;
	if (document.getElementById('paginaActual') != null) {
		pagina = document.getElementById('paginaActual').value;
	}
	cargarMensajes(pagina);
}

function enviarNuevoMensaje() {
	if (datosValidosNuevoMensaje()) {
		cargarPagina("mensajesNuevoGuardar.php",'divMensajes','grabacionOKMensaje','frmDatos',true,'');
	}
}

function grabacionOKMensaje() {
	cargarMensajes(0);
}

function datosValidosNuevoMensaje() {
	if (trim(document.getElementById('nombre').value) == '') {
		alert('Por favor ingresá tu nombre.');
		document.getElementById('nombre').focus();
		return false;
	}
	if (trim(document.getElementById('ciudad').value) == '') {
		alert('Por favor ingresá de donde sos.');
		document.getElementById('ciudad').focus();
		return false;
	}
	if (document.frmDatos.oratorioSi[1].checked && trim(document.getElementById('oratorio').value) == '') {
		alert('Por favor ingresá el Oratorio.');
		document.getElementById('oratorio').focus();
		return false;
	}
	if (trim(document.getElementById('mail').value) != '') {
		if (emailValido(trim(document.getElementById('mail').value)) == false) {
			alert('Por favor ingresá un mail válido.');
			document.getElementById('mail').focus();
			return false;
		}
	}
	if (trim(document.getElementById('mensaje').value) == '') {
		alert('Por favor ingresá tu mensaje.');
		document.getElementById('mensaje').focus();
		return false;
	}	
	if (longitudMensajeValida() == false) {
		alert('El mensaje puede tener como maximo 255 caracteres.');
		document.getElementById('mensaje').focus();
		return false;
	}
	
	return true;
}

function longitudMensajeValida(form) {
	var maximo = 255;
	if (document.getElementById('mensaje') != null) {
		if (document.getElementById('mensaje').value.length > maximo) {		
			return false;
		}
	} 
	return true;
}

function habilitarOratorioMensaje() {
	document.getElementById('oratorio').value ='';
	if (document.frmDatos.oratorioSi[0].checked) {
		document.getElementById('oratorio').disabled = true;
		document.getElementById('asisteOratorio').value = '0';
	} else {
		document.getElementById('oratorio').disabled = false;
		document.getElementById('asisteOratorio').value = '1';
	}
}

function verificarLongitudMensaje() {
	var maximo = 255;
	if (document.getElementById('mensaje') != null) {
		if (document.getElementById('mensaje').value.length > maximo) {		
			document.getElementById('mensaje').value = document.getElementById('mensaje').value.substring(0, maximo);
			alert("El mensaje puede tener como maximo 255 caracteres.");
		}
	}
 }
 
/* ---------------------------------------------------
			         NOVEDADES
------------------------------------------------------*/

function cargarNovedades(pagina) {
	cargarPagina("novedadesLista.php?pagina="+pagina,"divNovedades",'','',true,'');	
}

/* ---------------------------------------------------
			         FOTOS Y VIDEOS
------------------------------------------------------*/
function terminoCargaFotosYVideos(){	
	cargarCombosFotosYVideos();
}

function cargarCombosFotosYVideos() {
	cargarComboFotos();
	cargarComboVideos();
}

function cargarComboFotos(){
	var opt = new Option('Cargando...','0'); 		
	if (document.getElementById('paginaFotos') != null) {
		document.getElementById('paginaFotos').options[0]=opt; 
		document.getElementById('paginaFotos').disabled = true;
	}
	if (document.getElementById('btnIrFotos') != null) {
		document.getElementById('btnIrFotos').style.visibility = "hidden";
	}
	var idSeccion = document.getElementById('seccion').value;
	cargarPagina("fotosYVideosCargarPaginasFotos.php?idSeccion="+idSeccion,"divPaginasFotos",'cargarGaleriaFotos(false)','',true,'');	
}

function cargarComboVideos(){
	var opt = new Option('Cargando...','0'); 		
	if (document.getElementById('paginaVideos') != null) {
		document.getElementById('paginaVideos').options[0]=opt; 
		document.getElementById('paginaVideos').disabled = true;
	}
	if (document.getElementById('btnIrVideos') != null) {
		document.getElementById('btnIrVideos').style.visibility = "hidden";
	}
	var idSeccion = document.getElementById('seccion').value;
	cargarPagina("fotosYVideosCargarPaginasVideos.php?idSeccion="+idSeccion,"divPaginasVideos",'','',true,'');	
}

function cargarGaleriaFotos(mostrarMensajes) {
	var idSeccion = parseInt(document.getElementById('seccion').value);
	var pagina = 0;
	if (document.getElementById('paginaFotos') != null) {
		pagina = parseInt(document.getElementById('paginaFotos').value);
	}
	
	if (mostrarMensajes == null) {
		mostrarMensajes = true;
	}
	if (idSeccion <= 0) {
		if (mostrarMensajes) {
			alert('Debe seleccionar la seccion.');
		}
		return;
	}
	if (pagina <= 0) {
		if (mostrarMensajes) {
			alert('Debe seleccionar la pagina.');
		}
		return;
	}
	cargarPagina("fotosYVideosGaleriaFotos.php?idSeccion="+idSeccion+"&pagina="+pagina,"divFotosYVideos",'terminoCargaGaleriaFotos','',true,'');		
}

function terminoCargaGaleriaFotos() {
	if (document.getElementById('divGaleriaImagenes') != null) {
		$('#divGaleriaImagenes').gallery({ interval: 10000, height: '500px', width: '667px'});	
	}
}

function cargarGaleriaVideos() {
	var idSeccion = parseInt(document.getElementById('seccion').value);
	var pagina = 0;
	if (document.getElementById('paginaVideos') != null) {
		pagina = parseInt(document.getElementById('paginaVideos').value);
	}
	if (idSeccion <= 0) {
		alert('Debe seleccionar la seccion.');
		return;
	}
	if (pagina <= 0) {
		alert('Debe seleccionar la pagina.');
		return;
	}
	cargarPagina("fotosYVideosGaleriaVideos.php?idSeccion="+idSeccion+"&pagina="+pagina,"divFotosYVideos",'terminoCargaGaleriaVideos','',true,'');		
}

function terminoCargaGaleriaVideos() {
	if (document.getElementById('primerIdVideo') != null) {
		if (document.getElementById('primerIdVideo').value != "") {
			cargarVideo(document.getElementById('primerIdVideo').value);
		}
	}
}

function cargarVideo(id) {	
	cargarPagina("fotosYVideosGaleriaVideosCargarVideo.php?id="+id,"divVideo",'','',true,'fadeIn');		
}

/* ---------------------------------------------------
			            MURGA
------------------------------------------------------*/
function cargarTextoMurga(id,funcionFinCarga) {
	cargarPagina("murgaCargarTexto.php?id="+id,"divTextoMurga",funcionFinCarga,'',true,'fadeIn');
}

function cargarFotoMurga(nombre) {
	cargarPagina("murgaEnQueAndamosFotos.php?nombre="+nombre,"divFotosEnQueAndamos",'','',true,'fadeIn');
}

function abrirLetraCancionBuscandoUnAngel() {
	abrirVentana("murgaCancionBuscandoUnAngel.php",330,500);
}
