var base = '/hmag/view/default/';

var HmagBehaviour = {
    remove_obfuscation: function()
    {
        $('a.mail').map(function()
        {
            var href  = $(this).attr('href');
            var clean = href.replace(' (AT) ', '@').replace(' (PUNKT) ', '.');
            $(this).attr('href', clean);
            
            if (href.substr(7) == $(this).text()) {
                $(this).text(clean.substr(7));
            }
        });
    },
    
    rollover: function(obj)
    {
        if (typeof obj.map != 'undefined') {
            obj.map(function()
            {
                var src = $('img', this).attr('src');

                $(this).hover(function()
                {
                    var idx       = src.lastIndexOf('.');
                    if (idx > 0) {
                        var hover_src = src.substr(0, idx) + '-over' + src.substr(idx);

                        $('img', this).attr('src', hover_src);
                    }
                }, function()
                {
                    $('img', this).attr('src', src);
                });
            });
            
            return obj.length;
        }
        
        return -1;
    }
};

$(function()
{
    HmagBehaviour.remove_obfuscation();
    HmagBehaviour.rollover($('ul.select a'));
});
