$(document).ready(function() {
    if ($('#mycarousel').html() != null) {
        $('#mycarousel').jcarousel();
        $('a.tip').cluetip({
            local: true,
            cursor: 'pointer',
            width: '210',
            cluetipClass: 'jtip',
            arrows: 'true',
            dropShadowSteps: '5',
            sticky:'true',
            waitImage: true,
            showTitle: false,
            positionBy: 'fixed',
            activation: 'click',
            topOffset: -50
        });
        }
        if ($('#left-nav').html() != null) {
                // left Navigation / Treeview
                $.ajax({
                    type: 'GET',
                    url: '/wortundtat/de/javascript/jquery.treeview.pack.js',
                    success: function() {
                        $("#left-nav ul").treeview({
                            collapsed: true
                        });
                        $(".open").find(".treeview:eq(0)").css("display","block");
                    },
                    dataType: 'script',
                    cache: true
                });
            }
    
        $("a.elem1").toggle(function() {
            $(this).next(".treeview").css("display","block");
            $(this).removeClass("expandable");
            $(this).addClass("collapsable");
        }, function() {
            $(this).next(".treeview").css("display","none");
            $(this).removeClass("collapsable");
            $(this).addClass("expandable");
        });

        $('#left-nav a').click(function() {    
            var pathname = location.pathname;
            var filename = pathname.substr(pathname.lastIndexOf("/")+1,pathname.length);

            var xurl = $(this).attr("href");
            var hurl = xurl.substr(xurl.lastIndexOf("/")+1,xurl.length);
            
            if (hurl !="#" && hurl != filename) {
                window.location = $(this).attr("href");
            } else {
                return false;
            }
        });

    });
 
    $(window).load(function() {
        $(".hitarea.open-hitarea.expandable-hitarea").removeClass("hitarea open-hitarea expandable-hitarea").addClass("hitarea open-hitarea collapsable-hitarea");
    });