$(document).ready(function ()
{
    var comp = $('div.home-news-and-events');
    
    var news_panel = comp.find('#news');
    var events_panel = comp.find('#events');
    var panels = comp.find('div.panels');
    panels.height(news_panel.height());
    panels.css({position:'relative'});
    news_panel.css({position:'absolute',top:'0px',left:'0px'});
    events_panel.css({position:'absolute',top:'0px',left:'0px',visibility:'hidden',display:'block'});
    if (events_panel.height() > news_panel.height())
    {
        panels.height(events_panel.height());
    }
    events_panel.css({display:'none',visibility:'visible'});
    
    var buttons = comp.find('div.buttons a');
    buttons.click(function (e)
    {
        e.preventDefault();
        if ($(this).hasClass('active'))
        {
            return;
        }
        buttons.removeClass('active');
        if ($(this).hasClass('events'))
        {
            $('#news').hide();
            $('#events').show();
        }
        else
        {
            $('#events').hide();
            $('#news').show();
        }
        $(this).addClass('active');
    });
});