/**
 * @project  multimetrix
 * @author   Maik Mettenheimer
 * @version  2011-09-29
 */
 
$(document).ready(function()
{

    /**
     * superfish drop down menu
     * @see http://users.tpg.com.au/j_birch/plugins/superfish/
     */
    $('ul.sf-menu').superfish({ 
        hoverClass:    'sfHover',
        pathClass:     'current',
        delay:         400,
        animation:     {opacity:'show'},
        speed:         500,
        autoArrows:    false,
        dropShadows:   false,
        disableHI:     false
    }); 
    
    /**
     * add some link classes
     */
    $("a[href$='.pdf']").addClass('pdf');
    $("a[href^='mailto:']").addClass('email');
    $('a[href^="http://"]:not([href^="' + window.location.host + '"])').addClass('external');

    /**
     * typo3 crypted email-link
     */
    $("a[href^='javascript:linkTo_UnCryptMailto']").addClass('email');


    /**
     * add target=_blank for external links and pdf-files
     */
    $('a[href^="http://"]:not([href^="' + window.location.host + '"])').attr({target: "_blank"});
    $('a[href$=".pdf"]').attr({target: "_blank"});


    /**
     * tab container
     */
    $(".tabs").accessibleTabs({
        tabhead:         'h1',
        fx:              "fadeIn",
        currentInfoText: ''
    });
   
    /**
     * google analytics pdf download tracking
     */
    $('a').mouseup(function(){
        href = $(this).attr('href');
        href_lower = href.toLowerCase(); 
        if(href_lower.substr(-3) == "pdf") {
            _gaq.push(['_trackEvent', 'Download', 'PDF', href]);
        } 
    });

});

