﻿var curhash = "";
String.prototype.trim = function() {
    return this.replace(/^\s+|\s+$/g, "");
};
String.prototype.Trim = function() { return this.replace(/^\s+|\s+$/g, ""); };
String.prototype.trim = function() { return this.replace(/^\s+|\s+$/g, ""); };
String.prototype.Ltrim = function() { return this.replace(/^\s+/g, ""); };
String.prototype.Rtrim = function() { return this.replace(/\s+$/g, ""); };
String.prototype.isNum = function() {
    var A = new RegExp("^[0-9]*[1-9][0-9]*$");
    return A.test(this)
};
String.prototype.getRealLength = function() {
    return this.replace(/[^\x00-\xff]/g, "aa").length;
};
String.prototype.getQuery = function(A) {
    var B = new RegExp("(^|&)" + A + "=([^&]*)(&|$)");
    var C = this.substr(this.indexOf("?") + 1).match(B);
    if (C != null) {
        return C[2]
    } return null
};
String.prototype.isMail = function() {
    var s = false;
    var objReg = new RegExp("[A-Za-z0-9-_]+@[A-Za-z0-9-_]+[\.][A-Za-z0-9-_]");
    var IsRightFmt = objReg.test(this);
    var objRegErrChar = new RegExp("[^a-z0-9-._@]", "ig");
    var IsRightChar = (this.search(objRegErrChar) == -1);
    var IsRightLength = this.length <= 60;
    var IsRightPos = (this.indexOf("@", 0) != 0 && this.indexOf(".", 0) != 0 && this.lastIndexOf("@") + 1 != this.length && this.lastIndexOf(".") + 1 != this.length);
    var IsNoDupChar = (this.indexOf("@", 0) == this.lastIndexOf("@"));
    if (IsRightFmt && IsRightChar && IsRightLength && IsRightPos && IsNoDupChar) {
        s = true;
    } else {
        s = false;
    }
    return s;
}
if (typeof $C == "undefined") {
    $C = function(a) {
        return document.createElement(a)
    }
}
if (typeof $T == "undefined") {
    $T = function(a) { return document.createTextNode(a); };
}
var LoadBar = {
    show: function(text, type) {
        clearTimeout(this.timeout);
        text = text || '正在下载数据，请稍候...';
        this.build(text);

        this.element.style.display = '';
        this.element.style.right = '0px';
        this.element.style.top = document.documentElement.scrollTop + 30 + 'px';
        this.showStatusBar(text);
    },
    hide: function(delay) {
        if (LoadBar.element) {
            LoadBar.timeout = setTimeout(function() {
                if (LoadBar.element) {
                    LoadBar.element.style.display = 'none';
                    //Element.hide(LoadBar.element);
                }
                LoadBar.hideStatusBar();
            }, ((delay && !isNaN(delay)) ? delay : 0));
        }
    },
    destroy: function() {
        if (this.element) {
            document.body.removeChild(this.element);
            this.element = null;
        }
    },
    build: function(text) {
        if (this.element) {
            this.element.firstChild.firstChild.alt = text;
            this.element.firstChild.childNodes[1].nodeValue = text;
            return;
        }
        this.element = document.createElement('div');
        this.element.className = "loadBar";
        this.element.style.zIndex = 1000;
        this.element.style.position = 'absolute';
        this.element.style.display = 'none';
        var innerDiv = document.createElement('div');
        var img = 'images/loading.gif';
        innerDiv.innerHTML = '<img src="' + img + '" alt="text" />' + text;
        this.element.appendChild(innerDiv);
        document.body.appendChild(this.element);
    },
    showStatusBar: function(text) {
        setTimeout(function() {
            window.status = text;
        }, 10);
    },
    hideStatusBar: function() {
        setTimeout(function() {
            window.status = '';
        }, 10);
    },
    loadPage: function() {
        this.show('请稍候，正在下载...');
    }
};
var App = {
    Name: '后台管理',
    version: '1.0',
    author: 'LiFuPing',
    email: 'lifuping@p5w.net'
};
App.Call = function(callback, url, data, type, dataType) {
    if (!url) return;
    if (!type) type = "post";
    if (!dataType) dataType = "html";
    $.ajax({
        type: type,
        dataType: dataType,
        url: url,
        data: data,
        complete: function() { },
        success: function(rep) {
            try {
                callback(rep);
            }
            catch (e) {
                alert(e.message);
            }

        }
    });
};
App.DefCall = function(request) {
    LoadBar.hide();
    if (!request) {
        return App.connetionError();
    }
    try {
        eval('var data=' + request);
    } catch (e) { return App.notWebFormed(request); }

    if (typeof data.result == "undefined") {
        return App.notWebFormed(request);
    }
    if (data.result == 0) {
        try {
            if (data.data != "null") {
                alert(data.data);
                $('#runiframe').attr("src", data.data);
            }
        } catch (e) {
        }
        alert(data.message);
    } else {
        alert(data.message);
    }
};

