$('document').ready(function() {
    var helper = $('#takeover_button'),
        to = $('#takeover'),
        img = $('img', to),
        ww = $(window).width(),
        wh = $(window).height(),
        p1 = ww < img.width() ? ww / img.width() : 1,
        p2 = wh < img.height() ? wh / img.height() : 1,
        p = p1 > p2 ? p2 : p1;
        
    img.css({
        width: img.width() * p,
        height: img.height() * p
        });
        
    helper.click(function() {
        if (to.width() == img.width())
            to.animate({
                width: helper.width(),
                height: helper.height()
                });
        else
            to.animate({
                width: img.width(),
                height: img.height()
                });
                
        $(this).toggleClass('close');
        });
        
    $('#takeover_kill').click(function() {
        $('#takeover').remove();
        });
    });

