$(document).ready(function() {
    var discussion = false;
    var share = false;
    var top_nav = _.isNull($('#website-top-navbar-placeholder').height()) ? 0 : $('#website-top-navbar-placeholder').height();
    var vHeight = $(window).height() - ($('header').height() + top_nav);
    $('.cover_header').css('min-height', vHeight);
    function page_transist(event) {
        event.preventDefault();
        newLocation = $('.js_next')[0].href;
        $('.cover_footer')
        .fadeIn(900, newpage);
    }

    function animate(event) {
        event.stopImmediatePropagation();
        var target = this.hash;
        $target = $(target);
        $('html, body').stop().animate({
            'scrollTop': $target.offset().top
        }, 900, 'swing', function () {
            window.location.hash = target;
        });
    }

    //check custome options inline discussion and select to tweet(share) are checked.
    openerp.jsonRpc("/blogpsot/get_custom_options", 'call', {}).then(function(res){
        discussion = res['Allow comment in text'];
        share = res['Select to Tweet'];
        var content = $("#blog_content p");
        if(content.length && discussion){
            $('#discussions_wrapper').empty();
            new openerp.website.blog_discussion({'content' : content});
        }
        if (share) $("p,h1,h2,h3,h4,ul").share({'author_name':$('#blog_author').text()});
    });
    $('.cover_footer').on('click',page_transist);
    $('a[href^="#blog_content"]').on('click', animate);

    function page_upwards() {
        var translationValue = $("#wrap:last-child").get(0).getBoundingClientRect().top;
        $("#wrap:last-child").addClass('easing_upward');
        setTimeout(function(){
            $html = $(document.documentElement);
            $("#wrap:first-child").add($html).scrollTop(0);
            $("#wrap:last-child").removeClass('easing_upward');
            $("#wrap:first").remove();
            var content = $(document).find("#blog_content p");
            if (content && discussion){
               new openerp.website.blog_discussion({'content' : content});
            }
        }, 300 );
    }

    function newpage() {
        $.ajax({
            url: newLocation
        }).done(function(data) {
            $('main').append($(data).find('main').html());
            page_upwards();
            //bind again it takes control from now on, until page relaod.
            $(document).find('.cover_footer').on('click',page_transist);
            $(document).find('.cover_header').css('min-height', vHeight);
            $(document).find('a[href^="#blog_content"]').on('click', animate);
            if (share) $("p,h1,h2,h3,h4,ul").share({'author_name':$(data).find('#blog_author').text()});
            if (newLocation != window.location)
                history.pushState(null, null, newLocation);
        });
    }
});

@@ -67,32 +67,75 @@
  share = false;%0A
+%0A    function updateMinHeight(event) %7B%0A    
     var top_nav 
@@ -241,24 +241,28 @@
 ).height();%0A
+    
     var vHei
@@ -322,25 +322,44 @@
 p_nav);%0A    
-$
+    $(document).find
 ('.cover_hea
@@ -388,24 +388,31 @@
 , vHeight);%0A
+    %7D%0A%0A
     function
@@ -893,25 +893,101 @@
   %7D);%0A    %7D%0A
+    $( window ).on('resize', function() %7B%0A        updateMinHeight();%0A    %7D);
 %0A
-
     //check 
@@ -1653,16 +1653,39 @@
 nimate);
+%0A    updateMinHeight();
 %0A%0A    fu
@@ -2501,24 +2501,55 @@
 _upwards();%0A
+            updateMinHeight();%0A
             
@@ -2610,16 +2610,16 @@
 relaod.%0A
+
         
@@ -2687,82 +2687,8 @@
 t);%0A
-            $(document).find('.cover_header').css('min-height', vHeight);%0A
     

update cover height when page resize