//页面设置相关参数
var _pageW = 0;		//页面总长度
var _pageH = 0;		//页面总高度
var _pageMinW = 500;	//页面最小长度
var _pageMinH = 400;	//页面最小高度
var _topH = 40 + 62 + 2;		//头部高度
var _bottomH = 0;	//底部部分的高度
var _resultW = 300;	//结果容器的总长
var _closeW = 8;	//关闭按钮的宽
var _mapW = 0;		//地图窗口的宽
var _resultTitH = 29;	//结果框上部的标题高度
var _resultConH = 0;	//结果子容器内的容器高度
var _middleH = 0;
var _resultBotH = 29;	//结果容器分页容器高度
var _copyRightH = 29;   //结果容器底部信息容器高度
var _typeConH = 55;    //结果容器分类信息容器高度
var _resultTypeW = 39;
var _searchBoxLeft = 500;	//商业关键字搜索框的位置
var richmap = null;	//声明地图引擎对象
var myMoveObj = null;
var nowFocusIndex = 0;	//声明当前tab页聚焦的对象在其父节点中的索引位置
//页面载入完后需要运行的函数
var typeFlag = null;
function pageInit(){
	resetAllSize();
	richmap = new RWing(document.getElementById("mapContainer"));
	richmap.showMarkBtn(false);
	richmap.showEagle(true);
	richmap.showDirection(false);
	//richmap.showNoteBtn(true);
	richmap.setCityList(true);
	richmap.addEventListener("onsuccess","loadSuccess");
	richmap.init();
	Results.init();		//初始化结果容器对象
	//Results.close();	//默认关闭状态
	getHotKey(citycode);	//显示热点关键字
	myMoveObj = new moveObj();
	typeFlag = false;
	if(loadType != null && loadType != "null" && loadType != ""){
		var typeArr = loadType.split(",");
		firstType = typeArr[0];
		//nowType = typeArr[0];
		typeCode = typeArr[0];
		loadType = "," + typeArr.join(",") + ",";
		if(loadType.indexOf("01")>=0)getType('01','0101,0112,0105,0106,0107,0109,0113');
		if(loadType.indexOf("10")>=0)getType('10','1001,1002,1003');
		if(loadType.indexOf("02")>=0)getType('02','0202,0203,0204,0205,0206,0207,0208');
		if(loadType.indexOf("03")>=0)getType('03','0301,0302,0304,0305,0307,0309,0310,0311');
		if(loadType.indexOf("04")>=0)getType('04','0401,0402,0403,0404,0405');
		if(loadType.indexOf("05")>=0)getType('05','0501,0502,0503,0504,0505,0506,0508,0510');
		if(loadType.indexOf("07")>=0)getType('07','0701,0702,0703,0704,0705,0707,0708');
		if(loadType.indexOf("11")>=0)getType('11','1102,1105,1106,1107,1111,1118,1122');
	}else{
		getType('01','0101,0112,0105,0106,0107,0109,0113');
		getType('10','1001,1002,1003');
		getType('02','0202,0203,0204,0205,0206,0207,0208');
		getType('03','0301,0302,0304,0305,0307,0309,0310,0311');
		getType('04','0401,0402,0403,0404,0405');
		getType('05','0501,0502,0503,0504,0505,0506,0508,0510');
		getType('07','0701,0702,0703,0704,0705,0707,0708');
		getType('11','1102,1105,1106,1107,1111,1118,1122');
	}
	changeType(firstType);	
}
function moveObj(){
	this.m_oDragObj = document.getElementById("cityChoice");
	this.m_oMoveObj = document.getElementById("cityContainer");
	this.getPositionX = function(x){return parseInt(this.m_oMoveObj.style.left);};
	this.getPositionY = function(x){return parseInt(this.m_oMoveObj.style.top);};
	this.setPosition = function(x,y){this.m_oMoveObj.style.left = x;this.m_oMoveObj.style.top = y;};
}
//地图载入完成
function loadSuccess(){
	richmap.addEventListener("onerror","myerror");
	richmap.addEventListener("onchange","getAroundData");
	richmap.showCity(citycode,9);
	//得到一个显示对象
	//var flag = "showAroundResult";
	//if(!Results.getObj(flag,"地图区域","FJQZ","搜索结果"))return false;
	//getAroundData();
}
//选项卡的切换动作
function changeMainSearch(nIndex){
	if(nowFocusIndex == nIndex)return true;
	var searchConObj = getById("searchCon");
	var searchStrObj = getById("searchStr");
	searchConObj.children[nowFocusIndex].className = "tabTitle_blur_" + (nowFocusIndex + 1);
	searchStrObj.children[nowFocusIndex].style.display = "none";
	searchConObj.children[nIndex].className = "tabTitle_focus";
	searchStrObj.children[nIndex].style.display = "";
	nowFocusIndex = nIndex;
	return true;
}
/*
* 开始查询
*	@param act			查询类别
*	@param keyvalue		传入的第一个关键字的值
*	@param keyvalue1	传入的第二个关键字的值
*	@param flag			旧的查询标志
*/
var basePath = "";
function startSearch(act,keyvalue,keyvalue1,oldflag){
	var keyObj = null;
	var keyObj1 = null;
	switch(act){
		case 0:		//本地查询
			keyObj = getById("localKey");
			keyObj.value = clearKey(keyObj.value).trim();
			if(keyObj.value == ""){alert("请输入本地搜索关键字");keyObj.focus();return false;}
			//转向查询
			self.open(encodeURI("/map.jsp?act=local&key=" + keyObj.value + "&citycode=" + citycode));
			return;
			break;
		case 1:		//自驾方案
			keyObj = getById("driverBegin");
			keyObj.value = clearKey(keyObj.value).trim();
			if(keyObj.value == ""){alert("请输入自驾方案起点");keyObj.focus();return false;}
			keyObj1 = getById("driverEnd");
			keyObj1.value = clearKey(keyObj1.value).trim();
			if(keyObj1.value == ""){alert("请输入自驾方案终点");keyObj1.focus();return false;}
			self.open(encodeURI("/map.jsp?act=driver&begin=" + keyObj.value + "&end=" + keyObj1.value + "&citycode=" + citycode));
			break;
		default:
			return false;
			break;
	}
}
function setCityCode(code){
	citycode = code;
}
function closeCityList(){
	getById("cityContainer").style.display = "none";
}
function openCityList(){
	getById("cityContainer").style.display = "";
}
function changeCity(obj){
	citycode = obj.code;
	for(var i=1;i<3;i++){
		getById("cityname"+i).innerText = obj.innerText;
	}
	closeCityList();
	richmap.showCity(citycode,13);
	getAroundData();
}
function myerror(errstr){
	//alert(errstr);	
}
/*
*	根据页面的当前长度和高度重新调整所有需要调整的层的位置和大小
*/
function resetAllSize(act){
	_pageW = document.body.clientWidth;
	_pageH = document.body.clientHeight;
	if(_pageW<_pageMinW)_pageW = _pageMinW;
	if(_pageH <_pageMinH)_pageH = _pageMinH;
	if(Results.m_bIsClose){
		_mapW = _pageW - 2 - _closeW;	//得到地图的长度
	}else{
		_mapW = _pageW - _resultW - _closeW;	//得到地图的长度
	}
	_bottomH = _pageH - _topH;	//得到下面部分的框架高
	//设置地图容器的大小
	var mapContainer = document.getElementById("mapContainer");
	mapContainer.style.width = _mapW - 3;
	mapContainer.style.height = _bottomH - 3;
	if(act){richmap.resizeMap(_mapW - 3,_bottomH - 3);}
	//设置底部总容器的大小
	document.getElementById("part4").style.height = _bottomH;
	document.getElementById("closeCon").style.height = _bottomH;
	//设置关闭按钮的位置
	document.getElementById("closeBtn").style.top = _bottomH*0.5 - 40;
	//设置结果子容器的高度
	_middleH = _bottomH - _resultTitH - _resultBotH;
	document.getElementById("middle").style.height = _middleH;
	_resultConH = _bottomH - _resultTitH -_typeConH - _resultBotH;
	document.getElementById("resultCon").style.height = _resultConH;
	//设置结果底部信息容器位置
	document.getElementById("resultBot").style.top = _middleH + _resultTitH;
}
window.onresize = function(){resetAllSize(true);};
//关闭按钮的鼠标动作
function btnOver(obj){
	if(Results.m_bIsClose){
		obj.className='closeBtn_right_over';
	}else{
		obj.className='closeBtn_left_over';
	}
}
//关闭按钮的鼠标动作
function btnOut(obj){
	if(Results.m_bIsClose){
		obj.className='closeBtn_right_out';
	}else{
		obj.className='closeBtn_left_out';
	}
}
//结果容器对象
var Results = new function(){
	this.m_nCount = 0;					//保存结果集的序列，用于后退、前进、转到某结果等操作
	this.m_aObjCount = [];			//保存对象的同步索引
	this.m_aObjIndex = [];
	this.m_oContainer = null;		//结果外部总容器对象
	this.m_oResultCon = null;		//结果子容器对象
	this.m_oResultBot = null;		//结果容器底部信息对象
	this.m_oResultTit = null;		//结果容器标题
	this.m_aObj = [];		//保存各种结果对象的哈希表
	this.m_bIsClose = false;		//当前是否在关闭状态
	this.m_nWidth = 250;			//结果总容器的长
	this.m_nTitleCount = 11;		//最长10个汉字
	this.m_sFocusFlag = "";			//当前聚焦的子容器的flag
	this.init = function(){
		this.m_oContainer = document.getElementById("resultsCon");
		this.m_oResultCon = document.getElementById("resultCon");
		this.m_oResultBot = document.getElementById("resultBot");
		this.m_oResultTit = document.getElementById("showResultsTitle");
	};
	this.showTitle = function(str){
		this.m_oResultTit.title = str;
		if(str.length > this.m_nTitleCount){
			str = str.substring(0,this.m_nTitleCount-1) + "...";
		}
		this.m_oResultTit.innerText = str;
	};
	
	this.showHide = function(){
		if(this.m_bIsClose){
			this.open();
		}else{
			this.close();	
		}
	};
	//显示主容器
	this.open = function(){
		if(!this.m_bIsClose)return;
		//如果当前已经处在关闭状态
		this.m_bIsClose = false;
		//设置地图容器的位置
		var mapContainer = document.getElementById("mapContainer");
		mapContainer.style.left = _resultW + _closeW;
		resetAllSize(true);
		//设置关闭按钮的位置
		document.getElementById("closeCon").style.left = _resultW;
		//设置结果容器的大小
		this.m_oContainer.style.width = _resultW;
		//设置按钮里头的文字信息
		document.getElementById("closeBtn").className = "closeBtn_left_out";
		//document.getElementById("closeText").style.left = "-6px";
		//document.getElementById("closeText").innerText = "《";	
	};
	//隐藏主容器
	this.close = function(){
		if(this.m_bIsClose)return;
		this.m_bIsClose = true;
		//设置地图容器的位置
		var mapContainer = document.getElementById("mapContainer");
		mapContainer.style.left = _closeW + 2;
		resetAllSize(true);
		//设置关闭按钮的位置
		document.getElementById("closeCon").style.left = 2;
		//设置结果容器的大小
		this.m_oContainer.style.width = "0px";
		//设置按钮里头的文字信息
		document.getElementById("closeBtn").className = "closeBtn_right_out";
		//document.getElementById("closeText").style.left = "0px";
		//document.getElementById("closeText").innerText = "》";
	};
	//传入查询唯一标志来显示这个历史查询结果
	this.show = function(flag,htmlStr){
		if(this.m_aObj[flag] == null)return false;
		//找到之前在焦点的结果框并隐藏
		if(this.m_sFocusFlag != "" && this.m_sFocusFlag != flag){
			this.m_aObj[this.m_sFocusFlag].hidden();
		}
		this.m_sFocusFlag = flag;
		this.showTitle(this.m_aObj[flag].title + "-" + this.m_aObj[flag].zone);
		this.m_aObj[flag].show(htmlStr);
		//判断菜单显示样式
		//this.checkMenu();
		return true;
	};
};
var dataUrl = "search?act=mbrpoi&l=?l?&b=?b?&r=?r?&t=?t?&typecode=?typecode?&pageno=";
var helpStr = "<div style='padding:10px;'>"
				+ "在<font color='red'>当前地图区域范围</font>内查询不到“<font color='red'>?typename?</font>”类别相关的信息!</font>"
				+ "<br><br><b>建议您：</b><br><span style='color:#555555;line-height:18px;'>"
				+ "1、改变或扩大查询范围：可以拖动当前的地图改变区域，或使用地图上方的放大和缩小按钮来放大查询区域；<br>"
				+ "2、更改搜索类别：点击此处上方的文字链接来修改查询信息的小类别，或点击此处左边的按钮来修改查询信息的大类别；<br>"
				+ "3、如果您需要查找更具体的内容，请在上方的搜索工具栏，切换到本地查询进行搜索。"
				+ "</font></div>";
var nowFlag = "";
var bLock = false;
function getAroundData(pageUrl,pageNo){
	if(bLock)return;
	bLock = true;
	getById("resultCon").innerHTML = "<div style='padding:10px;'>读取信息，请稍候...</div>";
	getById("pageShow").innerHTML = "";
	if(pageUrl == null){
		pageUrl = dataUrl;
		var nowMBR = richmap.getMBR();
		pageUrl = pageUrl.replace("?l?",parseInt(nowMBR[0]));
		pageUrl = pageUrl.replace("?b?",parseInt(nowMBR[1]));
		pageUrl = pageUrl.replace("?r?",parseInt(nowMBR[2]));
		pageUrl = pageUrl.replace("?t?",parseInt(nowMBR[3]));
		pageUrl = pageUrl.replace("?typecode?",typeCode);
		pageNo = 1;
		nowFlag = getRandFlag();
	};
	//开始异步查询
	var xmlObj = Sarissa.getDomDocument();
	xmlObj.async = true;
	xmlObj.onreadystatechange = function(){
		if(xmlObj.readyState == 4){
			if(xmlObj.parseError!=0){
				getById("resultCon").innerHTML = helpStr.replace("?typename?",typeArray[nowFocusType]);
				bLock = false;
				return false;
			}
			try{
				var testNode = xmlObj.selectSingleNode("root/Return").text;
				if(testNode == "0"){
					getById("resultCon").innerHTML = helpStr.replace("?typename?",typeArray[nowFocusType]);
					bLock = false;
					return false;
				}
			}catch(e){
				getById("resultCon").innerHTML = helpStr.replace("?typename?",typeArray[nowFocusType]);
				bLock = false;
				return false;
			}
			var myNode = xmlObj.selectSingleNode("root/Content/Companies").childNodes;
			var flag = "mypoilist";
			POIListHashTable[flag] = new POIList();
			var j=0;
			var outStr = "";
			for(var i=0;i<myNode.length;i++){
				var dwkey = myNode[i].selectSingleNode("DwKey").text;
				var x = parseInt(myNode[i].selectSingleNode("ScreenX").text);
				var y = parseInt(myNode[i].selectSingleNode("ScreenY").text);
				if(POIHashTable[dwkey] == null){
					POIHashTable[dwkey] = new POI();
					POIHashTable[dwkey].id = dwkey;
					POIHashTable[dwkey].citycode = richmap.getCity();
					POIHashTable[dwkey].province = myNode[i].selectSingleNode("Province").text;
					POIHashTable[dwkey].city = myNode[i].selectSingleNode("City").text;
					POIHashTable[dwkey].county = myNode[i].selectSingleNode("County").text;
					POIHashTable[dwkey].isVipUser = myNode[i].selectSingleNode("VipUser").text;
					POIHashTable[dwkey].domainName = myNode[i].getAttribute("domainname");
					POIHashTable[dwkey].screenX = x;
					POIHashTable[dwkey].screenY = y;
					POIHashTable[dwkey].name = myNode[i].selectSingleNode("Name").text;
					POIHashTable[dwkey].displayName = myNode[i].selectSingleNode("Name").text;
					POIHashTable[dwkey].address = myNode[i].selectSingleNode("Address").text;
					POIHashTable[dwkey].phone = myNode[i].selectSingleNode("Phone").text;
				}else{
					POIHashTable[dwkey].displayName = myNode[i].selectSingleNode("Name").text;
					POIHashTable[dwkey].address = myNode[i].selectSingleNode("Address").text;
				}
				outStr += "<div style='width:100%;padding:3px;cursor:pointer;'";
				if(POIHashTable[dwkey].isVipUser == "true"){
					outStr += " class='info_normal' onMouseOver='cover(this);' onMouseOut='cout(this)' onClick=\"self.open('http:\/\/" + POIHashTable[dwkey].domainName + ".vip.richmap.cn/')\">"
					+ "<div style=\"float:left;width:23px;height:27px;margin:0;border:0;padding:0;"
					+ "filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled=true, sizingMethod=crop, "
					+ "src='images/icon/VIP/" + (i+1).toString() + ".png');"
					+ "background:none\">&nbsp;</div>"
					+ "<div style=\"width:180px;float:left;border:0;padding:0;margin:0;\">"
					+ "<div style=\"width:100%;border:0;padding:0;margin:0;\">"
					+ "&nbsp;&nbsp;<span class='infoTit_vip' >" + POIHashTable[dwkey].displayName + "</span></div>";
				}else{
					outStr += " class='info_normal' onMouseOver='cover(this);' onMouseOut='cout(this)' onClick=\"self.open('page/poi_" + dwkey + ".html')\">"
					+ "<div style=\"float:left;width:23px;height:28px;margin:0;border:0;padding:0;"
					+ "filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled=true, sizingMethod=crop, "
					+ "src='images/icon/POI/" + (i+1).toString() + ".png');"
					+ "background:none\">&nbsp;</div>"
					+ "<div style=\"width:180px;float:left;border:0;padding:0;margin:0;\">"
					+ "<div style=\"width:100%;border:0;padding:0;margin:0;\">"
					+ "&nbsp;&nbsp;<span class='infoTit_normal' >" + POIHashTable[dwkey].displayName + "</span></div>";
				}
				if(POIHashTable[dwkey].address != ""){
					outStr = outStr + "<div style='width:100%;'>地址：" + POIHashTable[dwkey].address + "</div>"; //.replace("<font color=#CC0033>","").replace("</font>","")
				}
				if(POIHashTable[dwkey].phone != ""){
					outStr = outStr + "<div style='width:100%;'>电话：" + POIHashTable[dwkey].phone + "</div>";
				}
				outStr = outStr + "</div></div>";
				//判定MBR
				if(i==0){
					POIListHashTable[flag].left = x;
					POIListHashTable[flag].bottom = y;
					POIListHashTable[flag].right = x;
					POIListHashTable[flag].top = y;
				}else{
					if(POIListHashTable[flag].left>x)POIListHashTable[flag].left = x;
					if(POIListHashTable[flag].bottom<y)POIListHashTable[flag].bottom = y;
					if(POIListHashTable[flag].right<x)POIListHashTable[flag].right = x;
					if(POIListHashTable[flag].top>y)POIListHashTable[flag].top = y;
				}
				//加入列表
				if(POIListHashTable[flag].xyList[x + "_" + y]==null){
					POIListHashTable[flag].poiList[j] = new Array();
					POIListHashTable[flag].xyList[x + "_" + y] = j;
					j++;
				}
				POIListHashTable[flag].poiShowNum[dwkey] = i+1;		//保存列表的位置
				POIListHashTable[flag].poiList[POIListHashTable[flag].xyList[x + "_" + y]].push(dwkey);
			}
			//提交地图显示
			Results.open();
			getById("resultCon").innerHTML = outStr;
			POIListHashTable[flag].toMap();
			outStr = null;
			//显示分页
			creatPage("pageShow",10,pageUrl,nowFlag,parseInt(xmlObj.selectSingleNode("root/Content/Companies").getAttribute("totalCount")),"getAroundData(","",1);
			bLock = false;	//解除锁定
		};
	};
	//alert(encodeURI(pageUrl+pageNo));
	xmlObj.load(encodeURI(pageUrl+pageNo));
};
function cover(obj){
	obj.className="info_vip_focus";
}
function cout(obj){
	obj.className="info_normal";
}
//关闭按钮的鼠标动作
function btnOver(obj){
	if(Results.m_bIsClose){
		obj.className='closeBtn_right_over';
	}else{
		obj.className='closeBtn_left_over';
	}
}
//关闭按钮的鼠标动作
function btnOut(obj){
	if(Results.m_bIsClose){
		obj.className='closeBtn_right_out';
	}else{
		obj.className='closeBtn_left_out';
	}
}
//结果子容器对象
function Result(sFlag,sTitle,sCityCode,sZone){
	this.flag = sFlag;		//保存每次查询的唯一标志
	this.title = sTitle;
	this.m_oFocusScript = null;	//保存聚焦对象索引
	this.citycode = sCityCode;	//保存城市代码
	this.zone = sZone;			//保存查询区域
	this.container = document.createElement("div");
	this.container.style.width = "100%";
	this.container.style.height = "100%";
	this.container.style.position = "absolute";
	this.container.style.left = "0px";
	this.container.style.top = "0px";
	this.container.style.overflowX = "hidden";
	this.container.style.overflowY = "auto";
	this.container.style.backgroundColor = "#ffffff";
	this.container.innerText = "读取信息中...";
	this.container.style.display = "none";
	Results.m_oResultCon.appendChild(this.container);
	//每个字容器的底部内容窗口
	this.container1 = document.createElement("div");
	this.container1.id = "showPage_"+this.flag;
	this.container1.style.width = "100%";
	this.container1.style.height = "100%";
	this.container1.style.position = "absolute";
	this.container1.style.left = "0px";
	this.container1.style.top = "0px";
	this.container1.style.padding = "5px";
	this.container1.style.overflow = "hidden";
	//this.container1.style.backgroundColor = "#ffffff";
	this.container1.style.textAlign = "right";
	this.container1.innerHTML = "开睿动力 Rich<font color='#C72307'>m</font><font color='#E4AE06'>a</font><font color='#37AB3C'>p</font> &copy; 2007";
	this.container1.style.display = "none";
	Results.m_oResultBot.appendChild(this.container1);
	//保存当前这个子对象聚焦的时候需要运行的脚本
	this.focusScript = function(){
		if(this.m_oFocusScript != null){
			try{this.m_oFocusScript.toMap();}catch(e){}
		}else{
			richmap.clearAllElement();
		}
	};
	//传入html代码在容器上显示内容,为空的时候显示这个子容器即可
	this.show = function(htmlStr){
		if(htmlStr != null && htmlStr != ""){
			this.container.innerHTML = htmlStr;
		}
		this.container.style.display = "";
		this.container1.style.display = "";
		//运行代码
		this.focusScript();
	};
	this.hidden = function(){
		this.container.style.display = "none";
		this.container1.style.display = "none";
	};
	this.del = function(){
		this.container.innerHTML = "";
		Results.m_oResultCon.removeChild(this.container);
		this.container = null;
		this.container1.innerHTML = "";
		Results.m_oResultBot.removeChild(this.container1);
		this.container1 = null;
		this.m_oFocusScript = null;
		//this = null;
	};
	//传入一个函数用于当这个结果对象聚焦的时候需要运行的脚本
	this.setFocusScript = function(obj){
		this.m_oFocusScript = obj;
	};
};

function getSearchTab(flag){
	var outStr = '<div style="width:100%;height:100%;"></div>'
};
var POIHashTable  = new Array();	//POI HashTable 用于保存POI对象
var POBHashTable = new Array();	//POB HashTable 用于保存POB对象
//POI对象
function POI(){
	this.id = "";	//唯一标示
	this.province = "";		//省份
	this.city = "";			//城市
	this.county	 = "";		//城镇
	this.citycode = "";		//城市代码
	this.isVipUser = "false";	//是否地图名片用户
	this.isPOI = true;	//是否是pub_company中的点信息
	this.screenX = "";		//加密经度
	this.screenY = "";		//加密纬度
	this.name = "";			//名称
	this.displayName = "";	//显示名称
	this.address = "";		//地址
	this.relateLink = "";	//名址详细页地址
	this.phone = "";		//电话
	this.showObj = null;	//显示对象
	//地图名片扩展属性
	this.getNamecardInfo = false;	//是否读取过namecard的信息
	this.profile = "";		//简介
	this.imgArr = [];		//公司图片数组
	this.email = "";		//email
	this.products = [];		//产品
	this.namecardId = "";	//名片id
	this.domainName = "";	//域名id
	//提交地图显示 showNum 显示点的时候的数字
	this.toMap = function(showNum){
		var tempPOI = this;
		//通过接口显示位置
		if(showNum == null)showNum = 1;
		this.showObj = new wingBasePoint("POI_" + this.id,this.screenX,this.screenY);
		this.showObj.nShadow = 1;
		var tempObj = new wingPicObj();
		tempObj.sImageSrc = "images/icon/"+(this.isVipUser=="true"?"VIP":"POI")+"/"+showNum+".png";		//图片地址
		if(this.isVipUser == "false"){
			tempObj.nImageWidth = 21;	//图片长
			tempObj.nImageHeight = 25;	//图片高
			tempObj.nScreenX = -10;			//图片热点相对坐标x
			tempObj.nScreenY = -27;			//图片热点相对坐标y		
		}else{
			tempObj.nImageWidth = 22;	//图片长
			tempObj.nImageHeight = 27;	//图片高
			tempObj.nScreenX = -11;			//图片热点相对坐标x
			tempObj.nScreenY = -29;			//图片热点相对坐标y		
		}
		tempObj.sAlt = this.name;
		tempObj.onmouseover = function(){
			try{wEMouseOver("POI_" + tempPOI.id);}catch(e){}
		};
		tempObj.onclick = function(){
			if(tempPOI.isVipUser == "false"){
				window.open("page/poi_" + tempPOI.id + ".html");
			}else{
				window.open("http:\/\/"+tempPOI.domainName+".vip.richmap.cn/");
			}
			//tempPOI.show();
		};
		this.showObj.addObj(tempObj);	
		var textObj = new wingTextObj();
		if(this.isVipUser == "true"){
			textObj.sText = "<nobr><a href=\"http:\/\/"+this.domainName+".vip.richmap.cn/\" target=_blank>" + this.name + "</a></nobr>";
		}else{
			textObj.sText = "<nobr><a href=\"page/poi_" + this.id + ".html\" target=_blank>" + this.name + "</a></nobr>";
		}
		textObj.sTextType = "HTML";
		textObj.sSize = "12px";
		if(this.isVipUser == "false"){
			textObj.nScreenX = 12;
			textObj.nScreenY = -27;
			textObj.sColor = "#000000";
			textObj.sBorder = "solid 1px #943008";
			textObj.sBgColor = "#FFFFFF";
		}else{
			textObj.nScreenX = 13;
			textObj.nScreenY = -29;
			textObj.sColor = "red";
			textObj.sBorder = "solid 1px red";
			textObj.sBgColor = "#F7F7CE";
		}
		textObj.sPadding = "2px";
		textObj.onmouseover = function(){
			try{wEMouseOver("POI_" + tempPOI.id);}catch(e){}
		};
		this.showObj.addObj(textObj);
		richmap.showElement(this.showObj);
	};
};
function wEMouseOver(elementId){
	if(nowFocusWingElement != ""){
		try{richmap.getElementObj(nowFocusWingElement).style.zIndex = 0;}catch(e){}
	}
	nowFocusWingElement = elementId;
	try{richmap.getElementObj(nowFocusWingElement).style.zIndex = 999;}catch(e){}
}
function wEMouseOut(elementId){
	richmap.getElementObj(nowFocusWingElement).style.zIndex = "";
	nowFocusWingElement = "";
}
var nowFocusSinglePoint = null;
var nowFocusWingElement = "";
var POIListHashTable = [];
//POI列表对象
function POIList(){
	this.left = 0;		//列表的最小加密经度
	this.bottom = 0;	//列表的最大加密纬度
	this.right = 0;		//列表的最大加密经度
	this.top = 0;		//列表的最小加密纬度
	this.poiList = new Array();	//保存POI的DWKEY，然后去POIHastTable里头去查找这个POI的对象
	this.poiShowNum = new Array();	//保存这个POI LIST的每个POI显示的时候的显示下标
	this.xyList = new Array();		//以x,y值做索引的哈希表,保存的是poilist数组的下标
	//提交地图显示
	this.toMap = function(){
		richmap.clearAllElement();
		var oPoiList = this;
		for(var i=0;i<this.poiList.length;i++){
			if(this.poiList[i].length == 1){
				POIHashTable[this.poiList[i][0]].toMap(this.poiShowNum[POIHashTable[this.poiList[i][0]].id]);
			}else{
				//显示多点的图片
				var listObj = new wingBasePoint("POIList_" + i,POIHashTable[this.poiList[i][0]].screenX,POIHashTable[this.poiList[i][0]].screenY);
				var tempObj = new wingPicObj();
				tempObj.sImageSrc = "images/icon/POI/0.png";		//图片地址
				tempObj.nImageWidth = 28;	//图片长
				tempObj.nImageHeight = 32;	//图片高
				tempObj.sAlt = "请选择具体的点";
				tempObj.nScreenX = 0;			//图片热点相对坐标x
				tempObj.nScreenY = -30;			//图片热点相对坐标y
				var doI = i;
				tempObj.onmouseover = function(){
					try{wEMouseOver("POIList_" + doI);}catch(e){}
					var showObjList = getById("showObjList");
					showObjList.innerHTML = "";
					for(var j=0;j<oPoiList.poiList[doI].length;j++){
						if(POIHashTable[oPoiList.poiList[doI][j]].isVipUser == "true"){
							showObjList.innerHTML += "<div style='cursor:pointer;border-bottom:solid 1px #eeeeee;'><a href='http:\/\/"+POIHashTable[oPoiList.poiList[doI][j]].domainName+".vip.richmap.cn/\" target=_blank>" + oPoiList.poiShowNum[POIHashTable[oPoiList.poiList[doI][j]].id] + "、" + POIHashTable[oPoiList.poiList[doI][j]].name + "</a></div>";
						}else{
							showObjList.innerHTML += "<div style='cursor:pointer;border-bottom:solid 1px #eeeeee;'><a href='/richmap4/page/poi_" + POIHashTable[oPoiList.poiList[doI][j]].id + ".html' target=_blank>" + oPoiList.poiShowNum[POIHashTable[oPoiList.poiList[doI][j]].id] + "、" + POIHashTable[oPoiList.poiList[doI][j]].name + "</a></div>";
						}
					}
					document.body.setCapture();
					showObjList.style.left = event.clientX - 3;
					showObjList.style.top = event.clientY - 3;
					document.body.releaseCapture();
					showHideObjList("");
				};
				tempObj.onmouseout = function(){
					showHideObjList("none");
				};
				listObj.addObj(tempObj);	
				richmap.showElement(listObj);
			}
		}
		//richmap.zoomToMBR(this.left,this.bottom,this.right,this.top);
	};
}
function showHideObjList(act){
	var showObjList = getById("showObjList");
	showObjList.style.display = act;
}
var sData_basePath = "";
var sData_hotKey = "search?act=GETHOT&size=?size?&zone=?zone?";
var HotKeyZoneStr = new Array();
function getHotKey(zone){
	if(HotKeyZoneStr[zone] != null){
		getById("hotKeyCon").innerHTML = HotKeyZoneStr[zone];
	}else{
		var sUrl = sData_basePath + sData_hotKey;
		sUrl = sUrl.replace("?size?","8");
		sUrl = sUrl.replace("?zone?",citycode);
		//开始异步查询
		var xmlObj = Sarissa.getDomDocument();
		xmlObj.async = true;
		xmlObj.onreadystatechange = function(){
			if(xmlObj.readyState == 4){
				if(xmlObj.parseError!=0){
					//Sarissa.getParseErrorText(xmlObj);
					return false;
				}
				try{
					var testNode = xmlObj.selectSingleNode("root/Return").text;
					if(testNode == "0"){
						return false;
					}
				}catch(e){
					return false;
				}
				//解析数据
				//alert(Sarissa.serialize(xmlObj));
				HotKeyZoneStr[zone] = "";
				var myNode = xmlObj.selectSingleNode("root/Content/Keywords").childNodes;
				for(var i=0;i<myNode.length;i++){
					HotKeyZoneStr[zone] += "　<a href='javascript:void(0);' onclick=\"singleLocalSearch('" + myNode[i].text + "')\">" + myNode[i].text + "</a>";
				};
				//getById("hotKeyCon").innerHTML = HotKeyZoneStr[zone];
			}
		};
		xmlObj.load(sUrl);
	}
};
function singleLocalSearch(text){
	self.open(encodeURI(basePath + "map.jsp?act=local&key=" + text + "&citycode=" + citycode));
}

var typeSearch = "search?act=gettype&type=?type?";
var typeArray = [];
function getType(type,typecode){
	sUrl = sData_basePath + typeSearch;
	sUrl = sUrl.replace("?type?",typecode);
	var xmlObj = Sarissa.getDomDocument();
	xmlObj.async = true;
	xmlObj.onreadystatechange = function(){
		if(xmlObj.readyState == 4){
			if(xmlObj.parseError!=0){
				document.getElementById("secondType"+type).innerHTML="读取信息错误...";
				return false;
			}
			try{
				var testNode = xmlObj.selectSingleNode("root/Return").text;
				if(testNode == "0"){
					document.getElementById("secondType"+type).innerHTML="<font color=red>没有结果</font>";
					return false;
				}
			}catch(e){
				return false;
			}			
			var seStr="";
			var code = "";
			var name = "";
			var pNode = xmlObj.selectSingleNode("root/Content/TypeCodes/TypeCode1").childNodes;
			for(var i=0;i<pNode.length;i++){
				code = pNode[i].getAttribute("ID");
				name = pNode[i].getAttribute("Name");
				typeArray[code] = name;
				seStr += "<img src='images/other/sort_45.gif'>&nbsp;";
				if(code == typeCode){
					seStr += "<span id='type"+code+"' style='color:#F46216;border:solid 1px #B04F04;padding:2px 3px 0px 3px;cursor:pointer;' onMouseOver=\"tover('"+code+"')\" onMouseOut=\"tout('"+code+"')\" onClick=\"searchType('"+code+"')\">"+name+"</span>&nbsp;&nbsp;&nbsp;&nbsp;";
				}else{
					seStr += "<span id='type"+code+"' style='cursor:pointer;padding:2px 3px 0px 3px;' onMouseOver=\"tover('"+code+"')\" onMouseOut=\"tout('"+code+"')\" onClick=\"searchType('"+code+"')\">"+name+"</span>&nbsp;&nbsp;&nbsp;&nbsp;";
				}
			}
			document.getElementById("secondType"+type).innerHTML=seStr;
			//getAroundData();
		}
	}
	xmlObj.load(sUrl);	
}
var nowType = "00";
typeArray["01"] = "餐饮美食";
typeArray["02"] = "休闲娱乐";
typeArray["03"] = "场馆会所";
typeArray["04"] = "金融银行";
typeArray["05"] = "医疗卫生";
typeArray["07"] = "学校科研";
typeArray["10"] = "宾馆饭店";
typeArray["11"] = "购物场所";

function changeType(type){
	if(type == nowType) return;
	if(type == null){type = firstType;}	
	var typename = "";
	switch(type){
		case "01": typename = '餐饮'; break;
		case "10": typename = '宾馆'; break;
		case "02": typename = '娱乐'; break;
		case "03": typename = '会馆'; break;
		case "04": typename = '金融'; break;
		case "05": typename = '医疗'; break;
		case "07": typename = '学校'; break;
		case "11": typename = '购物'; break;
		default : typename = '其他'; break;
	}
	if(nowType != "00"){
		document.getElementById("type"+nowType).src = "images/other/sort_"+nowType+".gif";
		document.getElementById("secondType"+nowType).style.display = "none";
	}
	if(document.getElementById("type"+type)){
		document.getElementById("type"+type).src = "images/other/sort1_"+type+".gif";
	}	
	document.getElementById("typePic").src = "images/other/sort2_"+type+".gif";
	document.getElementById("typeTit").innerText = typename+"查询结果";
	if(document.getElementById("secondType"+type)){
		document.getElementById("secondType"+type).style.display = "";
	}
	nowType = type;
	nowFocusType = type;
	if(typeFlag){
		if(document.getElementById("type"+typeCode)){
			document.getElementById("type"+typeCode).style.color="#000000";
			document.getElementById("type"+typeCode).style.border="0";
		}
		typeCode = type;
		getAroundData();
	}
	else typeFlag = true;
}
var nowSeType = typeCode;
var nowFocusType = "0101";
function searchType(typecode){
	if(typecode==nowType) return;
	if(document.getElementById("type"+nowSeType)){
		document.getElementById("type"+nowSeType).style.color="#000000";
		document.getElementById("type"+nowSeType).style.border="0";
		document.getElementById("type"+typecode).style.color="#F46216";
		document.getElementById("type"+typecode).style.border="solid 1px #B04F04";
	}
	nowFocusType = typecode;
	nowSeType = typecode;
	typeCode = typecode;
	getAroundData();
}
function tover(typecode){

	document.getElementById("type"+typecode).style.color="#F46216";
}
function tout(typecode){
	if(typecode!=nowSeType)document.getElementById("type"+typecode).style.color="#000000";
}
function upImg(){
	document.getElementById('resultType').scrollTop = parseInt(document.getElementById('resultType').scrollTop)+46;
}
function downImg(){
	document.getElementById('resultType').scrollTop = parseInt(document.getElementById('resultType').scrollTop)-46;
}

//------search notes begin-------------------------------
var g_arr_key = {
	'localBtn':{'localkey':'如：福州大学、肯德基、咖啡等名址或产品'},//本地查询
	'driverBtn':{'driverBegin':'比如：中亭街','driverEnd':'比如：东街口'}//自驾方案起点,终点
};
function et_loaded(){
	for(var i in g_arr_key){
		var btn_search = $(i);
		btn_search.onclick = search_btn_click;		
		for(var j in g_arr_key[i]){
			var key_txt = $(j);
			key_txt.setAttribute('defaultValue', g_arr_key[i][j]);
			key_txt.style.color = "#898A8A";
			key_txt.setAttribute('value', g_arr_key[i][j]);
			key_txt.setAttribute('searchType', i);
			et_event_attach(key_txt, 'click', key_text_click, false);
			et_event_attach(key_txt, 'blur', key_text_blur, false);
			key_txt.onkeydown = key_text_keydown;
		}
	}
}
et_event_attach(window, 'load', et_loaded, false);
function key_text_click(event){
	if(this.value == this.getAttribute('defaultValue')){
		this.value = '';
		this.style.color = "#000000";
	}
}
function key_text_blur(event){
	if(this.value == ''){
		this.value = this.getAttribute('defaultValue');
		this.style.color = "#898A8A";
	}
}

function key_text_keydown(event){
	if(typeof event == 'undefined'){event = window.event;}
	if(event.keyCode == 13){
		var search_type = this.getAttribute('searchType');
		validate_key_value(search_type);
	}
}

function search_btn_click(event){
	if(typeof event == 'undefined'){event = window.event}
	var search_type = this.getAttribute('id');
	validate_key_value(search_type);
}

function validate_key_value(search_type){
	//alert('begin validate');
	var search_index = -1;	
	for(var i in g_arr_key){
		search_index++;
		if(search_type != i){continue;}
		var valid = true;
		for(var j in g_arr_key[i]){
			var key_txt = $(j);
			if(key_txt.value == key_txt.getAttribute('defaultValue') || key_txt.value == ''){
				valid = false;
				break;
			}
		}
		if(valid){
			startSearch(search_index);
		}else{
			alert('无效关键词');
		}
	}
}	
//------search notes end-------------------------------