//FUNCIONES ESPECIFICAS	

//antes de cargar el DOM 
//$.elementReady('page', function(){ 
	//if ($.browser.msie && $.browser.version < 7) return;
	//$(this).prepend("<div id='flasher'><span></span></div>");});

//CARGANDO...
	$(document).ready(function() {

		// ESTILOS
			$("#videoScreen").addClass('oculto'); //ocultamos la pantalla			
			
			//anadimos estilo para utilizar las tipografias de typeface-js
				$(".post h2").addClass('typeface-js');
				$("#noticiasBox h2").addClass('typeface-js');
				$("body.galerias #mainContent h2").addClass('typeface-js');
	
	
		// PAGE PEEL
			$("#pagePeel").pagePeel({
				introAnim: false,
				bigWidth: 500,
				bigHeight: 500,
				adLinkTarget: '_blank',
				bigSWF: 'http://travelingpub.com/trv2009/wp-content/themes/trv2009/images/publi/page-peel-big.swf',
				bigAd: 'http://travelingpub.com/trv2009/wp-content/themes/trv2009/images/publi/bigAd4.jpg'
			});
			
		//MENU PRINCIPAL
			//Efectos y animacion
			// coje el texto del title d cada enlace y lo incluye en el span que va a aparecer con una animacion
				$('ul#navMain').css({'background-image' : 'url(http://travelingpub.com/trv2009/wp-content/themes/trv2009/images/navMain-trans.png)'});
				$("ul#navMain li span").css({'background-image' : 'url(http://travelingpub.com/trv2009/wp-content/themes/trv2009/images/bocata.png)'});
				$("ul#navMain li").append("<span class='info'></span>");
				$("ul#navMain li a").animate({opacity:".3"}, "fast").css({'background-color' : '#efefef'});
				$("ul#navMain li").hover(function() {
				  $(this).find("a").animate({opacity:"0"}, "slow");
					$(this).find("span").animate({opacity: "show", top: "-45"}, "500");
				  var hoverText = $(this).find("a").attr("title");
				  $(this).find("span").text(hoverText);
				}, function() {
				  $(this).find("span").animate({opacity: "hide", top: "-55"}, "1000");
				  $(this).find("a").animate({opacity:".3"}, "slow");
					});
			
			//VIDEO DESTACADO 
				//Ocultar enlace y mostrar pantalla
				$("#videoClick").click(function () {
       		$(this).animate({opacity: ".8", top: "-375"}, "5000");	
					$("#videoScreen").animate({opacity:"show"},"1000");
    		});
    		
    		//Ocultar pantalla y mostrar enlace
				$("#videoScreen a.cerrar").click(function () {
       		$("#videoScreen").animate({opacity: "hide"}, "500");	
					$("#videoClick").animate({opacity:"1", top: "0"}, "1000");
    		});


			//MUSICA: Desplegable Lista Reproduccion
				$(".playListBox .playList").hide('0').append("<span class='cerrar'></span>");
				$(".playListBox h2").click(function (e) {
					$(".playListBox").removeClass('jimi');
					$(this).parent('.playListBox').addClass('jimi');
					$(".playListBox.jimi .playList").slideDown("normal");
					$(".playListBox:not('.jimi')").find (".playList").slideUp("normal");
   			});
    		$("span.cerrar").click(function (f) {
					$(".playListBox.jimi .playList").slideUp("fast");
					$(".playListBox.jimi").removeClass('jimi');
   			});
				

			//ANIMACION INICIAL
				//animar todo el bloque de navegación al cargar la pagina despues elimina el flasher
					$("ul#navBox").addClass("animaInicial");
					$("ul#navBox").animate({opacity: "show", top: "320"}, "5000").animate({top: "258"}, "500", hideLoader);
				//elimina animacion inicial ...cargando pagina
					function hideLoader() {
							//$("div#flasher").remove();  
						};

			// ENLACES CON ANIMACION MENU SECUNDARIO
				$(function () {
 					if ($.browser.msie && $.browser.version < 7) return;
					$("ul#navSec a").removeClass('link').css({'position' : 'relative'}).append("<span class='contentHover'></span>");
					$("span.contentHover").css({'opacity' : '0'});		
					$('ul#navSec a span').hover(
							function(g) {
				      		$(this).stop().animate({opacity:".5"}, "slow");
				    	}, 
							function(g) {
				        $(this).stop().animate({opacity:"0"}, "slow");
				    });
				});


			//GALERIAS | Efectos y animaciones de las galerias
					
					$("div.ngg-widget").addClass('preview');
					$("div.ngg-widget a").attr({rel: "prettyPhoto"}).removeAttr("title");
					$("div.ngg-widget img").removeAttr("title");
					$("div.ngg-gallery-thumbnail a").attr({rel: "prettyPhoto"}).removeAttr("title");
			    $("div.ngg-gallery-thumbnail img").removeAttr("title");
					$("div.ngg-gallery-thumbnail").fadeTo('fast', 0.5).addClass('preview');
					$("div.ngg-album").fadeTo('fast', 0.7);
					
					$("a[rel^='prettyPhoto']").prettyPhoto({
						showTitle: false
					});

			    $("div.ngg-gallery-thumbnail").hover(function(e) {
			    		if ($.browser.msie && $.browser.version < 7) return;
				      $(this).fadeTo('slow', 1.0);
				    	}, function(e) {
				        $(this).fadeTo('slow', 0.5);
				    });

			    $("div.ngg-album").hover(function(e) {
			    		if ($.browser.msie && $.browser.version < 7) return;
				      $(this).fadeTo('slow', 1.0);
				    	}, function(e) {
				        $(this).fadeTo('slow', 0.7);
				    });

				    
				//Previsualizar miniaturas en las Galerias: Preview Plugin
					$(function () {
						//if ($.browser.msie && $.browser.version < 7) return;
						$("div.preview a").imgPreview({
					    containerID: 'imgPreviewWithStyles',
					    imgCSS: {
					        height: 200
					    },
					    onShow: function(link){
					        $(link).stop().animate({opacity:0.4});
					        $("img", this).stop().css({opacity:1});
					    },
					    onLoad: function(){
					        $(this).animate({opacity:1}, 300);
					    },
					    onHide: function(link){
					    	$(link).stop().animate({opacity:1});
					    }
						});
				});


			
	});	