var opacity = 1; setInterval("opacityChange()",500);

$(document).ready(function () {
    $('div').show();
    imgResize();
    $(window).resize(function() { imgResize(); })
});


function imgResize() {
    $('img').removeAttr('style').width($(window).width()).css('top', ($(window).height()/2)).css('margin-top', (($('img').height()/2) - $('img').height()));
    if($('img').height() > $(window).height()) {
        $('img').removeAttr('style').height($(window).height());
    }
}


function opacityChange() {
    if (opacity >= -0.1){
        $('div').css({'opacity': opacity.toFixed(2)});
        if (opacity < 0.1){ $('div').hide(); }
    }
    if (opacity <= -0.5){ document.location.href = $('a').attr('href'); }
    opacity = opacity.toFixed(2) - 0.2;
}
