﻿var agt = navigator.userAgent.toLowerCase();
var is_ie = ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1));
var is_gecko = (navigator.product == "Gecko");

var gIsPost = true;
window.getObj ? 0 : getObj = function (s) { return document.getElementById(s) };
$ = getObj;


~function () {
    var FNArray = [];
    var D = document;
    /**
    * 使用举例：
    window.onReady(FunctionName[,argu1,[argu2,[....]]]);
    */
    window.onReady = function (fallBackFunction) {


        var argu = [];
        for (var i = 1, len = arguments.length; i < len; i++) {
            argu.push(arguments[i]);
        }
        if (window.readyBound) return fallBackFunction.apply(this, argu);
        if (!is_ie) return fallBackFunction.apply(this, argu);
        FNArray.push(fallBackFunction);
        readyBound = true;
        var ready = 0;
        // Mozilla, Opera and webkit nightlies currently support this event
        if (D.addEventListener) {
            // Use the handy event callback
            D.addEventListener("DOMContentLoaded",
            function () {
                D.removeEventListener("DOMContentLoaded", arguments.callee, false);
                if (ready) return;
                ready = 1;

                for (var i = 0, len = FNArray.length; i < len; i++) {
                    FNArray[i] ? FNArray[i].apply(this, argu) : 0;
                }

            },
            false);

            // If IE event model is used
        } else if (D.attachEvent) {
            // ensure firing before onload,
            // maybe late but safe also for iframes
            D.attachEvent("onreadystatechange",
            function () {
                if (D.readyState === "complete") {
                    D.detachEvent("onreadystatechange", arguments.callee);

                    if (ready) return;
                    ready = 1;
                    for (var i = 0, len = FNArray.length; i < len; i++) {
                        FNArray[i] ? FNArray[i].apply(this, argu) : 0;
                    }
                }
            });

            // If IE and not an iframe
            // continually check to see if the D is ready
            if (D.documentElement.doScroll && window == window.top) (function () {
                if (ready) return;
                try {
                    // If IE is used, use the trick by Diego Perini
                    // http://javascript.nwbox.com/IEContentLoaded/
                    D.documentElement.doScroll("left");
                } catch (error) {
                    setTimeout(arguments.callee, 0);
                    return;
                }
                ready = 1;
                for (var i = 0, len = FNArray.length; i < len; i++) {
                    FNArray[i] ? FNArray[i].apply(this, argu) : 0;
                }

            })();
        }
    };
} ();


function ietruebody() {
    /*
    if (getObj('upPanel')) {
    return getObj('upPanel');
    }
    */
    return (document.compatMode && document.compatMode != "BackCompat") ? document.documentElement : document.body;
}
function getTop() {
    return typeof window.pageYOffset != 'undefined' ? window.pageYOffset : ietruebody().scrollTop;
}
function getLeft() {
    return (typeof window.pageXOffset != 'undefined' ? window.pageXOffset : ietruebody().scrollLeft)
}
function IsElement(id) {
    return document.getElementById(id) != null ? true : false;
}

