// JavaScript Document
$(document).ready(function(){
	prepararCajas();	
});

function prepararCajas(){
	//alert("Preparando cajas...");
	/* CONFIGURACIÓN DE LAS CAJAS DE LA GALERIA CON EL BOTÓN MÁS*/
	$("div.FDV_CAJA").hover(		
		function(){	
			$(this).css('cursor', 'pointer');
			$(this).find("div > div.FDV_BOTON_VER").fadeTo('fast', 0.5);			
		},	
		function(){		
			$(this).find("div > div.FDV_BOTON_VER").fadeOut('fast');		 
		}
	);
	/* EVENTO CLICK, live CONSIGUE QUE EL EVENTO SE LANCE SÓLO UNA VEZ*/
	$("div.FDV_CAJA").live("click", function(evento){		  	
		if ($(this).attr('rel') != undefined){
			window.open($(this).attr('rel'));
			return false;
		}
	});
	
	/*	HOVER DE LAS COLUMNAS CON FOTO */
	$("div.FDV_2COL").hover(
		function(){$(this).css('background-color', '#D8DFE7');},
		function(){$(this).css('background-color', '');}
	);
	$("div.FDV_2COL_1ELE").hover(
		function(){$(this).css('background-color', '#D8DFE7');},
		function(){$(this).css('background-color', '');}
	);
	
	$("div.FDV_3COL").hover(
		function(){$(this).css('background-color', '#D8DFE7');},
		function(){$(this).css('background-color', '');}
	);
	
	/* EVENTO CLICK, live CONSIGUE QUE EL EVENTO SE LANCE SÓLO UNA VEZ*/
	$("div.FDV_2COL").live("click", function(evento){		  	
		if ($(this).attr('rel') != undefined){
			window.open($(this).attr('rel'));
			return false;
		}
	});
	$("div.FDV_2COL_1ELE").live("click", function(evento){		  	
		if ($(this).attr('rel') != undefined){
			window.open($(this).attr('rel'));
			return false;
		}
	});
	
	$("div.FDV_3COL").live("click", function(evento){		  	
		if ($(this).attr('rel') != undefined){
			window.open($(this).attr('rel'));
			return false;
		}
	});	
	//ABRIMOS TODOS LOS ENLACES EN VENTANA NUEVA	
	/*$('a[href^="http://"]').attr({
		target: "_blank", 
	});*/
}

//Numero de foto aleatorio
function fotoAleatoria(capa, ruta, numFotos){
	//alert(capa);
	var ruta = "http://www.farodevigo.es/elementosWeb/gestionCajas/FDV/Image/taldiacomohoy/" + ruta + "/";
	var fecha = new Date();
	var numero = fecha.getSeconds() % numFotos;
	document.getElementById(capa).style.background = "url(" + ruta + numero + ".jpg)";
}
