$(document).ready(function(){

    function pagePeel() {

        this.labelVisibility = true;

    };

    $.ajax({
        type: "GET",
        url: "page-peel/index.html",
        success: function(msg){

            $("body").prepend(msg);

            var pp = new pagePeel;

            $("#page-peel .page-peel-label").hover(function(){

                $(this).animate({
                    right: "10px"
                }, 100);

            }, function(){

                if(pp.labelVisibility)
                    $(this).animate({
                        right: "-20px"
                    }, 100);

            }).click(function(){

                pp.labelVisibility = false;

                var width = $(this).width();

                $(this).animate({
                    right: "-" + width
                }, 300);

                $("#page-peel .page-peel-content").animate({
                    right: 0
                }, 400);

                return false;

            });

            $("#page-peel .page-peel-content .close a").click(function(){

                pp.labelVisibility = true;

                var width = $(this).width();

                $("#page-peel .page-peel-label").animate({
                    right: "-20px"
                }, 300);

                $("#page-peel .page-peel-content").animate({
                    right: "-" + width + 40
                }, 400);

                return false;

            });

        }
    });

});	