$(window).resize(function() {
    if(this.resizeTO) clearTimeout(this.resizeTO);
    this.resizeTO = setTimeout(function() {
        $(this).trigger('resizeEnd');
    }, 10);
});

function centerText() {
  $(".lines").css('margin-top', $(document).height()/2 - $(".lines").height()/2);
}

$(document).ready(function() {
    $(".lines").css('display', 'block');

    $(".item").resize(function() {
        $(this).contents().stretch();
    }).trigger("resize");

    centerText();

    $(window).bind('resizeEnd', function() {
        centerText();
    });
});

