/**
 * 首页中 点击"全文检索"触发的事件，填充查询的结果页面
 */
var homeSeachWord = "";//输入框中的检索词
var queryType = "zx";//选择是“资讯优先”还是“出行优先”
function actionValue() {
	homeSeachWord = trim(document.getElementById('trsWordSearch').value);	// 得到输入框中的检索
	var homeSeachWordOld = homeSeachWord;
	if (ltrim(homeSeachWord) == null || ltrim(homeSeachWord) == "" || ltrim(homeSeachWord) == "如：公园前") {
		document.getElementById("trsWordSearch").focus();
		document.getElementById('search_suggest').innerHTML = '';		// ajax输入条件在触发按钮时消失
		alert("请输入查询条件");
		return;
	}else{
		//var seachReg = /[\\\^\+\-\=\~\!\@\#\%\&\*\_\|\$]/g;
		/*for ( var i=0; i<homeSeachWord.length; i++ ) {
			homeSeachWord = homeSeachWord.replace( seachReg, "" );
		}*/
		var seachReg = /[º]/g;
		for ( var i=0; i<homeSeachWord.length; i++ ) {
			homeSeachWord = homeSeachWord.replace( seachReg, " " );
		}
		document.getElementById("trsWordSearch").focus();
		if ("" == homeSeachWord || null ==homeSeachWord) {
			document.getElementById("trsWordSearch").value = "";
			alert("输入非法字符，请重输！");
			return;
		} else {
			if ( typeof(dealStrTemp) == "undefined" ) {
				dealStrTemp = "";
			}
			document.getElementById("trsWordSearch").value = homeSeachWordOld;
			
			var ss=document.getElementById('search_suggest');
			ss.innerHTML = '';
			ss.style.display="none";		// ajax输入条件在触发按钮时消失

			var seachWord = strangecode(homeSeachWord);
			
			//alert("==" + seachWord + "===");
	        
			//	过滤掉特殊字符，如“#”、"@"等
			
	/*		var obj=document.getElementsByName("queryType");      //得到是“资讯优先”还是“出行优先”
		    for(var i=0;i<obj.length;i++){      
		    if(obj[i].checked){
		        queryType = obj[i].value;     
		        }      
		    }*/ 
		    queryType="zx";
	        document.getElementById("resultSet").innerHTML = '<iframe name = "homeMtrIfName" width="100%" height="100%" marginwidth="1" marginheight="0" frameborder="0" scrolling="auto" src="./trsQuery/rsList_homeTrs.jsp?keyWord='+encodeURI(seachWord)+'&type='+queryType+'"></iframe>';
			historyWord(homeSeachWordOld) ;									//历史检索词的操作，调用函数，插入数据库中
			
			
		}
		
		
	}
	
	
	
	
	

}

	/**
	 * 历史检索词的操作，插入数据库中
	 */
	function historyWord(seachWord) {
		//document.getElementById('search_suggest').innerHTML = '';		// ajax输入条件在触发按钮时消失
		var httprequest = false
		if (window.XMLHttpRequest) { // if Mozilla, Safari etc//Mozilla 浏览器
			httprequest = new XMLHttpRequest()
			if (httprequest.overrideMimeType)
				httprequest.overrideMimeType('text/xml');
		} else if (window.ActiveXObject)// if IE
		{
			try {
				httprequest = new ActiveXObject("Msxml2.XMLHTTP");
			} catch (e) {
				try {
					httprequest = new ActiveXObject("Microsoft.XMLHTTP");
				} catch (e) {
				}
			}
		}
		if (httprequest.readyState == 4 || httprequest.readyState == 0) {
			var str = document.getElementById('trsWordSearch').value;			//得到输入框的中的检索词
			str = ltrim(str);// 去掉左边空格
			if (str != "") {
				// 请求参数初始化
				httprequest.open("POST", 'historySearch?txtSearch=' + encodeURI(str),true);
				httprequest.setRequestHeader("Content-Type","application/x-www-form-urlencoded"); // 因为请求方式为POST,所以这里要设置请求头.(如果请求方式为GET,此句代码可以省略)
			//	httprequest.onreadystatechange = handleSearchSuggest;
				httprequest.send(null); // 向服务器端发送参数
			}
		}
	}
	
	   
//首页中"全文检索"响应回车键进行查询
function trsEnter(e) {
	 e = e || event;		//对火狐和IE事件的判断
	if (e.keyCode == 13) {
		actionValue();
		changeNavBG(document.getElementById('indexA'));
	}
}

//周边查询中，点击搜索，调用的方法
function homeAroundSearch(sid,mid,px, py) {
	var s_type = document.getElementById(sid).value;
	var s_mile = document.getElementById(mid).value;
	sendBufferSearchRequest(px, py, s_mile, s_type);
}

/* 点击首页中的“分类”按钮，触发事件*/
function trs_showType(){
	var resultdiv = document.getElementById("resultSet");
	resultdiv.innerHTM = "";
	document.getElementById('search_suggest').innerHTML = '';
	document.getElementById('search_suggest').style.display= 'none';// ajax输入条件在触发按钮时消失
	resultdiv.innerHTML = "<iframe  name = \"homeTypeIfName\" width = \"100%\" height=\"100%\" marginwidth='1' marginheight=\"0\" frameborder=\"0\" scrolling='auto' src=\"./trsQuery/rsList_homeType.jsp\"></iframe>";
}
/*点击首页中的“首页”按钮，触发事件*/
function showHomeInfo(){
	var resultdiv = document.getElementById("resultSet");
	resultdiv.innerHTM = "";
	document.getElementById('search_suggest').innerHTML = '';
	document.getElementById('search_suggest').style.display= 'none';// ajax输入条件在触发按钮时消失
	resultdiv.innerHTML = "<iframe width = \"100%\" height=\"100%\" marginwidth='1' marginheight=\"0\" frameborder=\"0\" scrolling='auto' src=\"./homeMtrInfo.jsp\"></iframe>";
}
/*点击首页中的“车站三维”按钮，触发事件*/
function orcl_showStn(){
	var resultdiv = document.getElementById("resultSet");
	resultdiv.innerHTM = "";
	document.getElementById('search_suggest').innerHTML = '';
	document.getElementById('search_suggest').style.display= 'none';// ajax输入条件在触发按钮时消失
	resultdiv.innerHTML = "<iframe width = \"100%\" height=\"100%\" marginwidth='1' marginheight=\"0\" frameborder=\"0\" scrolling='auto' src=\"./trsQuery/rsList_homeStn.jsp\"></iframe>";
}


