// JavaScript Document
/*导航
-----------------------------------------------------------------*/
function init(){
   document.getElementById('li001').className='li01';
   document.getElementById('li002').className='li02';
   document.getElementById('li003').className='li03';
   document.getElementById('li004').className='li04';
   document.getElementById('li005').className='li05';
   document.getElementById('li006').className='li06';
   document.getElementById('li007').className='li07';
   document.getElementById('li008').className='li08';
   document.getElementById('li009').className='li09';
   document.getElementById('li010').className='li10';
   document.getElementById('li011').className='li11';
   document.getElementById('li012').className='li12';
 }
function li(ttt){
	//alert(1);
   init();
   document.getElementById(ttt).className=ttt + "B";  
   document.getElementById('InfoBox').src=ttt + '.jsp';
}
/*头部按钮
-----------------------------------------------------------------*/
var temp=0;
var temp2=0;
function Entrance01(){
	if (temp==0){
		 document.getElementById('p3a').style.display='block';
	  	 document.getElementById('p4a').style.display='none';	
		 temp=1;
		 temp2=0;
	}else{
		document.getElementById('p3a').style.display='none';
	   	document.getElementById('p4a').style.display='none';
	   	temp=0;
	}
}
function Entrance02(){
	if (temp2==0){
		 document.getElementById('p4a').style.display='block';
	  	 document.getElementById('p3a').style.display='none';	
		 temp2=1;
		 temp=0;
	}else{
		document.getElementById('p4a').style.display='none';
	   	document.getElementById('p3a').style.display='none';
	   	temp2=0;
	}
}
function Entrance03()
{
		document.getElementById('p4a').style.display='none';
	   	document.getElementById('p3a').style.display='none';
	   	temp=0;
	   	temp2=0;	
}
/*查询
-----------------------------------------------------------------*/
function inFoBox01(){
	   document.getElementById('InitialA01').style.display='none';
	   document.getElementById('InitialA02').style.display='block';
	 }
function inFoBox02(){
	   document.getElementById('InitialB01').style.display='none';
	   document.getElementById('InitialB02').style.display='block';
	 }


		var PoiArr;
		var LineArr;
		var mapLock;
		var mapLockMsg;

	function initMapParameter() {
		PoiArr = new Array();//放入所有 点 对像的数组
		LineArr = new Array();//放入所有 线，面 对像的数组
		mapLock = false; //操作地图锁， true时不能利用工具栏对地图进行新增标注点、线、面的操作
		mapLockMsg = ""; //地图加锁后，显示的提示信息
	}

	function delPoi(poiObj) {
		var poiMarker = poiObj.marker;
		maplet.removeOverlay(poiMarker);

		//var i = getPoiIndexByObjId(poiObj.objId)
		//PoiArr.splice(i,1);
	}
	//在地图上删除最后显示的点
	function delLastPoi() {
		poiObj = PoiArr[PoiArr.length-1];
		delPoi(poiObj)
	}

	//从集合中根据objId获取Poi对象
	function getPoiByObjId(objId) {
		var pIndex = getPoiIndexByObjId(objId);
		if(pIndex==-1){
			return null;
		} else {
			return PoiArr[pIndex];
		}
	}

	//从集合中根据objId查找Poi对象的Index
	function getPoiIndexByObjId(objId) {
		for(var i=0; i<PoiArr.length; i++) {
			if(objId == PoiArr[i].objId) {
				return i;
			}
		}
		return -1;
	}

	//从集合中根据Id获取Poi对象
	function getPoiById(Id) {
		var pIndex = getPoiIndexById(Id);
		if(pIndex==-1){
			return null;
		} else {
			return PoiArr[pIndex];
		}
	}

	function getPoiIndexById(Id) {
		for(var i=0; i<PoiArr.length; i++) {
			if(Id == PoiArr[i].id) {
				return i;
			}
		}
		return -1;
	}
	
	function getPoiByLikeId(Id) {
		var pIndex = getPoiIndexByLikeId(Id);
		if(pIndex==-1){
			return null;
		} else {
			return PoiArr[pIndex];
		}
	}
	function getPoiIndexByLikeId(Id) {
		for(var i=0; i<PoiArr.length; i++) {
			if(PoiArr[i].id.indexOf(Id)>-1) {
				return i;
			}
		}
		return -1;
	}	
	function showPoiInfoById(Id) {
		//alert(Id);
		var i = getPoiIndexById(Id);
		//alert(i);
		if(i>-1){
			if(PoiArr[i].preIconReadSign<1000 && (PoiArr[i].preIcon==null || !PoiArr[i].preIcon.complete)){
				setTimeout("showPoiInfoById('"+Id+"')",10);
			}else if(PoiArr[i].preIcon!=null && PoiArr[i].preIcon.complete){
				setTimeout("PoiArr["+i+"].marker.openInfoWindow()",10);
			}
		}else{
			//alert("该点不存在，请刷新列表");
		}
	}
	
	function mapClean(){
		if(!mapLock) {
		  initMapParameter();
			maplet.clearOverlays();
			maplet.clean();
		}
	}	
	function addPoi(poiObj) {
	//alert(poiObj.strlatlon);
		var point = new MPoint(poiObj.strlatlon);

		if(getPoiIndexByObjId(poiObj.objId)==-1){
			PoiArr.push(poiObj);
		}

		if(poiObj.preIconReadSign<1000 && (poiObj.preIcon==null || !poiObj.preIcon.complete)){
			if(poiObj.preIcon==null){
					poiObj.preIcon=new Image();
					poiObj.preIcon.src=poiObj.icon;
			}
			poiObj.preIconReadSign++;
			setTimeout("addPoi(getPoiByObjId('"+poiObj.objId+"'))",10);

		} else {

			if(poiObj.preIcon.width<2 || poiObj.preIcon.height<2) {
				poiObj.iconWidth = 32;
				poiObj.iconHeight = 32;
			}else{
				poiObj.iconWidth = poiObj.preIcon.width;
				poiObj.iconHeight = poiObj.preIcon.height;
			}
			var icon = new MIcon(poiObj.getMarkerIcon(), poiObj.iconWidth, poiObj.iconHeight,(poiObj.iconWidth*poiObj.iconTargetLeft),(poiObj.iconHeight*poiObj.iconTargetTop));
			var infoWindow = new MInfoWindow(poiObj.getMarkerTitle(), poiObj.getMarkerContent());
			var poiMarker ;
			if (poiObj.getMarkerContent()=='')
			{
				poiMarker = new MMarker(point,icon,null);
			}
			else
			{
				poiMarker = new MMarker(point,icon,infoWindow);
			}
			maplet.addOverlay(poiMarker);//打点
			poiObj.marker = poiMarker;
		}
	}	 