﻿var CONST_Grid_Over_Color = "#e1edf6";
var CONST_CommonColor = "#FFFFFF";
var CONST_Grid_Favorite_Color = "#fff7d2";


function changebg(obj) 
{ 
    if( obj.__bgColor == CONST_Grid_Favorite_Color )
    {
        return;
    }
    obj.bgColor = "#FFFFFF";
}
function changebg1(obj)
{ 
    if( obj.bgColor != CONST_Grid_Favorite_Color )
    {
        obj.bgColor = CONST_Grid_Over_Color; 
    }
    obj.__bgColor = obj.bgColor;
}

function returnColor(value){
    var color = "";
    value = parseFloat(value);
    if(value == -1985 || value == -198500)
        return color;
    if(value){
        if(value > 0){
            color = "style='color:red'";
        }
        else if(value < 0){
            color = "style='color:green'";
        }
    }
    return color;
}

function GetFavoriteColor(code){
    var returnColor = CONST_CommonColor;
    if(myFavoriteFund != null){
        Codes = myFavoriteFund.split(';');
        if(Codes.indexOf(code)!=-1){
            return returnColor=CONST_Grid_Favorite_Color;
        }
    }
    return returnColor;
}

function __InitPos(str)
{
    try{
        var nav = document.getElementById("positionSpan");
        nav.innerHTML = str;
    }
    catch(e){}
}


function RefreshPage(){
    window.location.reload();
}

/*
set/get对象的属性值
*/
function GetAttributeValue(el, name){
    return el.attributes.getNamedItem(name).nodeValue;
}

function SetAttributeValue(el, name, value){
    el.setAttribute(name, value);
}
//弹出统一登陆窗口
function popupdialog(width, height, src, title, drag) {		    
	PDClassInatance.Popup(width, height, src, title,drag);
}
function LoadPopupDialog(width, height, src, title,drag) {
	if(window.PDClassInatance == undefined) {
		__CssLoader("http://inc.fund123.cn/Js/Class/PopupDialog/PopupDialog.css");
		if(drag)                   
			__JavascriptLoader("http://inc.fund123.cn/Js/Class/PopupDialog/Move.js");
		__JavascriptLoader("http://inc.fund123.cn/Js/Class/PopupDialog/PopupDialog.js", function() {popupdialog(width, height, src, title,drag);});
	}
	else
		popupdialog(width, height, src,title,drag);
}

//导出数据仅做提示做用
function opf_popupdialog(width, height, src, title, drag) {
    PDClassInatance.Popup(width, height, src, title, drag);
}

function opf_LoadPopupDialog(width, height, src, title, drag) {
    if (window.PDClassInatance == undefined) {
        __CssLoader("http://inc.fund123.cn/Js/Class/PopupDialog/PopupDialog.css");
        if (drag)
            __JavascriptLoader("http://inc.fund123.cn/Js/Class/PopupDialog/Move.js");
        __JavascriptLoader("http://inc.fund123.cn/Js/Class/PopupDialog/PopupDialog.js", function () { opf_popupdialog(width, height, src, title, drag); });
    }
    else
        opf_popupdialog(width, height, src, title, drag);
}

function opf_LoadDefault() {
    opf_LoadPopupDialog(400, 150, "DownLoadTip.htm", "友情提示", false);
}


function LoadDefault(){       
    var desc = escape("此功能需要登录后才能使用!");
    var buttonName = escape("登陆,关闭");    
    LoadPopupDialog(420,200,"http://user.fund123.cn/PopupLogin.htm?isSave=save&buttons=1,3&buttonNames="+buttonName+"&desc="+desc+"&Login=CallLogin&Close=CallClose","登陆",false);
}
function CallLogin(){ 
    PDClassInatance.Close();
    window.location.reload(); 
}
function CallClose(){
    PDClassInatance.Close();
}


/*
数据操作类
*/
Array.prototype.remove = function(index){
    if(index < 0 || index >= this.length){
        return;
    }
    var f = false;
    for(var i=0,n=0;i<this.length;i++){
        if(i != index){
            this[n++] = this[i];
        }
        else{
            f = true;
        }
    }
    if(f){
        this.length -= 1;
    }
}

Array.prototype.exists = function(str){
    var store = false;
    for(var i=0;i<this.length;i++){
        if(this[i] == str){
            store = true;
            break;
        }
    }
    return store;
}

/*
排序专用(同一时间只用有一个数组使用)
DESC:降序
ASC:升序
*/
var ArraySort = {
    Index : 0,
    Key : "",
    FloatSortByIndexDESC : function(x, y){
        if(parseFloat(x[ArraySort.Index]) < parseFloat(y[ArraySort.Index])) { return 1; } else { return -1; }
    },
    
    ChineseSortByIndexDESC : function(x, y){
        return y[ArraySort.Index].localeCompare(x[ArraySort.Index]);
    },
    
    FloatSortByKeyDESC : function(x, y){
        if(parseFloat(x[ArraySort.Key]) < parseFloat(y[ArraySort.Key])) { return 1; } else { return -1; }
    },
    
    ChineseSortByKeyDESC : function(x, y){
        return y[ArraySort.Key].localeCompare(x[ArraySort.Key]);
    },
    
    FloatSortByIndexASC : function(x, y){
        if(parseFloat(x[ArraySort.Index]) < parseFloat(y[ArraySort.Index])) { return -1; } else { return 1; }
    },
    
    ChineseSortByIndexASC : function(x, y){
        return x[ArraySort.Index].localeCompare(y[ArraySort.Index]);
    },
    
    FloatSortByKeyASC : function(x, y){
        if(parseFloat(x[ArraySort.Key]) < parseFloat(y[ArraySort.Key])) { return -1; } else { return 1; }
    },
    
    ChineseSortByKeyASC : function(x, y){
        return x[ArraySort.Key].localeCompare(y[ArraySort.Key]);
    }
}

/*
字符串操作类
*/
String.prototype.Deal = function(){
    var str = this.replace(/\n/gi, "<br />");
    return str;
}

String.prototype.DeDeal = function(){
    var str = this.replace(/\<br \/\>/gi, "\n");
    str = str.replace(/\<br\/\>/gi, "\n");
    return str;
}

this.json = typeof JSON != "undefined" ? JSON : null;

String.prototype.decode = function(){
   if(this == "")
        return;
   var text = this;
   if (this.json != null ) {
        return this.json.parse(text);
   }
   if (Browser.gecko) {
       return new Function( "return " + text )();
   }
   return eval( "(" + text + ")" )
}

String.prototype.AddZero = function(){
    var num = this;
    if(this.length == 1){
        num = "0" + this;
    }
    return num;
}

String.Format = function(template, data){
    var exp;    
    for(var i=0;i<data.length;i++){
        exp = new RegExp("\\{"+i+"\\}", "ig");
        template = template.replace(exp, data[i]);
    }
    return template;
}

String.prototype.Trim = function() {
    return this.replace(/(^\s*)|(\s*$)/g, "");
}

/*
Float操作类
*/
function FormatNumber(srcStr,nAfterDot)
{
　  srcStr = parseFloat(srcStr);
    return srcStr.toFixed(nAfterDot);
}

/*
日期操作类
*/
Date.prototype.formate = function(){
    var array = [];
    array.push(this.getFullYear());
    array.push("/");
    array.push((this.getMonth()+1).toString().AddZero());
    array.push("/");
    array.push(this.getDate().toString().AddZero());
    array.push(" ");
    array.push(this.getHours().toString().AddZero());
    array.push(":");
    array.push(this.getMinutes().toString().AddZero());
    array.push(":");
    array.push(this.getSeconds().toString().AddZero());
    return array.join('');
}

/*
浏览器
*/
var Browser = function() {
    var o = {
        ie: 0,
        opera: 0,
        gecko: 0,
        webkit: 0
    };
    var ua = navigator.userAgent, m;
    if ( ( /KHTML/ ).test( ua ) ) {
        o.webkit = 1;
    }
    // Modern WebKit browsers are at least X-Grade
    m = ua.match(/AppleWebKit\/([^\s]*)/);
    if (m&&m[1]) {
        o.webkit=parseFloat(m[1]);
    }

    if (!o.webkit) { // not webkit
        // @todo check Opera/8.01 (J2ME/MIDP; Opera Mini/2.0.4509/1316; fi; U; ssr)
        m=ua.match(/Opera[\s\/]([^\s]*)/);
        if (m&&m[1]) {
            o.opera=parseFloat(m[1]);
        } else { // not opera or webkit
            m=ua.match(/MSIE\s([^;]*)/);
            if (m&&m[1]) {
                o.ie=parseFloat(m[1]);
            } else { // not opera, webkit, or ie
                m=ua.match(/Gecko\/([^\s]*)/);
                if (m) {
                    o.gecko=1; // Gecko detected, look for revision
                    m=ua.match(/rv:([^\s\)]*)/);
                    if (m&&m[1]) {
                        o.gecko=parseFloat(m[1]);
                    }
                }
            }
        }
    }
    return o;
}();

/*
HTML操作方法
*/
//Object.prototype.insertAdjacentHTML=function(where, html){
//    var e=this.ownerDocument.createRange();
//    e.setStartBefore(this);
//    e=e.createContextualFragment(html);
//    switch (where) {
//        case 'beforeBegin': this.parentNode.insertBefore(e, this);break;
//        case 'afterBegin': this.insertBefore(e, this.firstChild); break;
//        case 'beforeEnd': this.appendChild(e); break;
//        case 'afterEnd':
//        if(!this.nextSibling) this.parentNode.appendChild(e);
//        else this.parentNode.insertBefore(e, this.nextSibling); break;
//    }
//}

//function insertHtml(where, el, html){
//    where = where.toLowerCase();
//    if(el.insertAdjacentHTML){
//        switch(where){
//            case "beforebegin":
//                el.insertAdjacentHTML('BeforeBegin', html);
//                return el.previousSibling;
//            case "afterbegin":
//                el.insertAdjacentHTML('AfterBegin', html);
//                return el.firstChild;
//            case "beforeend":
//                el.insertAdjacentHTML('BeforeEnd', html);
//                return el.lastChild;
//            case "afterend":
//                el.insertAdjacentHTML('AfterEnd', html);
//                return el.nextSibling;
//        }
//    }
//    var range = el.ownerDocument.createRange();
//    var frag;
//    switch(where){
//         case "beforebegin":
//            range.setStartBefore(el);
//            frag = range.createContextualFragment(html);
//            el.parentNode.insertBefore(frag, el);
//            return el.previousSibling;
//         case "afterbegin":
//            if(el.firstChild){
//                range.setStartBefore(el.firstChild);
//                frag = range.createContextualFragment(html);
//                el.insertBefore(frag, el.firstChild);
//                return el.firstChild;
//            }else{
//                el.innerHTML = html;
//                return el.firstChild;
//            }
//        case "beforeend":
//            if(el.lastChild){
//                range.setStartAfter(el.lastChild);
//                frag = range.createContextualFragment(html);
//                el.appendChild(frag);
//                return el.lastChild;
//            }else{
//                el.innerHTML = html;
//                return el.lastChild;
//            }
//        case "afterend":
//            range.setStartAfter(el);
//            frag = range.createContextualFragment(html);
//            el.parentNode.insertBefore(frag, el.nextSibling);
//            return el.nextSibling;
//        }
//}

//操作元素
function GetDom(id){
//    if(typeof id == "string"){
//        document.getElementById(""
//    }
}

var $C=function(tag)
{
   return document.createElement(tag);
}

var $N = function(s)
{
	return document.getElementsByName(s);
}

var $ = function(s)
{
	return document.getElementById(s);
}

/**
 * Bind Method
 */
Function.prototype.Bind = function() { 
	var __m = this, object = arguments[0], args = new Array(); 
	for(var i = 1; i < arguments.length; i++){
		args.push(arguments[i]);
	}
	
	return function() {
		return __m.apply(object, args);
	}
};

var isIE = false;
var userAgent = navigator.userAgent.toLowerCase();
if ((userAgent.indexOf('msie') != -1) && (userAgent.indexOf('opera') == -1)) {
	isIE = true;
}

var IO = {};
IO.Script = function(){
	this.Init.apply(this, arguments);
};

IO.Script.prototype = {
	_scriptCharset: 'gb2312',
	_oScript: null,
	
	/**
	 * Constructor
	 * 
	 * @param {Object} opts
	 */
	Init : function(opts){
		this._setOptions(opts);
	},
	
	_setOptions: function(opts) {
		if (typeof opts != 'undefined') {
			if (opts['script_charset']) {
				this._scriptCharset = opts['script_charset'];
			}
		}
	},
	
	_clearScriptObj: function() {
		if (this._oScript) {
			try {
				this._oScript.onload = null;
				if (this._oScript.onreadystatechange) {
					this._oScript.onreadystatechange = null;
				}
				
				this._oScript.parentNode.removeChild(this._oScript);
				//this._oScript = null;
			} catch (e) {
				// Do nothing here
			}
		}
	},
	
	_callbackWrapper: function(callback) {
		if (this._oScript.onreadystatechange) {
			if (this._oScript.readyState != 'loaded' && this._oScript.readyState != 'complete') {
				return;
			}
		}
		
		if (typeof callback != 'undefined') {
			callback();
		}
		
		this._clearScriptObj();
	},
	
	load: function(url, callback, encode){
		this._oScript = document.createElement('SCRIPT');
		this._oScript.type = "text/javascript";
		if(encode != undefined)
		    this._oScript.charset = encode;
		if(callback != null){		
		    if (isIE) {
			    this._oScript.onreadystatechange = this._callbackWrapper.Bind(this, callback);
		    } else {
			    this._oScript.onload = this._callbackWrapper.Bind(this, callback);
		    }
		}
		this._oScript.src = url;
		document.getElementsByTagName("head")[0].appendChild(this._oScript);
	}
}

function JavascriptLoader(url,fnCallback, encode){
    var script = document.createElement("SCRIPT");
    script.language = "javascript";
    script.type = "text/javascript";    
    script.src = url;
    if(encode != undefined)
        script.charset = encode;
    if(typeof fnCallback == 'function'){
        var argus;
        if(arguments.length > 2){
            argus = Array.prototype.slice.call(arguments,2)
        }
        if(Browser.ie){
            script.onreadystatechange = function(){
                if(script.readyState == "loaded"){
                    fnCallback(argus);
                }
            }
        }
        else{
            script.onload = function(){
                fnCallback(argus);
            }
        }
    }
    document.getElementsByTagName("head")[0].appendChild(script);
}



/*
生成Table的基础类
*/
function TableBase(instance, id, inteface){
    this.Instance = instance;
    this.ID = id;
    this.Inteface = inteface;
}

TableBase.prototype = {
    SendShow : function(DataSouce, Key, Codes){
        var el = document.getElementById(this.ID);
        var html = this.Inteface(DataSouce, Key, Codes);
        if(Browser.ie != 0){
            el.innerHTML = "";
            el.insertAdjacentHTML("afterBegin", html);
        }
        else{
            el.innerHTML = html;
        }
    },
    
    SendPromShow : function(DataSource){
        var el = document.getElementById(this.ID);
        el.style.display = "";
        var html = this.Inteface(DataSource);
        if(Browser.ie != 0){
            el.innerHTML = "";
            el.insertAdjacentHTML("afterBegin", html);
        }
        else{
            el.innerHTML = html;
        }
    }
}

/*
逐渐生成Table的基础类(不能用)
*/
function StepTableBase(instance, id, inteface){
    this.Instance = instance;
    this.ID = id;
    this.Inteface = inteface;
    this.Inited = false;
    this.Row = 50;
    this.Index = 0;
}

StepTableBase.prototype = {
    Init : function(datasource, key, codes){
        this.DataSource = datasource;
        this.Key = key;
        this.Codes = codes;
        this.Index = 0;
        this.SendShow();
        if(!this.Inited){
            var Instance = eval(this.Instance);
            if(window.attachEvent){
                window.attachEvent("onscroll", function(){ Instance.IsSendShow.apply(Instance);});
            }
            else if(window.addEventListener){
                window.addEventListener("scroll", function(){ Instance.IsSendShow.apply(Instance);}, false);
            }
            this.Inited = true;
        }
    },
    
    SendShow : function(){
        var index = this.Row * this.Index;
        var DS = [];
        if(index >= this.DataSource.length){
            return;
        }
        else if(index + this.Row >= this.DataSource.length){
            DS = this.DataSource.slice(index-1, -1);
        }
        else{
            DS = this.DataSource.slice(this.Index, index+this.Row);
        }
        this.Index++;
        var el = document.getElementById(this.ID);
        
        var html = this.Inteface(DS, this.Key, this.Codes);
        el.insertAdjacentHTML("afterBegin", html);
    },
    
    IsSendShow : function(){        
        var top = window.document.documentElement.scrollTop + window.document.documentElement.clientHeight;
        var height = window.document.documentElement.scrollHeight;
        if(height - top < 200){
            this.SendShow();
        }
    }
}


/*
全局变量
*/
var ShowCode = "0";
var FK_SelectedColor = "jt_2text";
var FK_BSelectedColor = "jt_4text";
var FK_CommonColor = "";
var Global_FundArray;
var myFavoriteFund = null;

/*
初始化界面
*/
var InitUI = {
    Company_FundKind : true,
    MyFavorite : true,
    Init : function(){
        if(InitUI.Company_FundKind){
            CompanyList.InitCompany();
            FundKindList.InitFundKind();
        }
        if(InitUI.MyFavorite){
            InitUI.InitMyFavorite();
        }
        if(document.getElementById("FundNumber")){
            document.getElementById("FundNumber").innerHTML = Global_FundArray.length + "只";
        }
        FundSort.Sort();
    },
    
    InitMyFavorite : function(){
        try
        {
            if( typeof(User) != 'undefined' )
            {
                if(typeof(User.FavoriteFund) != 'undefined' && User.FavoriteFund != "")
                {
                    myFavoriteFund = User.FavoriteFund;
                }
                if(typeof(User.FavoriteFund) != 'undefined' && User.FavoriteFund != "" && User.IsApply){
                    ShowCode = myFavoriteFund;
                    FundKindList.TabShow("myfundlist");
                }
            }
        } 
        catch(e)
        {
            myFavoriteFund = null;
        } 
    },
    
    RefreshPage : function(){
        if(InitUI.Company_FundKind){
            CompanyList.Reset();
            FundKindList.Reset();
        }
        ShowCode = "0";
        FundSort.Reset();
    }
}

/*
基金公司下拉选项
*/
var CompanyList = {
    ID : "CompanySelect",
        
    InitCompany : function(){
        var CompanySelect = document.getElementById(CompanyList.ID);
        if (companyData)
        {
            var oOption = document.createElement("OPTION");
            oOption.text = "全部基金公司";
	        oOption.value = "0";
	        CompanySelect.options.add(oOption);
	        for(var i=0;i<companyData.length;i++)
	        {   
		        if (companyData[i] && companyData[i][0].indexOf("证券") == -1)
		        {  
			        oOption = document.createElement("OPTION");
			        oOption.text=companyData[i][0];
			        oOption.value=companyData[i][1];
			        CompanySelect.options.add(oOption);
		        }
	        }
        }
        CompanySelect.onchange = CompanyList.OnChange;
    },
    
    TabCompany : function(){
        var CompanySelect = document.getElementById(CompanyList.ID);
        while(CompanySelect.childNodes.length > 0){
            CompanySelect.removeChild(CompanySelect.childNodes[0]);
        }
        var oOption = document.createElement("OPTION");
        oOption.text = "全部基金公司";
        oOption.value = "0";
        CompanySelect.options.add(oOption);
        for(var i=0;i<companyData.length;i++)
        {
	        if (companyData[i])
	        {
		        oOption = document.createElement("OPTION");
		        oOption.text=companyData[i][0];
		        oOption.value=companyData[i][1];
		        CompanySelect.options.add(oOption);
	        }
        }
    },
    
    OnChange : function(){
        var CompanySelect = document.getElementById(CompanyList.ID);
        ShowCode = CompanySelect.options[CompanySelect.selectedIndex].value;
        FundSendShow.SendShow();
        FundKindList.Reset();
    },
    
    AutoScroolSelect : function(evt){
        var objSelect = document.getElementById(CompanyList.ID);
        //列表自动滚动处理函数
	    var KeywordList = "b|宝|c|长|d|大|f|富|g|工|h|海|j|嘉|n|南|p|鹏|r|融|s|上|t|泰|w|万|x|新|y|易|z|招";
	    var arrKeyItem;
	    arrKeyItem = KeywordList.split("|");    	
	    var keyCode = String.fromCharCode(evt.keyCode);
	    keyCode = keyCode.toLowerCase();
	    //根据按下的鍵查找关键字
	    var Keyword = "";
	    for (var i = 0; i < arrKeyItem.length; i += 2)
	    {
		    if (keyCode == arrKeyItem[i])
		    {
			    //找到
			    Keyword = arrKeyItem[i + 1];
			    //查找列表中第一个以此开头的项目
			    for (i = 0; i < objSelect.length; ++i)
			    {	
				    if (0 == objSelect.options[i].text.indexOf(Keyword))
				    {
					    //找到
					    objSelect.selectedIndex = i;
					    break;
				    }
			    }
			    break;
		    }
	    }
    },
    
    //切换回初始状态
    Reset : function(){
        document.getElementById(CompanyList.ID).selectedIndex = 0;
    }
}

/*
基金类型选项
*/
var FundKindList = {
    CurrentID : "",
    
    InitID : "all",
    
    InitFundKind : function(){
        document.getElementById("myfundlist").onclick = function(){ //我关注的基金
            if(myFavoriteFund == null){
                //登录
                LoadDefault();
            }
            else{
                ShowCode = myFavoriteFund
                FundKindList.TabShow("myfundlist");
                FundKindList.Common();
            }
        };
        document.getElementById("all").onclick = function(){    //全部
            ShowCode = "0";
            FundKindList.TabShow("all");
            FundKindList.Common();
        };
        document.getElementById("stock").onclick = function(){  //股票
            ShowCode = stockFund[1];
            FundKindList.TabShow("stock");
            FundKindList.Common();
        };
        document.getElementById("bond").onclick = function(){   //债券
            ShowCode = bondFund[1];
            FundKindList.TabShow("bond");
            FundKindList.Common();
        };
        document.getElementById("mix").onclick = function(){    //混合
            ShowCode = mixFund[1];
            FundKindList.TabShow("mix");
            FundKindList.Common();
        };
        document.getElementById("keep").onclick = function(){   //保本
            ShowCode = keep[1];
            FundKindList.TabShow("keep");
            FundKindList.Common();
        };
        document.getElementById("etf").onclick = function(){    //etf
            ShowCode = etfFund[1];
            FundKindList.TabShow("etf");
            FundKindList.Common();
        };
        document.getElementById("qdii").onclick = function(){   //qdii
            ShowCode = QDIIFund[1];
            FundKindList.TabShow("qdii");
            FundKindList.Common();
        };
        FundKindList.Reset();
    },
    
    Common : function(){
        FundSendShow.SendShow();
        CompanyList.Reset();
    },
    
    TabShow : function(id){
        if(FundKindList.CurrentID != id){
            //做些切换工作
            if(FundKindList.CurrentID != ""){
                document.getElementById(FundKindList.CurrentID).parentNode.className = FK_CommonColor;
            }
            if(id == "myfundlist")
                document.getElementById(id).parentNode.className = FK_BSelectedColor;
            else
                document.getElementById(id).parentNode.className = FK_SelectedColor;
            FundKindList.CurrentID = id;
        }
    },
    
    //切换回初始状态
    Reset : function(){
        if(FundKindList.CurrentID != FundKindList.InitID){
            if(FundKindList.CurrentID != ""){
                document.getElementById(FundKindList.CurrentID).parentNode.className = FK_CommonColor;
            }
            if(FundKindList.InitID == "myfundlist")
                document.getElementById(FundKindList.InitID).parentNode.className = FK_BSelectedColor;
            else
                document.getElementById(FundKindList.InitID).parentNode.className = FK_SelectedColor;            
            FundKindList.CurrentID = FundKindList.InitID;
        }
    }
}

/*
基金排序
*/
var FundSort = {
    ID : "",
    InitID : "",
    InitSortType : "DESC",
    
    Sort : function(e){
        var info = e;
        if(e == undefined || e == "query")
            e = document.getElementById(FundSort.InitID);
        else
            FundSort.InitID = e.id;
            
        var key,sortType,kind;
        key = GetAttributeValue(e, "Key");
        kind = GetAttributeValue(e, "Kind");
        if(info == "query"){
            sortType = GetAttributeValue(e, "SortType") == FundSort.InitSortType ? "ASC" : "DESC";
        }
        else{
            sortType = GetAttributeValue(e, "SortType");
            var changeType = sortType == FundSort.InitSortType ? "ASC" : "DESC";
            SetAttributeValue(e, "SortType", changeType);            
//            SetAttributeValue(e, "SortType", sortType == FundSort.InitSortType ? "ASC" : "DESC");
            //切换图标 ASC降序 DESC升序
            var img = document.getElementById("arrow_D_U");
            if(img){
                img.parentNode.removeChild(img);
            }
            var arrow_D_U = document.createElement("img");
            arrow_D_U.id = "arrow_D_U";
            arrow_D_U.align = "absmiddle";
            arrow_D_U.border = 0;
            if(sortType == "ASC"){
                arrow_D_U.src = "Images/arrowDown.gif";
            }
            else if(sortType == "DESC"){
                arrow_D_U.src = "Images/arrowUp.gif";
            }
            e.parentNode.appendChild(arrow_D_U);
        }
        //排序
        FundSort.SortByKey(key, sortType, kind);
        //更改属性
        FundSort.ID = e.id;
    },
    
    SortByKey : function(Key, SortType, Kind){
        ArraySort.Key = Key;
        if(Kind == "C"){    //汉字
            if(SortType == "DESC"){
                Global_FundArray.sort(ArraySort.ChineseSortByKeyDESC);
            }
            else if(SortType == "ASC"){
                Global_FundArray.sort(ArraySort.ChineseSortByKeyASC);
            }
        }
        else if(Kind == "F"){   //数值
            if(SortType == "DESC"){
                Global_FundArray.sort(ArraySort.FloatSortByKeyDESC);
            }
            else if(SortType == "ASC"){
                Global_FundArray.sort(ArraySort.FloatSortByKeyASC);
            }
        }
        FundSendShow.SendShowByKey(Key);
        if(document.getElementById("loadingFrame"))
            document.getElementById("loadingFrame").style.display = "none";
    },
    
    Reset : function(){
        var e;
        if(FundSort.ID != FundSort.InitID){
            e = document.getElementById(FundSort.ID);
            SetAttributeValue(e, "SortType", FundSort.InitSortType);
        }
        e = document.getElementById(FundSort.InitID);
        SetAttributeValue(e, "SortType", FundSort.InitSortType);
        FundSort.Sort(e);
    }
}

/*
送显
*/
var FundSendShow = {
    Key : "",
    
    SendShowByKey : function(Key){
        FundSendShow.Key = Key;
        tb.SendShow(Global_FundArray, Key, ShowCode);
    },
    
    SendShow : function(){
        tb.SendShow(Global_FundArray, FundSendShow.Key, ShowCode);
    },
    
    SendPromotionShow : function(DS){
        tbp.SendPromShow(DS);
    }
}
