//定义页面
var selfURI="";
//定义参数容器
var parameterArray=new Array;
//定义参数
function parameter(varName,varValue){
	this.name=varName;
	this.value=varValue;
}
//获取参数所在容器中的位置
function getParamIndex(varName){
	var leng=parameterArray.length;
	for(var i=0;i<leng;i++){
		var param=parameterArray[i];
		if (param.name==varName)
			return i;
	}
	return leng;
}
//设置参数
function setParameter(varName,varValue){
	var param=new parameter(varName,varValue);
	var leng=getParamIndex(varName);
	parameterArray[leng]=param;
}
//替换不合法字符
function replace(eValue){
	eValue=eValue.replace(/&/g,"%26");
	eValue=eValue.replace(/=/g,"%3D");
	return eValue;
}
//替换不合法字符1
function replace1(eValue){
	eValue=eValue.replace("\n","<p>");
	eValue=eValue.replace(/=/g,"<p>");
	return eValue;
}
//设置页面
function setURI(URI){
	selfURI=URI;
}
//设置页面
function setURL(URI){
    selfURI=URI;
}
//组合查询变量
function bulidQueryString(){
	var queryString="";
	var leng=parameterArray.length;
	
	for(var i=0;i<leng;i++){
		var param=parameterArray[i];
		var varValue=replace(param.value);
		if (i==0)
			queryString+=param.name+"="+varValue;
		else
			queryString+="&"+param.name+"="+varValue;
	}
	
	return queryString;
}
//页面刷新
function switchPage(){
	
	var queryString=bulidQueryString();
    if (queryString=="")
		document.location.href=selfURI;
	else
		document.location.href=selfURI+"?"+queryString;
}
//翻页
function flipPage( pageNum ) {
	setParameter("currentPage",""+pageNum);
	switchPage();
}
//直接切换页码
function directFlip() {
	//if ( !logicalInput( currentPageInput, 'int', _cPageNumber ) ) return false;	
	flipPage(currentPageInput.value);		
}
//function directFlip(inputtext ) {
//	if ( !logicalInput( inputtext, 'int', _cPageNumber ) ) return false;	
//	flipPage(inputtext);		
//}
//打开一般信息
function openArticle( id , iAppType ) {
		var url="";
		if ( typeof iAppType== 'undefined' ) {
			url = "../common/info.jsp?id="+id;
		} else {
			if(iAppType==1)
				url = "../common/info.jsp?id="+id;
			else if(iAppType==0)
				url = "../common/investorg.jsp?id="+id;
			else if(iAppType==31)
				url = "../common/frnreport.jsp?id="+id;
			else if(iAppType==32)
				url = "../common/researchorg.jsp?id="+id;
			else if(iAppType==33)
				url = "../common/proffesional.jsp?id="+id;
			else if(iAppType==34)
				url = "../inveodds/tzyxshow.jsp?language="+language+"&id="+id;
			else if(iAppType==35)
				url = "../inveodds/tzyxedit.jsp?id="+id;
			else if(iAppType==36)
				url = "../intention/intenshow.jsp?id="+id;

			else if(iAppType==63)
				url = "../common/proffesional.jsp?id="+id;
			else if(iAppType==66)
				url = "../common/investorg.jsp?id="+id;

			else 
			url = "../common/info.jsp?id="+id;
		}
		window.open(url,"_blank");
}
function openArticleInveodd( id , iAppType ) {
		var url="";
		if ( typeof iAppType== 'undefined' ) {
			url = "../common/info.jsp?id="+id;
		} else {
			if(iAppType==1)
				url = "../common/info.jsp?id="+id;
			else if(iAppType==0)
				url = "../common/investorg.jsp?id="+id;
			else if(iAppType==31)
				url = "../common/frnreport.jsp?id="+id;
			else if(iAppType==32)
				url = "../common/researchorg.jsp?id="+id;
			else if(iAppType==33)
				url = "../common/proffesional.jsp?id="+id;
			else if(iAppType==34)
				url = "../inveodds/tzyxshow.jsp?language="+language+"&id="+id;
			else if(iAppType==35)
				url = "../inveodds/tzyxedit.jsp?id="+id;
			else if(iAppType==36)
				url = "../intention/intenshow.jsp?id="+id;

			else if(iAppType==63)
				url = "../common/proffesional.jsp?id="+id;
			else if(iAppType==66)
				url = "../common/investorg.jsp?id="+id;

			else 
			url = "../common/info.jsp?id="+id;
		}
		//window.open(url,"_blank");
    window.open(url,'','left=0,top=0,scrollbars=yes,location=no,resizable=yes,status=no,toolbar=no');
}
//打开投资机会
function openChance( id, language ) {
		var url = "../common/list.jsp?id="+id+"&language="+language;
		window.open(url,"_blank");
}
//打开法信律息
function openLawArticle( id ) {
		var url = "../ltlaw/lawinfodisp.jsp?id="+id+"&appId=1";
		window.open(url,"_blank");
}

function switchNote(category) {
//	alert("fd");
	setParameter("category",category);
	setParameter("currentPage","1");
	switchPage();
}

function switchAppNote(app,category) {
//	alert("fd");
	setParameter("app",app);
	setParameter("category",category);
	setParameter("currentPage","1");
	switchPage();
}

function switchApp() {
	switchNote('');
}

function swtichSearchCancelButtonVisible() {
	var bVisible = (searchDef == "" && advSearch == "")?"hidden":"visible";
	controlPad.searchCancelButton.style.visibility = bVisible;
}

	//切换查询条件
function switchSearchDef( searchStatement ) {
	advSearch = "";
	searchDef = searchStatement;
	setParameter("searchDef",searchStatement);
	switchPage();
	swtichSearchCancelButtonVisible()
}

//切换高级查询条件
function switchAdvSearch( advSearchStatement ) {
	if (advSearchStatement == "") {
		return;
	}
	searchDef = "";
	advSearch = advSearchStatement;
	setParameter("currentPage","1");
	setParameter("advSearch",advSearchStatement);
	setParameter("searchDef","advSearch");
	switchPage();
	swtichSearchCancelButtonVisible()
}

function doSearch(  ) {
	var param = controlPad.searchdef.value;
	if (param == "") {
		clearSearchDef();
		return;
	}
	switchSearchDef(param);
}

//清空查询条件
function clearSearchDef() {
	controlPad.searchdef.value="";
	advSearch = "";
	searchDef = "";
	setParameter("currentPage","1");
	setParameter("advSearch","");
	setParameter("searchDef","");
	switchPage();
	swtichSearchCancelButtonVisible()
}

function listModeSelectorOnChange(param){
	setParameter("listMode",param);
	switchPage();
}

function swtichLanguage(param){
	setParameter("language",param);
	switchPage();
}
