var noDetail='暂无';
var sp_imageURL='http://211.151.71.85:88/sp_image/';
var loadingHTML='<span><img src="image/loading.gif"></span>';
function GetObj(id){return document.getElementById(id);}
function ShowObj(id){document.getElementById(id).style.display='';}
function HideObj(id){document.getElementById(id).style.display='none';}
function EnableObj(id){document.getElementById(id).disabled=false;}
function DisableObj(id){document.getElementById(id).disabled=true;}
function FocusObj(id){document.getElementById(id).focus();}
function SetObjClassName(id,a){document.getElementById(id).className=a;}
function GetObjClassName(id){return document.getElementById(id).className;}
function GetObjValue(id){return document.getElementById(id).value;}
function SetObjValue(id,a){document.getElementById(id).value=a;}
function SetNull(id){document.getElementById(id).value='';}
function SetInnerHTML(id,a){document.getElementById(id).innerHTML=a;}
function SetOuterHTML(id,a){document.getElementById(id).outerHTML=a;}
function GetInnerHTML(id){ return document.getElementById(id).innerHTML;}
function showLoading_mine(div){try{SetInnerHTML(div,loadingHTML);}catch(e){}}
function filterContentbystr(s){return (s.replace(/<\/?[^>]*>/g,'')).replace(/[ | ]*\n/g,'\n');}
function CleanMap(){mapObj.removeAllOverlays();};
function quitDraw(){mapObj.quitMouseDraw();};
Array.prototype.unique=function(){var a=[];var l=this.length;for(var i=0;i<l;i++){for(var j=i+1;j<l;j++){if(this[i]===this[j])j=++i;}a.push(this[i]);}return a;};
if(typeof(HTMLElement)!="undefined"&&!window.opera){HTMLElement.prototype.__defineGetter__("outerHTML",function(){var a=this.attributes,str="<"+this.tagName,i=0;for(;i<a.length;i++)if(a[i].specified)str+=" "+a[i].name+'="'+a[i].value+'"';if(!this.canHaveChildren)return str+" />";return str+">"+this.innerHTML+"</"+this.tagName+">";});HTMLElement.prototype.__defineSetter__("outerHTML",function(s){var r=this.ownerDocument.createRange();r.setStartBefore(this);var df=r.createContextualFragment(s);this.parentNode.replaceChild(df,this);return s;});HTMLElement.prototype.__defineGetter__("canHaveChildren",function(){return !/^(area|base|basefont|col|frame|hr|img|br|input|isindex|link|meta|param)$/.test(this.tagName.toLowerCase());});}
String.prototype.trim=function(){return this.replace(/(^\s*)|(\s*$)/g,'');}
document.onkeydown=function(evt){var isie=(document.all)?true:false;var key;var srcobj;if(isie){key=event.keyCode;srcobj=event.srcElement;}else{key=evt.which;srcobj=evt.target;}if(key==13&&srcobj.type!='button'&&srcobj.type!='submit'&&srcobj.type!='reset'&&srcobj.type!='textarea'&&srcobj.type!=''){if(isie){event.keyCode=9;}else{var el=getNextElement(evt.target);if(el.type!='hidden'){el.focus();if(el.name=='searchsubmit'){var button=document.getElementById('searsubmitbutton');button.click();}}else{while(el.type=='hidden'){el=getNextElement(el);}}el.focus();return false;}}}
function getNextElement(a){var form=a.form;for(var e=0;e<form.elements.length;e++){if(a==form.elements[e]){break;}}return form.elements[++e%form.elements.length];}
function GetIconUsedOnMap(a){var icon='';if(a==0){icon='default';}else if(a==1){icon='dine';}else if(a==2){icon='wild';}else if(a==3){icon='show';}else if(a==4){icon='exhibit';}else if(a==5){icon='music';}else if(a==6){icon='salon';}else if(a==7){icon='gym';}else if(a==8){icon='gongyi';}if(icon!=''){return sp_imageURL+icon+'.png';}else{alert('缺少预置图片!');}}
function GetDefaultPointStyle(){var o = new MStyle();o.lineColor = '0xff230b';o.lineSize = 2;o.fillColor = '0xffffff';o.fillOpacity = 100;o.labelColor = '0xffffff';o.isShowLabels = false;o.isShowTip = true;o.textSize = 13;o.isLabelsFontBold = false;o.backgroundColor = '0xff230b';o.isLabelsBackground = false;o.textColor = '0xffffff';return o;}
function getRadioBoxValue(a){var obj=document.getElementsByName(a);for(i=0;i<obj.length;i++){if(obj[i].checked){return obj[i].value;}}}
var mapOptions=new MMapOptions();
mapOptions.mapId='fmptest';
mapOptions.zoomLevel=10;
if(typeof(initY)=='undefined'){
	mapOptions.center=new MLatLng('LQGWYKNRRPHLD','JIOMSQMUNTPLHL');
}else{
	mapOptions.center=new MLatLng(initY,initX);
}
var mapObj=new MMap('mapObj',mapOptions);
var kc=new Object();
kc.zoomkey=kc.dirkey=kc.pagekey=0;
mapObj.setKeyboardControl(kc);
mapObj.addEventListener(MMap.EVENT_POINT_DRAWN,pointDrawn);
mapObj.switchDefaultDBClickProcessor(false);
//mapObj.removeCompass();
mapObj.addEventListener(MMap.EVENT_GEOMETRY_CHANGED,pointMoved);
if(typeof(browse)=='undefined'){
	mapObj.setMapMode(MMapMode.EDIT);
}
mapObj.showFullScreenButton(true);
//mapObj.setMapColor({ra:100, rb:0, ga:85, gb:55, ba:80, bb:55, aa:100, ab:100});
function pointDrawn(event){
	quitDraw();
	var a=event.args.split(',');
	var pX=a[2];
	var pY=a[3];
	try{
		SetObjValue('sp_hd_hold_drawpointx',pX);
		SetObjValue('sp_hd_hold_drawpointy',pY);
		CleanMap();
		var t=GetObjValue('drawtype');
		if(t=='around'){
			DisableObj('searcharound_poi');
			SetObjValue('searcharound_poi','标点位置');
			SetObjValue('searcharound_poix',pX);
			SetObjValue('searcharound_poiy',pY);
		}else if(t=='bus1'){
			DisableObj('searchbus_start_name');
			SetObjValue('searchbus_start_name','起点');
			SetObjValue('searchbus_startx',pX);
			SetObjValue('searchbus_starty',pY);
		}else if(t=='bus2'){
			DisableObj('searchbus_end_name');
			SetObjValue('searchbus_end_name','终点');
			SetObjValue('searchbus_endx',pX);
			SetObjValue('searchbus_endy',pY);
		}else if(t=='drive1'){
			DisableObj('searchdrive_start_name');
			SetObjValue('searchdrive_start_name','起点');
			SetObjValue('searchdrive_startx',pX);
			SetObjValue('searchdrive_starty',pY);
		}else if(t=='drive2'){
			DisableObj('searchdrive_end_name');
			SetObjValue('searchdrive_end_name','终点');
			SetObjValue('searchdrive_endx',pX);
			SetObjValue('searchdrive_endy',pY);
		}
	}catch(e){
		try{
			document.registerform.x.value=pX;
			document.registerform.y.value=pY;
			mapObj.removeAllOverlays();
			var centerPoint=new MDragablePointWithoutTip(new MLatLng(pY,pX),new MStyle(),1000);
			mapObj.addOverlay(centerPoint,true);
		}catch(e){}
	}
	try{
		document.getElementById('actionpanel').style.display='';
	}catch(e){}
	try{
		document.hold.x.value=pX;
		document.hold.y.value=pY;
		mapObj.removeAllOverlays();
		var centerPoint=new MDragablePointWithoutTip(new MLatLng(pY,pX),new MStyle(),1000);
		mapObj.addOverlay(centerPoint,true);
	}catch(e){}
	try{
		var thisPicId=GetObjValue('currenteditpicid');
		var thisPicCity='city_'+thisPicId;
		try{
			document.getElementById(thisPicCity).value=GetObjValue('resideprovince')?GetObjValue('resideprovince'):GetObjValue(thisPicCity);
		}catch(e){}
		var x='x_'+thisPicId.toString();
		var y='y_'+thisPicId.toString();
		document.getElementById(x).value=pX;
		document.getElementById(y).value=pY;
		var thisPicId=parseInt(thisPicId);
		var thisPicLinkId='link_'+thisPicId.toString();
		var icon=document.getElementById(thisPicLinkId).value;
		var centerPointStyle=new MStyle();
		centerPointStyle.lineColor=0xff230b;
		centerPointStyle.lineSize=2;
		centerPointStyle.fillColor=0xffffff;
		centerPointStyle.fillOpacity=100;
		centerPointStyle.labelColor=0xffffff;
		centerPointStyle.labels=thisPicId;
		centerPointStyle.isShowLabels=false;
		centerPointStyle.isShowTip=false;
		centerPointStyle.textSize=13;
		centerPointStyle.isLabelsFontBold=false;
		centerPointStyle.backgroundColor=0xff230b;
		centerPointStyle.isLabelsBackground=false;
		centerPointStyle.textColor=0xffffff;
		mapObj.removePointById(thisPicId);
		var centerPoint=new MCustomPointOverlay(new MLatLng(pY,pX),icon,centerPointStyle,thisPicId);
		if(GetObjValue('modifiedpicids')==''){
			SetObjValue('modifiedpicids',thisPicId);
		}else{
			var o=document.getElementById('modifiedpicids').value+','+thisPicId;
			SetObjValue('modifiedpicids',o);
		}
		mapObj.addOverlay(centerPoint,true);
	}catch(e){}
	try{
		document.getElementById('incpalbum').value='1';
		var checkbox=document.forms['hold'].elements['box[]'];
		var allcheckpicsids=GetCheckboxValue(checkbox);
		checkedpicsarr=allcheckpicsids.split(',');
		for(i=0;i<checkedpicsarr.length;i++){
			if(checkedpicsarr[i]!=''){
				var thisPicId=checkedpicsarr[i];
				var thisPicCity='city_'+thisPicId;
				try{
					document.getElementById(thisPicCity).value=GetObjValue('resideprovince')?GetObjValue('resideprovince'):GetObjValue(thisPicCity);
				}catch(e){}
				var x='x_'+thisPicId.toString();
				var y='y_'+thisPicId.toString();
				SetObjValue(x,pX);
				SetObjValue(y,pY);
				var thisPicId=parseInt(thisPicId);
				var thisPicLinkId='link_'+thisPicId.toString();
				var icon=GetObjValue(thisPicLinkId);
				var centerPointStyle=new MStyle();
				centerPointStyle.lineColor=0xff230b;
				centerPointStyle.lineSize=2;
				centerPointStyle.fillColor=0xffffff;
				centerPointStyle.fillOpacity=100;
				centerPointStyle.labelColor=0xffffff;
				centerPointStyle.labels=thisPicId;
				centerPointStyle.isShowLabels=false;
				centerPointStyle.isShowTip=false;
				centerPointStyle.textSize=13;
				centerPointStyle.isLabelsFontBold=false;
				centerPointStyle.backgroundColor=0xff230b;
				centerPointStyle.isLabelsBackground=false;
				centerPointStyle.textColor=0xffffff;
				mapObj.removePointById(thisPicId);
				var centerPoint=new MCustomPointOverlay(new MLatLng(pY,pX),icon,centerPointStyle,thisPicId);
				if(GetObjValue('modifiedpicids')==''){
					SetObjValue('modifiedpicids',thisPicId);
				}else{
					var o=document.getElementById('modifiedpicids').value+','+thisPicId;
					SetObjValue('modifiedpicids',o);
				}
				mapObj.addOverlay(centerPoint,true);
			}
		}
	}catch(e){}
	getReturnCity(pX,pY);
}
function pointMoved(event){
	try{
		SetNull('sp_hd_hold_drawpointx');
		SetNull('sp_hd_hold_drawpointy');
		document.map.sp_hd_hold_drawpointreturncity.value='';
		var o_x=(((event.args.split(',')[2]).split(':'))[1]).replace(new RegExp("\"", "g"),'');
		SetObjValue('sp_hd_hold_drawpointx',o_x);
		var o_y=(((event.args.split(',')[3]).split(':'))[1]).replace(new RegExp("\"", "g"),'');
		SetObjValue('sp_hd_hold_drawpointx',o_y);
		getReturnCity(document.map.sp_hd_hold_drawpointx.value,document.formhold.sp_hd_hold_drawpointy.value);
	}catch(e){}
	try{
		document.hold.x.value='';
		document.hold.y.value='';
		document.hold.thishdcity.value='';
		document.hold.x.value=(((event.args.split(",")[2]).split(":"))[1]).replace(new RegExp("\"", "g"),'');
		document.hold.y.value=(((event.args.split(",")[3]).split(":"))[1]).replace(new RegExp("\"", "g"),'');
		getReturnCity(document.hold.x.value,document.hold.y.value);
	}catch(e){
		try{
			document.registerform.x.value='';
			document.registerform.y.value='';
			document.registerform.thishdcity.value='';
			document.registerform.x.value=(((event.args.split(",")[2]).split(":"))[1]).replace(new RegExp("\"", "g"),'');
			document.registerform.y.value=(((event.args.split(",")[3]).split(":"))[1]).replace(new RegExp("\"", "g"),'');
			getReturnCity(document.registerform.x.value,document.registerform.y.value);
		}catch(e){}
	}
	try{
		var nowpicid=GetObjValue('currenteditpicid');
		var nowpiccityid='city_'+nowpicid;
		var nowpicxid='x_'+nowpicid;
		var nowpicyid='y_'+nowpicid;
		var o_1=(((event.args.split(",")[2]).split(":"))[1]).replace(new RegExp("\"", "g"),'');
		SetObjValue(nowpicxid,o_1);
		var o_2=(((event.args.split(",")[3]).split(":"))[1]).replace(new RegExp("\"", "g"),'');
		SetObjValue(nowpicyid,o_2);
	}catch(e){}
	mapObj.setCenterByLatLng((((event.args.split(",")[3]).split(":"))[1]).replace(new RegExp("\"", "g"),''),(((event.args.split(",")[2]).split(":"))[1]).replace(new RegExp("\"", "g"),''));
} 