﻿function SetGridHeight(grid) {

    var gridEl = grid.getEl()

    if (grid && gridEl) {
        var windowHeight = 600;
        if (window.frameElement) {
            windowHeight = Ext.get(window.frameElement).getHeight();
        } else {
            if (window.innerHeight) {
                windowHeight = window.innerHeight;
            }
            else if (document.documentElement && document.documentElement.clientHeight) {
                windowHeight = document.documentElement.clientHeight;
            }
            else if (document.body) {
                windowHeight = document.body.clientHeight;
            }
        }
        var renderElementTop = gridEl.getTop();
        grid.setHeight((windowHeight - renderElementTop));
    }

}

function SetGridWidth(grid) {

    var gridEl = grid.getEl()

    if (grid && gridEl) {

        var containerWidth = 400;

        if (window.frameElement) {
            containerWidth = Ext.get(window.frameElement).getWidth();
        } else {
            if (window.innerHeight) {
                containerWidth = window.innerWidth;
            }
            else if (document.documentElement && document.documentElement.clientWidth) {
                containerWidth = document.documentElement.clientWidth;
            }
            else if (document.body) {
                containerWidth = document.body.clientWidth;
            }
        }

        grid.setWidth(containerWidth);
    }
}

function GetWindowHeight(supressHeight){

    var windowHeight = 600;
    if(window.frameElement)
    {
        windowHeight = Ext.get(window.frameElement).getHeight();
    }else{
		if (window.innerHeight) {
			windowHeight= window.innerHeight;
		}
		else if (document.documentElement && document.documentElement.clientHeight) {
			windowHeight = document.documentElement.clientHeight;
		}
		else if (document.body) {
			windowHeight = document.body.clientHeight;
		}
    }

    if (typeof contentElId != 'undefined') {

        if (Ext.getCmp('advisorPageHeader')) {
            windowHeight -= Ext.getCmp('advisorPageHeader').getHeight();
        }

        if (Ext.getCmp('advisorPageFooter')) {
            windowHeight -= Ext.getCmp('advisorPageFooter').getHeight();
        }

        if (typeof contentElId != 'undefined' && supressHeight && parseInt(supressHeight)) {
            windowHeight -= supressHeight;
        }
        
    }
    
    return windowHeight;
}


function GetWindowWidth(supressWidth) {

    var windowWidth = 600;
    if (window.frameElement) {
        windowWidth = Ext.get(window.frameElement).getWidth();
    } else {
        if (window.innerWidth) {
            windowWidth = window.innerWidth;
        }
        else if (document.documentElement && document.documentElement.clientWidth) {
            windowWidth = document.documentElement.clientWidth;
        }
        else if (document.body) {
            windowWidth = document.body.clientWidth;
        }
    }

    if (typeof contentElId != 'undefined' && supressWidth && parseInt(supressWidth)) {
        windowWidth -= supressWidth;
    }

    return windowWidth;
}
