// wait for the DOM to be loaded
$(document).ready(function() {

    vertAlign('#page_container')
    
    $(window).change(function(){
        vertAlign('#page_container')
    });
    
});
    
function vertAlign(elem){

    var viewport = getVPSize();
    
    var ele_height =  $(elem).height();
    
    var offset_y = Math.round((viewport[1] - ele_height) / 2);
    
    if(offset_y > 0){
        $(elem).css('margin-top', offset_y + "px");
    }

}

function getVPSize(){
    var doc_ele = document.documentElement;
    var vwidth = window.innerWidth || self.innerWidth || (doc_ele&&doc_ele.clientWidth) || document.body.clientWidth;
    var vheight = window.innerHeight || self.innerHeight || (doc_ele&&doc_ele.clientHeight) || document.body.clientHeight;
    arrayVPSize = [vwidth,vheight];
    return arrayVPSize;
}