﻿function f_clientWidth() {
    return f_filterResults(
        window.innerWidth ? window.innerWidth : 0,
        document.documentElement ? document.documentElement.clientWidth : 0,
        document.body ? document.body.clientWidth : 0
    );
}

function f_clientHeight() {
    return f_filterResults(
        window.innerHeight ? window.innerHeight : 0,
        document.documentElement ? document.documentElement.clientHeight : 0,
        document.body ? document.body.clientHeight : 0
    );
}

function f_scrollLeft() {
    return f_filterResults(
        window.pageXOffset ? window.pageXOffset : 0,
        document.documentElement ? document.documentElement.scrollLeft : 0,
        document.body ? document.body.scrollLeft : 0
    );
}

function f_scrollTop() {
    return f_filterResults(
        window.pageYOffset ? window.pageYOffset : 0,
        document.documentElement ? document.documentElement.scrollTop : 0,
        document.body ? document.body.scrollTop : 0
    );
}

function f_filterResults(n_win, n_docel, n_body) {
    var n_result = n_win ? n_win : 0;
    if (n_docel && (!n_result || (n_result > n_docel)))
        n_result = n_docel;
    return n_body && (!n_result || (n_result > n_body)) ? n_body : n_result;
}

function reSize() {
    if (document.getElementById("dProgress")) {
        document.getElementById("dProgress").style.left = (((f_clientWidth() + f_scrollLeft()) / 2) - 490) + 'px';
        document.getElementById("dProgress").style.top = ((f_clientHeight() + f_scrollTop()) - 25) + 'px';
    }

    if (document.getElementById("dReport")) {
        document.getElementById("dReport").style.top = ((f_clientHeight() + f_scrollTop()) - 50) + 'px';
    }

    if (document.getElementById("dPreview")) {
        document.getElementById("dPreview").style.left = (((f_clientWidth() + f_scrollLeft()) / 2) - 400) + 'px';
        document.getElementById("dPreview").style.top = (((f_clientHeight() / 2) + f_scrollTop()) - 225) + 'px';
    }
    
    if (document.getElementById("dMessage")) {
        document.getElementById("dMessage").style.left = (((f_clientWidth() + f_scrollLeft()) / 2) - 400) + 'px';
        document.getElementById("dMessage").style.top = (((f_clientHeight() / 2) + f_scrollTop()) - 225) + 'px';
    }

    if (document.getElementById("dSidePane")) {
        document.getElementById("dSidePane").style.left = (((f_clientWidth() + f_scrollLeft()) / 2) - 495) + 'px';
        document.getElementById("dSidePane").style.top = ((f_clientHeight() + f_scrollTop()) - 101) + 'px';
    }
}