
/* --------------------------------------------------------------------------------
   - Dimmer
   -------------------------------------------------------------------------------- */

dim = function() { new Effect.Appear('dimmer', {to: 0.5, duration: 0.5}); };
undim = function() { new Effect.Fade('dimmer', {duration: 0.5}); };


/* --------------------------------------------------------------------------------
   - OnLoad
   -------------------------------------------------------------------------------- */

Event.observe(window, 'load', function () {    
    // make external links external
    $$('a.extern').each(function (anchor) {
        Event.observe(anchor, 'click', function (event) {
            window.open(anchor.readAttribute('href'));
            Event.stop(event);
        });
    });
    
    // replace HRs (IE sucks!)
    if (/MSIE/.test(navigator.userAgent)) {
        $$('hr').each(function (hr) { hr.replace('<div class="hr"></div>'); });
    }
    
    $('trac-login') && Event.observe('trac-login', 'click', function (event) {
        showTracLogin();
        Event.stop(event);
    });
    
    // show tg_flash
    if ($('flash')) {
        var autohide = null;
        
        hideFlash = function (event) {
            clearTimeout(autohide);
            undim(); new Effect.Fade('flash');
        };
        
        dim(); new Effect.Appear('flash');
        autohide = setTimeout(hideFlash, 3000);
        
        Event.observe('flash', 'click', hideFlash);
    }
    
    // activate textfields & select contents
    $$('.field').each(function (field) {
        field.observe('click', function (event) {
            field.activate();
        });
    });
});
