/**
 * @author juanlopez4691@gmail.com
 */

var webTitle, webUrl;

$(document).ready(function(){
	webTitle = 'el espazio';
	webUrl = 'http://' + window.location.hostname;

	if (webUrl.indexOf('localhost') >= 0) {
		webUrl = webUrl + '/espazio';
	}

	//Inicia el sistema de pestañas
	$(".tabs").tabify();

	$('.topBtnItem').mouseover(function () {
			this.btnImg = $(this).attr('src');
			this.btnImgOn = this.btnImg.substr(0, this.btnImg.indexOf('.gif'))+'-on.gif';

			$(this).attr('src', this.btnImgOn);
			$(this).mouseout(function () { $(this).attr('src', this.btnImg);});
		})

	//Para mostrar las imágenes ampliadas cubriendo la pantalla
	//$('.zoomPic').lightBox()
	
	//Identificamos la página mostrada, para resaltar la entrada correspondiente en el índice de la web
	var szURL = document.URL;
	var componentList = szURL.split('/');
	var szDocument = componentList[componentList.length-1];
	var documentFilename = szDocument.split('.');
	var seccion = documentFilename[0];

	switch(seccion) {
		case "resultadoBusca":
			seccion = "home"
			break;

		case "sec_itinerariosGruposForm":
		case "sec_detalleItinerario":
			seccion = "sec_itinerariosGrupos";
			break;

		case "sec_actividadesForm":
		case "sec_detalleActividad":
			seccion = "sec_actividades";
			break;
		
		case "sec_cursosForm":
		case "sec_detalleCurso":
			seccion = "sec_cursos";
			break;

		case "sec_empleosForm":
		case "sec_detalleEmpleo":
			seccion = "sec_empleos";
			break;

		case "detalleEntrada":
			var tSec = $(".tituloSeccionNews").html();
			switch (true) {
				case ($(".tituloSeccionNews").html() != undefined):
					seccion = "sec_noticias";
				break;
				case ($(".tituloSeccionFreshNews").html() != undefined):
					seccion = "sec_destacados";
				break;
			}
			break;
	}
	if (seccion.indexOf("aplic-")==0) seccion = "aplicativos";		
   if (seccion.indexOf("sector-")==0) seccion = "sectoresFuturo"; 

	$('#menu #'+seccion).css('color', '#7eb801');

	//Vamos a hacer que los enlaces incluidos en el cuerpo de texto
	//de las noticias se abran en una nueva ventana/pestaña del navegador

	$('.newsItemFull a').attr("target", "_blank");

	//Los enlaces indicados también se abren en una nueva ventana/pestaña del navegador
	$('a._blank').attr("target", "_blank");
});


function validateEmail (email) {
	var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
	return reg.test(email);
}


