// JavaScript Document
function xy_GoToChannelPage(pageIndex)
{
    if(pageIndex =="")return;
    
    if(isNaN(pageIndex))return;
    
    var total = parseInt($("totalPage").value);
    
    var toPage = parseInt(pageIndex);
    
    if(toPage <=0)return;

    if(toPage > total)
    {
         alertmsg(false,"最大页数为" + total);
         return;
    }
	// %7bp%7d => {p}
    var href = $F("pageURL").replace("%7bp%7d",pageIndex) + $F("pageformat");
	window.location = href;
}

//
var i = 1;
for(;i<25;i++)
{
	eval("show_king_id_" + i.toString() + " = 1");
}

function show_king_list(m,e,k)
{
    if(eval("show_king_id_" + (m+1).toString()) == k) return true;
        o = $(String.fromCharCode("a".charCodeAt(0)+m) + eval("show_king_id_" + (m+1).toString()));
        o.className = "bg";
    e.className = " ";
    eval("show_king_id_" + (m+1).toString() + " = k ");
}
function initVouch()
{
try{
	for(i=0;i<24;i++)
	{
		obj = $(String.fromCharCode("a".charCodeAt(0)+i) + "1");
		if(obj)
		{
			obj.className = " ";
		}
	}
}catch(e)
{}
}


function change(id)
{
	var showID = "show" + id;
	var newsulID = "newsul" + id;

	if(showID=="show2")
	{	//alert(showID);
		document.getElementById("newsul2").style.display="block";
		document.getElementById("newsul1").style.display="none";
		document.getElementById("show1").style.background="none";			
		document.getElementById("show2").style.background="url(images/whitebg.jpg) no-repeat";
		}
	else
	{	//alert(showID);
		document.getElementById("newsul1").style.display="block";
		document.getElementById("newsul2").style.display="none";
		document.getElementById("show2").style.background="none";
		document.getElementById("show1").style.background="url(images/whitebg.jpg) no-repeat";			
		}
}

function getAssessment()
{
	if($("selJZ_C").value=="")
	{
		alertmsg(false,"请选择类别！");
		return;
	}
	if(!verifyFloat($("JZ_sourceMoney").value))
	{
		return;
	}
	if(!verifyFloat($("JZ_useYears").value))
	{
		return;
	}
	var url = "&useYears="+ $("JZ_useYears").value +"&sourceMoney="+ $("JZ_sourceMoney").value+"&id="+$("selJZ_C").value;
	var ajax = new Ajax("xy100",url);
	var msg = "";
    ajax.onSuccess =function(){
        if(ajax.state.result == "1")
        {   
            if(ajax.state.message == "err")
            {
                alertmsg(false,"【无效值】");
				msg = "对不起，评估数据无效";
            }
            else if(ajax.state.message == "ok")
			{
				if(parseFloat(ajax.data.content) <= 0)
				{
					msg = "您查询的资产已超过正常使用年限，实际价值需根据资产现状确定。";
				}
				else
				{
					msg = "您查询的资产价值约为<font color=red>"+ajax.data.content+"</font>万元";
				}
			}else{
				msg = "出错信息";
			}
			$("JZ_Result").innerHTML = msg;
        }
     }	
}
function verifyFloat(val) 
{ 
	var pattern = /^((-?|\+?)\d+)(\.\d+)?$/; 
	var flag = pattern.test(val);
	if(flag) 
	{ 
		return true; 
	} 
	else 
	{ 
		alertmsg(false,"您输入的原值或已使用年限无效！");
		return false;
	}
}

function eh_headSearch(type)
{
	if(type=="custom")
	{
		if($F("customkey1")=="" || $F("customkey2")=="")
			strComma = "";
		else
			strComma = ",";
		
		$("txtsearchkey").value = $F("customkey1")+ strComma + $F("customkey2");
		return "investment";
	}
	if(type=="investment")
	{
		$("txtsearchkey").value = $F("investmentkey");
		$("xy_InfoType").value = $F("investment_InfoType");
		return "investment";
	}
	if(type=="offer")
	{
		$("txtsearchkey").value = $F("offerkey");
		$("xy_InfoType").value = $F("offer_InfoType");
		return "offer";
	}
	if(type=="news")
	{
		$("txtsearchkey").value = $F("newskey");
		return "news";
	}
}

function switchTopSearchButton(id)
{
	var BTN_NUM = 4;
	for(var i=1; i<=BTN_NUM; i++)
	{
		if(i==id)
		{
			$("search"+i).style.display = "block";
			$("topSearchMenu"+i).className = "tabSelect";
		}
		else
		{
			$("search"+i).style.display = "none";
			$("topSearchMenu"+i).className = "tabUnSelect";
		}
	}
	switch(id)
	{
		case 1:
			$('xy_FlagName').value='custom';
			break;
		case 2:
			$('xy_FlagName').value='investment';
			break;
		case 3:
			$('xy_FlagName').value='offer';
			break;
		case 4:
			$('xy_FlagName').value='news';
			break;																
	}
	return false;
}

function changeRealTimeChannel(nt_id)
{
	if(config.BogusStatic)
	{
		window.location = config.WebURL + "news/realtime/channel-" + nt_id + "." + config.Suffix;
	}
	else
	{
		window.location = config.WebURL + "news/realtime/channel?nt_id=" + nt_id + "." + config.Suffix;
	}
}

function changeRealTimeNav(el)
{
	$(el).innerHTML = $(el).innerHTML.replace("\"/\">首页","index." + config.Suffix + ">即时资讯首页");
}
