(function ($) {
    // cache
    var nav = $('ul#nav');

    // show current sub
    if (nav.find('li.current ul').length > 0) {
        nav.find('li.current ul').show();
    }

    nav.find('li.top').each(function () {

        if ($(this).find('ul').length > 0) {

            var showSub, hideSub, config = {
                over: showSub,
                timeout: 500,
                out: hideSub
            },
                tmp = $(this).find('a:first'),
                txt = tmp.text();

            // append sub indicator
            tmp = tmp.text(txt + ' \u25BE');

            // show sub on hover
            showSub = function () {
                if (!$(this).hasClass('current')) {
                    nav.find('li.current ul').hide();
                    $(this).find('ul').animate({
                        opacity: 'toggle'
                    }, 200);
                }
            };

            // hide sub on exit
            hideSub = function () {
                if (!$(this).hasClass('current')) {
                    $(this).find('ul').animate({
                        opacity: 'toggle'
                    }, 500, function () {
                        nav.find('li.current ul').show();
                    });
                }
            };

            $(this).hoverIntent(config);
        }
    });

    $('a.preview').tooltip();

})(jQuery);

//swfobject.embedSWF("fileadmin/templates/flash/header.swf", "media", "900", "300", "9.0.0");

