//<![CDATA[
$(document).ready(function(){
	
    // Hay que añadir ésto para que funcione el slider
	$("#menu").append("<li id='magic-line'></li>");

    var $magicLine = $("#magic-line");
    
    $magicLine
        .width($(".selected").width())
        .css("left", $(".selected a").position().left)
        .data("origLeft", $magicLine.position().left)
        .data("origWidth", $magicLine.width());
        
    $("#menu li").find("a").hover(function() {
        $el = $(this);
        leftPos = $el.position().left;
        newWidth = $el.parent().width();
        
        $magicLine.stop().animate({
            left: leftPos,
            width: newWidth
        });
    }, function() {
        $magicLine.stop().animate({
            left: $magicLine.data("origLeft"),
            width: $magicLine.data("origWidth")
        });    
    });	
	
	// Inicializamos el pretty
	$("a[rel^='prettyPhoto']").prettyPhoto({social_tools:false,deeplinking:false});

	$('body').ajaxComplete(function(request, settings){
		$("a[rel^='prettyPhoto']").prettyPhoto({social_tools:false,deeplinking:false});
	});

	// Los links con este rel se abren en una nueva ventana
	$("a[rel=nueva_ventana]").click(function(){window.open($(this).attr('href'));return false;});

	// Al iframe del botón de "Me gusta" le añadimos los atributos necesarios (lo hacemos para que valide la página en el w3c)
	$('a.iframe').each(
		function (i) {
			$(this).replaceWith("<iframe src='" + this.getAttribute("href") + "'  frameborder='0' scrolling='no' style='border:none; overflow:hidden; width:100px; height:21px;' allowTransparency='true'></iframe>");
		}
	);	
	
	// Añadimos el botón de Google +1
	gapi.plusone.render('small', {'size': 'Medium', 'count': 'true'});
	
});
//]]>
