


 
var DATA_SERVEAR_LIST = [
      '202.108.13.239'
//	'172.17.160.21'
    ];

var WEB_SERVER = 'www.znz888.com';
//var WEB_SERVER = '172.17.160.21';

var SWF_SERVER = rdmDataDomainNameGet();

// Global function
function rdmDataDomainNameGet()
{
    var dmName = '';            
    dmName = DATA_SERVEAR_LIST[parseInt(Math.random()*1)];
    return dmName;
}
 
$d = document;
var userMod = function(){
    var pingbackurl = "/stock/t.gif";
    var refer = $d.referrer || "-";
    var uid = iCookie.get("CUID") || "-";
    if (uid == "-")
    {
        uid = parseInt(Math.random()*1000000).toString(16) + "" + (new Date().getTime() % 1000000).toString(16) + "." + parseInt(Math.random()*10000);
        iCookie.set("CUID", uid);
    }
    var doma = $d.domain;

    if (refer != "-"){
        var p = refer.indexOf(doma);
        if ((p>=0) && (p<=8))
        {
            refer = refer.substring(refer.indexOf(doma) + doma.length);
            refer = refer.substring(refer.indexOf("/") + 1);
        }
        if (refer.indexOf("[") == 0 && refer.lastIndexOf("]") == (refer.length-1))
        {
            refer="-";
        }
    }
    refer = encodeURIComponent(refer);

    var pingbackhead = "?r=" + refer + "&i=" + uid;

    var oldclick = $d.onclick || function(){};
    var staytime = new Date().getTime();

    $d.onclick = function (evt){
        try{
            var ret = oldclick(evt);
            clickit(evt);
            return ret;
        }catch(E){
        }
    }

    var clickit = function(evt){
        if ((evt&&(evt.button != 0))||((!evt)&&(window.event.button != 0)))
            return;  // not left click

        try{
            evt = evt || window.event;
            var srcElem = ((evt.target) ? evt.target : evt.srcElement);
            var divId = "";
            var oldDivId = "";
            var divClass = "";
            var oldDivClass = "";
            var divType = "";
            var tag = "";
            var dHref = "";
            while(divId == "" || divClass == "")
            {
                tag = srcElem.tagName.toUpperCase();
                if (!divClass)
                {
                    divClass = srcElem.className || "";
                }

                if (!oldDivId)
                {
                    oldDivId = srcElem.id || srcElem.getAttribute("name") || "";
                }
                else
                {
                    if (!divId) 
                    {
                        divId = srcElem.id || srcElem.getAttribute("name") || "";
                    }
                }
                if (tag == "A" || srcElem.onclick != null || tag == "LINK" || tag=="AREA"
                    || tag == "INPUT" && (srcElem.type == "submit" || srcElem.type == "image"
                    ||(srcElem.type == "button" && srcElem.onclick != null)))
                divType = tag;
                
                if (srcElem.href)
                {
                    dHref = (srcElem.href);
                    if (dHref.indexOf("http") == 0){
                        if (dHref.indexOf(doma) > 0){
                            dHref = dHref.substring(dHref.indexOf(doma)+doma.length);
                        }
                    }
                    dHref = encodeURIComponent(dHref);
                }

                if (srcElem.parentNode)
                    srcElem = srcElem.parentNode;
                else
                    break;
                
                if (!srcElem.tagName)
                    break;
            
                if ( divType && (divId && divClass))
                    break;
            }
        
            if (divType && (divId || oldDivId || divClass))
                pingbackclick(divId, oldDivId, divClass || oldDivClass, divType, dHref);
        }catch(e){}
    }
    
    var pingbackclick = function(divId, oldDivId, divClass, divType, dHref){
        var st = "";
        var tmp = staytime;
        if (staytime < 0) {
            tmp = 0-staytime;
        }else{
            staytime = 0-tmp;
        }
        st = "&st=" + parseInt((new Date().getTime() - tmp)/1000);
        
        pingaction("&di=" + divId + "&do=" + oldDivId + "&dc=" + divClass + "&dt=" + divType + "&dh=" + dHref + st);
    }

    var pingaction = function(para){
        var pbsrc = pingbackurl + pingbackhead + "&t=" + parseInt(new Date().getTime()/1000) + para;
        new Image().src = pbsrc;
    }
};

var s_um = new userMod();
 
//save for js innerHTML
function writeswf(swfid, swfsrc, noRandom){
    document.write(swfLoad(swfid, swfsrc, noRandom));
}

// Major version of Flash required
var requiredMajorVersion = 9;
// Minor version of Flash required
var requiredMinorVersion = 0;
// Minor version of Flash required
var requiredRevision = 0;

function swfLoad(swfid, swfsrc, noRandom)
{
    // check whether maxthon
    //alert(navigator.appName);
    var swfSRC = swfsrc||swfid;
    var tail = '';
    //if ((!noRandom)||navigator.userAgent.indexOf('Maxthon')>0 || navigator.userAgent.indexOf('MAXTHON')>0)
        tail = '?rdm=' + Math.random().toString() + '&from=' + window.location.host;
    //else
        //tail = '?' + 14;
    // Version check for the Flash Player that has the ability to start Player Product Install (6.0r65)
    var hasProductInstall = DetectFlashVer(6, 0, 65);
    
    // Version check based upon the values defined in globals
    var hasRequestedVersion = DetectFlashVer(requiredMajorVersion, requiredMinorVersion, requiredRevision);
    
    
    // Check to see if a player with Flash Product Install is available and the version does not meet the requirements for playback
    if ( hasProductInstall && !hasRequestedVersion ) 
    {
    	// MMdoctitle is the stored document.title value used by the installation process to close the window that started the process
    	// This is necessary in order to close browser windows that are still utilizing the older version of the player after installation has completed
    	// DO NOT MODIFY THE FOLLOWING FOUR LINES
    	// Location visited after installation is complete if installation is required
    	var MMPlayerType = (isIE == true) ? "ActiveX" : "PlugIn";
    	var MMredirectURL = window.location;
        document.title = document.title.slice(0, 47) + " - Flash Player Installation";
        var MMdoctitle = document.title;
    
    	return AC_FL_RunContent(
    		"src", 'http://' + SWF_SERVER + "/swf/playerProductInstall" + tail,
    		"FlashVars", "MMredirectURL="+MMredirectURL+'&MMplayerType='+MMPlayerType+'&MMdoctitle='+MMdoctitle+"",
    		"width", "100%",
    		"height", "100%",
    		"align", "middle",
    		"id", swfid,
    		"quality", "high",
    		"bgcolor", "#ffffff",
    		"name", swfid,
    		"allowScriptAccess","always",
    		"type", "application/x-shockwave-flash",
    		"pluginspage", "http://www.adobe.com/go/getflashplayer"
    	);
    } 
    else if (hasRequestedVersion) 
    {
    	// if we've detected an acceptable version
    	// embed the Flash Content SWF when all tests are passed
    	return AC_FL_RunContent(
    			"src", 'http://' + SWF_SERVER + '/swf/' + swfSRC + tail,
    			//"src", swfid,
    			"width", "100%",
    			"height", "100%",
    			"align", "middle",
    			"id", swfid,
    			"quality", "high",
    			"bgcolor", "#ffffff",
    			"name", swfid,
    			"wmode", "opaque",
    			"allowScriptAccess","always",
    			"type", "application/x-shockwave-flash",
    		    "pluginspage", "http://www.adobe.com/go/getflashplayer"
    	);
    }
    else 
    {  // flash is too old or we can't detect the plugin
        var alternateContent = '您的浏览器没有安装Flash播放器，请点击' + '<a href="/swf/flashplayer9r47_winax.exe">这里</a>下载安装';
        return alternateContent;
    }
}

// for load swf
function writeswf2(swfid, swfsrc, noRandom, fObjParams){
    document.write(swfLoad2(swfid, swfsrc, noRandom, fObjParams));
}

function swfLoad2(swfid, swfsrc, noRandom, fObjParams)
{
    // check whether maxthon
    //alert(navigator.appName);
    var swfSRC = swfsrc||swfid;
    var tail = '';
    if (!noRandom)
        tail = '?rdm=' + Math.random().toString() + '&from=' + window.location.host;
    else
        tail = '?' + 14 + '&from=' + window.location.host;
    // Version check for the Flash Player that has the ability to start Player Product Install (6.0r65)
    var hasProductInstall = DetectFlashVer(6, 0, 65);
    
    // Version check based upon the values defined in globals
    var hasRequestedVersion = DetectFlashVer(requiredMajorVersion, requiredMinorVersion, requiredRevision);
    
    var tmpFlashObjParams = fObjParams || {};
    // Check to see if a player with Flash Product Install is available and the version does not meet the requirements for playback
    if ( hasProductInstall && !hasRequestedVersion ) 
    {
    	// MMdoctitle is the stored document.title value used by the installation process to close the window that started the process
    	// This is necessary in order to close browser windows that are still utilizing the older version of the player after installation has completed
    	// DO NOT MODIFY THE FOLLOWING FOUR LINES
    	// Location visited after installation is complete if installation is required
    	var MMPlayerType = (isIE == true) ? "ActiveX" : "PlugIn";
    	var MMredirectURL = window.location;
        document.title = document.title.slice(0, 47) + " - Flash Player Installation";
        var MMdoctitle = document.title;
    
    	return AC_FL_RunContent(
    		"src", "swf/playerProductInstall" + tail,
    		"FlashVars", "MMredirectURL="+MMredirectURL+'&MMplayerType='+MMPlayerType+'&MMdoctitle='+MMdoctitle+"",
    		"width", "100%",
    		"height", "100%",
    		"align", "middle",
    		"id", swfid,
    		"quality", "high",
    		"bgcolor", tmpFlashObjParams['bgcolor'] || '#FFFFFF',
    		"name", swfid,
    		"allowScriptAccess","always",
    		"type", "application/x-shockwave-flash",
    		"pluginspage", "http://www.adobe.com/go/getflashplayer"
    	);
    } 
    else if (hasRequestedVersion) 
    {
    	// if we've detected an acceptable version
    	// embed the Flash Content SWF when all tests are passed
    	return AC_FL_RunContent(
    			"src", 'swf/' + swfSRC + tail,
    			//"src", swfid,
    			"width", "100%",
    			"height", "100%",
    			"align", "middle",
    			"id", swfid,
    			"quality", "high",
    			"bgcolor", tmpFlashObjParams['bgcolor'] || '#FFFFFF',
    			"name", swfid,
    			"wmode", "opaque",
    			"allowScriptAccess","always",
    			"type", "application/x-shockwave-flash",
    		  "pluginspage", "http://www.adobe.com/go/getflashplayer"
    	);
    }
    else 
    {  // flash is too old or we can't detect the plugin
        var alternateContent = '您的浏览器没有安装Flash播放器，请点击' + '<a href="swf/flashplayer9r47_winax.exe">这里</a>下载安装';
        return alternateContent;
    }
}

// for query
var suggestQuery = function(queryInputId, selectDivId, codeInputId, queryformId, defUrl, defUrlSubFunc, directSubmitFunc, need8161){
    this.mCurrLine = -1;
    this.mCurrTRs = [];
    this.mQueryInput = $(queryInputId);    
    this.mSelectDiv = $(selectDivId);
    this.mTableID = "";
    this.mCodeInput = $(codeInputId);
    this.mQueryForm = $(queryformId);
    this.mDefUrl = defUrl || "realstock.php";
    this.mDirectSubmitFunc = directSubmitFunc || null; 
    this.mDefUrlSubFunc = defUrlSubFunc || null;
    this.mNeed8161 = need8161 || true;
    this.mOnInput = false;
    this.mSelStockType = null;
    this.mSelStockCode = null;
    this.mSelStockName = null;
    this._init();
    
}

suggestQuery.prototype._init = function()
{   
    if(!this.mQueryInput)
        return;

    this.mQueryInput.value = '代码/名称/拼音';

    this.mQueryInput.onfocus = function()
    {        
        this.oninput = true;
        if(this.mQueryInput.value == '代码/名称/拼音')
            this.mQueryInput.value = '';            
    }.bind(this);
    
    this.mQueryInput.onclick = function()
    {
        if(this.mQueryInput.value == '代码/名称/拼音')
            this.mQueryInput.value = '';
    }.bind(this);
    
    this.mQueryInput.onblur = function ()
    {
        
        if(this.mQueryInput.value == '')
            this.mQueryInput.value = '代码/名称/拼音';
        this.mOnInput = false;
    }.bind(this);
    
    this.mQueryInput.onkeyup = function (ev)
    {
        ev = ev || window.event || null;
        if (typeof ev.keyCode != "number")
            return;        
        
        if(ev.keyCode == 38 || ev.keyCode == 40 )    // key is up or down
        {
            if (this.mCurrTRs)
            {
                var newLine = this.mCurrLine;
                if(ev.keyCode == 38)
                {
                    if(this.mCurrLine > 0)
                        newLine = this.mCurrLine - 1;  
                }
                else
                {
                    if(this.mCurrLine < this.mCurrTRs.length -1)
                        newLine = this.mCurrLine +1;
                }
                
                this.selectChange(newLine);
             }                
        }
        else
        {
            var query = this.mQueryInput.value;
            
            if (query.indexOf('代码/名称/拼音')>=0){
                query = query.replace('代码/名称/拼音', '');
                this.mQueryInput.value = query;
            }
            query = query.replace(' ', '');
            
            if( query == '') 
            {
                this.mSelectDiv.innerHTML = '';
                return;
            }
             
            var args = {
                method : 'get', onComplete : this.onSugRecved.bind(this)
            };
            query = encodeURIComponent(query); 
            query = 'http://' + WEB_SERVER + '/pyui/suggestion.py/handler?query=' + query;
            
            var myAjaj = new Ajaj(query, args);            
        }
    }.bind(this);
    
    var that = this;
    if(this.mDirectSubmitFunc)
    {
        this.mQueryForm.onsubmit = function(){
            if(that.mSelStockCode)
            {                           
                that.mDirectSubmitFunc(that.mSelStockType + that.mSelStockCode, that.mSelStockName);
            }
            else
            {
                alert('没有相应的股票存在！');
            }
            that.mSelectDiv.innerHTML = '';
            that.mSelectDiv.style.display = "none";
            that.mQueryInput.value = '';
            return false;
        };
        return;
    }
    else
    {
        this.mQueryForm.onsubmit = function(){
            this.submit();
            return false;
        };
    }
}

suggestQuery.prototype.onSugRecved = function(rep)
{
    var ret = decodeURIComponent(rep);
    
    var lines = ret.split('|');
    var query = this.mQueryInput.value;
    if (this.mNeed8161 && sug6181Data[query]){
        lines.unshift(sug6181Data[query]);
    }
    
    this.tableid = "select-table-" + Math.random();
    var content = '<table  id=\'' + this.tableid + '\' class=\'modview-select-table\'>'
    for(var i=0; i< lines.length&&i < 10; i++)
    {
        stocks = lines[i].split(';');
        if(stocks.length != 4 )
            continue;
        content += '<tr class=\'realstock-query-select-unselected\'>';        
        content += '<td>' + stocks[0] + '</td>' + '<td class=\'hide\'>' + stocks[1] + '</td>' + '<td>' + stocks[2] + '</td>' + '<td>' + stocks[3] + '</td>';
        content += '</tr>';
    }
    
    content += '</table>';
    this.mSelectDiv.innerHTML = content;
    this.mSelectDiv.style.display = "block";
    
    window.setTimeout(this.selectInit.bind(this), 100);
}

suggestQuery.prototype.selectInit = function()
{
    var table = $(this.tableid);
    var that = this;  
    if (table)
    {        
        if (table.childNodes[0])
        {            
            this.mCurrTRs = table.childNodes[0].childNodes;            
            this.selectChange(0)
            for (var i=0; i< this.mCurrTRs.length; i++)
            {
                this.mCurrTRs[i].onmouseover = function()
                {
                    var j = 0;
                    for(j =0; j< that.mCurrTRs.length; j ++)
                    {
                        if(that.mCurrTRs[j] == this)
                            break;
                    }
                    that.selectChange(j);
                }
                
                this.mCurrTRs[i].onclick = function()
                {
                    var j = 0;
                    for(j =0; j< that.mCurrTRs.length; j ++)
                    {
                        if(that.mCurrTRs[j] == this)
                            break;
                    }
                    that.mQueryForm.onsubmit();                    
                }
            }
        }
    }       
}

suggestQuery.prototype.selectChange = function(newLine)
{
    
    if (this.mCurrTRs.length <= 0)
    {
        this.mSelStockType = null;
        this.mSelStockCode = null;
        this.mSelStockName = null;
        return false;
    }
        
    if (this.mCurrLine < 0 || this.mCurrLine > this.mCurrTRs.length -1)
        this.mCurrLine = 0;
        
    this.mCurrTRs[this.mCurrLine].className = "realstock-query-select-unselected";
    this.mCurrTRs[newLine].className = "realstock-query-select-selected";
    this.mCurrLine = newLine;
    
    // set input values
    var tds = this.mCurrTRs[this.mCurrLine].childNodes;      
    var stype = tds[1].innerHTML;
    var code = tds[0].innerHTML;
    
    this.mSelStockType = stype;
    this.mSelStockCode = code;
    this.mSelStockName = tds[2].innerHTML;
    
    this.mCodeInput.name = 'code';
    var nowaction = this.mQueryForm.action.toString();
    
    if (nowaction.lastIndexOf("/") > 0){
        nowaction = nowaction.substring(0, nowaction.lastIndexOf("/")+1);
    }else{
        nowaction = "";
    }    
    
    if(stype == 'SH'){
        this.mQueryForm.action = nowaction + defaultu;
        this.mCodeInput.value = 'sh' + tds[0].innerHTML;
    }else{
        if(stype == 'SZ'){
            this.mQueryForm.action = nowaction + defaultu;
            this.mCodeInput.value = 'sz' + tds[0].innerHTML;                    
        }else{
            this.mQueryForm.action = nowaction + "newsort.php";
            this.mCodeInput.name = 'boardNo';
            this.mCodeInput.value = '' + tds[0].innerHTML;
            if(stype == 'IH'){
                this.mCodeInput.value = 'SHHQ' + tds[0].innerHTML;
            }
            if(stype == 'IZ'){
                this.mCodeInput.value = 'SZHQ' + tds[0].innerHTML;
            }
            if(stype.indexOf('68') == 0){
                this.mCodeInput.name = 'markettype';
                this.mCodeInput.value = tds[1].innerHTML.toString().substring(2);
            }
            
            if(this.mDefUrlSubFunc)
            {
                this.mQueryForm.onsubmit = function(){
                    that.mDefUrlSubFunc(stype);
                    return false;
                };
            }
        }
    }

}


// for query
var currLine = -1;
var currTRs = [];
var oninput = false;
var defaultu = "realstock.php";
var defSubmitFunc = null;
function queryInit(defaulturl, submitFunc)
{
    defaultu = defaulturl || "realstock.php";
    defSubmitFunc = submitFunc;
    
    var realstock_query_query = $('realstock-query-query');
    if(!realstock_query_query)
        return;
    window.setTimeout(function(){
        realstock_query_query.value = '代码/名称/拼音';
    }, 100);
    
    realstock_query_query.onfocus = function()
    {        
        oninput = true;
        if(realstock_query_query.value == '代码/名称/拼音')
            realstock_query_query.value = '';            
    }
    
    realstock_query_query.onclick = function()
    {
        if(realstock_query_query.value == '代码/名称/拼音')
            realstock_query_query.value = '';
    }
    
    realstock_query_query.onblur = function ()
    {
        
        if(realstock_query_query.value == '')
            realstock_query_query.value = '代码/名称/拼音';
        oninput = false;
    }
    
    realstock_query_query.onkeyup = function (ev)
    {
        ev = ev||window.event||null;
        if (typeof ev.keyCode != "number")
            return;        
        
        if(ev.keyCode == 38 || ev.keyCode == 40 )    // key is up or down
        {
            if (currTRs)
            {
                var newLine = currLine;
                if(ev.keyCode == 38)
                {
                    if(currLine > 0)
                        newLine = currLine -1;
  
                }
                else
                {
                    if(currLine < currTRs.length -1)
                        newLine = currLine +1;
                }
                
                selectChange(newLine);
             }                
        }
        else
        {
            var query =  realstock_query_query.value;
            
            if (query.indexOf('代码/名称/拼音')>=0){
                query = query.replace('代码/名称/拼音', '');
                realstock_query_query.value = query;
            }
            query = query.replace(' ', '');
            
            if( query == '') 
            {
                $('realstock-query-select').innerHTML = '';
                $('realstock-query-select').style.display = "none";
                return;
            }
    
            var args = {
                method : 'get', onComplete : onSugRecved
            };
            query = encodeURIComponent(query); 
            query = 'http://' + WEB_SERVER + '/pyui/suggestion.py/handler?query=' + query;
            
            var myAjaj = new Ajaj(query, args);            
        }
    }
}
var sug6181Data = {
    "61" : "61;68Ash;沪A排名;",
    "62" : "62;68Bsh;沪B排名;",
    "63" : "63;68Asz;深A排名;",
    "64" : "64;68Bsz;深B排名;",
    "81" : "81;68A81sh;沪A排名;",
    "82" : "82;68B81sh;沪B排名;",
    "83" : "83;68A81sz;深A排名;",
    "84" : "84;68B81sz;深B排名;"

}

function onSugRecved(rep, query)
{
    var ret = decodeURIComponent(rep);
    var lines = ret.split('|');
    var query = $('realstock-query-query').value;
    if (sug6181Data[query]){
        lines.unshift(sug6181Data[query]);
    }
    var content = '<table id=\'realstock-query-select-table\'>'
    for(var i=0; i< lines.length&&i < 10; i++)
    {
        stocks = lines[i].split(';');
        if(stocks.length != 4 )
            continue;
        content += '<tr class=\'realstock-query-select-unselected\'>';        
        content += '<td>' + stocks[0] + '</td>' + '<td class=\'hide\'>' + stocks[1] + '</td>' + '<td>' + stocks[2] + '</td>' + '<td>' + stocks[3] + '</td>';
        content += '</tr>';
    }
    
    content += '</table>';
    $('realstock-query-select').innerHTML = content;
    //$('realstock-query-select').style.display = "block";
    window.setTimeout(selectInit, 100);        
}

function selectInit()
{
    var table = $('realstock-query-select-table');
    
    if (table)
    {
        
        if (table.childNodes[0])
        {
            
            currTRs = table.childNodes[0].childNodes;            
            selectChange(0)
            for (var i=0; i< currTRs.length; i++)
            {
                currTRs[i].onmouseover = function()
                {
                    var j = 0;
                    for(j =0; j< currTRs.length; j++)
                    {
                        if(currTRs[j] == this)
                            break;
                    }
                    selectChange(j);
                }
                
                currTRs[i].onclick = function()
                {
                    var j = 0;
                    for(j =0; j< currTRs.length; j++)
                    {
                        if(currTRs[j] == this)
                            break;
                    }
                    $('realstock-query-form').onsubmit();
                }
            }
        }
    }    
}

function selectChange(newLine)
{
    if (currTRs.length <= 0)
        return false;
        
    if (currLine < 0 || currLine > currTRs.length -1)
        currLine = 0;
        
    currTRs[currLine].className = "realstock-query-select-unselected";
    currTRs[newLine].className = "realstock-query-select-selected";
    currLine = newLine;
    
    $('realstock-query-form').onsubmit = function(){
        $('realstock-query-form').submit();
        return false;
    };
    
    // set input values
    var tds = currTRs[currLine].childNodes;      
    var stype = tds[1].innerHTML;
    $('realstock-query-code').name = 'code';
    var nowaction = $('realstock-query-form').action.toString();
    if (nowaction.lastIndexOf("/") > 0){
        nowaction = nowaction.substring(0, nowaction.lastIndexOf("/")+1);
    }else{
        nowaction = "";
    }
    if(stype == 'SH'){
        $('realstock-query-form').action = nowaction + defaultu;
        $('realstock-query-code').value = 'sh' + tds[0].innerHTML;
    }else{
        if(stype == 'SZ'){
            $('realstock-query-form').action = nowaction + defaultu;
            $('realstock-query-code').value = 'sz' + tds[0].innerHTML;                    
        }else{
            $('realstock-query-form').action = nowaction + "newsort.php";
            $('realstock-query-code').name = 'boardNo';
            $('realstock-query-code').value = '' + tds[0].innerHTML;
            if(stype == 'IH'){
                $('realstock-query-code').value = 'SHHQ' + tds[0].innerHTML;
            }
            if(stype == 'IZ'){
                $('realstock-query-code').value = 'SZHQ' + tds[0].innerHTML;
            }
            if(stype.indexOf('68') == 0){
                $('realstock-query-code').name = 'markettype';
                $('realstock-query-code').value = tds[1].innerHTML.toString().substring(2);
            }
            
            if(defSubmitFunc)
            {
                $('realstock-query-form').onsubmit = function(){
                        defSubmitFunc(stype);
                        return false;
                    };
            }
        }
    }

}

function queryStock()
{
    if($('realstock-query-code').value == '')
      return;
      
    //$('realstock-query-query').value = '';
    //$('realstock-query-form').submit();

}

function znzStock6181(keys, num, stype, interval, data)
{
    this.keys = keys;
    this.num = num;
    this.stype = stype;
    this.interval = interval;
    if(data)
        this.data = data.substr(0, data.length -1);
    this.inited = false;
    
    this._init();

}

znzStock6181.prototype._init = function()
{
    this._update();
    this.inited = true;
}

znzStock6181.prototype._update = function()
{
    if(this.data)
    {
        this._set(this.data);
        this.data = null;    
    }
    else
    {
        if(!this.inited || inHqTime())
            this._refresh();
    }
    
    window.setTimeout(this._update.bind(this), this.interval);
}

znzStock6181.prototype._refresh = function()
{
    var args = {
       method : 'get', onComplete : function(rep){    
            this._set(rep);
        }.bind(this)
    };
     
    var infoURL = 'http://' + rdmDataDomainNameGet() + '/test/sort.py/sort.znzDo?cmd='+ this.stype + '|' + this.num + '|' + Math.random().toString();  
    var myAjaj = new Ajaj(infoURL, args); 
}

znzStock6181.prototype._set = function(dataStr)
{
    var dataObj = dataStr.parseJSON();

    if (dataObj['ret'] != 'OK')
        return;
    
    for(var j=0; j< this.keys.length; j++)
    {
        var stocklist = dataObj['sortInfo'][this.keys[j]];
        var div = '';
        var nfix = 2;
        var vfix = 2;
        var tail = '';
        
        if(this.keys[j].split('_')[0] == 'inc' || this.keys[j].split('_')[0] == 'inc5min')
        {
            nfix = 2;
            tail = '%';
            div = '<table>\n<tr class=\'hasbtm\'><td class=\'table-center\'>排名</td><td class=\'table-center\'>名&nbsp;&nbsp;称</td><td class=\'table-center\'>价&nbsp;&nbsp;格</td><td class=\'table-center\'>涨跌幅</td></tr>\n';
        }
        if(this.keys[j].split('_')[0] == 'vol')
        {
            nfix = 0;
            div = '<table>\n<tr class=\'hasbtm\'><td class=\'table-center\'>排名</td><td class=\'table-center\'>名&nbsp;&nbsp;称</td><td class=\'table-center\'>价&nbsp;&nbsp;格</td><td class=\'table-center\'>成交量</td></tr>\n';
        }
        if(this.keys[j].split('_')[0] == 'amount')
        {
            nfix = 0;
            div = '<table>\n<tr class=\'hasbtm\'><td class=\'table-center\'>排名</td><td class=\'table-center\'>名&nbsp;&nbsp;称</td><td class=\'table-center\'>价&nbsp;&nbsp;格</td><td class=\'table-center\'>成交额</td></tr>\n';
        }      
        if(this.keys[j].split('_')[0] == 'tr')
        {
            nfix = 2;
            tail = '%';
            div = '<table>\n<tr class=\'hasbtm\'><td class=\'table-center\'>排名</td><td class=\'table-center\'>名&nbsp;&nbsp;称</td><td class=\'table-center\'>价&nbsp;&nbsp;格</td><td class=\'table-center\'>换手率</td></tr>\n';
        }
        if(this.keys[j].split('_')[0] == 'vr')
        {
            nfix = 2;
            div = '<table>\n<tr class=\'hasbtm\'><td class=\'table-center\'>排名</td><td class=\'table-center\'>名&nbsp;&nbsp;称</td><td class=\'table-center\'>价&nbsp;&nbsp;格</td><td class=\'table-center\'>量&nbsp;&nbsp;比</td></tr>\n';
        }

        if(this.keys[j].split('_')[2] == 'j' || this.keys[j].split('_')[2] == 'b')   
        {
            vfix = 3;
        }
            
        for(var i = 0; i< this.num; i++)
        {
            var color1 = 'nocolor';
            var color2 = 'nocolor';
            var stype = 'SH';
                
                        
            if(this.keys[j].split('_')[1] == 'sz')
                stype = 'SZ';
            else
                stype = 'SH';
                   
            if( i != this.num -1)
                div += '<tr class=\'hasbtm\'>';
            else
                div += '<tr>';
            
            if( i < stocklist.length) 
            {
                if(stocklist[i][4] > stocklist[i][3])
                    color1 = 'decolor';
                if(stocklist[i][4] < stocklist[i][3])
                    color1 = 'incolor';
                    
                color2 = color1;
                
                if(this.keys[j].split('_')[0] == 'inc5min')
                {
                    if(stocklist[i][2] < 0.00)
                        color2 = 'decolor';
                    if(stocklist[i][2] > 0.00)
                        color2 = 'incolor';                   
                }                         
                div += '<td class = \'table-center\'>' + (i+1).toString() + '</td>';
                div += '<td class=\'table-left\'><div class=\'stock-name\'><a href=\'./realstock.php?code=' + stype.toLowerCase() + stocklist[i][0] + '\' >' + decodeURIComponent(stocklist[i][1]) + '</a></div></td>';
                div += '<td class = \'' + color1 + ' table-right\'>' + (stocklist[i][3]/10).toFixed(vfix).toString() + '</td>';    
                div += '<td class = \'' + color2 + ' table-right\'>' + stocklist[i][2].toFixed(nfix).toString() + tail + '</td>';
                div += '</tr>\n'
            }
            else
            {
                div +='<td class = \'table-center\'>-</td><td class = \'table-left\'>--</td><td class = \'table-right\'>--</td><td class = \'table-right\'>--</td>';
            }
         }
        div += '</table>';      
        innerSet($(this.keys[j] + '_content'), div, null);
    }
    
}

// for hot stock
function znzHotStock(divID, interval)
{
    this.divID = divID;
    this.interval = interval;
    this.inited = false;
    this._init();
    
}

znzHotStock.prototype._init = function()
{
    this._update();
    this.inited = true;
}

znzHotStock.prototype._update = function()
{
    if(!this.inited || inHqTime())
        this._refresh();
    
    window.setTimeout(this._update.bind(this), this.interval);
}

znzHotStock.prototype._refresh = function()
{
    var args = {
       method : 'get', onComplete : function(rep){
    
            var ret = rep;  
            var retObj = ret.parseJSON();
            var stocklist = retObj['sortInfo']['vol_sh_a_top'];
            
            for(var i =0; i<retObj['sortInfo']['vol_sz_a_top'].length; i++)
            {
                stocklist[stocklist.length] = retObj['sortInfo']['vol_sz_a_top'][i];
            }
            
            var div = '<table>\n<tr class=\'hasbtm\'><td class=\'table-center\'>名&nbsp;&nbsp;称</td><td class=\'table-center\'>价&nbsp;&nbsp;格</td><td class=\'table-center\'>涨跌幅</td></tr>\n';
            for(var i=0; i< stocklist.length; i++)
            {
                var color = 'nocolor';
                var nfix = 2;
                
                //check long price
                
                var stype = 'SH';
                if(stocklist[i][4] > stocklist[i][3])
                    color = 'decolor';
                if(stocklist[i][4] < stocklist[i][3])
                    color = 'incolor';
                    
                if(i < 5)
                    stype = 'SH';
                else
                    stype='SZ';
                       
                if( i != stocklist.length -1)
                    div += '<tr class=\'hasbtm\'>';
                else
                    div += '<tr>';
                
                var curValStr;
                var curRateStr;
                  
                if (stocklist[i][3] != 0.00)
                {
                    curValStr = (stocklist[i][3]/10).toFixed(nfix).toString();
                    curRateStr = ((stocklist[i][3] - stocklist[i][4]) * 100/stocklist[i][4]).toFixed(nfix).toString() + '%';
                }
                else
                {
                    curValStr = '--';
                    curRateStr = '--%';
                }        
                                                                  
                div += '<td class=\'table-left\'><div class=\'stock-name\'><a href=\'./realstock.php?code=' + stype.toLowerCase() + stocklist[i][0] + '\' >' + decodeURIComponent(stocklist[i][1]) + '</a></div></td>';
                div += '<td class = \'' + color + ' table-right\'>' + curValStr + '</td>';  
                div += '<td class = \'' + color + ' table-right\'>' + curRateStr + '</td>';
                div += '</tr>\n'
            }
            div += '</table>';
            
            innerSet($(this.divID), div, null);
            
        }.bind(this)
    };
     
    var infoURL = 'http://' + rdmDataDomainNameGet() + '/test/sort.py/sort.znzDo?cmd=vol_shsz_a_top|5' + '|' + Math.random().toString();  
    var myAjaj = new Ajaj(infoURL, args); 
    
}

// for last visit
// default last visit list

var defaultLastList = [["000001", "SH"], ["399001", "SZ"], ["000300", "SH"], ["399005", "SZ"],
     ["000016", "SH"], ["000002", "SH"], ["399002", "SZ"], ["000003", "SH"], ["399003", "SZ"]];

// class znzLastVisit
function znzLastVisit(divID, interval, setCookie, stockCode, stockType, jumpURL, numShow, defaultList)
{
    this.divID = divID;
    this.interval = interval;
    this.setCookie = setCookie;
    this.stockCode = stockCode;
    this.stockType = stockType;    
    this.mJumpURL = jumpURL || 'realstock.php';
    this.numMax = 15;
    this.mDefaultList = (defaultList && defaultList.constructor == Array) ? defaultList : null;
    if(numShow && numShow <= this.numMax)
        this.numShow = numShow;
    else
        this.numShow = 10;
    
    this.lastVisit = [];
    this.running = true;
    this.inited = false;
    this._init();
}

znzLastVisit.prototype._init = function()
{    
    var lastVStr = iCookie.get('LASTVISIT');
    //alert(lastVStr);
    if (lastVStr && lastVStr != '')
    {
        stocks = lastVStr.split(',');
        //alert(stocks.length);
        for(var i = 0; i< stocks.length; i++)
        {
            items = stocks[i].split('|');
            if(items.length == 2 && items[0] != 'undefined' && items[1] != 'undefined'
               && (items[1] == 'SH' || items[1] == 'SZ'))
            {
                var tmp = [];
                tmp.push(items[0], items[1]);
                this.lastVisit.push(tmp);
            }
        }
    }
    
    if((!this.lastVisit || this.lastVisit.length == 0) && this.mDefaultList)
    {
        this.lastVisit =  this.mDefaultList;
        this._writeCookie();
    }

    // update cookie for new stock
    if(this.setCookie == true && this.stockCode != 'undefined' && this.stockType != 'undefined')
    {
        var tmp = [];
        tmp.push(this.stockCode, this.stockType);
        this.lastVisit.push(tmp);
        
        for(var i = 0; i< this.lastVisit.length -1; i++)
        {
            if(this.lastVisit[i][0] == this.stockCode && this.lastVisit[i][1] == this.stockType)
            {
                this.lastVisit.remove(i);
                break;
            }
        }
        if(this.lastVisit.length > this.numMax)
            this.lastVisit.remove(0);
        this._writeCookie();       
    }
    
    // get stock name
    if(this.lastVisit.length >=1)
    {
        var args = {
            method : 'get', onComplete : function(rep){
    
                var ret = rep;
                
                var retObj = ret.parseJSON();
                for(var i = 0; i< this.lastVisit.length; i++)
                {
                    if(retObj[this.lastVisit[i][1].toLowerCase() + this.lastVisit[i][0]])
                        this.lastVisit[i].push(decodeURIComponent(retObj[this.lastVisit[i][1].toLowerCase() + this.lastVisit[i][0]]));
                }
                
                this._update(); 
                this.inited = true;    
                
            }.bind(this)
        };
        //alert(lastVisit);        
        var infoURL = '';
        for(var i = 0; i< this.lastVisit.length; i++)
        {   
            infoURL += this.lastVisit[i][1].toLowerCase() + this.lastVisit[i][0] + ',';
        }
        //alert(infoURL);
        infoURL = 'http://' + rdmDataDomainNameGet() + '/test/sCode.py/get.znzDo?cmd=' + infoURL + '|' + Math.random().toString();  

        var myAjaj = new Ajaj(infoURL, args); 
        
        // show parent node
        $(this.divID).parentNode.style.display = 'block';
    }
    else
    {
        //hide parent node
        //$(this.divID).parentNode.style.display = 'none';
    }    
}

znzLastVisit.prototype._writeCookie = function()
{
     var cookieValue = '';
     for(var i = 0; i< this.lastVisit.length; i++)
     {
         cookieValue += this.lastVisit[i][0] + '|' + this.lastVisit[i][1] + ',';
     }
     iCookie.set('LASTVISIT', cookieValue);
}

znzLastVisit.prototype._update = function()
{
    if(!this.inited || inHqTime())
        this._refresh();
        
    window.setTimeout(this._update.bind(this), this.interval);    
}

znzLastVisit.prototype._set = function(retStr)
{
    var retObj = retStr.parseJSON();
    for(var i = 0; i< this.lastVisit.length; i++)
    {
        if(retObj[this.lastVisit[i][1].toLowerCase() + this.lastVisit[i][0]])
        {
            if(this.lastVisit[i].length == 3)
             {
                this.lastVisit[i].push(retObj[this.lastVisit[i][1].toLowerCase() + this.lastVisit[i][0]]);
             }
             else if (this.lastVisit[i].length == 4)
             {
                this.lastVisit[i][3] = retObj[this.lastVisit[i][1].toLowerCase() + this.lastVisit[i][0]];
             }
             else
             {
                //alert('error: lastVisit = ' + this.lastVisit.toJSONString());
             }
        }
    }
 
    //alert(lastVisit.toJSONString());
    //set last visit stock valuses
    var start = this.lastVisit.length - this.numShow;
    if(start < 0)
        start = 0;
 
    var div = '<table>\n<tr class=\'hasbtm\'><td class=\'table-center\'>名&nbsp;&nbsp;称</td><td class=\'table-center\'>价&nbsp;&nbsp;格</td><td class=\'table-center\'>涨跌幅</td></tr>\n';
    for(var i = start; i < this.lastVisit.length; i++)
    {
        var color = 'nocolor';
        var nfix = 2;
        var curValue;
        var curRate;
        
        //alert("start:" + start);
        if( i != this.lastVisit.length -1)
            div += '<tr class=\'hasbtm\'>';
        else
            div += '<tr>';
 
        if(this.lastVisit[i][3])
        {
            // alert(this.lastVisit[i][3]);
            if (this.lastVisit[i][3][0] == 1)
                nfix = 3;
                            
 
            if(this.lastVisit[i][3][2] > this.lastVisit[i][3][1])
                color = 'incolor';
 
            if(this.lastVisit[i][3][2] < this.lastVisit[i][3][1])
                color = 'decolor';   

            if(this.lastVisit[i][3][2] == 0)
            {
                curValue = '--';       
                curRate  = '--%';
                color = 'nocolor';
            }
            else
            {
                curValue = this.lastVisit[i][3][2].toFixed(nfix).toString();
                if ((this.lastVisit[i][3][2] - this.lastVisit[i][3][1])/this.lastVisit[i][3][1] > 10.00)
                    curRate = ((this.lastVisit[i][3][2] - this.lastVisit[i][3][1])/this.lastVisit[i][3][1]).toFixed(2).toString();
                else
                    curRate = ((this.lastVisit[i][3][2] - this.lastVisit[i][3][1]) * 100/this.lastVisit[i][3][1]).toFixed(2).toString() + '%';
 
            }
        }
        else
        {
            curValue = '--';       
            curRate = '--%';
            color = 'nocolor';
        }
                    
        div += '<td class=\'table-left\'><div class=\'stock-name\'><a href=\'./' + this.mJumpURL + '?code=' + this.lastVisit[i][1].toLowerCase() + this.lastVisit[i][0] + '\' >' + decodeURIComponent(this.lastVisit[i][2]) + '</a></div></td>';
        div += '<td class = \'' + color + ' table-right\'>' + curValue + '</td>';
        div += '<td class = \'' + color + ' table-right\'>' + curRate  + '</td>';
        div += '</tr>\n'
 
    }
                
    div += '</table>';
 
    if (this.running)
       innerSet($(this.divID), div, null);
}

znzLastVisit.prototype._refresh = function()
{
 
    //get stock values from server
    if( this.lastVisit.length >=1)
    {
        var args = {
            method : 'get', 
            onComplete : function(rep){
    
                var ret = rep;  
                this._set(ret);
                
 
            }.bind(this)
        };
      
        var infoURL = '';
 
        for(var i = 0; i< this.lastVisit.length; i++)
        {   
 
                    infoURL += this.lastVisit[i][1].toLowerCase() +  this.lastVisit[i][0] + ',';
        }
        infoURL = 'http://' + rdmDataDomainNameGet()+ '/test/data.py/prices.znzDo?cmd=' + infoURL + '|' + Math.random().toString();  
        //alert(infoURL);
 
        var myAjaj = new Ajaj(infoURL, args); 
         
    }
}

// for index summary

function znzIdxSummary(divID, interval, data, realDomain, targetType, setFunction, jmpUrl)
{
    this.divID = divID;
    this.interval = interval;
    if(data)   
        this.data = data.substr(0, data.length -1);
    if(realDomain)
        this.realDomain = realDomain;
    
    this.targetType = '_self';    
    if(targetType)
        this.targetType = targetType;
    
    this._set = setFunction || this._set; 
    this.mJumpUrl = jmpUrl || "realstock.php";
    this.inited = false;
    this._init();  
}

znzIdxSummary.prototype._init = function()
{
    this._update();  
    this.inited = true;
}

znzIdxSummary.prototype._update = function()
{
    if(this.mTimer)
        window.clearTimeout(this.mTimer);
    
    if(this.data)
    {
        this._set(this.data);
        this.data = null;
    }
    else
    {
        if(!this.inited || inHqTime())
            this._refresh();
    }
    
    this.mTimer = window.setTimeout(this._update.bind(this), this.interval);
}

znzIdxSummary.prototype._refresh = function()
{    
     var args = {
        method : 'get', onComplete : function(rep){
            this._set(rep);
        }.bind(this)
    };
   
    infoURL = 'http://' + rdmDataDomainNameGet()+ '/test/data.py/prices.znzDo?cmd=sh000001,sz399001,sh000300|' + Math.random().toString(); 
    var myAjaj = new Ajaj(infoURL, args); 
   
}

znzIdxSummary.prototype._set = function(dataStr)
{
    var retObj = dataStr.parseJSON();
               
    var div = '<table><tr>';
    
    var color = 'nocolor';            
    if (retObj['sh000001'][2] > retObj['sh000001'][1])
        color = 'incolor';
    if (retObj['sh000001'][2] < retObj['sh000001'][1])
        color = 'decolor';
    
    var urlPrefix = '';
    
    if (this.realDomain)
    {
        urlPrefix = 'http://' + this.realDomain + '/stock/';
    }

    var flag0, flag1, flag2;
    flag0 = flag1 = flag2 = "+";
    if(retObj['sh000001'][2]-retObj['sh000001'][1] < 0.0)
        flag0 = "";
    if(retObj['sz399001'][2]-retObj['sz399001'][1] < 0.0)
        flag1 = "";        
    if(retObj['sh000300'][2]-retObj['sh000300'][1] < 0.0)
        flag2 = "";  
        
    if(typeof idxSumIndec == "undefined")
            idxSumIndec = "rate";
                        
    div += '<td><a href=\'' + urlPrefix + this.mJumpUrl +'?code=sh000001\' target=\'' + this.targetType + '\'>上证指数</a></td><td class=\''+ color + '\'>' + retObj['sh000001'][2].toFixed(2);
    if(idxSumIndec == "rate")
        div += '<td class=\''+ color + '\'>' + flag0 + ((retObj['sh000001'][2]-retObj['sh000001'][1])*100/retObj['sh000001'][1]).toFixed(2) + '%';
    else     
        div += '<td class=\''+ color + '\'>' + flag0 + (retObj['sh000001'][2]-retObj['sh000001'][1]).toFixed(2);
    div += '</td><td>' +  (retObj['sh000001'][3]/10000).toFixed(2) + '亿元</td>';
    
    color = 'nocolor';            
    if (retObj['sz399001'][2] > retObj['sz399001'][1])
        color = 'incolor';
    if (retObj['sz399001'][2] < retObj['sz399001'][1])
        color = 'decolor';
                    
    div += '<td>|</td><td><a href=\'' + urlPrefix + this.mJumpUrl + '?code=sz399001\' target=\'' + this.targetType + '\'>深证成指</a></td><td class=\''+ color + '\'>' + retObj['sz399001'][2].toFixed(2);
    if(idxSumIndec == "rate")
        div += '<td class=\''+ color + '\'>' + flag1 + ((retObj['sz399001'][2]-retObj['sz399001'][1])*100/retObj['sz399001'][1]).toFixed(2) + '%';
    else
        div += '<td class=\''+ color + '\'>' + flag1 + (retObj['sz399001'][2]-retObj['sz399001'][1]).toFixed(2);
    div += '</td><td>' +  (retObj['sz399001'][3]/10000).toFixed(2) + '亿元</td>';
    
    color = 'nocolor';            
    if (retObj['sh000300'][2] > retObj['sh000300'][1])
        color = 'incolor';
    if (retObj['sh000300'][2] < retObj['sh000300'][1])
        color = 'decolor';
         
    div += '<td>|</td><td><a href=\'' + urlPrefix + this.mJumpUrl + '?code=sh000300\' target=\'' + this.targetType + '\'>沪深300</a></td><td class=\''+ color + '\'>' + retObj['sh000300'][2].toFixed(2);
    if(idxSumIndec == "rate")
        div += '<td class=\''+ color + '\'>' + flag2 + ((retObj['sh000300'][2]-retObj['sh000300'][1])*100/retObj['sh000300'][1]).toFixed(2) + '%';
    else
        div += '<td class=\''+ color + '\'>' + flag2 + (retObj['sh000300'][2]-retObj['sh000300'][1]).toFixed(2);
    div += '</td><td>' +  (retObj['sh000300'][3]/10000).toFixed(2) + '亿元</td>';
        
    div += '</tr></table>';
    
    innerSet($(this.divID), div, null);
                
}
// for summary news
var newsSrc = {'baidu': 'baiduBusi', 'sina': 'sinaBusi', 'sohu': 'sohuStock'};

function znzSummaryNews(divID, ntype, interval, data)
{
    this.divID = divID;
    this.ntype = ntype;
    this.interval = interval;
    if(data)
        this.data = data.substr(0, data.length -1);
        
    this.inited = false;    
    this._init();
}

znzSummaryNews.prototype._init = function()
{
    this._update();
    this.inited = true;
}

znzSummaryNews.prototype._update = function()
{
    if(this.data)
    {
        this._set(this.data);
        this.data = null;
    }
    else
    {
        if(!this.inited || inHqTime())
            this._refresh();
    }
    
    window.setTimeout(this._update.bind(this), this.interval);
}

znzSummaryNews.prototype._refresh = function()
{
     var args = {
        method : 'get', onComplete : function(rep){
            ret = rep;
            this._set(ret);
        }.bind(this)
    };
   
    var infoURL = 'http://' + rdmDataDomainNameGet() + '/test/news.py/get.znzDo?cmd=' + newsSrc[this.ntype] + '|' + Math.random().toString();  
    var myAjaj = new Ajaj(infoURL, args); 
    
}

znzSummaryNews.prototype._set = function(dataStr)
{
    var retObj = dataStr.parseJSON(); 
    
    var div = '<table>';
    var len = 11;
    if (retObj.length < len)
        len = retObj.length;
        
    for(var i = 0; i< len; i++)
    {
        div += '<tr><td class=\'table-pointer\'></td><td class=\'smry-news-title\'>';
        
        div += '<a href=\'' + retObj[i][2] + '\' target=\'_blank\'>' + decodeURIComponent(retObj[i][1]) + '</a>';
        div += '</td></tr>';
    }          
    
    div += '</table>';
    innerSet($(this.divID), div, null);
}

// for stock news
function znzStockNews(divID, divID2, interval, stockCode, stockType, isNews, data, divId, divId2)
{
    this.divID = divID;
    this.divID2 = divID2;
    this.interval = interval;
    this.divId = divId||divID;
    this.divId2 = divId2||divID2;
    
    this.stockCode = stockCode;
    this.stockType = stockType;
    this.isnews = isNews||false;
    if(data)
        this.data = data.substr(0, data.length -1);
    this.inited = false;    
    this._init();
    
}

znzStockNews.prototype._init = function()
{
    this._update();
    this.inited = true;
}
znzStockNews.prototype._update = function()
{
    if(this.data)
    {
        this._set(this.data);
        this.data = null;
    }
    else
    {
        if(!this.inited || inHqTime())
            this._refresh();
    }
    
    window.setTimeout(this._update.bind(this), this.interval);
    
}

znzStockNews.prototype._refresh = function()
{
     var args = {
        method : 'get', onComplete : function(rep){
            var ret = rep;
            this._set(ret);
        }.bind(this)
    };
    
    var prefix = 'SHHQ';
    if (this.stockType == 'SZ')
        prefix = 'SZHQ';
    
    prefix += this.stockCode;
    
    var infoURL = 'http://' + rdmDataDomainNameGet() + '/test/stockNews.py/get.znzDo?cmd=' + prefix + '|' + (this.isNews?"news":"notice") + '|' + Math.random().toString();  
    var myAjaj = new Ajaj(infoURL, args); 
    
}

znzStockNews.prototype._set = function(dataStr)
{
 
    var retObj = dataStr.parseJSON()||[]; 
    
    var div = '<table>\n<tr class=\'hasbtm\'><td class=\'table-left\'>标题</td><td class=\'table-right\'>发布时间</td></tr>\n';
    if(retObj.length == 0||retObj[0] == -1)
    {
        // hide parent node
        $(this.divID).parentNode.style.display = 'none';
        return;
    }
    else
    {
        // show parent node
        $(this.divID).parentNode.style.display = 'block';
        retObj.reverse();
        
    }
    var len = 8;
    if (retObj.length < len)
        len = retObj.length;
    for(var i = 0; i< len; i++)
    {
        if( i != retObj.length -1)
            div += '<tr class=\'hasbtm\'>';
        else
            div += '<tr>';
        
        var alink = 'stocknews.php?newsid=' + retObj[i][0];    
        div += '<td><a href=\'' + alink + '\' target=\'_blank\'>' + decodeURIComponent(retObj[i][1]).substr(0, 30) + '</a></td>';
        div += '<td class="table-right">' + retObj[i][2].substr(0, 10)+ '</td>';
       // div += '<td>' +  decodeURIComponent(retObj[i][3]) + '</td>';
        div += '</tr>';
    }          
    
    div += '</table>';
    div += '<div style="float: right; margin-right: 2%; display: inline;"><a href="newslist.php?code=' + this.stockType.toLowerCase() + this.stockCode + '" target="_blank">显示全部</a></div>';
    if (this.isNews){
        innerSet($(this.divID), div, null);
        innerSet($(this.divId), div, null);
    }else{
        innerSet($(this.divID2), div, null);
        innerSet($(this.divId2), div, null);
    }
}

// for realstock
function znzRealStock(swfID, divID, stockCode, stockName, stockType, dataRecvFunc, interval, data, swfW, swfH, titleMargins, theme)
{
    this.swfID = swfID;
    this.divID = divID;
    this.stockCode = stockCode || '000001';
    this.stockName = stockName || '上证指数';
    this.stockType = stockType || 'SH';
    this.stockURL = this._realURLGet();    
    this.dataRecvFunc = dataRecvFunc || null;
    this.interval = interval;
    this.titleMargins = titleMargins || [0, 0, 0, 0, 0, 0];
    this.mW = swfW;
    this.mH = swfH;
    this.mTheme = theme || 'znz';
    
    if(data) this.initData = data.substr(0, data.length -1);;
    this.dataStr = this.initData;
    
    this.timeInfo = ['00000000', '000000'];
    this.sNumber = '0';
    
    this.running = false;
    this.timer = null;
    this.inited = false;
    
    
    this.olddata = [];
    if (this.initData)
        this.olddata.push(this.initData);
    
    this.myAjaj = null; 
    
    this._init();
    
    this.stop = false;
    this.i = 0;
}

znzRealStock.prototype.restart = function(stockCode, stockName, stockType)
{
    if(stockCode == this.stockCode)
    {
        return;    
    }
    
    this.stockCode = stockCode || this.stockCode;
    this.stockName = stockName || this.stockName;
    this.stockType = stockType || this.stockType;
    this.initData = null;
    this.dataStr = null;
    this.timeInfo = ["00000000", "000000"];
    this.sNumber = "0";
    this.running = false;
    this.initData = null;
    this.inited = false;
    
    if(this.timer)
    {
        window.clearTimeout(this.timer);
        this.timer = null;
    }
    this.olddata = [];
    this._init();
    this.stop = false;
}

znzRealStock.prototype._init = function()
{   
    this._start();
      
    // data update
    this._update();
    
    this.inited = true;
}

znzRealStock.prototype.destroy = function()
{
   this.stop = true;
   if (this.timer){
      window.clearTimeout(this.timer);
   }
   if (this.myAjaj){
      this.myAjaj.destroy();
      this.myAjaj.onComplete = function(){};
   }
   this.close();
}

znzRealStock.prototype._update = function()
{
    if (this.stop)
       return;
    
    // set init data to ui
    if(this.initData)
    {
        this._upd2ui(this.initData);
        
        var retObj = this.initData.parseJSON();
        if( retObj && retObj['ret'] == 'OK')
        {
            this.timeInfo = retObj['info']['timeInfo'];
            this.sNumber = retObj['info']['sNumber'];
        }

        this.initData = null;
    }
    else
    {
        if(!this.inited || inHqTime())
            this._refresh();
    }

    this.timer=window.setTimeout(this._update.bind(this), this.interval);
}

znzRealStock.prototype._refresh = function()
{
    if (this.myAjaj){
        this.myAjaj.destroy();
        this.myAjaj = null;
    }
    var args = {
        method : 'get', onComplete : function(rep){
            this.dataStr = rep;
            
            this.olddata.push(this.dataStr);
            
            // update ui and flash
            this._upd2ui(this.dataStr);
            this._upd2swf();

            // for next fetch
            var retObj = this.dataStr.parseJSON();
            if( retObj && retObj['ret'] == 'OK')
            {
                this.timeInfo = retObj['info']['timeInfo'];
                this.sNumber = retObj['info']['sNumber'];
            }                
        }.bind(this)
    };
   
    var infoURL = this.stockURL + '?cmd=' + this.stockType.toLowerCase();
    infoURL += this.stockCode + '|' + this.timeInfo[0] + '|' + this.timeInfo[1];
    infoURL += '|' + this.sNumber + '|' + Math.random().toString();
            
    this.myAjaj = new Ajaj(infoURL, args);     
}

znzRealStock.prototype._upd2ui = function(dataStr)
{
    var dataObj = dataStr.parseJSON();
    try
    {
        this.dataRecvFunc(dataObj);
    }
    catch(e)
    {
        
    }
}

znzRealStock.prototype._upd2swf = function()
{
    if (!this.running)
        return;
    
    if(!this.realSwf)
    {
        this.realSwf = $(this.swfID);
        if(this.realSwf)
            this.realSwf = document[this.swfID];
    }
    
    var dataStr = this.olddata.shift();
    if(!dataStr)
    {
        return;
    }
    try
    {
        this.realSwf.update("k-day-current", dataStr);        
        this.running = true;     
    }
    catch(E)
    {
        this.running = false;
    }
    
    if (this.olddata.length > 0){
        this._upd2swf();
    }
}

znzRealStock.prototype._start = function()
{    
      
    if(!this.realSwf)
    {        
        this.realSwf = $(this.swfID);
        if(!this.realSwf)
        {
            this.realSwf = document[this.swfID];
        }
    }    
    try
    {
        var dataHost = rdmDataDomainNameGet();
        var jmpURL = "./realstock.php?code=" + this.stockType.toLowerCase() + this.stockCode;
        if(typeof logoShow == "undefined")
            logoShow = true;

        this.realSwf.start(dataHost, this.stockCode, this.stockType, this.stockName,
                ["real", "rvol"], ["k-day-current"], this.mW, this.mH, logoShow,
                this.titleMargins, jmpURL, this.mTheme); 
        
        this.running = true;
    }
    catch(E)
    {
        //alert(E);
        this.running = false;
        this.timer = window.setTimeout(this._start.bind(this), 1000);
        return;
    }
    
    var dataStr = this.dataStr;
    if (this.olddata.length > 0)
    {
        dataStr = this.olddata.shift();
    }    
    if(!dataStr)
    {
        return;
    }
    
    try
    {
        this.realSwf.update("k-day-current", dataStr);
    }
    catch(E)
    {
        this.olddata.unshift(dataStr);
    }
}

znzRealStock.prototype.close = function()
{
    var realSwf = $(this.swfID);
    if(!realSwf)
        realSwf = document[this.swfID];
    if(realSwf && this.running == true)
    {
        try
        {
            this.running = false;
        }
        catch(E)
        {
        }
    }
}

znzRealStock.prototype._realURLGet = function()
{
    return 'http://' + rdmDataDomainNameGet()+ '/test/data.py/quick.znzDo';
}

// for ddx
DDX_SUPBIG = 3;
DDX_BIG = 2;
DDX_MID = 1;
DDX_SMALL = 0;

BUY_CNT_OFFSET = 5;
BUY_VOL_OFFSET = 13;
BUY_AMT_OFFSET = 17;
SELL_CNT_OFFSET = 9;
SELL_VOL_OFFSET = 21;
SELL_AMT_OFFSET = 25;

function znzDDX(divID, swfID, swfDivID, interval, stockCode, stockType)
{
    this.divID = divID;
    this.swfID = swfID;
    this.swfDivID = swfDivID;
    this.interval = interval;   
    this.stockCode = stockCode;
    this.stockType = stockType;
    this.dataStr = null;
    this.inited = false;
    this._init();    
}

znzDDX.prototype._init = function()
{
        this._start();
        this._update();
        this.inited = true;
}

znzDDX.prototype._start = function()
{
    var ddzSwf = $(this.swfID);
    if(!ddzSwf)
        ddzSwf = document[this.swfID];
    
    try{        
        ddzSwf.ddzStart();
        this._upd2swf();         
    }catch(E)
    {
        window.setTimeout(this._start.bind(this), 100);
    }
}

znzDDX.prototype._upd2swf = function()
{    
    var ddzSwf = $(this.swfID);
    if(!ddzSwf)
        ddzSwf = document[this.swfID];
    
    try{
        if(!this.dataStr)
            return;
        ddzSwf.ddzUpdate(this.dataStr);             
    }catch(E)
    {
        //alert(E);
    }    
}

znzDDX.prototype.upd2swf = function()
{
      window.setTimeout(this._upd2swf.bind(this), 100);  
}

znzDDX.prototype._update = function()
{
    if(!this.inited || inHqTime())
        this._refresh();
        
    this.timer = window.setTimeout(this._update.bind(this), this.interval);
}

znzDDX.prototype.destroy = function()
{
   if (this.timer){
      window.clearTimeout(this.timer);
   }
   if (this.myAjaj){
      this.myAjaj.destroy();
      this.myAjaj.onComplete = function(){};
   } 
}
znzDDX.prototype._refresh = function()
{
     var args = {
        method : 'get', onComplete : function(rep){
            var ret = rep;
            this.dataStr = ret;
            var retObj = ret.parseJSON();
            
            if(retObj[0] != -1)
            {                
                //alert(retObj.length);
                var div = '';

                div += "<div class='table-title'>&nbsp;&nbsp;&nbsp;数据日期："+retObj[0].substring(0,4)+"-"+retObj[0].substring(4,6)+"-"+retObj[0].substring(6,8);
                div += "</div>";
                
                var totalBuyBillCount = retObj[BUY_CNT_OFFSET + DDX_SUPBIG] + retObj[BUY_CNT_OFFSET + DDX_BIG] + retObj[BUY_CNT_OFFSET + DDX_MID] + retObj[BUY_CNT_OFFSET + DDX_SMALL];
                var totalBuyBillVol = ((retObj[BUY_VOL_OFFSET + DDX_SUPBIG] + retObj[BUY_VOL_OFFSET + DDX_BIG] + retObj[BUY_VOL_OFFSET + DDX_MID] + retObj[BUY_VOL_OFFSET + DDX_SMALL])/100).toFixed(0);
                var avgBuyBillVol;
                if (totalBuyBillCount == 0)
                    avgBuyBillVol = 0.00;
                else
                    avgBuyBillVol = (totalBuyBillVol/totalBuyBillCount).toFixed(1);
                
                div += "<div class='table-title'><table cellpadding=0 cellspacing=0><tr class='hasbtm'><td><font color='red'>委买</font>：</td><td>" +  totalBuyBillCount + "单</td><td>" + totalBuyBillVol + "手</td><td>" + avgBuyBillVol + "手/单</td></tr></table></div>";
                
                div += "<table cellpadding=0 cellspacing=0>";
                div += "<tr class='hasbtm'><td width='20px'><img src='images/ddz_b3.gif'/></td><td>特大</td><td align='right'>" + retObj[BUY_CNT_OFFSET + DDX_SUPBIG] + "单</td><td align='right'>" + (retObj[BUY_VOL_OFFSET + DDX_SUPBIG]/100).toFixed(0)　+ "手</td></tr>";
                div += "<tr class='hasbtm'><td width='20px'><img src='images/ddz_b2.gif'/></td><td>大单</td><td align='right'>" + retObj[BUY_CNT_OFFSET + DDX_BIG] + "单</td><td align='right'>" + (retObj[BUY_VOL_OFFSET + DDX_BIG]/100).toFixed(0)　+ "手</td></tr>";
                div += "<tr class='hasbtm'><td width='20px'><img src='images/ddz_b1.gif'/></td><td>中单</td><td align='right'>" + retObj[BUY_CNT_OFFSET + DDX_MID] + "单</td><td align='right'>" + (retObj[BUY_VOL_OFFSET + DDX_MID]/100).toFixed(0)　+ "手</td></tr>";
                div += "<tr class='hasbtm'><td width='20px'><img src='images/ddz_b0.gif'/></td><td>小单</td><td align='right'>" + retObj[BUY_CNT_OFFSET + DDX_SMALL] + "单</td><td align='right'>" + (retObj[BUY_VOL_OFFSET + DDX_SMALL]/100).toFixed(0)　+ "手</td></tr>";
                div += "</table>";
                
                var totalSellBillCount = retObj[SELL_CNT_OFFSET + DDX_SUPBIG] + retObj[SELL_CNT_OFFSET + DDX_BIG] + retObj[SELL_CNT_OFFSET + DDX_MID] + retObj[SELL_CNT_OFFSET + DDX_SMALL];
                var totalSellBillVol = ((retObj[SELL_VOL_OFFSET + DDX_SUPBIG] + retObj[SELL_VOL_OFFSET + DDX_BIG] + retObj[SELL_VOL_OFFSET + DDX_MID] + retObj[SELL_VOL_OFFSET + DDX_SMALL])/100).toFixed(0);
                var avgSellBillVol;
                if (totalBuyBillCount == 0)
                    avgSellBillVol = 0.00;
                else
                    avgSellBillVol = (totalSellBillVol/totalSellBillCount).toFixed(1);
                    
                div += "<div class='table-title'><table cellpadding=0 cellspacing=0><tr class='hasbtm'><td><font color='green'>委卖</font>：</td><td>" +  totalSellBillCount + "单</td><td>" + totalSellBillVol + "手</td><td>" + avgSellBillVol + "手/单</td></tr></table></div>";
                
                div += "<table cellpadding=0 cellspacing=0>";
                div += "<tr class='hasbtm'><td width='20px'><img src='images/ddz_s3.gif'/></td><td>特大</td><td align='right'>" + retObj[SELL_CNT_OFFSET + DDX_SUPBIG] + "单</td><td align='right'>" + (retObj[SELL_VOL_OFFSET + DDX_SUPBIG]/100).toFixed(0)　+ "手</td></tr>";
                div += "<tr class='hasbtm'><td width='20px'><img src='images/ddz_s2.gif'/></td><td>大单</td><td align='right'>" + retObj[SELL_CNT_OFFSET + DDX_BIG] + "单</td><td align='right'>" + (retObj[SELL_VOL_OFFSET + DDX_BIG]/100).toFixed(0)　+ "手</td></tr>";
                div += "<tr class='hasbtm'><td width='20px'><img src='images/ddz_s1.gif'/></td><td>中单</td><td align='right'>" + retObj[SELL_CNT_OFFSET + DDX_MID] + "单</td><td align='right'>" + (retObj[SELL_VOL_OFFSET + DDX_MID]/100).toFixed(0)　+ "手</td></tr>";
                div += "<tr class='hasbtm'><td width='20px'><img src='images/ddz_s0.gif'/></td><td>小单</td><td align='right'>" + retObj[SELL_CNT_OFFSET + DDX_SMALL] + "单</td><td align='right'>" + (retObj[SELL_VOL_OFFSET + DDX_SMALL]/100).toFixed(0)　+ "手</td></tr>";
                div += "</table>";

			          innerSet($(this.divID), div, null);   
			    
    	          $('realstock-entrust-name').style.display = 'block';			    
                this._upd2swf();			    
            } 
            else
            {
                $('realstock-entrust-name').style.display = 'none';	
            }
                                  
        }.bind(this)
    };
   
    var infoURL = 'http://' + rdmDataDomainNameGet() + '/test/ddz.py/history.znzDo?cmd=' + this.stockCode + '|' + Math.random().toString();  
    this.myAjaj = new Ajaj(infoURL, args); 
    
}

// for stocks indec
var indecVars = {
                    '000001': {'name': '上证指数',  'url': './realstock.php?code=sh000001'},
                    '000002': {'name': 'Ａ股指数',  'url': './realstock.php?code=sh000002'},
                    '000003': {'name': 'Ｂ股指数',  'url': './realstock.php?code=sh000003'},
                    '399001': {'name': '深证成指',  'url': './realstock.php?code=sz399001'},
                    '399002': {'name': '成份Ａ指',  'url': './realstock.php?code=sz399002'},
                    '399003': {'name': '成份Ｂ指',  'url': './realstock.php?code=sz399003'},
                    '000300': {'name': '沪深300',   'url': './realstock.php?code=sh000300'},
                    '000016': {'name': '上证50',    'url': './realstock.php?code=sh000016'},
                    '399005': {'name': '中小板指',  'url': './realstock.php?code=sz399005'},
                    '000908': {'name': '300能源',   'url': './realstock.php?code=sh000908'},
                    '000909': {'name': '300材料',   'url': './realstock.php?code=sh000909'},
                    '000910': {'name': '300工业',   'url': './realstock.php?code=sh000910'},
                    '000911': {'name': '300可选',   'url': './realstock.php?code=sh000911'},
                    '000912': {'name': '300消费',   'url': './realstock.php?code=sh000912'},
                    '000913': {'name': '300医药',   'url': './realstock.php?code=sh000913'},
                    '000914': {'name': '300金融',   'url': './realstock.php?code=sh000914'},
                    '000915': {'name': '300信息',   'url': './realstock.php?code=sh000915'},
                    '000916': {'name': '300电信',   'url': './realstock.php?code=sh000916'},
                    '000917': {'name': '300公用',   'url': './realstock.php?code=sh000917'}, 
                    '399110': {'name': '农林指数',  'url': './realstock.php?code=sz399110'},
                    '399120': {'name': '采掘指数',  'url': './realstock.php?code=sz399120'},
                    '399130': {'name': '制造指数',  'url': './realstock.php?code=sz399120'},
                    '399131': {'name': '食品指数',  'url': './realstock.php?code=sz399131'},
                    '399132': {'name': '纺织指数',  'url': './realstock.php?code=sz399132'},
                    '399133': {'name': '木材指数',  'url': './realstock.php?code=sz399133'},
                    '399134': {'name': '造纸指数',  'url': './realstock.php?code=sz399134'},
                    '399135': {'name': '石化指数',  'url': './realstock.php?code=sz399135'},
                    '399136': {'name': '电子指数',  'url': './realstock.php?code=sz399136'},
                    '399137': {'name': '金属指数',  'url': './realstock.php?code=sz399137'},
                    '399138': {'name': '机械指数',  'url': './realstock.php?code=sz399138'},
                    '399139': {'name': '医药指数',  'url': './realstock.php?code=sz399139'},
                    '399140': {'name': '水电指数',  'url': './realstock.php?code=sz399140'},
                    '399150': {'name': '建筑指数',  'url': './realstock.php?code=sz399150'},
                    '399160': {'name': '运输指数',  'url': './realstock.php?code=sz399160'},
                    '399170': {'name': 'IT指数',    'url': './realstock.php?code=sz399170'},
                    '399180': {'name': '批零指数',  'url': './realstock.php?code=sz399180'},
                    '399190': {'name': '金融指数',  'url': './realstock.php?code=sz399190'},
                    '399200': {'name': '地产指数',  'url': './realstock.php?code=sz399200'},
                    '399210': {'name': '服务指数',  'url': './realstock.php?code=sz399210'},
                    '399220': {'name': '传播指数',  'url': './realstock.php?code=sz399220'},
                    '399230': {'name': '综企指数',  'url': './realstock.php?code=sz399230'}                    
                };
              
var indecLists = {
                   'summary':  ['000001', '000016', '000300',  '399001', '399005', '000002', '000003', '399002', '399003'],
                   'block300': ['000908', '000909', '000910', '000911', '000912', '000913', '000914', '000915', '000916', '000917'],
                   'block399': ['399110', '399120', '399130', '399131', '399132', '399133', '399134', '399135', '399136', '399137', '399138', '399139', '399140', '399150', '399160', '399170', '399180', '399190', '399200', '399210', '399220', '399230']
                };


var indecURLs = {
                   'summary':  '/test/data.py/index.znzDo?cmd=',
                   'block300': '/test/data.py/index300.znzDo?cmd=',
                   'block399': '/test/data.py/index399.znzDo?cmd='   
               }
function znzIndec(divID, interval, indecType, withSort, data, realDomain, targetType)
{
    this.divID = divID;
    this.interval = interval;  
    this.indecType = indecType;  
    this.withSort = withSort; 
    if(data)
        this.data = data.substr(0, data.length -1);;       
    if(realDomain)
        this.realDomain = realDomain;
    
    this.targetType = '_self';    
    if(targetType)
        this.targetType = targetType;
        
    this.inited = false;    
    this._init();    
}

znzIndec.prototype._init = function()
{
    this._update();
    this.inited = true;
}

znzIndec.prototype._update = function()
{
    if(this.data)
    {
        this._set(this.data);
        this.data = null;   
    }
    else
    {
        if(!this.inited || inHqTime())
            this._refresh();
    }
    
    window.setTimeout(this._update.bind(this), this.interval);
}

znzIndec.prototype._refresh = function()
{
     var args = {
        method : 'get', onComplete : function(rep)
        {
            this._set(rep);
        }.bind(this)
    };
   
    var infoURL = 'http://' + rdmDataDomainNameGet() + indecURLs[this.indecType] + Math.random().toString();  
    var myAjaj = new Ajaj(infoURL, args); 
    
}

znzIndec.prototype._set = function(dataStr)
{
    var retObj = dataStr.parseJSON();
    
    var idxList = indecLists[this.indecType];
    
    var dataList = [];
    
    for(var i=0; i< idxList.length; i++)
    {
        var valueStr;
        var rate;                
        var rateStr;
        var inc;
        var dec;
        var keep;
        
        if (retObj[idxList[i]] == null)
        {
            valueStr = 0.00;      
            rate = 0.00;
            rateStr = rate.toFixed(2) + '%';
            inc = 0;
            dec = 0;
            keep = 0;
            
        }
        else
        {
            valueStr = retObj[idxList[i]][0].toFixed(2).toString();      
            rate = (retObj[idxList[i]][0] - retObj[idxList[i]][1])*100/retObj[idxList[i]][1];
            rateStr = rate.toFixed(2) + '%';
            inc = retObj[idxList[i]][2];
            keep = retObj[idxList[i]][3];
            dec = retObj[idxList[i]][4];
        }
        
        var color = 'nocolor';
        if (rate > 0)
            color = 'incolor';
        if (rate < 0)
            color = 'decolor';
         
        dataList.push([idxList[i], color, valueStr, rate, rateStr, inc, keep, dec]);
    
    }
    
    // sort by rate
    if(this.withSort == true)
    {
        function rateCmp(a, b)
        {
            return b[3] - a[3];
        }
        
        dataList.sort(rateCmp);
    }
    
    div = '';
    div += '<table>\n';
    div += ' <tr class=\'hasbtm\'><td>名&nbsp;&nbsp;称</td><td align=\'center\'>指&nbsp;&nbsp;数</td><td align=\'center\' width=\'40px\'>涨跌幅</td><td align=\'right\' width=\'32px\'>上涨</td><td align=\'right\' width=\'32px\'>平盘</td><td align=\'right\' width=\'32px\'>下跌</td></tr>'
    
    var urlPrefix = '';   
    if (this.realDomain)
    {
        urlPrefix = 'http://' + this.realDomain + '/stock/';
    }
    
    for(var i=0; i< dataList.length; i++)
    {
        if(i == idxList.length -1)
            div += '<tr>';
        else
            div += '<tr class=\'hasbtm\'>';
            
        div += '<td><a href=\'' + urlPrefix + indecVars[dataList[i][0]]['url'] + '\' target=\'' + this.targetType + '\'>' + indecVars[dataList[i][0]]['name'] + '</a></td>';
        div += '<td  align=\'right\' class=\'' + dataList[i][1] + '\'>' + dataList[i][2] + '</td>';
        div += '<td  align=\'right\' class=\'' + dataList[i][1] + '\'>' + dataList[i][4] + '</td>';
        div += '<td class=\'incolor\' align=\'right\'>' + dataList[i][5] + '</td>';
        div += '<td align=\'right\'>' + dataList[i][6] + '</td>';
        div += '<td class=\'decolor\' align=\'right\'>' + dataList[i][7] + '</td>';
        
        div += '</tr>\n';
            
    }
    div += '</table>'; 
    innerSet($(this.divID), div, null);                      
                
}

//for ddz sort
function znzDDZSort(divID, interval, ctrID, data)
{
    this.divID = divID;
    interval = interval||60000;
    if (!(interval < 60000))
        interval = 60000;

    this.interval = interval;
    this.ctrID = ctrID;
    this.topOrder = true;
    this.dataObj = null;
    if(data)
        this.data = data.substr(0, data.length -1);
    this.inited = false;
    this._init();    
}

znzDDZSort.prototype._init = function()
{
    if(!$(this.ctrID))
        return;
        
    $(this.ctrID).onclick = function()
    {
        
        if (this.topOrder == true)
        {
            this.topOrder = false;
            $(this.ctrID).innerHTML = '切换至排行前十';
            $(this.ctrID).className = 'incolor';
        }
        else
        {
            this.topOrder = true;
            $(this.ctrID).innerHTML = '切换至排行后十';
            $(this.ctrID).className = 'decolor';
        }
        
        window.setTimeout(this._refresh.bind(this), 100);
        
    }.bind(this)
    
    this._update();
    this.inited = true;
}

znzDDZSort.prototype._update = function()
{
    if(this.data)
    {
        this._set(this.data);
        this.data = null;
    }
    else
    {
        if(!this.inited || inHqTime())
            this._refresh();  
    }
    
    window.setTimeout(this._update.bind(this), this.interval);

}

znzDDZSort.prototype._refresh = function()
{
     var args = {
        method : 'get', onComplete : function(rep)
        {
            
            this._set(rep);
            
        }.bind(this)
    };
   
   
    var infoURL;
    if(this.topOrder == true)
        infoURL = 'http://' + rdmDataDomainNameGet() + '/test/ddz.py/history_top10.znzDo?cmd=' + Math.random().toString();  
    else
        infoURL = 'http://' + rdmDataDomainNameGet() + '/test/ddz.py/history_last10.znzDo?cmd='+ Math.random().toString(); 
      
    var myAjaj = new Ajaj(infoURL, args); 
}

znzDDZSort.prototype._set = function(dataStr){
    
    var retObj = dataStr.parseJSON();

    div = '';
    div += '<table>\n';
    div += ' <tr class=\'hasbtm\'><td class=\'table-center\'>名&nbsp;&nbsp;称</td><td class=\'table-center\'>价&nbsp;&nbsp;格</td><td class=\'table-center\'>&nbsp;主力动向</td></tr>'

    if(retObj[0] == -1)
    {
        return;
    }
    
    for(var i=0; i< retObj.length; i++)
    {
        //if(i == retObj.length -1)
        //    div += '<tr>';
        //else
            div += '<tr class=\'hasbtm\'>';
            
        
        var currValue;
        var lastValue;
        var stockName;
        var stockCode;
        var ddzValue;
        
        
        currValue = retObj[i][4]; 
        lastValue = retObj[i][3];
        if (currValue == null || lastValue == null){
            return;
        }
        stockName = decodeURIComponent(retObj[i][2]);  
        stockCode = retObj[i][0];
        ddzValue = retObj[i][1];  
        
      
        var valueColor = 'nocolor';
        if (currValue > lastValue)
            valueColor = 'incolor';
        if (currValue < lastValue)
            valueColor = 'decolor';
            
        var ddzColor = 'nocolor';
        if (ddzValue > 0)
            ddzColor = 'incolor';
        if (ddzValue < 0)
            ddzColor = 'decolor';
              
        div += '<td class=\'table-left\'><div class=\'stock-name\'><a href=\'./realstock.php?code=sh' + stockCode + '\'>' + stockName + '</a></div></td>';
        div += '<td class=\'' + valueColor + ' table-right\'>' + currValue.toFixed(2).toString() + '</td>';
        div += '<td class=\'' + ddzColor + ' table-right\'>' + ddzValue.toFixed(2).toString() + '</td>';
        
        div += '</tr>\n';
    }
    
    div += '</table>'; 
    innerSet($(this.divID), div, null); 
                 
}

// for ad
function znzAD(divID, ifrmUrl, w, h, mode)
{
    this.divID = divID;
    this.ifrmUrl = ifrmUrl;
    this.w = w;
    this.h = h;
    this.adMode = mode;
    
    this._set();
}

znzAD.prototype._set = function()
{
    //set ad into div
    var adDiv = $(this.divID);
    if (!adDiv) 
        return;
        
    // adMode == 1 means ad code, not iframe
    if(this.adMode && this.adMode == 1)
    {
        activeSet(adDiv, this.ifrmUrl);
    }
    else
    {            
        if (this.ifrmUrl.indexOf('?') != -1)
            this.ifrmUrl = this.ifrmUrl + '&from=' + window.location.host;	
        else
    	      this.ifrmUrl = this.ifrmUrl + '?from=' + window.location.host;
    	      
        adDiv.innerHTML = "<iframe src='" + this.ifrmUrl + "' width='" + this.w + "px' height='" + this.h + "px' marginwidth='0' marginheight='0' frameborder='0' scrolling='no' style='float: left;'></iframe>";
    }

}

// for news from iframe
function znzSummaryNewsFromIframe(divID, newsURL)
{
    this.divID = divID;
    this.newsURL = newsURL;
    this._set();
}

znzSummaryNewsFromIframe.prototype._set = function()
{
    var div = '<iframe src="' + this.newsURL + '" width="100%" height="300px" frameborder="0" scrolling="no"></iframe>';
    innerSet($(this.divID), div, null);
}

// for price table
function znzPriceTable(stockCode, stockType, dataRecvFunc, interval)
{
    this.stockCode = stockCode || '000001';
    this.stockType = stockType || 'sh';
    this.stockURL = this._realURLGet();    
    this.dataRecvFunc = dataRecvFunc || null;
    this.interval = interval;
    
    this.running = false;
    this.inited = false;
    this._init();
}

znzPriceTable.prototype._init = function()
{
    // data update
    this._update();
    this.inited = true;
}

znzPriceTable.prototype._update = function()
{
    if(!this.inited || inHqTime())
        this._refresh();
    
    window.setTimeout(this._update.bind(this), this.interval);
}

znzPriceTable.prototype._refresh = function()
{
     var args = {
        method : 'get', onComplete : function(rep){
            this.dataStr = rep;
            
            // update ui
            this._upd2ui(this.dataStr);
                
        }.bind(this)
    };
   
    var infoURL = this.stockURL + '?cmd=' + this.stockType.toLowerCase() + this.stockCode + '|'  + Math.random().toString(); 
         
    var myAjaj = new Ajaj(infoURL, args); 
    
}

znzPriceTable.prototype._upd2ui = function(dataStr)
{
    var dataObj = dataStr.parseJSON();
    try
    {
        this.dataRecvFunc(dataObj);
    }
    catch(e)
    {
        
    }
}

znzPriceTable.prototype._realURLGet = function()
{
    //return 'http://' + rdmDataDomainNameGet()+ '/test/data.py/quick';
    return 'http://'+rdmDataDomainNameGet()+'/test/data.py/priceTable.znzDo';
}


var znzIdxBlock = function(decDivId, incDivId, interval){
    this.interval = interval;
    this.decDivId = decDivId;
    this.incDivId = incDivId;
    $(decDivId).innerHTML = "加载中...";
    $(incDivId).innerHTML = "加载中...";
    this.running = false;
    this.inited = false;
}

znzIdxBlock.prototype.start = function(){
    if (!this.running){
        this.running = true;
        this._update();
        this.inited = true;
    }    
}

znzIdxBlock.prototype._update = function(){
    
    if(!this.inited || inHqTime())
        this._refresh();
    
    window.setTimeout(this._update.bind(this), this.interval);
}

znzIdxBlock.prototype._refresh = function(){
    var args = {
       method : 'get', onComplete : function(rep){    
            this._set(rep);
        }.bind(this)
    };
     
    var infoURL = 'http://'+rdmDataDomainNameGet()+'/test/board.py/topBoards.znzDo?cmd=' + Math.random().toString();  
    var myAjaj = new Ajaj(infoURL, args); 
}

znzIdxBlock.prototype._setDiv = function(divId, retList){
    var div = "<table>";
    div += '<tr class=\'hasbtm\'><td>名&nbsp;&nbsp;称</td><td align=\'center\' width=\'44px\'>成交(亿)</td><td align=\'right\' width=\'32px\'>上涨</td><td align=\'right\' width=\'32px\'>平盘</td><td align=\'right\' width=\'32px\'>下跌</td><td align=\'center\'>涨跌幅</td></tr>'
    while (retList.length > 10)
        retList.pop();
    for (var i = 0; i < retList.length; i++){
        div += "<tr " + ((i!=retList.length-1)?"class=\'hasbtm\' ":"") + ">";
        div += "<td><a href='newsort.php?&boardNo="+retList[i][0]+"'>"+decodeURIComponent(retList[i][2])+"</a></td>";
        var classN = "nocolor";
        if (retList[i][1][6] > 0)
            classN = "incolor";
        if (retList[i][1][6] < 0)
            classN = "decolor";

        div += "<td align=\'right\' >"+(parseFloat(retList[i][1][5])/10000).toFixed(2)+"</td>";
        div += "<td align=\'right\' class='incolor'>"+(retList[i][1][0])+"</td>";
        div += "<td align=\'right\' class='nocolor'>"+(retList[i][1][1])+"</td>";
        div += "<td align=\'right\' class='decolor'>"+(retList[i][1][2])+"</td>";            
        
        div += "<td align=\'right\' class='"+classN+"'>"+(retList[i][1][6]).toFixed(2) +"%</td>";
        div += "</tr>";
    }
    div += "</table>";
    $(divId).innerHTML = div;
}
        
znzIdxBlock.prototype._set = function(rep){
    var retObj = rep.parseJSON();
    if (retObj["dec"]){
        var retList = retObj["dec"];
        this._setDiv(this.decDivId, retList);
    }
    if (retObj["inc"]){
        var retList = retObj["inc"];
        this._setDiv(this.incDivId, retList);
    }
}

var znzIdxSort = function(keys, count, interval, data){
    this.interval = interval;
    this.count = count;
    this.keys = keys;
    if(data)
        this.data = data.substr(0, data.length -1);
    
    this.inited = false;
    this._init();
    
}
znzIdxSort.prototype._init = function()
{
    this._update();
    this.inited = true;    
}
    
znzIdxSort.prototype._update = function()
{
    if(this.data)
    {
        this._set(this.data);
        this.data = null;    
    }
    else
    {
        if(!this.inited || inHqTime())
            this._refresh();
    }
    
    window.setTimeout(this._update.bind(this), this.interval);
}

znzIdxSort.prototype._refresh = function(){
    var args = {
       method : 'get', onComplete : function(rep){    
            this._set(rep);
        }.bind(this)
    };
     
    var infoURL = 'http://'+rdmDataDomainNameGet()+'/test/sort2.py/sortCover.znzDo?cmd=' + Math.random().toString();  
    var myAjaj = new Ajaj(infoURL, args); 
}

znzIdxSort.prototype._setDiv = function(divId, retList){
    var divText = "";
    for (var i in this.keys){
        if (this.keys[i] && this.keys[i].indexOf && this.keys[i].indexOf(divId)==0){
            divId = i;
            divText = this.keys[i].split(":");
            divText = divText[1];
            break;
        }
    }    

    var div = "";
    div += "<table>\n<tr class=\'hasbtm\'><th class=\'table-center\'>排名</th><th class=\'table-center\'>名&nbsp;&nbsp;称</th><th class=\'table-center\'>价&nbsp;&nbsp;格</th><th class=\'table-center\'>";
    div += divText+"</th></tr>\n";
    while (retList.length > this.count)
        retList.pop();

    for (var i = 0; i < retList.length; i++){
        div += "<tr " + ((i!=retList.length-1)?"class=\'hasbtm\' ":"") + ">";
        div += "<td class='table-center'>"+(i+1)+"</td>";
        var stockcode = retList[i][0].toLowerCase().replace("hq","");
        div += "<td class='table-left'><a href='realstock.php?code="+stockcode+"'>"+decodeURIComponent(retList[i][1])+"</a></td>";
        var classN = "nocolor";
        if (retList[i][2] < retList[i][3])
            classN = "incolor";
        if (retList[i][2] > retList[i][3])
            classN = "decolor";

        div += "<td class='table-right "+classN+"'>"+parseFloat(retList[i][3]).toFixed(retList[i][5]?3:2)+"</td>";

        classN = "nocolor";
        if (divText == "涨跌幅"){
            if (retList[i][4] > 0)
                classN = "incolor";
            if (retList[i][4] < 0)
                classN = "decolor";
            retList[i][4] = retList[i][4].toFixed(2)+"%";
        }else{
            if (divText == "量比"){
                retList[i][4] = retList[i][4].toFixed(2);
            }else{
                retList[i][4] = retList[i][4].toFixed(0)+"万";
            }
        }

        div += "<td class='table-right "+classN+"'>"+(retList[i][4])+"</td>";
        div += "</tr>";
    }
    div += "</table>";
    innerSet($(divId+"_content"), div, null);
}
        
znzIdxSort.prototype._set = function(rep){
    var retObj = rep.parseJSON();
    if (retObj["sz"]){
        var retHash = retObj["sz"];
        for (var r in retHash){
            if (retHash[r].length && retHash[r].length > 4){
                var retList = retHash[r];
                this._setDiv("sz_"+r, retList);
            }
        }
    }
    if (retObj["sh"]){
        var retHash = retObj["sh"];
        for (var r in retHash){
            if (retHash[r].length && retHash[r].length > 4){
                var retList = retHash[r];
                this._setDiv("sh_"+r, retList);
            }
        }
    }
}

function fixHeaderTable(tabledata, fixedRow, fixedCol, displayRow, displayCol, divId, dwidth, dheight, getDataFunc){
    this.getDataFunc = getDataFunc;
    this.tabledata = tabledata;
    this.fixedRow = fixedRow;
    this.fixedCol = fixedCol;
    this.displayRow = displayRow;
    this.displayCol = displayCol;
    this.dwidth = dwidth;
    this.dheight = dheight;

    this.rx = 0;
    this.ry = 0;
    this.div = $(divId);
    this.divId = divId;
    this.dragging = false;
    window[divId+"movefunc"] = this.move.bind(this);
    window[divId+"mousedownfunc"] = this.startdrag.bind(this);

    window.setTimeout(function(){
        if (this.div){
            if (this.div.addEventListener){
                this.div.addEventListener('DOMMouseScroll', this._mousewheel.bind(this), false);
            }
            this.div.onmousewheel = this._mousewheel.bind(this);
        }
    }.bind(this),600);

}

fixHeaderTable.prototype._mousewheel = function(event){
    if (this.stopped)
        return;
    var delta = 0;
    if (!event) /* For IE. */
            event = window.event;
    if (event.wheelDelta) { /* IE/Opera. */
        delta = event.wheelDelta/120;
        if (window.opera)
                delta = -delta;
    } else if (event.detail) { /** Mozilla case. */
        delta = -event.detail/3;
    }
    if (delta){
        window[this.divId+"movefunc"](0,-delta*(delta*delta));
    }
    if (event.preventDefault)
            event.preventDefault();
    event.returnValue = false;
}

fixHeaderTable.prototype._showCol = function(rx, ry){
    if (this.tabledata[ry].length <= rx){
        return "<li>--</li>";
    }

    var div = "<li";
    if (this.tabledata[ry][rx].length > 1){
        div += " class='"+(this.tabledata[ry][rx][1]||"")+"'";
    }
    if (this.tabledata[ry][rx].length > 2){
        div += "><a href='"+(this.tabledata[ry][rx][2]||"").replace(/'/g, "\'")+"'>";
        div += this.tabledata[ry][rx][0]+"</a>";
    }else{
        div += ">"+this.tabledata[ry][rx][0];
    }
    return div+"</li>";
}

fixHeaderTable.prototype._showRow = function(rx, ry){
    if (this.tabledata.length <= ry){
        return "";
    }
    var div = '';
    if(ry%2 == 0 && ry != 0)
        div = '<ul class="huebg">';
    else
        div = '<ul>';
        
    var i = 0;
    for (; i < this.fixedCol; i++){
        div += this._showCol(i, ry);
    } 
    for (; i < this.displayCol; i++){
        div += this._showCol(i+rx, ry);
    }
    div += "</ul>";
    return div;
}

fixHeaderTable.prototype.showBox = function(){
    var rx = this.rx;
    var ry = this.ry;
    var div = "<div class='fixTableMain' style='height:"+this.dheight+"px;width:" + this.dwidth + "px'>";
    div += "<div class='fixTableHeader'>";
    var i = 0;
    for (; i < this.fixedRow; i++){
        div += this._showRow(rx, i);
    }
    div += "</div>";
    div += "<div class='fixTableBody'>";
    for (; i < this.displayRow&&(i+ry<this.tabledata.length) ; i++){
        var tmp = this._showRow(rx, ry+i);
        div += tmp;
    }
    div += "</div></div>";
    return div;
}

fixHeaderTable.prototype.showTable = function(notupdate){
    if (this.stopped)
        return;
    var div = this.olddiv||"";
    if (!notupdate){
        div = this.showBox();
        this.olddiv = div;
    }
    div += "<div class='fixTableLeftScroll' style='height:"+this.dheight+"px'>";
    div += this._showLeftBar(this.ry);
    div += "</div>";
    div += "<div class='fixTableBottomScroll'>";
    div += this._showBottomBar(this.rx);
    div += "</div>";

    innerSet(this.div, div, null);
    return div;
}

fixHeaderTable.prototype._showLeftBar = function(ry){
    var div = "<ul>";
    var totallen = this.tabledata.length;
    if (totallen < this.displayRow){
        totallen = this.displayRow;
    }
    var heightc = ((this.dheight-36)/totallen);
    var barheight = heightc*this.displayRow;
    if (barheight < 20){
        barheight = 20;
    }
    if (totallen - this.displayRow > 0)
        heightc = (this.dheight-36-barheight)/(totallen - this.displayRow);
    else{
        barheight = this.dheight-36;
        heightc = 0;
    }
    this.oneheight = heightc;
    var liwidth = (this.dheight-barheight-(heightc*(totallen - this.displayRow)))/2;

    div += "<li style='height: "+liwidth+"px;' class='fixtable-up' onclick='window[\""+this.divId+"movefunc\"](0,-1);'><div></div></li>";

    var direction = 0-(this.displayRow-2);
    if (ry > 0)
        div += "<li style='height: "+(heightc*(ry))+"px;' class='fixtable-bg' onclick='window[\""+this.divId+"movefunc\"](0,"+direction+");'></li>";
    div += "<li id='scrollleftblock"+this.divId+"' style='height: "+(barheight)+"px;' class='fixtable-bar' onmousedown='window[\""+this.divId+"mousedownfunc\"](1, this.id, arguments);return false;'><div></div></li>";
    direction = this.displayRow-2;
    if (totallen > (ry+this.displayRow))
    div += "<li style='height: "+(heightc*(totallen-(ry+this.displayRow)))+"px;' class='fixtable-bg' onclick='window[\""+this.divId+"movefunc\"](0,"+direction+");'></li>";
    
    div += "<li style='height: "+liwidth+"px;' class='fixtable-down' onclick='window[\""+this.divId+"movefunc\"](0,1);'><div></div></li>";
    return div+"</ul>";
}

fixHeaderTable.prototype._showBottomBar = function(rx){
    var div = "<ul>";
    var totallen = this.tabledata[0].length;
    if (totallen <= 0){
        totallen = 1;
    }
    var heightc = ((this.dwidth-36)/totallen);
    var liwidth = (this.dwidth-(heightc*totallen))/2;
    this.onewidth = heightc;
    
    div += "<li style='width: "+liwidth+"px;' class='fixtable-left' onclick='window[\""+this.divId+"movefunc\"](-1, 0);'><div></div></li>";

    var direction = 0-(this.displayCol-2);
    if (rx > 0)
        div += "<li style='width: "+(heightc*(rx))+"px;' class='fixtable-bg2' onclick='window[\""+this.divId+"movefunc\"]("+direction+",0);'></li>";
    div += "<li id='scrollleftblock' style='width: "+(heightc*this.displayCol)+"px;' class='fixtable-bar2' onmousedown='window[\""+this.divId+"mousedownfunc\"](0, this.id, arguments);return false;'><div></div></li>";
    direction = this.displayCol-2;
    if (totallen > (rx+this.displayCol))
    div += "<li style='width: "+(heightc*(totallen-(rx+this.displayCol)))+"px;' class='fixtable-bg2' onclick='window[\""+this.divId+"movefunc\"]("+direction+",0);'></li>";

    div += "<li style='width: "+liwidth+"px;' class='fixtable-right' onclick='window[\""+this.divId+"movefunc\"](1, 0);'><div></div></li>";
    return div+"</ul>"
}

fixHeaderTable.prototype.move = function(mx, my, notupdate){
    if(isNaN(my))
    {
        return;
    }
    
    this.rx += mx;
    this.ry += my;

    if (this.rx < 0) this.rx = 0;
    var totallen = this.tabledata[0].length-this.displayCol;
    if (totallen < 0){
        totallen = 0;
    }
    if (this.rx > totallen) this.rx = totallen;
    
    if (this.ry < 0) this.ry = 0;
    totallen = this.tabledata.length-this.displayRow;
    if (totallen < 0){
        totallen = 0;
    }
    if (this.ry > totallen) this.ry = totallen;
    
    if (!notupdate){
        for (var i = this.ry; i-this.ry < this.displayRow&&(i+this.fixedRow<this.tabledata.length) ; i++){
            if (this.tabledata[i].length == 0){
                if (this.getDataFunc){
                    //refetch data
                    window.setTimeout(function(){
                        this.getDataFunc(i);
                        this.showTable();
                    }.bind(this), 100);
                    return "fail";
                }
            }
        }
    }    
    this.showTable(notupdate);
}

fixHeaderTable.prototype.setTableData = function(tabledata){
    this.tabledata = tabledata;
}

fixHeaderTable.prototype.getMsPosition = function (ev){
        ev = ev||window.event;
        var pos = {};
        if (this.isUpdown){
            pos.y = ev.pageY || (ev.clientY +
                   (document.documentElement.scrollTop || document.body.scrollTop));
        }else{
            pos.y = ev.pageX || (ev.clientX +
               (document.documentElement.scrollLeft || document.body.scrollLeft));
        }
        return pos;
};


fixHeaderTable.prototype.startdrag = function(isUpdown, elemid,  ev){
    ev = ev[0];
    if ((ev&&(ev.button != 0))||((!ev)&&(window.event.button != 1)))
        return;  // not left click
    
    if (typeof(document.onselectstart) != "undefined")
        document.onselectstart = function (){return false};

    
    this.backupDocument = document.onmouseup;
    this.backupDocument2 = document.onmousemove;
    this.dragging = true;
    this.isUpdown = isUpdown;
    this.moveDirect = 0;
    var pos = this.getMsPosition(ev);
    var tpos = this.getPosition($(elemid));
    this.pos = pos;
    this.diff = tpos-pos.y;
    this.elemid = elemid;
    document.onmouseup = function(){
        if (typeof(document.onselectstart) != "undefined")
            document.onselectstart = function (){return true};

        this.dragging = false;
        this.move(0, 0);
        document.onmouseup = this.backupDocument;
        document.onmousemove = this.backupDocument2;
    }.bind(this);
    document.onmousemove = function(ev){
        if (this.dragging){
            this.pos = this.getMsPosition(ev);
        }
    }.bind(this);
    window.setTimeout(this.drag.bind(this), 10);
}


fixHeaderTable.prototype.drag = function(isUpdown, ev){
    if (this.dragging){
        var tpos = this.getPosition($(this.elemid));
        var diff2 = tpos-this.pos.y;

        if (this.isUpdown){
            if (diff2-this.diff < 0-this.oneheight){
                this.move(0, parseInt((this.diff-diff2)/this.oneheight), true);
            }
            if (diff2-this.diff > this.oneheight){
                this.move(0, parseInt((this.diff-diff2)/this.oneheight), true);
            }
        }else{
            if (diff2-this.diff < -this.onewidth){
                this.move(parseInt((this.diff-diff2)/this.onewidth), 0, true);
            }
            if (diff2-this.diff > this.onewidth){
                this.move(parseInt((this.diff-diff2)/this.onewidth), 0, true);
            }
        }
        this.moveDirect = 0;
        window.setTimeout(this.drag.bind(this), 10);
    }
};

fixHeaderTable.prototype.getPosition = function (e){
	var left = 0;
	var top  = 0;
	//while (e!=null)
	while (e!=null)
	{
		left += e.offsetLeft;
		top  += e.offsetTop;
		e     = e.offsetParent;
	}
	if (this.isUpdown){
	    return top;
	}else{
	    return left;
	}
};



var Passport = function(){
}

Passport.prototype.passportObj = {};
Passport.prototype.passportGet = false;
Passport.prototype.logined = false;

Passport.prototype.isPassportGet = function(){
    return Passport.prototype.passportGet;
}

Passport.prototype.isLogin = function(){
    return Passport.prototype.logined;
}

Passport.prototype._reset = function(){
    Passport.prototype.passportObj = {};
    Passport.prototype.passportGet = false;
    Passport.prototype.logined = false;
}

Passport.prototype.logout = function(callback){
    this._reset();
    var args = {
        method : 'get',
        onComplete : function(rep){
            if (callback)
                callback(Passport.prototype.logined, rep.responseText);
        }.bind(this)
    };
    
    var infoURL = 'logout.php'; 
    var myAjax = new Ajax(infoURL, args);
    
}

Passport.prototype.login = function(passport, passwd, timestamp, callback){
    this._reset();
    var args = {
        method : 'post',
        parameters: 'passport='+passport+'&passwdMd5='+passwd+'&timestamp='+timestamp,
        onComplete : function(rep){
            if (rep.responseText == 'OK'){
                Passport.prototype.logined = true;
                this.getPassport();
            }else{
                Passport.prototype.logined = false;
            }
            if (callback)
                callback(Passport.prototype.logined, rep.responseText);
        }.bind(this)
    };
    
    var infoURL = 'userlogin.php?action=submit'; 
    var myAjax = new Ajax(infoURL, args);
}

Passport.prototype.register = function(passport, passwd, callback){
    this._reset();
    var args = {
        method : 'post',
        parameters: 'passport='+passport+'&passwd='+passwd,
        onComplete : function(rep){
            if (rep.responseText == 'OK'){
                Passport.prototype.logined = true;
                this.getPassport();
            }else{
                Passport.prototype.logined = false;
            }
            if (callback)
                callback(Passport.prototype.logined, rep.responseText);
        }.bind(this)
    };
    
    var infoURL = 'userregister.php?action=submit'; 
    var myAjax = new Ajax(infoURL, args);
}


Passport.prototype.getPassport = function(){ 
    var args = {
        method : 'get', onComplete : function(rep){
            this.parsePassport(rep.responseText);
        }.bind(this)
    };
    
    var infoURL = 'userprofile.php?action=get&cmd=' + Math.random().toString(); 

    var myAjax = new Ajax(infoURL, args);
    //timeout after 10s
    this.getTimer = window.setTimeout(this.ontimeout.bind(this), 10000);
}

Passport.prototype.setPassport = function(callback){ 
    var args = {
        method : 'post',
        parameters : 'profile=' + Passport.prototype.passportObj.toJSONString(),
        onComplete : function(rep){
            if (rep.responseText != "OK"){
                Passport.prototype.logined = false;
            }
            if (callback)
                callback(Passport.prototype.logined, rep.responseText);
        }.bind(this)
    };
    
    var infoURL = 'profUpd.php?&cmd='+ Math.random().toString(); 

    var myAjax = new Ajax(infoURL, args);
}

Passport.prototype.ontimeout = function(){ 
    Passport.prototype.passportGet = true;
}

Passport.prototype.parsePassport = function(passportStr){ 
    if (this.getTimer)
        window.clearTimeout(this.getTimer);
    this._reset();
    if ((typeof passportStr != "undefined")&&(passportStr != "fail")){
        Passport.prototype.logined = true;
        try{
            Passport.prototype.passportObj = passportStr.parseJSON();
        }catch(E){
            Passport.prototype.passportObj = {};
        }        
    }else{
        Passport.prototype.logined = false;
    }
    Passport.prototype.passportGet = true;
}

Passport.prototype.getType = function(typename){
    if (typeof Passport.prototype.passportObj[typename] == "undefined"){
        return null;
    }else{
        return Passport.prototype.passportObj[typename];
    }
}

Passport.prototype.setType = function(typename, val){
    Passport.prototype.passportObj[typename] = val;

}

var znzMyStock = function(divID, interval, varName, code, addDivid, setFunc)
{
    this.divID = divID;
    this.interval = interval;
    this.running = true;
    this.mystock = [];
    this.stocknames = {};
    this._set = setFunc || this._set;
    this.mAddDivID = addDivid || null;
    this.getUrl = './profile.php';
    this.setUrl = './profUpd.php?profile=';
    this.mTimer = null;
    this.mVarName = varName;
    this.mCode = code ? code.toLowerCase() : null ;
    this.mUp = false;
    this.mCurSortedCol = null;
    this.mStockData = [];
    this.mRetObj = null;
    this.mInited = false;
    this.mForce = true;
    this.mSelStates = {};
    this.mFirst = true;
    this._init();
    
}

znzMyStock.prototype._init = function(){
    this.mInited = true; 
    this._getMyStock();
}

znzMyStock.prototype._cmp = function(a, b)
{
    if(!this.mUp)
    {
        if(typeof a[this.mCurSortedCol] == "string")
        {
            return b[this.mCurSortedCol].localeCompare(a[this.mCurSortedCol]);
        }
        else
        {
            return b[this.mCurSortedCol] - a[this.mCurSortedCol];//asc
        } 
    }
    else
    {
        if(typeof a[this.mCurSortedCol] == "string")
        {
            return a[this.mCurSortedCol].localeCompare(b[this.mCurSortedCol]);
        }
        else
        {
            return a[this.mCurSortedCol] - b[this.mCurSortedCol];//des
        } 
        
    }
}

znzMyStock.prototype._getMyStock = function()
{
    var args = {
        method : 'post',
        onComplete : this._getMyStockCallBack.bind(this)
    };
    var ajax = new Ajax(this.getUrl, args);
}

znzMyStock.prototype._getMyStockCallBack = function(rep)
{
    repStr = rep.responseText;
    if(repStr == '{}')
    {
        $(this.mAddDivID).style.display = "";
        this.mystock = [];
        return;
    }
    
    try
    {
        this.mystock = repStr.parseJSON();
    }
    catch(E)
    {
        this.mystock = [];
        $(this.mAddDivID).style.display = "";
        return;
    }
    
    if(this.mystock.length && this.mystock.length == 0)
    {
        $(this.mAddDivID).style.display = "";
        return;
    }
    
    if(this.mAddDivID && this.mystock.indexOf(this.mCode) < 0)
    {
        $(this.mAddDivID).style.display = "";
    }
    this._getMyStockName(this._update.bind(this));
}

znzMyStock.prototype._getMyStockName = function(addCallBack){
    var args = {
        method : 'post', 
        onComplete :function(rep){
             this._getMyStockNameCallBack(rep);
             
             if(addCallBack)
             {                 
                 addCallBack()
             }
        }.bind(this)
    };
 
    var infoURL = '';
    for(var i = 0; i < this.mystock.length; i++)
    {   
        if(! this.stocknames[this.mystock[i].toLowerCase()])            
            infoURL += this.mystock[i].toLowerCase() + ',';
    }
    
    infoURL = 'http://' + rdmDataDomainNameGet() + '/test/sCode.py/get.znzDo?cmd=' + infoURL + '|' + Math.random().toString();  
    var myAjaj = new Ajaj(infoURL, args); 
}
znzMyStock.prototype._getMyStockNameCallBack = function(rep)
{
    var ret = rep; 
      
    var retObj = ret.parseJSON();
    for(var i = 0; i < this.mystock.length; i++)
    {
        if(retObj[this.mystock[i].toLowerCase()])
        {                    
            this.stocknames[this.mystock[i].toLowerCase()] = decodeURIComponent(retObj[this.mystock[i].toLowerCase()]);
        }
    }
}

znzMyStock.prototype._update = function(force)
{
    if(this.mTimer)
        window.clearTimeout(this.mTimer);
    if(this.mForce || !this.mInited || inHqTime())
    {
        this.mForce = false;
        this._refresh();
    }
    this.mTimer = window.setTimeout(this._update.bind(this), this.interval);    
}

znzMyStock.prototype._refresh = function()
{
    //get stock values from server
    if(this.mystock && this.mystock.length >=1)
    {
        var args = {
            method : 'post', onComplete : function(rep){                
                this._set(rep);
            }.bind(this)
        };
      
        var infoURL = '';
        for(var i = 0; i< this.mystock.length; i++)
        {   
            infoURL += this.mystock[i].toLowerCase() + ',';
        }
        infoURL = 'http://' + rdmDataDomainNameGet()+ '/test/data.py/prices.znzDo?cmd=' + infoURL + '|' + Math.random().toString();  
        var myAjaj = new Ajaj(infoURL, args);          
    }
    else{
        this._set();
    }
}

znzMyStock.prototype._set = function(rep){
    var ret = rep || "[]";  
    
    this.mRetObj = ret.parseJSON();
    this.mStockData = [];
    for(var i = 0; i < this.mystock.length; i++)
    {
        var curValue;
        var curRate;
        
        var row = [this.mystock[i], this.stocknames[this.mystock[i]]];
        if(this.mRetObj[this.mystock[i]])
        {   
            var oneStockData = this.mRetObj[this.mystock[i]];

            if (oneStockData[2] == 0)
            {
                curValue = 0;       
                curRate = 0.00;
            }
            else
            {
                curValue = oneStockData[2];
                var diff = oneStockData[2] - oneStockData[1];
                if(oneStockData[1] != 0)
                    curRate = diff * 100 / oneStockData[1];
                else
                    curRate = 0.00;
            }
        }
        else
        {
            curValue = 0; 
            curRate = 0.00;
        }
        row.push(curValue);
        row.push(curRate);
        this.mStockData.push(row);
    }
    this._setTable(); 
}

znzMyStock.prototype._setTable = function()
{
    var div = '<table>\n<tr class=\'hasbtm\'><td class=\'table-center\'>名&nbsp;&nbsp;称</td><td class=\'table-center\'>价&nbsp;&nbsp;格</td><td class=\'table-center\'>涨跌幅</td></tr>\n';
    for(var i = 0; i < this.mystock.length; i++)
    {
        var color = 'nocolor';
        var nfix = 2;
        var curValue;
        var curRate;
        
        if(this.mRetObj[this.mystock[i]])
        {   
            var oneStockData = this.mRetObj[this.mystock[i]];     
            if (oneStockData[0] == 1)
                nfix = 3;
                
            if(oneStockData[2] > oneStockData[1])
                color = 'incolor';
            if(oneStockData[2] < oneStockData[1])
                color = 'decolor';

            div += '<tr class=\'hasbtm\'>';

            if (oneStockData[2] == 0)
            {
                curValue = '--';       
                curRate = '--%';
                color = 'nocolor';
            }
            else
            {
                curValue = oneStockData[2].toFixed(nfix).toString();
                var diff = oneStockData[2] - oneStockData[1];
                if(oneStockData[1] != 0)
                    curRate = (diff * 100 / oneStockData[1]).toFixed(nfix).toString() + '%';
                else
                    curRate = "0.00%";
                if (diff > 0)
                    curRate = "+" + curRate;
            }
        }
        else
        {
            curValue = '--'; 
            curRate = '--%';
            color = 'nocolor';
        }
        
        div += '<td class=\'table-left\'><div class=\'stock-name\'><a href=\'./realstock.php?code=' + this.mystock[i].toLowerCase() + '\' >' + this.stocknames[this.mystock[i]] + '</a></div></td>';
        div += '<td class = \'' + color + ' table-right\'>' + curValue + '</td>';
        div += '<td class = \'' + color + ' table-right\'>' + curRate  + '</td>';
        div += '</tr>\n'
    }    
    
    div += '</table>';
    if (this.running)
        innerSet($(this.divID), div, null);
    
    if(typeof defaultShowMyStock == 'function' && this.mFirst)
    {
        defaultShowMyStock();
        this.mFirst = false;
    }
}

znzMyStock.prototype.addStock = function(scode, stockName){
    
    if(this.mystock.length >= 20)
    {
        alert('您自选股中股票数已达到最大上限【20只】！');
        return false;
    }
    this.mForce = true;
    var idx = this.mystock.indexOf(scode);
    if(idx >= 0)
    {
        this.mystock.remove(idx);
    }
    
    // stop update right now
    if(this.mTimer)
        window.clearTimeout(this.mTimer);
    
    this.mystock.unshift(scode);
    if(stockName)
    {
        this.stocknames[scode] = stockName;
        this.sendToServer();
    }
    else
    {
        this._getMyStockName(this.sendToServer.bind(this));
    }
    return true; 
}

znzMyStock.prototype.delStocks = function(stockCodes)
{
    var removeAtLastOne = false;
    var i = 0;
    for(i = 0; i < stockCodes.length; i ++)
    {
        removeAtLastOne |= this._removeStock(stockCodes[i]);
    }
    if(removeAtLastOne)
    {
        this.sendToServer(this._setTable.bind(this));
    }
}

znzMyStock.prototype._removeStock = function(stockCode)
{
    var idx = this.mystock.indexOf(stockCode);
    if(idx >= 0)
    {
        this.mystock.remove(idx);
        delete this.stocknames[stockCode];
        delete this.mSelStates[stockCode];
        this.mStockData.remove(idx);
        return true;
    }
    else
    {
        return false;
    }
}

znzMyStock.prototype.up = function(stockCode, stepNum)
{
    var idx = this.mystock.indexOf(stockCode);
    if(idx >= 0)
    {
        var i;
        for(i = idx; i > 0 && i > (idx - stepNum); i --)
        {
            this.mystock[i] = this.mystock[i - 1];
        }
        this.mystock[i] = stockCode;
        this.sendToServer(this._setTable.bind(this));
    }
}

znzMyStock.prototype.down = function(stockCode, stepNum)
{
    var idx = this.mystock.indexOf(stockCode);
    if(idx >= 0)
    {
        var i;
        for(i = idx; i < (this.mystock.length - 1) && i < (idx + stepNum); i ++)
        {
            this.mystock[i] = this.mystock[i + 1];
        }
        this.mystock[i] = stockCode;
        this.sendToServer(this._setTable.bind(this));
    }
}
znzMyStock.prototype.delStock = function(stockCode)
{    
    if(!confirm("您确认要删除:" + this.stocknames[stockCode]+ "(" + stockCode.substr(2) + ")?"))
        return;
    if(this._removeStock(stockCode))
    {
        this.sendToServer(this._setTable.bind(this));
    }    
}

znzMyStock.prototype.sendToServer = function(callBack)
{    
    var codeStr = this.mystock.toJSONString();
    var requestURL = this.setUrl + codeStr;
    var callBackFunc = callBack || this._sendCallBack;
    var args = {
        method:"get",
        onComplete: callBackFunc.bind(this)
    };
    var send = new Ajax(requestURL, args);
}

znzMyStock.prototype._sendCallBack = function(rep)
{
    var repStr = rep.responseText;
    if(repStr == "OK")
        this._update();
}

znzMyStock.prototype.sort = function(colNum)
{
    if(this.mCurSortedCol == colNum)
    {
        this.mUp = !this.mUp;
    }
    else
    {
        this.mCurSortedCol = colNum;
        this.mUp = false;
    }
    
    this.mStockData.sort(this._cmp.bind(this));
    var tmpArr = [];
    var len = this.mStockData.length;
    for(var i = 0; i < len; i ++)
    {
        tmpArr.push(this.mStockData[i][0]);
    }
    this.mystock = tmpArr;

    this._setTable();
    this.sendToServer();    
}

znzMyStock.prototype.selStateSet = function(selStatesObj)
{
    this.mSelStates = selStatesObj;
}

znzMyStock.prototype.stateSet = function(stockCode, state)
{
    if(this.mSelStates == null)
    {
        this.mSelStates = {};
    }
    this.mSelStates[stockCode] = state;
}

znzMyStock.prototype.showSwf = function(marketCode, force, offsetOfY)
{
    if(this.mShowMarketCode == marketCode && !force)
    {
        return;
    }
    else
    {
        if(this.mShowMarketCode)
            this.hiddenSwf();
        this.mShowMarketCode = marketCode;
        //if(this.mShowTimer)
          //  window.clearTimeout(this.mShowTimer);
        //this.mShowTimer = window.setTimeout(this.hiddenSwf.bind(this), 2000);
    }
    
    var obj;
    if(obj = $('stock-chart'))
    {
        offsetOfY = offsetOfY || 26;
        this.hasMouseOver = true;
        var arrIndex = this.mystock.indexOf(marketCode);
        obj.style.left = "150px";
        obj.style.top = ((arrIndex + 1) * offsetOfY + 18) + "px";
        var jumpUrl = "http://" + http_host + "/stock/realstock.php?code=" + marketCode;        
        jumpUrl = encodeURIComponent(jumpUrl);
        obj.className = "swfshow";       
        obj.innerHTML = '<object id="flashchart_f_small" onmouseover="' + this.mVarName+ '.mouseOver()" onmouseout="' + this.mVarName+ '.mouseOut()" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0" accesskey="f" title="stock chart" width="192" height="96"> <param name="movie" value="http://www.znz888.com/stock/swf/znzYahooRealMod.swf?code=' + marketCode + '&jump=1&url=' + jumpUrl + '"> <param name="quality" value="high"> <param name="wmode" value="opaque"> <param name="allowScriptAccess" value="always"> <embed src="http://www.znz888.com/stock/swf/znzYahooRealMod.swf?code=' + marketCode + '&jump=1&url=' + jumpUrl + '" quality="high" pluginspage="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" allowscriptaccess="always" flashvars="code=' + marketCode + '&jump=1&url=' + jumpUrl + '" type="application/x-shockwave-flash" wmode="opaque" width="192" border="0" height="96"> </object>';
    }
}

znzMyStock.prototype.hiddenSwf = function()
{   
    if(this.hasMouseOver)
        return;
    var obj;
    if(obj = $('stock-chart'))
    {
        obj.className = "hidden";
        obj.innerHTML = '';
        this.mShowMarketCode = null;
    }
}

znzMyStock.prototype.mouseOver = function()
{
    this.hasMouseOver = true;
    if(this.mShowTimer)
        window.clearTimeout(this.mShowTimer);
}

znzMyStock.prototype.mouseOut = function()
{
    this.hasMouseOver = false;
    if(this.mShowTimer)
        window.clearTimeout(this.mShowTimer);
    this.mShowTimer = window.setTimeout(this.hiddenSwf.bind(this), 500);
}

// for F10
function znzF10(divID, stockCode, stockType, data)
{
    this.divID = divID;
    this.stockCode = stockCode || '000001';
    this.stockType = stockType || 'SH';
    if(data)
        this.data = data;
    this._init();
}

znzF10.prototype._init = function()
{
    if(!this.data)
        return;

    var infoarr = this.data.parseJSON();
    
    if(infoarr.length == 1 && infoarr[0] == -1)
        return;
        
    btm = "hasbtm";
    var inne = "<table><tr>";
    for(var i = 0; i < infoarr.length; i++){
      if (i % 2 == 0 && i > 0){
        inne += "</tr><tr>";
      }

      inne += "<td><a target='_blank' href='F10.php?code="+this.stockType.toLowerCase() + this.stockCode+"&type="+infoarr[i][1]+"'>"+decodeURIComponent(infoarr[i][0])+"</a></td>";
    }
    inne += "</tr></table>";
    if (infoarr.length % 2 == 1){
      inne += "<td></td>";
    }

    $(this.divID + "-table").innerHTML = inne;
    if($(this.divID))
    {
        $(this.divID).style.display = "block";
    }
}

//for board
function znzBoard(divID, interval, stockCode, stockType, data, setFunc)
{
    this.divID = divID;
    this.interval = interval;
    this.stockCode = stockCode || '000001';
    this.stockType = stockType || 'SH';
    if(data)
        this.data = data.substr(0, data.length -1);
    this._set = setFunc || this._set;
    
    this.inited = false;
    this._init();
}

znzBoard.prototype._init = function()
{
    this._update();
    this.inited = true;
}

znzBoard.prototype._update = function()
{
    if(this.data)
    {
        this._set(this.data);
        this.data = null;    
    }
    else
    {
        if(!this.inited || inHqTime())
            this._refresh();
    }
    
    window.setTimeout(this._update.bind(this), this.interval);
}

znzBoard.prototype._refresh = function()
{
    var args = {
       method : 'get', onComplete : function(rep){    
            this._set(rep);
        }.bind(this)
    };
    
    var infoURL = 'http://' + rdmDataDomainNameGet() + '/test/board.py/stockBoards?cmd='+ this.stockType + 'HQ' + this.stockCode + '|' + Math.random().toString();  
    var myAjaj = new Ajaj(infoURL, args); 
}

znzBoard.prototype._set = function(dataStr)
{
    if(!dataStr)
        return;
        
    var infoObj = dataStr.parseJSON();
    
    if(infoObj.length == 1 && infoObj[0] == -1)
        return;
        
    var boardList = [];
    for(var i in infoObj){
        if (i != "toJSONString")
        {
            boardList.push([i, infoObj[i][0], infoObj[i][1]]);
        }    
    }  
    
    function rateCmp(a, b)
    {
        return b[2] - a[2];
    }
        
    boardList.sort(rateCmp);
    
    var inne = "<table>";
    for(var i = 0; i< boardList.length; i++)
    {
        btm = "hasbtm";
        if(i == boardList.length -1)
            btm = "";
        inne += "<tr class='" + btm + "'><td><a href='newsort.php?boardNo="+ boardList[i][0] +"&high="+this.stockType + "HQ" + this.stockCode+"'>"+decodeURIComponent(boardList[i][1])+"</a></td>";
        color = "incolor";
        if(boardList[i][2] < 0)
          color = "decolor";
        inne += "<td class='" + color + "'>" + boardList[i][2].toFixed(2) + "%</td></tr>"
    }
    
    inne += "</table>";
    $(this.divID + "-table").innerHTML = inne;
    if($(this.divID))
    {
        $(this.divID).style.display = "block";
    }
}
// for kline
function znzKLine(kLineType, swfID, divID, indList, stockCode, stockType, stockName, swfWidth, swfHeight)
{
    this.running = false;
    this.kLineType = kLineType;
    this.swfID = swfID;
    this.divID = divID;
    this.indList = indList;
    this.stockCode = stockCode || '000001';
    this.stockType = stockType || 'SH';
    this.stockName = stockName || '上证指数';
    this.swfWidth = swfWidth || 0;
    this.swfHeight = swfHeight || 0;
    
    this._init();
}

znzKLine.prototype._init = function()
{

    window.setTimeout(this._start.bind(this), 100);
}

znzKLine.prototype._start = function()
{    
    var kLineSwf = $(this.swfID);
    if(!kLineSwf)
        kLineSwf = document[this.swfID];

    try{ 
        if(typeof logoShow == "undefined")
            logoShow = true;
            
        kLineSwf.start(rdmDataDomainNameGet(), this.kLineType, this.stockCode, 
            this.stockType + "HQ", this.stockName, this.indList,
            ["k-day-current"], 1, 1, 0.12, this.swfWidth, this.swfHeight, logoShow);
        this.running = true; 
                
    }catch(E)
    {
        //alert(E);
        this.running = false;
        
    }
    
    if(this.running == false)
        window.setTimeout(this._start.bind(this), 1000);
        
}

znzKLine.prototype.update = function(dataStr)
{    
    if (!this.running)
        return false;
    var kLineSwf = $(this.swfID);
    if(!kLineSwf)
        kLineSwf = document[this.swfID];

    try{
        kLineSwf.update("k-day-current", dataStr);
    }catch(E){
        return false;
    }
    return true;
}

znzKLine.prototype.restart = function(kLineType, stockCode, stockType, stockName)
{
    this.kLineType = kLineType || this.kLineType;
    this.stockCode = stockCode || this.stockCode;
    this.stockType = stockType || this.stockType;
    this.stockName = stockName || this.stockName;
    
    var kLineSwf = $(this.swfID);
    if(!kLineSwf)
        kLineSwf = document[this.swfID];
    
    try{    
        kLineSwf.restart(rdmDataDomainNameGet(), this.kLineType, this.stockCode, this.stockType + 'HQ', this.stockName, this.indList, ["k-day-current"], 1, 1, 0.12, this.swfWidth, this.swfHeight, logoShow);
        this.running = true;   
    }catch(E)
    {
        //alert(E);
        this.running = false;
    }
    
}

znzKLine.prototype.indAdd = function(indicator)
{
    this.indList.push(indicator);
    this._indSet();

}

znzKLine.prototype.indRemove = function(indicator)
{
    for(var i=0; i< this.indList.length; i++)
    {
       if(indicator == this.indList[i])
       {
            this.indList.remove(i); 
       }
    }

    this._indSet();    
}

znzKLine.prototype._indSet = function()
{  
    var kLineSwf = $(this.swfID);
    if(!kLineSwf)
        kLineSwf = document[this.swfID];
    if(this.running == true)
    {
        try{
            kLineSwf.indset(this.indList);
        }catch(E)
        {
            //alert(E);
            //window.setTimeout(this._update.bind(this), 100);
        }
    }
    else
         window.setTimeout(this._indSet.bind(this), 1000);
}

// for finance data

var finTypes = 
[
    ["totalEquity", "总股本(万股)"], 
    ["tq", "流通盘(万股)"], 
    ["PE", "动态市盈率"],
    ["PB", "动态市净率"],
    ["inPerSecDr", "年化每股收益(元)"],
    ["quarterInPerSec", "季报每股收益(元)"],
    ["midInPerSec", "中报每股收益(元)"],
    ["yearInPerSec", "年报每股收益(元)"],
    ["netCapitalPerSec", "每股净资产(元)"], 
    ["nAssiProfitPerSec", "每股未分配利润(元)"],
    ["capitalAccuPerSec","每股资本公积金(元)"],
    ["netProfitAscRatio", "净利润增长率(%)"],
    ["netCapitalRatio", "净资产收益率(%)"],
    ["mainOpRatio", "主营业务增长率(%)"]    
];

var infoTypes = 
[
    ["chinaName", "公司全称"],
    ["marketDate", "上市日期"], 
    ["regAddr", "注册地址"],
    ["market", "上市地点"], 
    ["legalPerson", "法人代表"],
    ["directorateSecretary", "董事会秘书"],
    ["contactNumber", "电话"],
    ["fax", "传真"],
    ["webAddr", "信息披露网址"],
    ["email", "电子邮箱"]
];

function znzFinance(divID, data)
{
    this.divID = divID;
    if(data)
        this.data = data;
    this.currValue = null;
    this.version = Math.random();
    this._init();
}

znzFinance.prototype._init = function()
{
    if(!this.data)
        return;
    
    this.dataObj = this.data.parseJSON();
    this._set();
}

znzFinance.prototype._set = function()
{
    this._dataSet();    
    this._partnerSet();
    this._infoSet();
    this._gsSet();
    if($(this.divID))
        $(this.divID).style.display = "block"; 
}

znzFinance.prototype._dynamicSet  = function()
{
    this._dataSet();
}

znzFinance.prototype._dataSet = function()
{
    var html = "<table cellspacing='0'><tr>";
    for(var i=0; i< finTypes.length; i++)
    {
           
        tabValue = "--";
        if(finTypes[i][0] == "PE")
        {
            if(this.currValue && this.dataObj["inPerSecDr"]) //&& this.dataObj["inPerSecDr"] > 0.0)
                tabValue = (this.currValue / this.dataObj["inPerSecDr"]).toFixed(2).toString();
               
        }
        else if(finTypes[i][0] == "PB" )
        {
            if(this.currValue && this.dataObj["netCapitalPerSec"]) //&& this.dataObj["netCapitalPerSec"] > 0.0)
                tabValue = (this.currValue / this.dataObj["netCapitalPerSec"]).toFixed(2).toString();
               
        }
        else if(this.dataObj[finTypes[i][0]])
        {
            if( typeof this.dataObj[finTypes[i][0]] == "number")
                tabValue = this.dataObj[finTypes[i][0]].format(2, ",").toString();
            else
                tabValue = decodeURIComponent(this.dataObj[finTypes[i][0]]);
        }
        
        html += "<td>" + finTypes[i][1] + "</td>" + "<td>" + tabValue + "</td>";
        
        if(i % 2 == 1 && i < finTypes.length -1)
            html += "</tr><tr>";
    }
    
    html += "</tr></table>";
    
    $(this.divID + '-datatable').innerHTML = html;
    
    if(this.dataObj["reportDate"])
    {
        var dateStr = this.dataObj["reportDate"];
        $(this.divID + '-reportdate').innerHTML = "报告日期："  + dateStr.substr(0, 4) + '年' + dateStr.substr(4, 2) + '月' + dateStr.substr(6, 2) + '日';
    }
}

znzFinance.prototype._infoSet = function()
{
    var html = "<table cellspacing='0'><tr>";
    for(var i=0; i< infoTypes.length; i++)
    {
        tabValue = "--";
        if(infoTypes[i][0] == "marketDate" )
        {
            if(this.dataObj[infoTypes[i][0]])
            {
               var dateStr =  this.dataObj[infoTypes[i][0]];
               tabValue = dateStr.substr(0, 4) + '年' + dateStr.substr(4, 2) + '月' + dateStr.substr(6, 2) + '日';
            }            
        }
        else if(infoTypes[i][0] == "market" )
        {
            if(stockType == "SH")
                tabValue = "上海证券交易所";
            else
                tabValue = "深圳证券交易所";
        }
        else if(infoTypes[i][0] == "email" )
        {
            
            if(this.dataObj[infoTypes[i][0]])
            {
                tabValue = decodeURIComponent(this.dataObj[infoTypes[i][0]]);
                tabValue = "<a href='mailto:" + tabValue + "' >" + tabValue + "</a>";
            }
            
        }
        else if(infoTypes[i][0] == "webAddr" )
        {
            
            if(this.dataObj[infoTypes[i][0]])
            {
                tabValue = decodeURIComponent(this.dataObj[infoTypes[i][0]]);
                tabValue = "<a href='http://" + tabValue + "' target='_blank'>" + tabValue + "</a>";
            }
            
        }
        else if(this.dataObj[infoTypes[i][0]])
        {
            if( typeof this.dataObj[infoTypes[i][0]] == "number")
                tabValue = this.dataObj[infoTypes[i][0]].format(2, ",").toString();
            else
            {
                try
                {
                    tabValue = decodeURIComponent(this.dataObj[infoTypes[i][0]]);
                }
                catch(E)
                {
                    tabValue = this.dataObj[infoTypes[i][0]];
                }
                
            }
        }
        
        html += "<td>" + infoTypes[i][1] + "</td>" + "<td>" + tabValue + "</td>";
        
        if(i % 2 == 1 && i < infoTypes.length -1)
            html += "</tr><tr>";
    }
    
    html += "</tr></table>";
    
    $(this.divID + '-infotable').innerHTML = html;
}

znzFinance.prototype._partnerSet = function()
{
    if(!this.dataObj["tenPartners"] || !$(this.divID + '-partnertable'))
        return;
    
    var partnerList = this.dataObj["tenPartners"];
    
    var html = "<table cellspacing='0'>";
    html += "<tr><th class='table-center'>排名</th><th class='table-center' width='45%'>股东名称</th><th class='table-center'>股份性质</th><th class='table-center'>持股数量(万股)</th><th class='table-center'>持股比例(%)</th></tr>";

    for(var i=0; i< partnerList.length; i++)
    {      
        
        html += "<tr><td class='table-center'>" + partnerList[i][0] + "</td><td class='table-left'>" + decodeURIComponent(partnerList[i][1]) + "</td><td class='table-center'>" + decodeURIComponent(partnerList[i][2]) + "</td><td class='table-right'>" + partnerList[i][3] + "</td><td class='table-right'>" + partnerList[i][4] + "</td></tr>";

    }
    
    html += "</table>";
    
    $(this.divID + '-partnertable').innerHTML = html;
}

znzFinance.prototype._gsSet = function()
{
    if(!this.dataObj["gsDetails"] || !$(this.divID + '-gstable'))
        return;
    
    var gsList = this.dataObj["gsDetails"];
    
    var html = "<img src='/finance/images/gs/" + stockType + "HQ" + stockCode + ".png?" + this.version +"'>";
    
    html += "<div><table cellspacing='0'>";
    html += "<tr><th class='table-center' width=35%'>限售股持有人</th><th class='table-center'>数量(万股)</th><th class='table-center'>状态</th><th class='table-center'>解禁时间</th></tr>";
  
    for(var i=0; i< gsList.length; i++)
    {      
        var colorClass = '';
        var holderStat = '未解禁';
        if(gsList[i][3] == -1)
        {
            colorClass = 'gray';
            holderStat = '已解禁';
            //if(i < gsList.length - 3)
            //    continue;
        }
        
        if(gsList[i][3] == 0)
        {
            colorClass = 'red';
            holderStat = '今解禁';
        }
        
        var holderName = '--';
        try
        {
            holderName = decodeURIComponent(gsList[i][0]);
        }
        catch(E)
        {
        }
        html += "<tr class='" + colorClass + "'><td class='table-left' style='WORD-WRAP: break-word;TABLE-LAYOUT: fixed;word-break:break-all'>" 
                + holderName + "</td><td class='table-right'>" + gsList[i][1].toFixed(2) 
                + "</td><td class='table-right'>" + holderStat + "</td><td class='table-right'>" + gsList[i][2].toString().substr(0, 4) 
                + '-' + gsList[i][2].toString().substr(4, 2) + '-' + gsList[i][2].toString().substr(6, 2) + "</td></tr>";

        
    }
    
    html += "</table></div><span id='realstock-finance-gsbutton' onclick='gsIntroChange()'>显示说明文字</span><span id='realstock-finance-gsall'><a href='globalshare.php' target='_blank'>查看市场全流通进度</a></span>";
    
    $(this.divID + '-gstable').innerHTML = html;
}

znzFinance.prototype.update = function(currv)
{
    if(!currv || !this.dataObj)
        return;
    
    this.currValue = currv;
    this._dynamicSet();
}

// for big weight stock
var BWStockList = ["sh601857", "sh601398", "sh601939", "sh601988", "sh600028", "sh601628", "sh601088", "sh601328", "sh601318", "sh600036", "sh601998", "sh601186", "sh600030", "sh601390", "sh600050", "sh601006", "sh600519", "sh601601", "sh601898", "sh601600", "sh600019", "sh600011", "sh601991", "sh601919", "sh600016", "sh600000", "sh601166", "sh601727", "sz000002", "sh600900"];
var BWNameList =  ["中国石油", "工商银行", "建设银行", "中国银行", "中国石化", "中国人寿", "中国神华", "交通银行", "中国平安", "招商银行", "中信银行", "中国铁建", "中信证券", "中国中铁", "中国联通", "大秦铁路", "贵州茅台", "中国太保", "中煤能源", "中国铝业", "宝钢股份", "华能国际", "大唐发电", "中国远洋", "民生银行", "浦发银行", "兴业银行", "上海电气", "万科A", "长江电力"];
var BWStockLen = 21;
function znzBWStock(divID, interval)
{
    this.divID = divID;
    this.interval = interval;
    this.inited = false;
    this._init();
}

znzBWStock.prototype._init = function()
{    
            
   this._update();
   this.inited = true;
    
}

znzBWStock.prototype._update = function()
{
    if(!this.inited || inHqTime())
        this._refresh();
    
    window.setTimeout(this._update.bind(this), this.interval);    
}

znzBWStock.prototype._set = function(retStr)
{
    var retObj = retStr.parseJSON();

    var div = '<table cellspacing="0" id="realstock-bigweight-table-tbody"><tr>';
    for(var i = 0; i< BWStockLen; i++)
    {
        var color = 'nocolor';
        var nfix = 2;
        var curValue;
        var curRate;

        if(retObj[BWStockList[i]])
        {
            if (retObj[BWStockList[i]][0] == 1)
                nfix = 3;
    
            if(retObj[BWStockList[i]][2] > retObj[BWStockList[i]][1])
                color = 'incolor';
            if(retObj[BWStockList[i]][2] < retObj[BWStockList[i]][1])
                color = 'decolor';
    
            if (retObj[BWStockList[i]][2] == 0)
            {
                curValue = '--';
                curRate = '--%';
                color = 'nocolor';
            }
            else
            {
                curValue = retObj[BWStockList[i]][2].toFixed(nfix).toString();
                if ((retObj[BWStockList[i]][2] - retObj[BWStockList[i]][1])/retObj[BWStockList[i]][1] > 10.00)
                    curRate = ((retObj[BWStockList[i]][2] - retObj[BWStockList[i]][1])/retObj[BWStockList[i]][1]).toFixed(2).toString();
                else
                        curRate = ((retObj[BWStockList[i]][2] - retObj[BWStockList[i]][1]) * 100/retObj[BWStockList[i]][1]).toFixed(2).toString() + '%';
             }
        }
        else
        {
            curValue = '--';
            curRate = '--%';
            color = 'nocolor';
        }
    
        div += '<td class=\'table-right\'><a href=\'./realstock.php?code=' + BWStockList[i] + '\' >' + BWNameList[i] + '</a></td>';
        div += '<td class = \'' + color + ' table-right\'>' + curValue  + '</td>';
        div += '<td class = \'' + color + ' table-right hasright\'>' + curRate  + '</td>';
    
        if(i % 3 == 2 && i < BWStockLen - 3)
            div += '</tr><tr>';
    
    }
    
    div += '</tr></table>';
    
    $(this.divID).style.display = "block";
    innerSet($(this.divID + '-table'), div, null);
    
}

znzBWStock.prototype._refresh = function()
{
    var args = {
        method : 'get', onComplete : function(rep){
    
            var ret = rep;
            this._set(ret);
             
    
         }.bind(this)
     };
    
     var infoURL = '';
     for(var i = 0; i< BWStockLen; i++)
     {
        infoURL += BWStockList[i] + ',';
     }
     
     infoURL = 'http://' + rdmDataDomainNameGet()+ '/test/data.py/prices.znzDo?cmd=' + infoURL + '|' + Math.random().toString();
     //alert(infoURL);
     var myAjaj = new Ajaj(infoURL, args);
}

// for big trade
function znzBigTradeStock(divID, interval, stockCode, stockType)
{
    this.divID = divID;
    this.interval = interval;
    this.stockCode = stockCode || '600028';
    this.stockType = stockType || 'SH';
    this.sNumber = 0;
    this.dateTime = "00000000";
    this.tradeItems = [];
    this.inited = false;
    this._init();
}

znzBigTradeStock.prototype._init = function()
{    
            
   this._update();
   this.inited = true;
    
}

znzBigTradeStock.prototype._update = function()
{
    if(!this.inited || inHqTime())
        this._refresh();
        
    window.setTimeout(this._update.bind(this), this.interval);    
}

znzBigTradeStock.prototype._refresh = function()
{
    var args = {
        method : 'get', onComplete : function(rep){
    
            var ret = rep;
            var retObj = ret.parseJSON();
            
            //alert(retObj);
            if( !retObj || retObj.length != 2 || retObj[1].length != 3)
                return;
                
            if(retObj[0] != this.dateTime)
            {
                this.dateTime = retObj[0];
                this.tradeItems = [];
                this.sNumber = retObj[1][1];
            }
            
            this.sNumber = retObj[1][1];
            this.dataObj = retObj;
            
            this._set();
            
             
    
         }.bind(this)
     };
    
     var infoURL = 'http://' + rdmDataDomainNameGet()+ '/test/data.py/bigTradeStock.znzDo?cmd=' + this.stockType.toLowerCase() + this.stockCode + '|' + this.dateTime + '|' + this.sNumber + '|' + Math.random().toString();
     //alert(infoURL);
     var myAjaj = new Ajaj(infoURL, args);
}

znzBigTradeStock.prototype._set = function()
{

    if(!stockFix || !lastValue)
    {
        window.setTimeout(this._set.bind(this), 1000); 
        return;
    }

    this.tradeItems = this.tradeItems.concat(this.dataObj[1][2]);
    
    // limit length to 50
    while(this.tradeItems.length > 50)
    {
        this.tradeItems.shift();
    }
    
    var tableStr = '<table cellpadding=0 cellspacing=0>';
    for(i=this.tradeItems.length -1; i>= 0; i--)
    {
        var volColor = 'nocolor';
        var valColor = 'nocolor';
    
        if (this.tradeItems[i][3] == 'B')
            volColor = 'incolor';
        if (this.tradeItems[i][3] == 'S')
            volColor = 'decolor';
    
        if(this.tradeItems[i][1] > lastValue)
            valColor = 'incolor';
    
        if(this.tradeItems[i][1] < lastValue)
            valColor = 'decolor';

        if(i == 0)
            tableStr += '<tr><td align=\'left\' width=\'50px\'>' + timeStrGen(this.tradeItems[i][0]) + '</td>';
        else
            tableStr += '<tr class=\'hasbtm\'><td align=\'left\' width=\'50px\'>' + timeStrGen(this.tradeItems[i][0]) + '</td>';
    
        tableStr += '<td align=\'right\' class=\'' + valColor + '\'>' + this.tradeItems[i][1].toFixed(stockFix) + '</td>'
        tableStr += '<td align=\'right\' class=\'' + volColor + '\'>' + this.tradeItems[i][2] + '</td>';
        tableStr += '</tr>';
    
    
    }
    tableStr +='</table>';
    innerSet($(this.divID + '-table'), tableStr, null);
    
}

// for market big trade stock
function znzMarketBigTradeStock(divID, interval, stockType)
{
    this.divID = divID;
    this.interval = interval;
    this.stockType = stockType || 'SH';
    this.sNumber = 0;
    this.dateTime = "00000000";
    this.tradeItems = [];
    this.running = true;
    this.mTimer = null;
    this.inited = false;
    this._init();
}

znzMarketBigTradeStock.prototype._init = function()
{           
   this._update();
   this.inited = true;    
}

znzMarketBigTradeStock.prototype._update = function()
{
    if(this.mTimer)
        window.clearTimeout(this.mTimer);
    if(this.running)
    {
        if(!this.inited || inHqTime())
            this._refresh();
            
        this.mTimer = window.setTimeout(this._update.bind(this), this.interval);        
    } 
}

znzMarketBigTradeStock.prototype._refresh = function()
{
    var args = {
        method : 'get', onComplete : function(rep){
    
            var ret = rep;
            var retObj = ret.parseJSON();
            
            if( !retObj || retObj.length != 2 || retObj[1].length != 3)
                return;
                
            if(retObj[0] != this.dateTime)
            {
                this.dateTime = retObj[0];
                this.tradeItems = [];
            }
            
            this.sNumber = retObj[1][1];
            this.dataObj = retObj; 
            this.tradeItems = this.tradeItems.concat(this.dataObj[1][2]);
                
            // limit length to 50
            while(this.tradeItems.length > 50)
            {
                this.tradeItems.shift();
            }          
            this._set();    
         }.bind(this)
     };
    
     var infoURL = 'http://' + rdmDataDomainNameGet()+ '/test/data.py/bigTradeMarket.znzDo?cmd=' + this.stockType.toLowerCase() + '|' + this.dateTime + '|' + this.sNumber + '|' + Math.random().toString();
     //alert(infoURL);
     var myAjaj = new Ajaj(infoURL, args);
}

znzMarketBigTradeStock.prototype._set = function()
{    
    //alert(this.tradeItems.length);    
    var tableStr = '<table cellpadding=0 cellspacing=0>';
    for(i=this.tradeItems.length -1; i>= 0; i--)
    {
        var volColor = 'nocolor';
        var valColor = 'nocolor';
    
        if (this.tradeItems[i][1][3] == 'B')
            volColor = 'incolor';
        if (this.tradeItems[i][1][3] == 'S')
            volColor = 'decolor';
        if(i == 0)
            tableStr += '<tr><td align=\'left\' width=\'50px\'>' + timeStrGen(this.tradeItems[i][1][0]) + '</td>';
        else
            tableStr += '<tr class=\'hasbtm\'><td align=\'left\' width=\'50px\'>' + timeStrGen(this.tradeItems[i][1][0]) + '</td>';
            
        tableStr += '<td align=\'left\' style=\'padding-left: 5px;\'><a href="./realstock.php?code=' + this.stockType.toLowerCase() + this.tradeItems[i][0] +'">' + decodeURIComponent(this.tradeItems[i][2]) + '</a></td>'    
        tableStr += '<td align=\'right\' class=\'' + valColor + '\'>' + this.tradeItems[i][1][1].toFixed(2) + '</td>'
        tableStr += '<td align=\'right\' class=\'' + volColor + '\'>' + this.tradeItems[i][1][2] + '</td>';
        tableStr += '</tr>';    
    }
    
    tableStr +='</table>';
    innerSet($(this.divID + '-table'), tableStr, null);
    $(this.divID).style.display = "block";
}

znzMarketBigTradeStock.prototype.stop = function()
{
    this.running = false;
    if(this.mTimer)
        window.clearTimeout(this.mTimer);
}

znzMarketBigTradeStock.prototype.restart = function()
{
    this.running = true;
    this._update();
}

/*constructor*/
function cateBoards(divID, boardName, interval, funcName, boarddata, sortCol, pBoardname, up)
{
    this._init(divID, boardName, interval, funcName, boarddata, sortCol, pBoardname, up);
}

/*some value for table drawing*/
//列样式
cateBoards.prototype.colorArray = ["", "incolor", "nocolor", "decolor", "", "nocolor", "nocolor"]

//标示那列可排序
cateBoards.prototype.sortable = [0, 1, 1, 1, 1, 1, 1, 1, 1];

/*init*/
cateBoards.prototype._init = function(divID, boardName, interval, funcName, boarddata, sortCol, pBoardname, up){
    this.funcName = funcName;
    this.pBoardname = pBoardname;
    this.up = up || false;
    this.colNum = sortCol;
    this.cateBoardData = null;
    this.divID = divID;
    this.boardName = boardName;
    //数据更新时间间隔
    this.interval = interval;
    //预取数据
    this.boarddata = null;
    //列标题
    this.colNames = ["板块名称", "涨幅%", "上涨家数", "平家数", "下跌家数", "平均价格", "成交总量(手)", "成交总金额(万)" ];
    if(null != boarddata)
        this.boarddata = boarddata.substring(0, boarddata.length - 1);
    this.inited = false;
}

/*start fetching*/
cateBoards.prototype.start = function(){
    this.running = true;
    this._update();
    this.inited = true;
}

/*update wed data*/
cateBoards.prototype._update = function(){
    if(this.running)
    {
        if(this.boarddata)
        {
            this._set(this.boarddata);
            this.boarddata = null;
        }
        else{
            if(!this.inited || inHqTime())
                this._refresh();
        }
    }
    window.setTimeout(this._update.bind(this), this.interval);
}

cateBoards.prototype._refresh = function(){
    var args = {
        method : "get",
        onComplete : function(re)
        {
            this._set(re);
        }.bind(this)
    }
    var infoUrl = "http://" + rdmDataDomainNameGet() + "/test/board.py/cateBoards.znzDo?cmd=";
    infoUrl += this.boardName + "|" + Math.random().toString();
    var myAjaj = new Ajaj(infoUrl, args);
}

/*show data in format of table*/
cateBoards.prototype._set = function(jsonStr){
    if (this.boardName == "index" || this.boardName == "industry300"
        || this.boardName == "industry399")
    {
        this.colNames[5] = "指数值";
    }
    else
    {
        this.colNames[5] = "平均价格";
    }
    
    if(jsonStr == "[-1]")
        return ;
    this.cateBoardData = new Array();
    var reObj = jsonStr.parseJSON();
    var i, j;

    for(i in reObj)
    {
    
        if( !reObj[i].length || reObj[i].length != 2 )
        {
            continue;
        }
        //add block no to data arr
        reObj[i].push(i);
        this.cateBoardData.push(reObj[i]);
    }
    //keep the old sort
    this.up = ! this.up;
    this.sort(this.colNum);
    this.showTable();
}

/*sort data*/
cateBoards.prototype.sort = function(colNum){
    if(this.colNum != colNum)
    {
        this.up = true;
        this.colNum = colNum;
    }
  
    this.cateBoardData.sort(this._cmp.bind(this));
    this.up = ! this.up;
}

/*compare function*/
cateBoards.prototype._cmp = function(a, b){
    if(this.up)
    {
        return b[1][this.colNum] - a[1][this.colNum];//asc
    }
    else
    {
        return a[1][this.colNum] - b[1][this.colNum];//des
    }
}

/* show table*/
cateBoards.prototype.showTable = function(){
    if(!this.running)
    {
        return;
    }
    
    var i, j;
    var div = "<table cellspacing='1' cellpadding=5 border='0'><tr><th>序号</th>";
    for (i = 0; i < this.colNames.length; i ++){
        div += "<th>";
        if (this.sortable[i])
        {
            div += "<a id='sortli"+i+"' href='javascript:void(0)' onclick='" + this.funcName + "(" + ( i - 1) + ")'>";
        }
        div += this.colNames[i];

        if (this.colNum == i - 1)
        {
            if (!this.up)
            {
                div += "↓"
            }
            else
            {
                div += "↑"
            }
        }
        if (this.sortable[i])
        {
            div += "</a>";
        }
        div += "</th>";
    }
    div += "</tr>";

    for(i = 0; i < this.cateBoardData.length; i ++)
    {
        div += "<tr>";
        div += "<td>"+(i+1)+"</td>";
        div += "<td>";
        var prefix = this.cateBoardData[i][2].substr(0, 4)
        if(prefix == 'SHHQ' || prefix == "SZHQ")
        {
            var tmpPrefix = (prefix == "SHHQ" ? 'sh' : 'sz');
            div += decodeURIComponent(this.cateBoardData[i][0]);
            div += "&nbsp;&nbsp;<a href='realstock.php?&code=" + tmpPrefix;
            div += this.cateBoardData[i][2].substr(4) + "'>";
            div += "[行情]</a>"
            div += "&nbsp;&nbsp;<a href='newsort.php?&boardNo=";
            div += this.cateBoardData[i][2] + "'>";
            div += "[个股]</a>"
        }
        else
        {
            div += "<a href='newsort.php?&boardNo=";
            div += this.cateBoardData[i][2] + "'>";
            div += decodeURIComponent(this.cateBoardData[i][0]) + "</a>";
        }
        div += "</td>";
        for(j = 0 ; j < this.cateBoardData[i][1].length; j ++)
        {
            var colorClass = "nocolor";
            if (this.colorArray[j])
            {
                colorClass = this.colorArray[j];
            }
            else
            {
                if (this.cateBoardData[i][1][0]>0)
                {
                    colorClass = "incolor";
                }
                else
                {
                    if (this.cateBoardData[i][1][0]<0)
                    {
                        colorClass = "decolor";
                    }
                }
            }

            div += "<td class='"+colorClass+"'>"+((j == 0)?this.cateBoardData[i][1][j].toFixed(2)+"%":this.cateBoardData[i][1][j].toString())+"</td>";
        }
        div += "</tr>";
    }
    div += "</table>";

    //add to web page
    innerSet(document.getElementById(this.divID), div, null);
    innerSet($('stockblock-pagebar'), "", null);
    $('stockblock-pagebar').style.display = 'none';
}

//主力动态show
function dzzIllShow()
{
    $('rela_exco').style.display = "block";
}

function hideDDZShow()
{
    $('rela_exco').style.display = "none";
}

function defaultShowMyStock()
{
    
    if ($('stock-mystock').className == 'title-current') 
        return;
    
    var divHtmlObj = null;    
    if(divHtmlObj = $('stock-lastv-name'))
    {
        divHtmlObj.className = 'title-uncurr';
    }
        
    if( divHtmlObj = $('stock-mystock'))
    {
        divHtmlObj.className = 'title-current';
    }
    
    if(divHtmlObj = $('stock-lastv-table'))
    {
        divHtmlObj.style.display  = 'none';
    }
    
    if( divHtmlObj = $('stock-mystock-table'))
    {
        divHtmlObj.style.display = 'block';
    }
}