function initBrowserCapture() {
    document.getElementById("ScreenHeight").value = screen.height;
    document.getElementById("ScreenWidth").value = screen.width;

    var myWidth = -1, myHeight = -1;
    if (typeof (window.parent.innerWidth) == 'number') {
        //Non-IE or IE8
        myWidth = window.parent.innerWidth;
        myHeight = window.parent.innerHeight;
    } else if (document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight)) {
        //IE 6+ in 'standards compliant mode'
        myWidth = window.parent.document.documentElement.clientWidth;
        myHeight = window.parent.document.documentElement.clientHeight;
    } else if (document.body && (document.body.clientWidth || document.body.clientHeight)) {
        //IE 4 compatible
        myWidth = window.parent.document.body.clientWidth;
        myHeight = window.parent.document.body.clientHeight;
    }

    if (myWidth == -1 || myHeight == -1) {
        if (typeof (window.innerWidth) == 'number') {
            //Non-IE or IE8
            myWidth = window.innerWidth;
            myHeight = window.innerHeight;
        } else if (document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight)) {
            //IE 6+ in 'standards compliant mode'
            myWidth = window.document.documentElement.clientWidth;
            myHeight = window.document.documentElement.clientHeight;
        } else if (document.body && (document.body.clientWidth || document.body.clientHeight)) {
            //IE 4 compatible
            myWidth = window.document.body.clientWidth;
            myHeight = window.document.body.clientHeight;
        }
    }

    document.getElementById("BrowserHeight").value = myHeight;
    document.getElementById("BrowserWidth").value = myWidth;
    document.getElementById("UserAgent").value = navigator.userAgent;

    if (navigator.userAgent.indexOf("MSIE") != -1) {
        var version = IEVersion();
        document.getElementById("Browser").value = "MSIE";
        document.getElementById("BrowserMode").value = version.BrowserMode;
        document.getElementById("DocMode").value = version.DocMode;
        document.getElementById("BrowserVersion").value = version.Version;
    }
    else if (navigator.userAgent.indexOf("Firefox") != -1) {
        document.getElementById("Browser").value = "Firefox";
        var index = navigator.userAgent.indexOf("Firefox");
        var fStop = (navigator.userAgent.length > index + 13) ? navigator.userAgent.length : index + 13;
        var ffVersion = navigator.userAgent.substring(index + 8, fStop);
        document.getElementById("BrowserVersion").value = ffVersion;
    }
    else if (navigator.userAgent.indexOf("Chrome") != -1) {
        document.getElementById("Browser").value = "Chrome";
        var cIndex = navigator.userAgent.indexOf("Chrome");
        var cVersion = navigator.userAgent.substring(cIndex + 7, cIndex + 17);
        document.getElementById("BrowserVersion").value = cVersion;
    }
    else if (navigator.userAgent.indexOf("Safari") != -1) {
        document.getElementById("Browser").value = "Safari";
        var sIndex = navigator.userAgent.indexOf("Safari");
        var sStop = (navigator.userAgent.length > sIndex + 13) ? navigator.userAgent.length : sIndex + 13;
        var sVersion = navigator.userAgent.substring(sIndex + 7, sStop);
        document.getElementById("BrowserVersion").value = sVersion;
    }

}

/*
* Author: Rob Reid
* CreateDate: 20-Mar-09
* Description: Little helper function to return details about IE 8 and its various compatibility settings either use as it is
* or incorporate into a browser object. Remember browser sniffing is not the best way to detect user-settings as spoofing is
* very common so use with caution.
*/
function IEVersion() {
    var _n = navigator, _w = window, _d = document;
    var version = "NA";
    var na = _n.userAgent;
    var ieDocMode = "NA";
    var ie8BrowserMode = "NA";
    // Look for msie and make sure its not opera in disguise
    if (/msie/i.test(na) && (!_w.opera)) {
        // also check for spoofers by checking known IE objects
        if (_w.attachEvent && _w.ActiveXObject) {
            // Get version displayed in UA although if its IE 8 running in 7 or compat mode it will appear as 7
            version = (na.match(/.+ie\s([\d.]+)/i) || [])[1];
            // Its IE 8 pretending to be IE 7 or in compat mode		
            if (parseInt(version) == 7) {
                // documentMode is only supported in IE 8 so we know if its here its really IE 8
                if (_d.documentMode) {
                    version = 8; //reset? change if you need to
                    // IE in Compat mode will mention Trident in the useragent
                    if (/trident\/\d/i.test(na)) {
                        ie8BrowserMode = "Compat Mode";
                        // if it doesn't then its running in IE 7 mode
                    } else {
                        ie8BrowserMode = "IE 7 Mode";
                    }
                }
            } else if (parseInt(version) == 8) {
                // IE 8 will always have documentMode available
                if (_d.documentMode) { ie8BrowserMode = "IE 8 Mode"; }
            }
            // If we are in IE 8 (any mode) or previous versions of IE we check for the documentMode or compatMode for pre 8 versions			
            ieDocMode = (_d.documentMode) ? _d.documentMode : (_d.compatMode && _d.compatMode == "CSS1Compat") ? 7 : 5; //default to quirks mode IE5				   			
        }
    }

    return {
        "UserAgent": na,
        "Version": version,
        "BrowserMode": ie8BrowserMode,
        "DocMode": ieDocMode
    }
}
