﻿var headerHeight = 88;
var footerHeight = 45;
var footerMarginHeight = 10;
var bodyContainerTopHeight = 12;
var bodyContainerProgressHeight = 100;

Event.observe(window, 'load', function() {
    resizeBody();
    Xaprb.InputMask.setupElementMasks();
});

Event.observe(window, 'resize', function() {
    resizeBody();
});

Position.getWindowSize = function(w) {
    var width, height;
    w = w ? w : window;
    width = w.innerWidth || (w.document.documentElement.clientWidth || w.document.body.clientWidth);
    height = w.innerHeight || (w.document.documentElement.clientHeight || w.document.body.clientHeight);
    return { width: width, height: height }; 
}

function resizeBody() {
    var dim = Position.getWindowSize();
    if (dim.width < 700 || Prototype.Browser.MobileSafari) {
        $('CP_Body').setStyle({height:''});
        $('CP_Body_Container').setStyle({height:'100%'});
        $('CP_Body_Container_Middle').setStyle({height:'100%'});
        return;
    }
    
    var bodyHeight = dim.height - headerHeight;
    if (bodyHeight < 400)
        bodyHeight = 400;
    
    var bodyContainerHeight = bodyHeight - footerHeight - footerMarginHeight;
    var bodyContainerMiddleHeight = bodyContainerHeight - bodyContainerTopHeight - bodyContainerProgressHeight - 10;
    $('CP_Body').setStyle({height:bodyHeight + 'px'});
    $('CP_Body_Container').setStyle({height:bodyContainerHeight + 'px'});
    $('CP_Body_Container_Middle').setStyle({height:bodyContainerMiddleHeight + 'px'});
}

