﻿
/* Menu toggling */
$(document).ready(function() {
    //Start by hiding the menus
    $("a.menu-node").not(".current").not(".no-toggle").find("+ ul").hide();

    //Add event listener on links
    $("a.menu-node").not(".no-toggle").click(function() {
        $(this).find("+ ul").slideToggle(200);
    });

    //Toggles
    $(".toggle").each(function() {
        //Wrap with hyperlink
        var link = document.createElement('a');
        link.setAttribute('href', 'javascript:void(0)');
        $(this).wrapInner(link).append(" »");

        //Hide next DOM element
        $(this).next().hide();

        //Add toggle handler on element
        $(this).click(function() {
            $(this).next().slideToggle(300);
        });
    });

    //Init email links
    setTimeout(function() {
        $(".mail-link").each(function() {
            var content = $(this).html();

            var link = content.replace(/ \(at\) /gi, "@");
            link = link.replace(/ \(dot\) /gi, ".");

            $(this).html("<a href=\"mailto:" + link + "\">" + link + "</a>");
        });
    }, 1000);

    //Init FancyZoom
    setupZoom();
});
