/* 
* Copyright (c) 2011 email:master@aspxjob.com
* Date: 2012-09-07 09:19:21 QQ:340461
*/
var App = {};
var currpop = null;
var POPS = [];
(function ($) {
    $.extend({
        ie: $.browser.msie,
        firefox: $.browser.firefox,
        other: !this.ie && !this.firefox,
        ie6: $.browser.msie && ('6.0' == $.browser.version),
        ie9: $.browser.msie && ('9.0' == $.browser.version),
        cssloaded: [],
        evalscripts: [],
        is_undefined: function (v) { return typeof variable == 'undefined' ? true : false; },
        strlen: function (str) { return ($.ie && str.indexOf('\n') != -1) ? str.replace(/\r?\n/g, '_').length : str.length; },
        mb_strlen: function (str) {
            var len = 0;
            for (var i = 0; i < str.length; i++) {
                len += str.charCodeAt(i) < 0 || str.charCodeAt(i) > 255 ? (charset == 'utf-8' ? 2 : 3) : 1;
            }
            return len
        },
        mb_cutstr: function (str, maxlen, dot) {
     
            var len = 0;
            var ret = '';
            var dot = !dot ? '...' : '';
            maxlen = maxlen - dot.length;
            for (var i = 0; i < str.length; i++) {
                len += str.charCodeAt(i) < 0 || str.charCodeAt(i) > 255 ? (charset == 'utf-8' ? 2 : 3) : 1;
                if (len > maxlen) {
                    ret += dot;
                    break;
                }
                ret += str.substr(i, 1);
            }
            return ret;
        },
        //htmlEncode:function(text){return text.replace(/&/g, '&amp;').replace(/"/g, '&quot;').replace(/</g, '&lt;').replace(/>/g, '&gt;');},
        url_encode: function (str) { return encodeURIComponent(str); },
        in_array: function (n, arr) {
            if (typeof n == "string" || typeof n == "number") {
                for (var i in arr) { if (arr[i] == n) return true; }
            }
            return false;
        },
        is_empty: function (val) {
            switch (typeof (val)) {
                case 'string':
                    return this.trim(val).length == 0 ? true : false;
                    break;
                case 'number':
                    return val == 0;
                    break;
                case 'object':
                    return val == null;
                    break;
                case 'array':
                    return val.length == 0;
                    break;
                default:
                    return true;
            }
        },
        is_number: function (val) { var reg = /^[\d|\.|,]+$/; return reg.test(val); },
        is_int: function (val) { if (val == "") return false; var reg = /\D+/; return !reg.test(val); },
        is_email: function (email) {
            var reg1 = /([\w-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([\w-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)/;
            return reg1.test(email);
        },
        is_tel: function (tel) { var reg = /^(([0\+]\d{2,3}-)?(0\d{2,3})-)(\d{7,8})(-(\d{3,}))?$/; return reg.test(tel); }, //return (/^(([0\+]\d{2,3}-)?(0\d{2,3})-)(\d{7,8})(-(\d{3,}))?$/.test(this.Trim()));
        is_mobile: function (mobile) { return (/^(?:13\d|15[0-9]|18[0-9])-?\d{5}(\d{3}|\*{3})$/.test(mobile)); },
        fix_event: function (e) { var evt = (typeof e == "undefined") ? window.event : e; return evt; },
        srcElement: function (e) { if (typeof e == "undefined") e = window.event; var src = document.all ? e.srcElement : e.target; return src; },
        is_date: function (val) { var reg = /^\d{4}-\d{2}-\d{2}$/; return reg.test(val); },
        is_time: function (val) { var reg = /^\d{4}-\d{2}-\d{2}\s\d{2}:\d{2}:\d{2}$/; return reg.test(val); },
        redirect: function (r) { window.location.replace(r); },
        request: function (url, item) { var sValue = url.match(new RegExp("[\?\&]" + item + "=([^\&]*)(\&?)", "i")); return sValue ? sValue[1] : sValue; },
        loadcss: function (cssname) {
            if (!$.cssloaded[cssname]) {
                $("head").append("<style type=\"text/css\" rel=\"stylesheet\" href=\"" + cssname + ".css\"></style>");
                $.cssloaded[cssname] = 1;
            }
        },
        doane: function (event) {
            e = event ? event : window.event;
            if (!e) return;
            if ($.ie) {
                e.returnValue = false;
                e.cancelBubble = true;
            } else if (e) {
                e.stopPropagation();
                e.preventDefault();
            }
        },
        cookies: {
            set: function (cookieName, cookieValue, seconds, path, domain, secure) {
                var expires = new Date();
                expires.setTime(expires.getTime() + seconds * 1000);
                domain = !domain ? cookiedomain : domain;
                path = !path ? cookiepath : path;
                document.cookie = escape(cookieName) + '=' + escape(cookieValue)
					+ (expires ? '; expires=' + expires.toGMTString() : '')
					+ (path ? '; path=' + path : '/')
					+ (domain ? '; domain=' + domain : '')
					+ (secure ? '; secure' : '');
            },
            get: function (name) {
                var cookie_start = document.cookie.indexOf(name);
                var cookie_end = document.cookie.indexOf(";", cookie_start);
                return cookie_start == -1 ? '' : unescape(document.cookie.substring(cookie_start + name.length + 1, (cookie_end > cookie_start ? cookie_end : document.cookie.length)));
            }

        },
        get_position: function (o) {
            var t = o.offsetTop;
            var l = o.offsetLeft;
            while (o = o.offsetParent) {
                t += o.offsetTop;
                l += o.offsetLeft;
            }
            var pos = { top: t, left: l };
            return pos;
        },
        hash: function (string, length) {
            var length = length ? length : 32;
            var start = 0;
            var i = 0;
            var result = '';
            filllen = length - string.length % length;
            for (i = 0; i < filllen; i++) { string += "0"; }
            while (start < string.length) {
                result = $.stringxor(result, string.substr(start, length));
                start += length;
            }
            return result;
        },
        stringxor: function (s1, s2) {
            var s = '';
            var hash = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
            var max = Math.max(s1.length, s2.length);
            for (var i = 0; i < max; i++) {
                var k = s1.charCodeAt(i) ^ s2.charCodeAt(i);
                s += hash.charAt(k % 52);
            }
            return s;
        },
        appendscript: function (src, text, reload, charset) {
            var id = $.hash(src + text);
            if (!reload && $.in_array(id, $.evalscripts)) return;
            if (reload && $("#" + id)) { $("#" + id).remove(); }
            $.evalscripts.push(id);
            var _chartset = charset ? charset : ($.firefox ? document.characterSet : document.charset);
            var jacascript_str = "";
            jacascript_str += "<script id=\"" + id + "\" type='text/javascript'";
            try {
                if (src) {
                    jacascript_str += "src=\"" + src + "\"></script>";
                } else if (text) {
                    jacascript_str += ">" + text + "</script>";
                }
                $("head").append(jacascript_str);
            } catch (e) { }
        },
        evalscript: function (s) {
            if (s.indexOf('<script') == -1) return s;
            var p = /<script[^\>]*?>([^\x00]*?)<\/script>/ig;
            var arr = [];
            while (arr = p.exec(s)) {
                var p1 = /<script[^\>]*?src=\"([^\>]*?)\"[^\>]*?(reload=\"1\")?(?:charset=\"([\w\-]+?)\")?><\/script>/i;
                var arr1 = [];
                arr1 = p1.exec(arr[0]);
                if (arr1) {
                    $.appendscript(arr1[1], '', arr1[2] + "reload=\"1\"", arr1[3]);
                } else {
                    p1 = /<script(.*?)>([^\x00]+?)<\/script>/i;
                    arr1 = p1.exec(arr[0]);
                    $.appendscript('', arr1[2], arr1[1].indexOf('reload=') != -1);
                }
            }
            return s;
        },
        stripscript: function (s) { return s.replace(/<script.*?>.*?<\/script>/ig, ''); },
        getparastr: function () {
            var hrefstr, pos, parastr, para, tempstr1;
            hrefstr = window.location.href;
            pos = hrefstr.indexOf("?");
            parastr = hrefstr.substring(pos + 1);
            return parastr;
        },
        print: function (p) {
            var html = "";
            for (var i in p) { html += i + ":" + p[i] + "\n" };
            alert(html);
            //$("body").prepend(html);
        }
    })
})(jQuery);
// THINKHU Trans AJAX
(function ($) {
    var transbase = {
        debug: 1,
        error_url: "error.php",
        loadtxt: '<span>正在处理中...请稍后</span>',
        loadbox: 'transwait',
        urls: [],
        stackid: 0,
        xmlhttps: [],
        recv_type: "XML",
        ajax_frame_id: "ajax_frame",
        ajax_form: null,
        ajax_form_recall: null,
        showloading: function () { if ($("#" + parm.loadbox)) $("#" + parm.loadbox).show(); },
        closeloading: function () { if ($("#" + parm.loadbox)) $("#" + parm.loadbox).hide(); },
        create_xmlhttp: function () {
            var request = false;
            if (window.XMLHttpRequest) {
                request = new XMLHttpRequest();
                if (request.overrideMimeType) {
                    request.overrideMimeType('text/xml');
                }
            } else if (window.ActiveXObject) {
                var versions = ['Microsoft.XMLHTTP', 'MSXML.XMLHTTP', 'Microsoft.XMLHTTP', 'Msxml2.XMLHTTP.7.0', 'Msxml2.XMLHTTP.6.0', 'Msxml2.XMLHTTP.5.0', 'Msxml2.XMLHTTP.4.0', 'MSXML2.XMLHTTP.3.0', 'MSXML2.XMLHTTP'];
                for (var i = 0; i < versions.length; i++) {
                    try {
                        request = new ActiveXObject(versions[i]);
                        if (request) {
                            return request;
                        }
                    } catch (e) { }
                }
            }
            return request;
        },
        form_resulthandle: function () {
            var res = new Object();
            var s = null;
            var ajax_frame_id = transbase.ajax_frame_id;
            try {
                var _obj = $("body #" + transbase.ajax_frame_id).get(0);
                if ($.ie) {
                    s = _obj.contentWindow.document.XMLDocument.lastChild.childNodes;
                } else {
                    s = _obj.contentWindow.document.documentElement.childNodes;
                }
                for (var k = 0; k < s.length; k++) {
                    res[s[k].nodeName] = $.trim(s[k].firstChild.nodeValue);
                }
            } catch (e) {
                if ($.ie) {
                    //alert(transbase.ajax_frame.contents().find("body").find(".jsoncontent").html());
                    eval("res = " + transbase.ajax_frame.contents().find("body").find(".jsoncontent").html());
                    res.content = (transbase.ajax_frame.contents().find("body").find(".htmlcontent").html());
                    if (typeof res.midlogin_info != "undefind") {
                        res.midlogin_info = (transbase.ajax_frame.contents().find("body").find(".midlogin_info").html());
                    }
                    if (typeof res.toplogin_info != "undefind") {
                        res.toplogin_info = (transbase.ajax_frame.contents().find("body").find(".toplogin_info").html());
                    }
                } else {
                    var error = transbase.ajax_frame.contents().find("body").html();
                    res = { error: 1, message: error };
                }
            }
            transbase.ajax_form.target = "";
            transbase.ajax_frame.contents().find("body").html("");
            if (typeof transbase.ajax_form_recall == 'function') transbase.ajax_form_recall(res);
        },
        form: function (formobj, recall) {
            if (!formobj || formobj.action == "") return false;
            transbase.ajax_form = formobj;
            transbase.ajax_form_recall = recall;
            transbase.ajax_frame = $("<iframe id=\"" + transbase.ajax_frame_id + "\" name=\"" + transbase.ajax_frame_id + "\"></iframe>")
			                       .css({ "display": "none" });
            if ($("body #" + transbase.ajax_frame_id)) $("body #" + transbase.ajax_frame_id).remove();
            transbase.ajax_frame.appendTo($("body")).bind("load", transbase.form_resulthandle);
            formobj.action += (formobj.action.indexOf('?') === -1) ? "?" : "";
            formobj.action += (formobj.action.indexOf("&inajax=1") === -1) ? "&inajax=1" : "";
            formobj.action += "&inform=1";
            formobj.target = transbase.ajax_frame_id;
            formobj.submit();
        },
        get: function () {
            var trans = {};
            trans.id = transbase.stackid++;
            trans.xmlhttp = transbase.xmlhttps[trans.id] = transbase.create_xmlhttp();
            trans.handle = null;
            trans.process_handle = function () {
                if (trans.xmlhttp.readyState == 4 && trans.xmlhttp.status == 200) {
                    for (k in transbase.urls) {
                        if (transbase.urls[k] == trans.targeturl) transbase.urls[k] = null;
                    }
                    if (transbase.recv_type == 'HTML') {
                        trans.handle(trans.xmlhttp.responseText, trans);
                    } else if (transbase.recv_type == 'XML') {
                        var _xml = trans.xmlhttp.responseXML;
                        var resobj = {};
                        try {
                            for (var k = 0; k < _xml.lastChild.childNodes.length; k++) {
                                resobj[_xml.lastChild.childNodes[k].nodeName] = $.trim(_xml.lastChild.childNodes[k].firstChild.nodeValue);
                            }
                        } catch (e) {
                            var error = "";
                            error = trans.xmlhttp.responseText.replace(/\r?\n/g, '\\n');
                            resobj = { error: 1, message: error }
                        }
                        if (resobj.content != "") {
                            //$.evalscript(resobj.content);
                        }
                        trans.handle(resobj, trans);
                    }
                }
            };
            trans.getdata = function (targeturl, handle) {
                for (var i in transbase.urls) {
                    if (transbase.urls[trans.id] == targeturl) return false;
                }
                trans.targeturl = transbase.urls[trans.id] = targeturl;
                trans.xmlhttp.onreadystatechange = trans.process_handle;
                trans.handle = handle;
                if (window.XMLHttpRequest) {
                    setTimeout(function () {
                        trans.xmlhttp.open('GET', targeturl);
                        trans.xmlhttp.send(null);
                    }, 100);
                } else {
                    setTimeout(function () {
                        trans.xmlhttp.open("GET", targeturl, true);
                        trans.xmlhttp.send();
                    }, 100);
                }
            };
            return trans;
        }
    };
    $.extend({
        trans: function (o) {
            if (typeof o == "undefined") o = {};
            s = o || {};
            s.url = o.url || transbase.error_url;
            s.recall = o.recall || function (res) { if (res.error == 1) alert(res.message); return false; };
            s.type = o.type || "get";
            s.form = o.form || null;
            switch (s.type) {
                default:
                    var x = new transbase.get();
                    x.getdata(s.url, s.recall);
                    break;
                case "form":
                    transbase.form(s.form, s.recall);
                    return false;
                    break;
            }
        }
    });
})(jQuery);
//THINKHU POP
(function ($) {
    var popbase = function (o) {
        if (typeof o == "undefined") o = {};
        p = o || {};
        p.title = o.title || '弹出对话';  //弹出框标题
        p.width = o.width || 300;
        p.height = o.height || "";
        p.head = (typeof o.head == "undefined") ? 1 : o.head; //是否显示标题
        p.close = o.close || "关闭";
        p.dragable = (typeof o.dragable == "undefined") ? 1 : o.dragable; //是否可以移动
        p.align = o.align || "center"; //是否可以移动
        p.fixed = (typeof o.fixed == "undefined") ? 0 : o.fixed; //是否跟随页面滚动。
        p.autoclose = (typeof o.autoclose == "undefined") ? 0 : o.autoclose; ;
        p.overlay = (typeof o.overlay == "undefined") ? 1 : o.overlay;
        p.type = o.type || "text";
        p.value = o.value || "";
        p.padding = (typeof o.padding == "undefined") ? 0 : o.padding;
        p.id = o.id || (popbase.prototype.auto_k++);
        p.zindex = popbase.prototype.zindex;
        p.position = o.position || { x: 0, y: 0 };
        p.extattr = o.extattr || "";
        popbase.prototype.zindex = p.zindex + 3;

        var ie6 = $.browser.msie && ('6.0' == $.browser.version);
        var is_show = 0;
        var time_id = null;

        var wrapper = $("<div id='wrapper_" + p.id + "' class='pop-wrapper wrapper" + p.id + "'></div>").css({ "z-index": (p.zindex + 1), 'position': 'absolute', 'filter': 'alpha(opacity=0)', 'opacity': 0 });
        var pophead = (p.head == 1) ? $("<div id='pop_head_" + p.id + "' class='pop-head'><span class='title'>" + p.title + "</span></div>") : "";
        var popbody = $("<div id=\"pop_body_" + p.id + "\" class=\"pop-body\"><div class=\"inner\"></div></div>");
        var popclose = $("<a class=\"pop-close\" title=\"" + p.close + "\">[关闭]</a>").css({ 'position': 'absolute', 'top': '2px', 'right': '7px' });
        var popbox = $("<div id=\"pop_" + p.id + "\" dataid=\"" + p.id + "\" " + p.extattr + " class=\"pop-box " + p.id + "\"></div>").css({ "z-index": (p.zindex + 2), 'position': 'absolute', width: p.width, height: p.height, 'filter': 'alpha(opacity=0)', 'opacity': 0 }).append(pophead).append(popclose).append(popbody);
        var popoverlay = (p.overlay == 1) ? $("<div id=\"overlay_" + p.id + "\" class='pop-overlay overlay" + p.id + "'></div>").css({ "z-index": p.zindex, 'position': 'absolute', 'filter': 'alpha(opacity=0)', 'opacity': 0, 'top': 0, 'left': 0, 'width': "100%", 'height': $(document).height() }) : "";
        var init = function () {
            $("body").append(popbox).append(wrapper).append(popoverlay);
            popbox.css({ 'position': p.fixed ? 'fixed' : 'absolute' });
            reset_pos();
            if (ie6 && p.fixed) {
                popbox.css('position', 'absolute');
                var top = parseInt(popbox.css('top')) - $(document).scrollTop();
                var left = parseInt(popbox.css('left')) - $(document).scrollLeft();
                $(window).scroll(function () {
                    popbox.css({ 'top': $(document).scrollTop() + top, 'left': $(document).scrollLeft() + left });
                    wrapper.css({ top: ($(document).scrollTop() + top - p.padding), left: ($(document).scrollLeft() + left - p.padding), height: (popbox.height() + 2 * p.padding), width: (popbox.width() + 2 * p.padding) });
                });
            }
            var mouse = { x: 0, y: 0 };
            function move_pop(event) {
                var e = window.event || event;
                var top = parseInt(popbox.css('top')) + (e.clientY - mouse.y);
                var left = parseInt(popbox.css('left')) + (e.clientX - mouse.x);
                popbox.css({ top: top, left: left });
                wrapper.css({ top: (top - p.padding), left: (left - p.padding) });
                if ((p.overlay == 1)) {
                    popoverlay.css({ 'height': $(document).height() });
                }
                mouse.x = e.clientX;
                mouse.y = e.clientY;
            };
            popbox.find('.pop-head').mousedown(function (event) {
                if (!p.dragable == 1) { return; }
                var e = window.event || event;
                mouse.x = e.clientX;
                mouse.y = e.clientY;
                $(document).bind('mousemove', move_pop);
            });
            $(document).mouseup(function (event) {
                $(document).unbind('mousemove', move_pop);
            });
            popbox.find('.pop-close').bind('click', this.close);
            $(".pop-overlay").bind('click', this.close);
            if (0 != p.autoclose) { time_id = setTimeout(this.close, p.autoclose); }
        }
        var reset_pos = function () {
            var left = 0;
            var top = 0;
            var width = popbox.width();
            var height = popbox.height();
            var confheight = (height > $(window).height()) ? ($(window).height() - 50) : height;
            var overflow = "hidden";
            if (popbox.find('.pop-body').attr("fetchcontent") == 1) {
                if (height > $(window).height()) {
                    if (confheight < height) {
                        overflow = "scroll";
                    }
                }
                popbox.find('.pop-body').css({ "height": (confheight - ((pophead) ? pophead.height() : 0)), "overflow-y": overflow });
            }
            if (p.align == "center") {
                left = ($(window).width() - popbox.width()) / 2;
                top = ($(window).height() - confheight) / 2;
            } else {
                if (($(window).width() - p.position.x) < popbox.width()) {
                    left = ($(window).width() - popbox.width()) / 2;
                } else {
                    left = p.position.x;
                }
                if (($(window).height() - p.position.y) < height) {
                    top = ($(window).height() - confheight) / 2;
                } else {
                    top = p.position.y;
                }
            }
            if (!ie6 && p.fixed) {
                popbox.css({ top: top, left: left });
                wrapper.css({ top: (top - p.padding), left: (left - p.padding), height: (confheight + 2 * p.padding), width: (width + 2 * p.padding) });
            } else {
                popbox.css({ top: top + $(document).scrollTop(), left: left + $(document).scrollLeft() });
                wrapper.css({ top: (top + $(document).scrollTop() - p.padding), left: (left + $(document).scrollLeft() - p.padding), height: (confheight + 2 * p.padding), width: (width + 2 * p.padding) });
            }
        }
        //隐藏select框
        var tset_select = function (status) {
            var select_obj = $("select");
            if (typeof status == 'number' && status == 1) {
                var popboxsel = popbox.find("select");
                var popboxsel_len = popboxsel.length;
                select_obj.each(function () {
                    var myobj = this;
                    var isfind = false;
                    if (popboxsel_len > 0) {
                        popboxsel.each(function () {
                            if (this == myobj) isfind = true;
                        });
                    }
                    if (isfind == false) $(myobj).css({ "visibility": "hidden" });
                });
            } else {
                select_obj.each(function () {
                    $(this).css({ "visibility": "visible" });
                });
            }
        };
        //重新获取内容
        this.refresh = function (newvalue) {
            p.value = newvalue;
            this.getcontent({ type: p.type, value: p.value });
            reset_pos();
        }
        //一些方法
        this.getcontent = function (o) {
            var contentbox = popbox.find('.pop-body');
            if ('object' == typeof (o)) {
                switch (o.type.toLowerCase()) {
                    case 'id': // 将ID的内容复制过来，原来的还在。
                        contentbox.find(".inner").html($('#' + o.value).html());
                        break;
                    case 'img':
                        contentbox.html('加载中...');
                        $('<img alt="" />').load(function () { contentbox.find(".inner").empty().append($(this)); reset_pos(); }).attr('src', o.value);
                        break;
                    case 'url':
                        contentbox.html('加载中...');
                        $.ajax({ url: o.value, success: function (html) { contentbox.find(".inner").html(html); reset_pos(); }, error: function (xml, textStatus, error) { contentbox.find(".inner").html('加载出错啦') } });
                        break;
                    case 'iframe':
                        contentbox.append($('<iframe src="' + o.value + '" />'));
                        break;
                    case 'alert':
                        contentbox.find(".inner").append("<div class='alert'><span class = 'icon'></span><span class='content'>" + o.value + "</span><span style=\"clear:both;\"></span></div>");
                        break;
                    case 'text':
                    default:
                        contentbox.find(".inner").html(o.value);
                        break;
                }
                contentbox.attr("fetchcontent", 1);
            } else { contentbox.html(c) }
        }
        this.show = function () {
            tset_select(1);
            if (undefined != p.before && !p.before()) { return; }
            /* 是否显示背景遮罩层 */
            if (p.overlay) { $('#overlay_' + p.id).fadeTo('fast', 0.3); }
            wrapper.fadeTo('fast', 0.3);
            popbox.fadeTo('fast', 1, function () {
                if (undefined != p.after) { p.after(); }
                is_show = 1;
            });
            // 自动关闭 
            //if(0 != p.autoclose){time_id = setTimeout(this.close, p.autoclose);}
            reset_pos();
        };
        this.close = function () {
            if (undefined != p.before_close && !p.before_close()) { return; }
            wrapper.fadeOut('fast', function () { $(this).remove(); });
            popbox.fadeOut('fast', function () {
                $(this).remove();
                is_show = 0;
                if (undefined != p.after_close) { p.after_close(); }
            });
            tset_select(0);
            if ($('#overlay_' + popbox.attr("dataid"))) { $('#overlay_' + popbox.attr("dataid")).fadeOut('fast', function () { $(this).remove(); }); }
            clearTimeout(time_id);
        };
        this.hide = function () {
            if (!isShow) { return; }
            wrapper.fadeOut('fast', null);
            popbox.fadeOut('fast', null);
            if (p.overlay) { $('#overlay_' + p.id).fadeOut('fast', null) }
            clearTimeout(time_id);
            isShow = 0;
        };

        init.call(this);
        this.getcontent({ type: p.type, value: p.value });
    };
    popbase.prototype.auto_k = 100;
    popbase.prototype.zindex = 1000;
    $.extend({
        pop: function (o) {
            var x1 = new popbase(o);
            x1.show();
            return x1;
            //var x2 = new popbase({overlay:0,title:"wo"});
        }
    });
})(jQuery);
//整理 方法集合
(function ($) {
    App.get = function (url, func) {
        url += (url.indexOf('?') === -1) ? "?" : "";
        url += (url.indexOf("&inajax=1") === -1) ? "&inajax=1" : "";
       
        $.trans({ url: url, recall: func, type: "get" });
    };
    App.form = function (form, func) {
        var ispass = true;
        $("select[check='noempty'],input[check='noempty']").each(function (i) {
            if (this.value == "" || this.value == 0) {
                $(this).addClass("noempty");
                $(this.parentNode).append("<span style=\"color:#f00\">&nbsp;必须填写</span>");
                ispass = false;
            }
            $(this).bind("focus", function () {
                $(this).removeClass("noempty");
            });
        });
        if (ispass == false) return false;
        $.trans({ form: form, recall: func, type: "form" });
    };
    App.pop = function (o) {
        $.pop(o);
    };
    App.html = function (htmltext, title, width, height, close_handle) {
        var width = typeof width == "undefined" ? 800 : width;
        var title = typeof title == "undefined" ? "弹出窗体" : title;
        return $.pop({ type: "text", value: htmltext, title: title, width: width, height: height, after_close: close_handle });
    };
    App.alert = function (text, width, height, close_handle) {
        var width = typeof width == "undefined" ? 300 : width;
        return $.pop({ type: "alert", value: text, title: "温馨提示", width: width, height: height, after_close: close_handle });
    }
    App.select = function (text, width, height, e) {
        var width = typeof width == "undefined" ? 320 : width;
        var pos = { x: e.clientX, y: e.clientY };
        return $.pop({ type: "text", value: text, title: "请选择", overlay: 0, padding: 2, head: 0, align: "left", position: pos, width: width, height: height });
    }
    App.ipop = function (obj) {
        var method = $(obj).attr("_get");
        var code = $(obj).attr("_code");
        var num = $(obj).attr("_num");
        if (typeof obj == "undefined" || typeof method == "undefined") return false;
        num = typeof num == "undefined" ? 1 : num;
        var url = "";
        App.get(url, function (res) {
            if (res.error == 1) {
                App.alert(res.message);
            } else {
                var width = $(obj).attr("_width");
                var title = $(obj).attr("title");
                var id = $(obj).attr("id");
                width = typeof width == "undefined" ? 620 : width;
                tid = "sel_area"; //typeof id == "undefined"?"ipop":id;
                POPS[tid] = $.pop({ id: tid, type: "text", value: res.content, title: title, overlay: 1, padding: 0, width: width, extattr: "_btn=" + id });
            }
        });
    }
    App.tab = function () {

    }
    App.redirect = function (u) {
        $.redirect(u);
    }
    App.apop = function (obj) {
        var url = $(obj).attr("href");
        var title = $(obj).attr("title");
        var width = $(obj).attr("_width");
        var height = $(obj).attr("_height");
        width = typeof width == "undefined" ? 400 : width;
        height = typeof height == "undefined" ? null : height;
        App.get(url, function (res) {
            if (res.error == 1) {
                App.alert(res.message);
                if (res.url) {
                    setTimeout("App.redirect('" + res.url + "')", 2000);
                }
            } else {
                currpop = App.html(res.content, title, width, height);
            }
        });
        return false;
    }
    App.formsubmit = function (formobj) {
        App.form(formobj, function (res) {
            if (res.error == 1) {
                alert(res.message);
                if (res.url) {
                    setTimeout("App.redirect('" + res.url + "')", 500);
                }
            } else {
                if (res.content) alert(res.content);
                //App.alert(res.content);
                if (res.url) {
                    setTimeout("App.redirect('" + res.url + "')", 500);
                } else {
                    currpop.close();
                }
            }
        });
        return false;
    }
    App.showbox = function (o) {
        var box_id = "SHOWBOX_" + o.id;
        if ($("#" + box_id)[0]) return $("#" + box_id);
        var box = $("<div class=\"showbox showbox-" + o.id + "\" id=\"" + box_id + "\"></div>").css({ "z-index": 500, "position": "absolute", "width": o.width });
        var boxhead = $("<div class=\"box-head\"><strong>" + o.title + "</strong><span>" + (o.desc ? ("(" + o.desc + ")") : "") + "</span><a class=\"close\"></a></div>");
        var boxbody = $("<div class=\"box-body\"></div>");
        var maskbox = $("<div class=\"box-mask\" id=\"mask_" + box_id + "\"></div>").css({ "z-index": 499, "position": "absolute", "left": 0, "top": 0, "width": "100%", "height": $(document).height(), "background": "#fff", 'filter': 'alpha(opacity=20)', 'opacity': 0.2 });
        box.append(boxhead).append(boxbody);

        var left = ($(window).width() - o.width) / 2;
        var top = $(document).scrollTop() + ($(window).height() - box.height()) / 2;
        box.css({ "top": top, "left": left });
        $("body").append(box).append(maskbox);
        box.find(".close").click(function () {
            setTimeout(function () {
                box.remove();
                maskbox.remove();
                set_select(box, 0);
            }, 200);
        })
        if (o.type == "ajax") {
            App.get(o.url, function (res) {
                if (res.error == 1) {
                    alert(res.message);
                } else {
                    box.find(".box-body").html(res.content);
                    top = $(document).scrollTop() + ($(window).height() - box.height()) / 2;
                    box.css({ "top": top });
                }
            })
        } else {
            box.find(".box-body").html(o.content);
            top = $(document).scrollTop() + ($(window).height() - box.height()) / 2;
            box.css({ "top": top });
        }
        POPS[o.id] = box;
        set_select(box, 1);
        return POPS[o.id];
    }
    App.tips = function (o) {
        var box_id = "TIPBOX_" + o.id;
        if ($("#" + box_id)[0]) return $("#" + box_id);
        var box = $("<div class=\"tipbox tipbox-" + o.id + "\" id=\"" + box_id + "\"></div>").css({ "z-index": 500, "position": "absolute", "width": o.width });
        var boxbody = $("<div class=\"box-body\"></div>");
        box.append(boxhead).append(boxbody);

        var left = ($(window).width() - o.width) / 2;
        var top = $(document).scrollTop() + ($(window).height() - box.height()) / 2;
        box.css({ "top": top, "left": left });
        $("body").append(box).append(maskbox);
        box.find(".close").click(function () {
            setTimeout(function () {
                box.remove();
                maskbox.remove();
            }, 200);
        })
        if (o.type == "ajax") {
            App.get(o.url, function (res) {
                if (res.error == 1) {
                    alert(res.message);
                } else {
                    box.find(".box-body").html(res.content);
                    top = $(document).scrollTop() + ($(window).height() - box.height()) / 2;
                    box.css({ "top": top });
                }
            })
        } else {
            box.find(".box-body").html(o.content);
            top = $(document).scrollTop() + ($(window).height() - box.height()) / 2;
            box.css({ "top": top });
        }
        POPS[o.id] = box;
        return POPS[o.id];
    }
})(jQuery);
//隐藏select框
var set_select = function (box, status) {
    var select_obj = $("select");
    if (typeof status == 'number' && status == 1) {
        var boxsel = box.find("select");
        select_obj.each(function () {
            var myobj = this;
            var isfind = false;
            if (boxsel.length > 0) {
                boxsel.each(function () {
                    if (this == myobj) isfind = true;
                });
            }
            if (isfind == false) $(myobj).css({ "visibility": "hidden" });
        });
    } else {
        select_obj.each(function () {
            $(this).css({ "visibility": "visible" });
        });
    }
}
//时间戳转换成日期格式
function getDate(tm) {
    var tt = new Date(parseInt(tm) * 1000).toLocaleString()
    return tt;
}
function unix_timestamp(str) {
    var tt = new Date(Date.parse(str.replace(/-/g, "/")));
    return parseInt(parseInt(tt.getTime()) / 1000);
}


//处理字符串连接字符串
function dou_replace(codeval, thecode, rechar) {
    var rechar = typeof rechar == "undefined" ? "," : rechar;
    if (codeval.indexOf(rechar + thecode + rechar) != -1) {
        codeval = codeval.replace((rechar + thecode + rechar), rechar);
    } else if (codeval.indexOf(rechar + thecode) != -1) {
        codeval = codeval.replace((rechar + thecode), "");
    } else if (codeval.indexOf(thecode + rechar) != -1) {
        codeval = codeval.replace((thecode + rechar), "");
    } else {
        codeval = codeval.replace((thecode), "");
    }
    return codeval;
}
//日期选择器
function showdate(id) {
    return showCalendar(id, '%Y-%m-%d %H:%M:%S', false, false, id);
}
//日期选择器
function showday(id) {
    return showCalendar(id, '%Y-%m-%d', false, false, id);
}
 
 
//获取url参数
function getarg() {
    var url = unescape(window.location.href);
    var allargs = url.split("?")[1];
    var args = allargs.split("&");
    for (var i = 0; i < args.length; i++) {
        var arg = args[i].split("=");
    }
}
//随滚动条
function gotop() {
    var obj = document.getElementById("div_gotop");
    function getScrollTop() {
        return document.documentElement.scrollTop;
    }
    function setScrollTop(value) {
        document.documentElement.scrollTop = value;
    }
    window.onscroll = function () { getScrollTop() > 0 ? obj.style.display = "" : obj.style.display = "none"; }
    obj.onclick = function () {
        var goTop = setInterval(scrollMove, 10);
        function scrollMove() {
            setScrollTop(getScrollTop() / 1.1);
            if (getScrollTop() < 1) clearInterval(goTop);
        }
    }
}
/********************************************
消息提示:MessageBox.show(msg,t,_timeout,_fn)
msg:消息内容，t:消息类型（0-正常提示，1-正确，2-错误），_timeout：自动隐藏时间，单位为毫秒；_fn:消息隐藏后执行的方法
创建人：belyn
创建时间：2010/11/14

********************************************/

var MessageBox = new function () {
    var msgbox = new Object();
    msgbox.count = 0;
    msgbox.index = 0;
    //msgbox.isloaded = false;//是否已经加载过了
    msgbox.id_pre = "div_tip_";
    msgbox.hide = function (id, d) {
        var dom_obj = document.getElementById(id);
        var d = d || false;
        if (dom_obj)
        {
            if (d == true)
            {
                dom_obj.style.display = "none";
            } else
            {
                dom_obj.parentNode.removeChild(dom_obj);
            }
        }
    }
    msgbox.$ = function (id) { return document.getElementById(id); }
    msgbox.getid = function (i) {
        if (i < 10)
        {
            return msgbox.id_pre + "00" + i;
        } else if (i < 100)
        {
            return msgbox.id_pre + "0" + i;
        } else
        {
            return msgbox.id_pre + i;
        }
    }
    msgbox.newid = function () {
        var id_temp = "";
        for (var i = 0; i < msgbox.count; i++)
        {
            id_temp = msgbox.getid(i);
            if (msgbox.$(id_temp))
            {
                continue;
            }
            msgbox.index = i;
            return id_temp;
        }
        id_temp = msgbox.getid(msgbox.count);
        msgbox.index = msgbox.count;
        msgbox.count = msgbox.count + 1;

        return id_temp;
    }

    //t:默认为0-提示,1-成功消息,2-错误消息
    this.show = function (msg, t, _timeout, _fn) {
        var type = t || 0;
        if (type > 2) type = 0;

        var timeout = _timeout || 5000;
        var nullFn = function () { };
        var fn = _fn || nullFn;

        var type_classes = new Array();
        type_classes[0] = "gtl_ico_hits";
        type_classes[1] = "gtl_ico_succ";
        type_classes[2] = "gtl_ico_fail";

        var newlayer_id = msgbox.newid();

        var newlayer = document.createElement("div");
        newlayer.id = newlayer_id;
        newlayer.className = "gb_tip_layer";
        newlayer.style.marginTop = 0 * parseInt(msgbox.index) + "px";


        var tip_b = document.createElement("span");
        tip_b.className = type_classes[type];
        newlayer.appendChild(tip_b);

        var tip_c = document.createElement("span");
        tip_c.innerHTML = msg;
        newlayer.appendChild(tip_c);

        var tip_e = document.createElement("span");
        tip_e.className = "gtl_end";
        newlayer.appendChild(tip_e);

        document.body.appendChild(newlayer);

        if (timeout > 0)
        {
            setTimeout(function () { newlayer.parentNode.removeChild(newlayer); fn(); }, timeout);
        }

        return newlayer;
    }

    this.remove = function (obj) {
        obj.parentNode.removeChild(obj);
    }


}
 