
$(document).ready(function(){
    $("#pageCont .inside").jScrollPane({showArrows:true,
                                    scrollbarMargin:"0",
                                    scrollbarWidth:10});
    $("#pageCont .inside").css("margin-top", "232px").animate({marginTop:"0"},500);
    $("#dataContent").css("margin-top", "232px").animate({marginTop:"0"},500);
    $("ul.menuLeft .backDown").hide();
    $("ul.menuLeft span.backDown").slideUp(1);
    $("ul.menuLeft .textOn").hover(function(){
        if(!$(this).parent().eq(0).hasClass("selected")){
            $(this).parent().eq(0).find("span.backUp").slideUp(150);
            $(this).parent().eq(0).find("span.backDown").slideDown(150);
            $(this).parent().eq(0).find("span.block").animate({width:"35px"},200);
        }
    }, function(){
        if(!$(this).parent().eq(0).hasClass("selected")){
            $(this).parent().eq(0).find("span.backDown").slideUp(200);
            $(this).parent().eq(0).find("span.backUp").slideDown(200);
            $(this).parent().eq(0).find("span.block").animate({width:"20px"},400);
        }
    });
    
    $(".textOn").click(function(){
        $("#loadCont").show();
        var link = $(this).find("a").attr("href");
        $("ul.menuLeft li").removeAttr("class");
        $("ul.menuLeft li span.backUp").show();
        $("ul.menuLeft li span.backDown").hide();
        $("ul.menuLeft li span.block").css("width","20px");
        $(this).parent().eq(0).addClass("selected");
        $(this).parent().eq(0).find("span.backUp").hide();
        $(this).parent().eq(0).find("span.backDown").css("display","block");
        $(this).parent().eq(0).find("span.block").css("width","35px");
        $("#pageCont .inside").animate({marginTop:"0"},500,goToLayout(link));
        return false;
    });

    /*   Menu de la seccion 'Datos'  */
    $(".hiddenData").hide();
    $("#contInsert").jScrollPane({showArrows:true,
    scrollbarMargin:"0",
    scrollbarWidth:10});
    $(".dataName .parent").click(function(){
        if($(this).hasClass("open")){
            $(this).parent().find("ul.dataSubmenu").slideUp("slow");
            $(this).removeClass("open").css("background", "url("+wpUrl+"/wp-content/themes/sanchez/images/data-nav1.png) no-repeat 0 0");
        }else{
            $(this).parent().find("ul.dataSubmenu").slideDown("slow");
            $(this).addClass("open").css("background-image", "url("+wpUrl+"/wp-content/themes/sanchez/images/data-nav2.png)");
        }
    });
    
    $(".postDataName").click(function(){
        if(!$(this).hasClass("open")){
            $(".hiddenData, #dataIntro").hide();
            $(".postDataName").removeClass("open");
            var secId = $(this).find("span").attr("class");
            $("#"+secId).fadeIn(500);

            $("#contInsert").jScrollPane({showArrows:true,
                                          scrollbarMargin:"0",
                                          scrollbarWidth:10});
            $("#contInsert").css("margin-top", "250px").animate({marginTop:"0"},500);
            $(this).addClass("open");
        }
    });
});

function goToLayout(link){
    document.location.href=link;
}
