jQuery(document).ready(function()
{
	//bordes redondos para IE < 9
	jQuery("header.header").corner("keep bottom 10px");
	jQuery("#main").corner("10px");
	jQuery("footer.footer").corner("keep top 10px");
	
	/*************************************************************************/
	
	/**
	* Funció que espera milisegons // ex: jQuery('sel').wait(500)
	**/
	
	jQuery.fn.wait = function(time, type) {
        time = time || 1000;
        type = type || "fx";
        return this.queue(type, function() {
            var self = this;
            setTimeout(function() {
                jQuery(self).dequeue();
            }, time);
        });
    };
	
	/*************************************************************************/
	
	//Para que :first-child y :last-child funcionen en IE
	jQuery("*:first-child").addClass("first-child"); 
	jQuery("*:last-child").addClass("last-child"); 
	
	/*************************************************************************/
	
	/**
	* Lazy load para que la carga de las imágenes no ralentize la página;
	* Lo pongo al final para que no interfiera con el resto de funciones que afectan a imágenes.
	**/
	
	 jQuery("img:not(div.no-lazy img)").lazyload({
	    	effect : "fadeIn",
     		failurelimit : 200
	 });
	 
	
	/*************************************************************************/
	//Haze visible el span correspondiente al titular elegido del menu principal de la página
	
	var attr_title = jQuery("nav#access ul.menu li.current-menu-item a").attr("title");
	var attr_title_home = jQuery(".home.blog #access .menu-header li.first-child a").attr("title");
	jQuery("nav#access ul.menu li.current-menu-item").append("<span>"+attr_title+"</span>");
	jQuery(".home.blog #access .menu-header li.first-child").append("<span>"+attr_title_home+"</span>");

	if( jQuery("body").hasClass("home") ){
		jQuery("nav#access ul.menu li.menu-item:not(.current-menu-item,.first-child) a")
			.mouseover(function(){
				jQuery(this).parent().addClass("li-hover");
				jQuery(this).parent().append("<span>"+jQuery(this).attr("title")+"</span>");
			})
			.mouseleave(function(){
				jQuery(this).parent().removeClass("li-hover");
				jQuery("nav#access ul.menu li.menu-item:not(.current-menu-item,.first-child) span").remove();
			});
	}else{

		jQuery("nav#access ul.menu li.menu-item:not(.current-menu-item) a")
			.mouseover(function(){
				jQuery(this).parent().addClass("li-hover");
				jQuery(this).parent().append("<span>"+jQuery(this).attr("title")+"</span>");
			})
			.mouseleave(function(){
				jQuery(this).parent().removeClass("li-hover");
				jQuery("nav#access ul.menu li.menu-item:not(.current-menu-item) span").remove();
			});
	}


	/****************************************************************************/
	//Hace aparecer la caja correspondiente al elemento seleccionado del menu lateral, mediante una pequeña animación

	jQuery("div#leftfloat_menu ul.lista_buttons li")
		.mouseover(function(){
			jQuery(this).addClass("activat");
			jQuery(this).children("div").stop(true,false).animate({width: '182px'}, 1000);
			if(jQuery(this).children("div").hasClass("form")){
				//jQuery("input#s").focus();
			}
		})
		.mouseleave(function(){
			jQuery(this).children("div").stop(true,false).animate(
				{width: '0px'},
				{
					duration: 1000,
					complete: function(){
						jQuery(this).parent().removeClass("activat");
					}
				});
		});
	
	/****************************************************************************/
	// Script que comprueba en el momento de realizar la busqueda, si la caja está vacia. Si lo está muestra un mensaje y anula la busqueda
	jQuery("form#searchform")
	.submit(function(){
		if(jQuery(this).find("div input#s").val() == ""){
			var lang = jQuery(this).find("input[name=lang]").val();
			var string;
			if(lang == "ca"){
				string = "No estas buscant res.";
			}else{
				if(lang == "es"){
					string = "No estas buscando nada.";
				}else{
					if(lang == "en"){
						string = "You're not searching anything.";
					}
				}
			}
			alert(string);
			return false;
		}
		else form.submit();
	});

	/****************************************************************************
	//Mostra/Amaga el contenidor de l'informació propia de cada post
	jQuery("div.info-links a.mesinfo")
	.click(function(){
		if( jQuery(this).parents("article").children("footer.entry-utility").hasClass("screen-reader-text") ){
			jQuery(this).parents("article").children("footer.entry-utility").removeClass("screen-reader-text");
			jQuery(this).children("span.first-child").removeClass("visible");
			jQuery(this).children("span.last-child").addClass("visible");
		}else{
			jQuery(this).parents("article").children("footer.entry-utility").addClass("screen-reader-text");
			jQuery(this).children("span.first-child").addClass("visible");
			jQuery(this).children("span.last-child").removeClass("visible");
		}
		return false;
	}); */
});
	 
	
/*************************************************************************/

function popup(url) 
{
	params  = 'width='+screen.width;
	params += ', height='+screen.height;
	params += ', top=0, left=0'
	params += ', fullscreen=yes';
	
	newwin=window.open(url,'windowname4', params);
	if (window.focus) {newwin.focus()}
	return false;
}

/*************************************************************************/




