// DOM Ready
$(function() {

    var $el, leftPos, newWidth;
    
    /*
        EXAMPLE ONE
    */
    
    /* Add Magic Line markup via JavaScript, because it ain't gonna work without */
//    $("#nav-bar").append("<li id='magic-line'></li>");
    
    /* Cache it */
    var $magicLine = $("#magic-line");

    $magicLine
        .width($(".current_page_item").width())
        .css("left", $(".current_page_item a").position().left)
        .data("origLeft", $magicLine.position().left)
        .data("origWidth", $magicLine.width());
        
    $("#nav-bar 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")
        });    
    });

	//Situar el selector de temas al principio
    $("#css_selector").appendTo("body").show();

	//Ocultar algunas secciones y prepararlo todo para poder restaurarlas
	$("section.resume h1").css("cursor","pointer");
	$("section.resume h1").prepend("<span>(click to open)</span>");
	$("section.resume ul:gt(2)").hide();
	$("section.resume h1:lt(3) span").hide();
	$("section h1").click(function() {$(this).parent().find("ul").toggle();$(this).find("span").toggle();});

    
});

