// Behaviours
$(document).ready(function() {
    // All non-GET requests will add the authenticity token
    // if not already present in the data packet
    $("body").bind("ajaxSend", function(elm, xhr, s) {
        if (s.type == "GET") return;
        if (s.data && s.data.match(new RegExp("\\b" + window._auth_token_name + "="))) return;
        if (s.data) {
            s.data = s.data + "&";
        } else {
            s.data = "";
            // if there was no data, jQuery didn't set the content-type
            xhr.setRequestHeader("Content-Type", s.contentType);
        }
        s.data = s.data + encodeURIComponent(window._auth_token_name)
        + "=" + encodeURIComponent(window._auth_token);
    });
});

// All ajax requests will trigger the wants.js block
// of +respond_to do |wants|+ declarations
jQuery.ajaxSetup({ 
    'beforeSend': function(xhr) {
        xhr.setRequestHeader("Accept", "text/javascript")
        }
    });
function setFooter() {
    if ($(window).height() > 0) {
        var topHeight = ($(window).height() - ( $('#lbb').height() + $('#ft').height() ) );
        if (topHeight >= 0) {
            $('#ft').css('top', (topHeight + 'px') )
        }
        else {
            $('#ft').css('top', '0px' )
        }
    }
}
    
window.onresize = function() { 
    setFooter();
}
window.onload = function(){
    setFooter();
}