/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */


var Christmas = {
    light : false,
    hover : false,
    
    init : function() {
        if ($('#welcome-discount').length == 0)
            return;
        
        var c = Christmas;
        
        c.getHandler().html('Kedvezményes előfizetés');
        setInterval("Christmas.toggleLight()", 600);
        c.getHandler().css({
            backgroundImage : "url('" + base_url + "files/christmas/button-bg.jpg')",
            backgroundPosition: 'top left'
        });
        
        c.getHandler()
            .mouseover(Christmas.hoverChanged)
            .mouseout(Christmas.hoverChanged);
        c.getHandler().append('<div id="christmas-tree"></div>');
        $('#christmas-tree').css({
            position: 'absolute',
            top: '-140px',
            right: '-5px',
            height: '138px',
            width: '128px',
            backgroundImage: "url('" + base_url + "files/christmas/christmastree.png')"
        });
        
        $('#welcome-discount').css('width', '130px');
        
        
        var helpBox = $($('#welcome-right').find('.smalltext').get(0));
        var headerCell = $($('#welcome-right').find('thead').find('td').get(1));
        headerCell.html(headerCell.html().replace('*', ''));
        headerCell.append('<img style="cursor: help;" title="' + helpBox.html() + '" src="' + base_url + 'files/christmas/question.png" />');
        
        helpBox.remove();
        
    },
    
    
    hoverChanged : function() {
        var c = Christmas;
        c.hover = !c.hover;
        c.renderButton();
    },
    
    renderButton : function() {
        var c = Christmas;
        var vertical = c.hover ? 'bottom' : 'top';
        
        if (c.light)
            c.getHandler().css({'background-position' : '0px ' + vertical});
        else
            c.getHandler().css({'background-position' : '-263px ' + vertical});
    },
    
    toggleLight : function() {
        var c = Christmas;
        c.light = !c.light;
        c.renderButton();
    },
    
    getHandler : function() {
        return $('#welcome-link-subscribe');
    }

    
    
};


$(Christmas.init);

