﻿if (typeof _weburl == "undefined") {
    _weburl = "";
}
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
};
Function.prototype.Bind = function () {
    var d = this, b = arguments[0], a = new Array();
    for (var c = 1; c < arguments.length; c++) {
        a.push(arguments[c]);
    }
    return function (e) {
        return d.apply(b, [(e || window.event)].concat(a));
    };
};
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';
                }
                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 = _weburl + '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('请稍候，正在下载...');
    }
};
if (typeof App == "undefined") {
    var App = {}
}
var $STRINGS = { close: '关闭', title: '系统提示信息', ok: '确定', cancel: '取消', A00001: '用户名不能为空。', A00002: '登录密码不能为空。', A00003: '请输入验证码。' };
App.strings = { 0: '揭示您手中个股涨跌背后的秘密！盘中提供实时资金流量数据查询，盘后提供历史资金流量数据查询。', 1: '<p>查看“实时监控”每次扣<span>10</span>点</p><p>查看“历史数据”每次扣<span>5</span>点</p><p>查看“盈利预测”、“投资评级”、“千股千评”仅需每次<span>1</span>点。</p>', 2: '<span>1</span>元=<span>30</span>点。', 3: '<p>包月<span>218</span>元；包季<span>580</span>元；包年<span>1580</span>元。扣点：<span>1</span>元=<span>30</span>点。' };
App.connetionError = function () {
    var str = +'错误: 连接错误。\n\n';
    str += '无法获得服务器连接。\n';
    str += '请尝试重新刷新页面。如果仍有错误，请联系管理员。\n';
    alert(str);
    return null;
}
App.notWebFormed = function (request) {
    var str = '错误: 分析文件失败。\n\n';
    str += '获取到的文件格式似乎有些问题。\n';
    str += '请尝试重新刷新页面。如果仍有错误，请联系管理员。\n';
    str += '-------------------------\n';
    str += (request.responseText.length <= 100) ? request.responseText : request.responseText.substring(0, 100) + '...';
    alert(str);
    return null;
}
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) {
        App.alert({ text: data.message }, { icon: 1, ok: function () {
            try {
                if (data.data != "null") {
                    $('#runiframe').attr("src", data.data);
                }
            } catch (e) { }
        }
        });
    } else {
        App.alert({ text: data.message }, { icon: 1 });
    }
};
App.ActiveUser = function () {
    var u = App.confirm('确定要激活您的财富天下会员帐号吗？', {
        ok: function () {
            LoadBar.show("正在激活您的会员帐号，请稍候...");
            var url = _weburl + "service/activeaccount.asp";
            App.Call(App.DefCall, url, {});
        },
        cancel: function () {
            u.close()
        }
    })   
}
App.AddStock = function (code) {
    if (!code) {
        App.alert({ text: "请输入股票代码。" }, { icon: 1 });       
        return;
    }
    LoadBar.show('正在保存数据,请稍候...');

    var url = _weburl + "addstock_from_page.asp";
    var params = "daima=" + code;

    App.Call(App.DefCall, url, params);
}

