/*
2013/7/31
*/
var IsIE = document.all ? true : false;
var _loadingimg1 = "/Images/loading/loading16x16b.gif";
var SourceConfig = {
    tooltipBackground: "/Images/ui/promptup.gif",
    wait: "<img src='/Images/ui/loader2.gif' alt='loading' title='loading'/>"
}
var bx= {
    id: function (idstr) { return document.getElementById(idstr); },
    utility: {
        isIE: document.all ? true : false,
        date: function (_date) { return new Date(parseInt(_date.replace("/Date(", "").replace(")/", ""))) },
        dateFormat: function (format, d) {
            d = d == null ? new Date() : new Date(d);
            return format.replace("yyyy", d.getFullYear()).replace("MM", d.getMonth()).replace("dd", d.getDate()).replace("hh", d.getHours()).replace("mm".d.getMinutes()).replace("ss".setSeconds());
        },
        formatDate: function (v, format) {
            var d = this.date(v);
            if (format == null) {
                return d.getFullYear() + "/" + d.getMonth() + "/" + d.getDate() + " " + d.getHours() + ":" + d.getMinutes() + ":" + d.getSeconds();
            } else { return format.replace("yyyy", d.getFullYear()).replace("MM", d.getMonth()).replace("dd", d.getDate()).replace("hh", d.getHours()).replace("mm".d.getMinutes()).replace("ss".setSeconds()); }
        },
        imgLazy: function (areaId) { new ImgLazy(areaId).load(); },
        returnTop: function (objId) {
            if (objId == null) {
                objId = "toTop";
                var aobj = document.createElement("a");
                aobj.id = objId; aobj.href = "#"; aobj.style.display = "inline";
                aobj.innerHTML = "<span id=\"toTopHover\" style=\"opacity: 0;\"></span>";
            }
        },
        addEvent: function (obj, type, fn) { if (obj.attachEvent) { obj.attachEvent('on' + type, fn); } else { obj.addEventListener(type, fn, false); } }
    },
    status: {
        loadPage: {
            load: function () { this.start(); window.onload = function () { document.getElementById("_pageLoadStatus").style.display = "none"; }; },
            start: function () {
                var ct = "position:fixed;border:1px blue solid;width:200px;top:0px;left:0px;background-color:#FFF;";
                document.write("<div style=\"" + ct + "\" id=\"_pageLoadStatus\" class=\"_pageLoadStatus\"><img src=\"" + _loadingimg1 + "\" alt=\"loading\"/>加载中......</div>")
            },
            end: function () {
                /// <summary>
                /// 状态结束
                /// </summary>
                document.getElementById("_pageLoadStatus").style.display = "none";
            }
        },
        click: function () {
            /// <summary>
            /// 单击状态
            /// </summary>
            var obj = document.createElement("div");
            obj.className = "_pageLoadStatus";
            obj.style.cssText = "position:fixed;border:1px blue solid;width:200px;top:0px;left:0px;background-color:#FFF;";
            obj.innerHTML = "<img src=\"" + _loadingimg1 + "\" alt=\"loading\"/>加载中......";
            if (document.all) { document.body.appendChild(obj); } else { document.documentElement.appendChild(obj); }
        },
        waiting: function (param) {
            jspopup.closeWindow();
            if (param != null && param.action != null && param.action == "start") {
                if (param.background != null && param.background == true) { jspopup.createBackground(); }
                jspopup.show({ content: (param.text != null ? param.text : SourceConfig.wait) });
            }
        }
    },
    request: {
        queryString: function (key) { return this.params(key); },//兼容 
        params: function (key) {
            /// <summary>
            /// 获取HTTP查询字符串变量集合
            /// </summary>
            /// <param name="key">键值项</param>
            var _search = window.location.search.substring(window.location.search.lastIndexOf('?') + 1);
            var _searchArray = _search.split('&'); var _searchKeyValue;
            if (_search != "") {
                for (var i = 0; i < _searchArray.length; i++) {
                    _searchKeyValue = _searchArray[i].split('=');
                    if (_searchKeyValue.length == 2) { if (_searchKeyValue[0] == key) { return _searchKeyValue[1]; } else { continue; } }
                }
                return "";
            } else { return ""; }
        },
        url: {
            directory: function (index) {
                /// <summary>
                /// 获取目录名称
                /// </summary>
                /// <param name="index">索引</param>
                var _pathArray = window.location.pathname.split('/');
                if (_pathArray[index + 1] == undefined) { return ""; } else { return _pathArray[index + 1]; }
            },
            fileinfo: function () {
                /// <summary>
                /// 获取URL文件信息,返回一维数组
                /// </summary>
                var _pathArray = window.location.pathname.split('/'); var _returnValue = new Array();
                _returnValue.push(""); _returnValue.push(""); _returnValue.push("")
                if (_pathArray[_pathArray.length - 1].indexOf('.') != -1) {
                    _returnValue[0] = _pathArray[_pathArray.length - 1]; //全文件名
                    _returnValue[1] = _pathArray[_pathArray.length - 1].substring(0, _pathArray[_pathArray.length - 1].lastIndexOf('.')); //文件名
                    _returnValue[2] = _pathArray[_pathArray.length - 1].substring(_pathArray[_pathArray.length - 1].lastIndexOf('.')); //扩展名
                }
                return _returnValue;
            }
        }
    },
    popup: {
        messageBox: function (params) {
            /// <summary>
            /// Div消息窗口
            /// </summary>
            /// <param name="params">参数集合</param>
            if (params == null) { return; }
            if (params.background != null && params.background == true) { jspopup.createBackground(); }
            if (params.style == null || params.style == "1") {
                var vContent = "<div class=\"window-skin-1\" style=\"padding: 5px;\"><div class=\"window-outer-1\"><div class=\"window-inner-1\" style=\"width:auto; height:auto; overflow: auto;\">{$text}</div></div><div title=\"关闭\" onclick=\"jspopup.closeWindow();\" class=\"window-close-1\"></div></div>";
                jspopup.show({ "content": vContent.replace("{$text}", params.text == null ? "" : params.text) });
            }
            else if (params.style == "2") {
                var vContent = "<div class=\"window-skin-2\"><div class=\"window-title-2\" onmousedown=\"jspopup.onMoveWindow(event);\"><a href=\"javascript:\" class=\"window-close-2\" onclick=\"jspopup.closeWindow()\">x</a></div><div class=\"window-content-2\">{$text}</div><div class=\"window-operition-2\">button</div></div>";
                jspopup.show({ "content": vContent.replace("{$text}", params.text == null ? "" : params.text) });
            }
            window.onresize = jspopup.onChangeWindowSize;
        },
        dialog: function (params, callback) {
            /// <summary>
            /// 对话框
            /// </summary>
            /// <param name="params">参数集合,text:对话框内容,title:标题,button:按钮,background:布尔值,默认为true,是否创建背景,callback:回调函数,参数为对象</param>
            /// <param name="callback">回调函数</param>
            if (params == null) { return; }
            callback = callback != null ? callback : (params.callback != null ? params.callback : "null");
            var wframe = "";
            wframe += "<div class=\"window-skin-4\">";
            wframe += "    <div class=\"window-title\"><input class=\"window-close\" type=\"button\" value=\"\" onclick=\"jspopup.closeWindow();\" />{title}</div>";
            wframe += "    <div class=\"window-content\"><p>{content}</p></div>";
            wframe += "    <div class=\"window-operition\">";
            if (params.button == null || params.button == "" || params.button == "ok") {
                wframe += "        <div class=\"window-operition-buttons\"><input class=\"window-operition-ok\" value=\"确定\" type=\"button\" onclick=\"_innerobject.callback(" + callback + ",{'result':'ok'});\" /></div>";
            }
            else if (params.button.toLocaleLowerCase() == "okcancel") {
                wframe += "        <div class=\"window-operition-buttons\"><input class=\"window-operition-ok\" value=\"确定\" type=\"button\" onclick=\"_innerobject.callback(" + callback + ",{'result':'ok'});\" /><input class=\"window-operition-ok\" value=\"取消\" type=\"button\" onclick=\"_innerobject.callback(" + callback + ",{'result':'cancel'});\" /></div>";
            }
            wframe += "    </div>";
            wframe += "</div>";
            if (params.title != null) { wframe = wframe.replace("{title}", params.title); } else { wframe = wframe.replace("{title}", ""); }
            wframe = wframe.replace("{content}", params.text);
            if (params.background == null || params.background == true) { jspopup.createBackground(); }
            jspopup.show({ "content": wframe });
            window.onresize = jspopup.onChangeWindowSize;
        },
        close: function () { jspopup.closeWindow(); },
        window: function (params) {
            /// <summary>
            /// 空白窗口,参数text:自定义内容
            /// </summary>
            /// <param name="params">参数集合</param>
            if (params == null) { return; }
            if (params.background != null && params.background == true) { jspopup.createBackground(params.opacity != null ? params.opacity : null); }
            jspopup.show({ "content": params.text });
            window.onresize = jspopup.onChangeWindowSize;
        },
        tips: function (params) {
            if (params == null) { return; }
            var fm = " <div class=\"window-skin-3\">";
            fm += "<div class=\"window-title-3\">&nbsp;</div>";
            fm += "<div class=\"window-content-3\">" + params.text + "</div>";
            fm += "<div class=\"window-operition-3\">&nbsp;</div>";
            fm += " </div>";
            jspopup.show({ "content": fm });
            window.setTimeout(function () { jspopup.closeWindow() }, 2000);
        }
    },
    follow: {
        add: function (objid) {
            /// <summary>
            /// 添加要紧贴浏览器顶部
            /// </summary>
            /// <param name="objid">对象id</param>
            var obj = document.getElementById(objid);
            if (obj == null) { return; }
            _followObj.push(obj);
            _followObjOffsetTop.push(obj.offsetTop);
            window.onscroll = function () {
                var top = document.all ? document.documentElement.scrollTop : window.pageYOffset;
                for (var i = 0; i < _followObj.length; i++) {
                    if (top >= _followObjOffsetTop[i]) { _followObj[i].style.position = "fixed"; _followObj[i].style.top = "0"; }
                    else { _followObj[i].style.position = "static"; _followObj[i].style.top = _followObjOffsetTop[i]; }
                }
            }
        }
    },
    xml: {
        selectNodes: function (xmlDoc, xpath) {
            /// <summary>
            /// XML多节点查询
            /// </summary>
            /// <param name="xmlDoc">查询对象</param>
            /// <param name="xmlDoc">xpath</param>
            if (document.all) { try { return xmlDoc.documentElement.selectNodes(xpath); } catch (e) { } }
            else {
                var xpe = new XPathEvaluator();
                var nsResolver = xpe.createNSResolver(xmlDoc.ownerDocument == null ? xmlDoc.documentElement : xmlDoc.ownerDocument.documentElement);
                var results;
                try { results = xpe.evaluate(xpath, xmlDoc, nsResolver, XPathResult.ORDERED_NODE_ITERATOR_TYPE, null); } catch (e) { }//注:如果xpath表达式未写对,这里将报错
                var aNodes = new Array();
                if (results != null) {
                    var oElement = results.iterateNext();
                    while (oElement) { aNodes.push(oElement); oElement = results.iterateNext(); }
                }
                return aNodes;
            }
        }
    },
    dom: {
        radio: {
            get: function (domName) {
                var rdolist = document.getElementsByName(domName);
                for (var i = 0, j = rdolist != null ? rdolist.length : 0; i < j; i++) {
                    if (rdolist[i].checked) { return rdolist[i]; break; }
                }
            },
            set: function (domName, vstr) {
                var rdolist = document.getElementsByName(domName);
                for (var i = 0, j = rdolist != null ? rdolist.length : 0; i < j; i++) {
                    if (rdolist[i].value == vstr) { rdolist[i].checked = "checked"; } else { rdolist[i].checked = false; }
                }
            }
        },
        checkbox: {
            get: function (domName) {
                var ckblist = document.getElementsByName(domName); var tempval = "";
                for (var x = 0; x < ckblist.length; x++) { if (ckblist[x].checked) { tempval += ckblist[x].value + ","; } }
                return tempval.substr(0, tempval.length - 1);
            },
            set: function (domName, vstr) {
                var ckblist = document.getElementsByName(domName);
                var vlist = vstr.split(',');
                for (var x = 0; x < ckblist.length; x++) {
                    for (var y = 0; y < vlist.length; y++) { if (ckblist[x].value == vlist[y]) { ckblist[x].checked = true; } }
                }
            }
        },
        select: {
            get: function (domId) { return document.getElementById(domId).options[document.getElementById(domId).selectedIndex].value; },
            set: function (domId, value) {
                var options = document.getElementById(domId).options;
                for (var i = 0; i < options.length; i++) {
                    options[i].selected = false;
                    if (options[i].value == value) { options[i].selected = true; }
                }
            }
        }
    },
    store: {
        cookie: {
            get: function (name) {
                var cklist = document.cookie.split(";");
                for (var i = 0; i < cklist.length; i++) {
                    var ck = cklist[i].split("=");
                    if (ck[0] == name) { return unescape(ck[1]); }
                }
                return "";
            },
            set: function (name, value, expires) { var d = new Date(); d.setTime(d.getTime() + expires); document.cookie = name + "=" + escape(value) + ";expires=" + d.toGMTString(); },
            clear: function (name) { this.set(name, "", -1000); }
        }
    }
    //end
};
var _followObj = new Array();
var _followObjOffsetTop = new Array();
var jspopup = {
    winObj: null,
    bgObj: null,
    winStyle: "position:fixed;_position:absolute;z-index:9999;", 
    bjStyle: "top:0px;left:0px;position:absolute;background:#666;z-index:9998;", 
    show: function (params) {
        var windowObj = document.createElement("div");
        windowObj.innerHTML = params.content == null ? "" : params.content; 
        windowObj.style.cssText = this.winStyle;
        document.body.appendChild(windowObj);
        this.winObj = windowObj;
        var vTop = this.getWindowLocation("top"); 
        var vLeft = this.getWindowLocation("left");
        this.winObj.style.top = vTop + "px";
        this.winObj.style.left = vLeft + "px";
    },
    createBackground: function (_opacity) {
        var vWidth = parseInt(document.documentElement.scrollWidth);
        var vHeight = parseInt(document.documentElement.scrollHeight);
        var divObject = document.createElement("div");
        divObject.style.cssText = this.bjStyle + "width:" + vWidth + "px;height:" + vHeight + "px;" + (IsIE == true ? "filter:alpha(opacity=0)" : "opacity:0");
        this.bgObj = divObject;
        document.body.appendChild(this.bgObj); 
        this.changeBackground(this.bgObj,_opacity!=null?_opacity:30); 
    },
    changeBackground: function (divObj, opacityMaxValue) {
        if (document.all) {
            try {
                document.createElement("canvas").getContext("2d");
                if (divObj.style.opacity == false)
                {
                    divObj.style.opacity = 0;
                }
                var opa = parseFloat(divObj.style.opacity);
                opa += 0.1;
                divObj.style.opacity = opa;
                if (opa < (opacityMaxValue / 100)) {
                    setTimeout(function () { jspopup.changeBackground(divObj, opacityMaxValue) }, 5);
                }
            } catch (e) {
                divObj.filters.alpha.opacity += 10;
                if (divObj.filters.alpha.opacity < opacityMaxValue) {
                    setTimeout(function () { jspopup.changeBackground(divObj, opacityMaxValue); }, 5); 
                }
            }
        }
        else {
            var opa = parseFloat(divObj.style.opacity);
            opa += 0.1;
            divObj.style.opacity = opa;
            if (opa < (opacityMaxValue / 100)) {
                setTimeout(function () { jspopup.changeBackground(divObj, opacityMaxValue) }, 5);
            }
        }
    },
    getWindowLocation: function (topLeft) {
        if (topLeft == "top") {
            var top = (document.documentElement.clientHeight - this.winObj.clientHeight) / 2;
            return top;
        }
        else if (topLeft == "left") {
            var left = (document.documentElement.clientWidth - this.winObj.clientWidth) / 2;
            return left;
        }
        else {
            return 0;
        }
    },
    onChangeWindowSize: function () {
        if (jspopup.bgObj != null) {
            jspopup.bgObj.style.width = parseInt(document.documentElement.scrollWidth) + "px"; 
            jspopup.bgObj.style.height = parseInt(document.documentElement.scrollHeight) + "px";

            jspopup.winObj.style.top = jspopup.getWindowLocation("top") + "px"; 
            jspopup.winObj.style.left = jspopup.getWindowLocation("left") + "px";
        }
    },
    onMoveWindow: function (evt) {
        var evtObj = window.event ? event : evt;
        var X1 = evtObj.clientX; 
        var Y1 = evtObj.clientY;
        var L1 = this.winObj.style.left; 
        L1 = L1.substring(0, L1.indexOf("px") != -1 ? L1.indexOf("px") : 0);
        L1 = parseInt(L1);
        var T1 = this.winObj.style.top;
        T1 = T1.substring(0, T1.indexOf("px") != -1 ? T1.indexOf("px") : 0);
        T1 = parseInt(T1);
        var IsMove = true;
        document.onmouseup = function () {
            IsMove = false;
        }
        document.onmousemove = function (evt) {
            if (IsMove == true) {
                var x = (L1 + (IsIE ? evtObj.clientX : evt.clientX) - X1);
                var y = (T1 + (IsIE ? evtObj.clientY : evt.clientY) - Y1);
                jspopup.winObj.style.left = x + "px";
                jspopup.winObj.style.top = y + "px";
                return false;
            }
        };
        return false;
    },
    closeWindow: function () {
        if (this.winObj != null) {
            this.winObj.parentNode.removeChild(this.winObj);
            this.winObj = null;
        }
        if (this.bgObj != null) {
            this.bgObj.parentNode.removeChild(this.bgObj);
            this.bgObj = null;
        }
        if (IsIE) {

        }
    }
}
var Pagination = function (_showPage) {
    var previousPage = "上一页", nextPage = "下一页";
    var total = 0;
    var showPage = _showPage != null ? parseInt(_showPage) : 5;
    var min = 0, max = 0;
    Pagination.prototype.IsShowTotal = false;
    Pagination.prototype.totalPage = 1;
    Pagination.prototype.list = function (link, page, totalRows, maximumRows) {
        /// <summary>
        /// 列表页分页
        /// </summary>
        /// <param name="link">链接地址,也可以是js</param>
        /// <param name="page">当前页</param>
        /// <param name="totalRows">总行数</param>
        /// <param name="maximumRows">每页的最大行数</param>
        var _paginationcode = create(link, page, totalRows, maximumRows, this.IsShowTotal);
        this.totalPage = total;
        return _paginationcode;
    };
    function create(link, page, totalRows, maximumRows, _isShowTotal) {
        if (totalRows < 1) {
            return "";
        }
        page = parseInt(page);
        range(page, totalRows, maximumRows);
        var next = 0, pre = 0;
        if (page > 1) {
            pre = page - 1;
        }
        if (page < total) {
            next = page + 1;
        }
        var sb = "<ul class=\"pagination\">";
        if (_isShowTotal) {
            sb += "<li class=\"total\"><a>共 " + totalRows + " 条记录</a></li>";
        }
        if (previousPage != null) {
            if (pre == 0) {
                sb += ("<li class=\"previouspage\"><a>首页</a></li>");
                sb += ("<li class=\"previouspage\"><a>" + previousPage + "</a></li>");
            }
            else {
                sb += ("<li class=\"previouspage\"><a href=\"" + link.replace("@page", "1") + "\">首页</a></li>");
                sb += ("<li class=\"previouspage\"><a href=\"" + link.replace("@page", pre) + "\">" + previousPage + "</a></li>");
            }
        }
        for (var i = min; i <= max; i++) {
            if (i == page) {
                sb += ("<li class=\"otherpage\"><a class=\"currentpage\">" + i + "</a></li>");
            }
            else {
                sb += ("<li class=\"otherpage\"><a href=\"" + link.replace("@page", i) + "\">" + i + "</a></li>");
            }
        }
        if (nextPage != null) {
            if (next == 0) {
                sb += ("<li class=\"previouspage\"><a>" + nextPage + "</a></li>");
                sb += ("<li class=\"previouspage\"><a>尾页</a></li>");
            }
            else {
                sb += ("<li class=\"nextpage\"><a href=\"" + link.replace("@page", next) + "\">" + nextPage + "</a></li>");
                sb += ("<li class=\"nextpage\"><a href=\"" + link.replace("@page", total) + "\">尾页</a></li>");
            }
        }
        if (_isShowTotal) {
            sb += "<li class=\"totalpage\"><a>页次:" + page + "/" + total + " 页</a></li>";
        }
        sb += "</ul>";
        return sb;
    }
    function range(page, totalRows, maximumRows) {
        total = (totalRows % maximumRows) == 0 ? parseInt(totalRows / maximumRows) : parseInt(totalRows / maximumRows) + 1;
        var show = showPage;
        if (page < show) {
            if (total >= show) {
                min = 1;
                max = show;
            }
            else {
                min = 1; max = total;
            }
        }
        else {
            if ((page + parseInt(show / 2)) > total) {
                min = total - page != 0 ? total - (show - (total - page)) : total - (show - 1);
                max = total;
            }
            else {
                if (show % 2 == 0) {
                    min = page - (parseInt(show / 2) - 1);
                    max = page + parseInt(show / 2);
                }
                else {
                    min = page - parseInt(show / 2);
                    max = page + parseInt(show / 2);
                }
            }
        }
    }
}

var _innerobject = {
    callback: function (f, data) {
        if (f != null && typeof (f) == "function") {
            data.close = function () {
                jspopup.closeWindow();
            }
            f(data);
        }
        jspopup.closeWindow();
    }
}
var clientValidate = {
    isEmail: function (data) { return this.test(/^[\w-]+(\.[\w-]+)*@[\w-]+(\.[\w-]+)+$/, data); },
    isDigit: function (data) { return this.test(/^\d+$/, data); },
    isLettert: function (data) { return this.test(/^\d+$/, data) },
    isDigitLetter: function (data) { return this.test(/^\w+$/, data); },
    isTelephone: function (data) { return this.test(/(\d{3}-|\d{4}-)?(\d{8}|\d{7})/, data); },
    isMobilePhone: function (data) { return this.test(/^1{1}\d{10}$/, data); },
    test: function (express, data) { return new RegExp(express).test(data); }
};
var ImgLazy = function (areaid) {
    var loadobj = document.getElementById(areaid);
    var settings = {
        attributeName: "data-original",
        distance: 100,
        defaultval:50
    };
    var lazyLoadList = new Array();
    var loadLazyObj = function () {
        lazyLoadList.length = 0;
        if (loadobj != null) {
            var imgList = loadobj.getElementsByTagName("img");
            for (var i = 0; i < imgList.length; i++) {
                if (imgList[i].attributes[settings.attributeName] != null)
                {
                    if (imgList[i].style.filter) {
                        imgList[i].style.filter = "alpha(opacity=" + settings.defaultval + ")";
                    }
                    else {
                        imgList[i].style.opacity = (settings.defaultval / 100);
                    }
                    lazyLoadList.push(imgList[i]);
                }
            }
        }
    };
    var scrollEvent = function () {
        if (loadobj != null) {
            var otop = loadobj.offsetTop;
            var stop = document.all ? document.documentElement.scrollTop : window.pageYOffset;
            var oheight = document.all ? document.documentElement.offsetHeight : window.innerHeight;
            var eventheight = stop + oheight;
            if (eventheight >= otop) {
                for (var i = 0; i < lazyLoadList.length; i++) {
                    var _offsetTop = lazyLoadList[i].offsetTop==0?lazyLoadList[i].offsetParent.offsetTop:lazyLoadList[i].offsetTop;
                    if (eventheight - settings.distance > _offsetTop) {
                        lazyLoadList[i].src = lazyLoadList[i].attributes[settings.attributeName].value;
                        fadeout(lazyLoadList[i], 50);
                        lazyLoadList[i].removeAttribute(settings.attributeName);
                    }
                }
            }
            loadLazyObj();
        }
    };
    var addEvent = function (obj, type, fn) {
        if (obj.attachEvent) {
            obj.attachEvent('on' + type, fn);
        }
        else {
            obj.addEventListener(type, fn, false);
        }
    };
    var fadeout = function (fadeobj, speed, satartval) {
        if (fadeobj != null) {
            fadeobj.onload = function () {
            var _t = fadeobj.style.filter ? (fadeobj.style.filter = "alpha(opacity=" + settings.defaultval + ")") : (fadeobj.style.opacity = (settings.defaultval/100));
                var i = satartval == null ?settings.defaultval: satartval;
                var val = window.setInterval(function () {
                    if (fadeobj.style.filter) {
                        if (fadeobj.style.filter < 100) {
                            fadeobj.style.filter = "alpha(opacity=" + i + ")";
                        }
                        else {
                            window.clearInterval(val);
                        }
                    }
                    else {
                        if (fadeobj.style.opacity < 1) {
                            fadeobj.style.opacity = i / 100;
                        }
                        else {
                            window.clearInterval(val);
                        }
                    }
                    i += 10;
                }, speed);
           }
        }
    };
    ImgLazy.prototype.load = function () {
        addEvent(window, 'scroll', scrollEvent);
    };
    loadLazyObj();
    scrollEvent();
};
var follow = {
    Items: new Array(),
    cursor: function (objid, html) {//光标跟随
        var obj = document.getElementById(objid); var show2 = this._show2;
        var mousefun = function (e) { show2(e, e.clientX, e.clientY, obj, html); };
        if (obj.attachEvent) { obj.attachEvent("onmousemove", mousefun); obj.attachEvent("onmouseout", this.close); } else { obj.addEventListener("mousemove", mousefun, false); obj.addEventListener("mouseout", this.close, false); }
    },
    rightkey: function (evt, obj, html) {;//右键显示
        evt = window.event ? window.event : evt; this.close();
        this.show(evt, evt.offsetX ? evt.offsetX : evt.layerX, evt.offsetY ? evt.offsetY : evt.layerY, obj, html);
    },
    show: function (evt, x, y, obj, html) {//任意坐标显示
        this.close();
        evt = window.event ? window.event : evt;
        var div = document.createElement("div");
        div.innerHTML = html; div.style.position = "absolute";
        div.style.left = x.toString().replace("px", "") + "px"; div.style.top = y.toString().replace("px", "") + "px";
        if (obj.parentNode.style.position == "") { obj.parentNode.style.position = "relative"; };
        if (document.attachEvent) { document.attachEvent("onclick", this.close); } else { document.addEventListener("click", this.close, false); }
        if (evt.stopPropagation) { evt.stopPropagation(); } else { evt.cancelBubble = true; }
        obj.parentNode.appendChild(div);
        follow.Items.push(div);
    },
    _show2: function (evt, x, y, obj, html) {
        evt = window.event ? window.event : evt;
        var wd = document.getElementById("_follow_window");
        if (wd == null) {
            var div = document.createElement("div");
            div.id = "_follow_window"; div.innerHTML = html; div.style.position = "fixed"; obj.parentNode.appendChild(div);
            wd = div; follow.Items.push(div);
        }
        wd.style.left = (parseInt(x.toString().replace("px", "")) + 20) + "px";;
        wd.style.top = y.toString().replace("px", "") + "px";
    },
    close: function () {
        for (var i = 0; i < follow.Items.length; i++) { follow.Items[i].parentNode.removeChild(follow.Items[i]); }
        follow.Items.length = 0;
    }
}
var ReturnTop = {
    updownsrc: "/Images/UI/updownarrow.gif",
    upsrc: "/Images/UI/uparrow.gif",
    _divobj: null,
    load: function (params) {
        if (params == null || (params != null && params.down == null)) {
            if (params != null && params.content != null) {
                this._divobj = this.adddivobj(params.content, params);
            } else { this._divobj = this.adddivobj(this.addimgobj(false), params); }
            if (window.attachEvent) {
                window.attachEvent("onscroll", this.scrollevent);
            }
            else { window.addEventListener("scroll", this.scrollevent, false); }
        }
        else {
            if (document.body.scrollHeight > window.screen.availHeight) { this._divobj = this.adddivobj(this.addimgobj(true)); this._divobj.style.display = "block"; }
        }
    },
    adddivobj: function (contentobj, params) {
        var divobj = document.createElement("div");
        divobj.style.position = "fixed"; divobj.style.display = "none"; divobj.style.right = params != null && params.right != null ? params.right : "20px"; divobj.style.bottom = params != null && params.bottom != null ? params.bottom : "50px";
        if (typeof (contentobj) == "object") {
            divobj.appendChild(contentobj);
        } else { divobj.innerHTML = contentobj; }
        document.body.appendChild(divobj);
        return divobj;
    },
    addimgobj: function (_isdown) {
        var imgobj = document.createElement("img");
        if (_isdown == null || _isdown == false) {
            imgobj.src = this.upsrc; imgobj.title = "返回顶部"; imgobj.style.cssText = "cursor:pointer;";
            imgobj.onclick = function (e) { ReturnTop.up(); }
        }
        else {
            imgobj.src = this.updownsrc; imgobj.style.opacity = 0.3; imgobj.style.cursor = "pointer";
            imgobj.onmouseover = function () { this.style.opacity = 1; };
            imgobj.onmouseout = function () { this.style.opacity = 0.3; };
            imgobj.onclick = function (e) {
                var y = e.clientY - this.parentNode.offsetTop;
                if (this.offsetHeight / 2 > y) { ReturnTop.up(); }
                else { ReturnTop.down(); }
            };
        }
        return imgobj;
    },
    scrollevent: function () {
        if (document.documentElement.scrollTop > 100 || window.pageYOffset > 100) {
            ReturnTop._divobj.style.display = "block";
        } else {
            ReturnTop._divobj.style.display = "none";
        }
    },
    up: function () { window.scrollTo(0, 0); },
    down: function () { window.scrollTo(0, document.body.scrollHeight); }
};
Array.prototype.cantains = function (obj) {
    var a = this.length;
    while (a--) {
        if (this[a] == obj) {
            return true;
        }
    }
    return false;
}