﻿function pageLoad(sender, args) {
    //Update Panels don't hit JQuery's ready on a partial page postback,
    //so things that need to run repeatedly should go in the aptly named function
    //(e.g. wiring events without using JQuery live bindings).
    if (!args.get_isPartialLoad()) {
        $(document).trigger('fullPageLoad', [sender, args]);
    }
    $(document).trigger('allPageLoads', [sender, args]);
    setupGetBoxObjectFor();
}

//Setup the Deprecated function that was pulled from FireFox, Infragistics uses this.
//Code from http://blogs.infragistics.com/forums/p/36753/216923.aspx#218073
function setupGetBoxObjectFor() {
    if (!document.getBoxObjectFor) {
        document.getBoxObjectFor = function(el) {
            var pos = {};

            pos.x = el.offsetLeft;
            pos.y = el.offsetTop;
            parent = el.offsetParent;
            if (parent != el) {
                while (parent) {
                    pos.x += parent.offsetLeft;
                    pos.y += parent.offsetTop;
                    parent = parent.offsetParent;
                }
            }

            parent = el.offsetParent;
            while (parent && parent != document.body) {
                pos.x -= parent.scrollLeft;
                if (parent.tagName != 'TR') {
                    pos.y -= parent.scrollTop;
                }
                parent = parent.offsetParent;
            }

            return pos;
        };
    }
}

function fixMsWebkitDetection() {
    Sys.Browser.WebKit = {};
    if (navigator.userAgent.indexOf('WebKit/') > -1) {
        Sys.Browser.agent = Sys.Browser.WebKit;
        Sys.Browser.version = parseFloat(navigator.userAgent.match(/WebKit\/(\d+(\.\d+)?)/)[1]);
        Sys.Browser.name = 'WebKit';
    }
}