function write_mt(x,y,z){ document.write("<a href='mailto:", y, "@", x, "'>", z, "</a>"); }
function write_ml(x,y){ document.write("<a href='mailto:", y, "@", x, "'>", y, "@", x, "</a>"); }



if(typeof($) == 'function') {

    jQuery.fn.betterToggle = function(accordion, header, body, speed, openClass) {
        var parent = this;

        $(parent).find(header).removeClass(openClass);

        if(!$(parent).find(header).hasClass('open')) {
            $(parent).find(header).hover(
                function() {
                    $(this).addClass("hover");
                },
                function() {
                    $(this).removeClass("hover");
                }
            );
        }

        $(parent).find(body).addClass('hidden');
        $(parent).find(header).click(
            function() {
                if(accordion && !$(this).hasClass(openClass)) {
                    $(parent).find(header).next(body + ":visible").slideToggle(speed);
                    $(parent).find(header).removeClass(openClass);

                    $(this).next(body).slideToggle(speed);
                    $(this).hasClass(openClass) ? $(this).removeClass(openClass) : $(this).addClass(openClass);
                } else if(!accordion) {
                    $(this).next(body).slideToggle(speed);
                    $(this).hasClass(openClass) ? $(this).removeClass(openClass) : $(this).addClass(openClass);
                }
            }
        );

        $(parent).find(header + ":first").addClass(openClass);
        $(parent).find(header + ":first").next(body).removeClass('hidden');

    };

    $(document).ready(function(){

        $('.l-wrap').addClass('js');

        if($('.list').length > 0) {
            $(".list").betterToggle(true, "h4.toggler", "ul", "fast", "open");
            if(document.location.hash.length != 0) {
                $('.list #id-' + document.location.hash.substring(1) + ' h4').trigger('click');
            }
        }

        if($('.list-two').length > 0) {
            $(".list-two").betterToggle(true, "h4.toggler", "ul", "fast", "open");
            if(document.location.hash.length != 0) {
                $('.list-two #id-' + document.location.hash.substring(1) + ' h4').trigger('click');
            }
        }


    });

}

