 function startMarker(){
 
 			  //添加标注菜单
	 	     addMarkerMenu();
	 	     
			if(usertype=="-1000"||usertype=="-100"){ 			  
	 			 document.getElementById("biaozhu_close").style.display = "none";
	 			 document.getElementById("markerPermissionsPanelBtn").style.display = "none";
	 			 document.getElementById("markerNamePermissionsPanelBtn").style.display = "none";
	 			 document.getElementById("fencePermissionsPanelBtn").style.display = "none";	 			   
			 }else{
			 	
			 	 //点击地图时关闭已经打开的弹出框
	 			  mapclickEvent();
	   
	  			  //获取标注Josn集
				  getMarkerJson();
				  
				  //获取标注组Json集
				  getGroupJson();
				  
				  //获取所有标注组Json集
				  getAllMarkerGroupJson();
				  
				  //绘制标注树
				  showMarkerGroupTree();
				    
				  //添加所有标注  
				  addAllMarker();
	 			
	 			 //添加标注组选择框
	 			 //addMarkerGroupSelect("marker_group_option");
	 			
	             //添加标注窗口开始
					frame("markerContentWin","moveMarkerWin","closecmarkerWin");
				 //添加标注窗口结束
				 
				 //添加标注组窗口开始
					frame("addGroupContentWin","moveGroupWin","closeGroupWin");
				 //添加标注组窗口结束
				 
				 //标注头像选择窗口开始
					frame("selectMarkerPhotoWin","moveSelectMarkerPhotoWin","closeSelectMarkerPhotoWin");
				 //标注头像选择窗口结束
				 
				  //标注绑定设备窗口开始
					frame("marker_vehicle_binding_ContentWin","move_marker_vehicle_binding_Win","close_marker_vehicle_binding_Win");
				 //标注绑定设备窗口结束
				 
				 //装载区域大小滑块
				 loadAreaSlider();
				 
				  MarkerTreeMenu.init();
				 
				 $("#fencePermissionsPanelBtn").show();
  				 electronicFence.tree.init();
			 }
			 
			 addEvent();
			 
}



var isChrome = navigator.userAgent.toLowerCase().match(/chrome/) != null;
var markerGroupJson=null;
var allMarkerGroupJson=null;
	
var markerObject={
	markerJson : "",
	markerArr : {},
	myLatlng : null,
	infowindow : null,
	markerids : new Array(),
	markertitlearr : new Array(),
	addMarker : function(_id,_lat,_lng,_icon){
					 if(this.markerids.indexOf(_id) < 0) this.markerids.push(_id);
					 this.myLatlng=new google.maps.LatLng(_lat,_lng);
					 var image = {
								    url: _icon,
								    // This marker is 20 pixels wide by 32 pixels tall.
								    size: new google.maps.Size(32, 32),
								    // The origin for this image is 0,0.
								    origin: new google.maps.Point(0,0),//位置
								    // The anchor for this image is the base of the flagpole at 0,32.
								    anchor: new google.maps.Point(16, 16)
								  };
					 
					 var competence = markerObject.markerArr[_id].competence;
					 
					 var marker = new google.maps.Marker({
									      position: this.myLatlng,
									      map: map,
									      icon: image,
									      draggable : (competence ==1 ? true : false)
									});
					
					 google.maps.event.addListener(marker, 'drag', function(polygon) {	
					 		
							markerObject.infowindow.setPosition(marker.getPosition());
							
							var _marker = markerObject.markerArr[_id]; 	
							
							$("#infoWinLat").text(marker.getPosition().lat().toFixed(5));
							$("#infoWinLng").text(marker.getPosition().lng().toFixed(5));
							
							$("#markerlat").val(marker.getPosition().lat());							
	    					$("#markerlng").val(marker.getPosition().lng());	    					
							
							ceneterLatlng = marker.getPosition();
					 		
					 		if(_marker.area){
	 							
	 							LatLngBounds = new google.maps.LatLngBounds(
					 			
					 				getAreaSWLatlng(marker.getPosition().lat(),marker.getPosition().lng(),_marker.areaRadius),
					 				getAreaNELatLng(marker.getPosition().lat(),marker.getPosition().lng(),_marker.areaRadius)
					 			
					 			);
	 							
					 			_marker.area.setBounds(LatLngBounds);
					 			
					 		}
					 		
					 		if($("#bzcheckbox").is(":checked") && curmarkerNameLabe){
					 		
					 			curmarkerNameLabe.latLng_ = marker.getPosition();
					 			curmarkerNameLabe.draw();
					 			
					 		}
					 
					 });
					 
					 google.maps.event.addListener(marker, 'dragstart', function(polygon) {	
					 		
					 		var _marker = markerObject.markerArr[_id]; 			 						
							
							 markerObject.closeInfowindow();
							 
							 var contentHtml;

							 contentHtml="<div style=\"width:200px;height:auto !important;min-height:15ppx;overflow: hidden;display:block;\"><b>"+language.mc+"</b>&nbsp;&nbsp;&nbsp;&nbsp;"+_marker.title+"</br><b>"+language.jingdu+"</b>:&nbsp;&nbsp;&nbsp;&nbsp;<span id ='infoWinLng'>"+_marker.lng.toFixed(5)+"</span></br><b>"+language.weidu+"</b>:&nbsp;&nbsp;&nbsp;&nbsp;<span id ='infoWinLat'>"+_marker.lat.toFixed(5)+"</span></br><b>"+language.ms+"</b>&nbsp;&nbsp;&nbsp;&nbsp;"+_marker.text+"</br><b><a  style=\"display:none;\" href=\"javascript:openUpdateMarkerWin("+_marker.id+");\"><font color=\"#0000FF\">"+language.xgbj+"<font></a></b></div>";
							 
							 markerObject.infowindow = new google.maps.InfoWindow({ 
							     content:contentHtml,
							     maxWidth:200
							 }); 
							 
							 markerObject.infowindow.id = _id;
							
							 curmarkerNameLabe = markerObject.markerArr[_id].lable;			
							 
							 closeVehicleInfoWindow();
							 
							 markerObject.infowindow.open(map,this);
 
							 google.maps.event.addListener(markerObject.infowindow, 'closeclick', function(e) {
							  	if($("#moveMarkerBtn").is(":visible")){
								  	if(confirm(language.bcbz)){							  		
								  		updateMarkerPosition(_id);
								  	}else{
								  		calcleupdateMarkerPosition(_id);
								  	}							  	
							  	}
							 
							 });							 							 							 

					 });
					 
					 google.maps.event.addListener(marker, 'dragend', function(polygon) {	
							 
							 var _marker = markerObject.markerArr[_id];

							 markerObject.infowindow.setContent(contentHtml="<div style=\"width:200px;height:auto !important;min-height:15ppx;overflow: hidden;display:block;\">"+
								 												"<b>"+language.mc+"</b>&nbsp;&nbsp;&nbsp;&nbsp;"+_marker.title+"</br>"+
								 												"<b>"+language.jingdu+"</b>:&nbsp;&nbsp;&nbsp;&nbsp;"+
								 													"<span id ='infoWinLng'>"+_marker.marker.getPosition().lng().toFixed(5)+"</span></br>"+
								 												"<b>"+language.weidu+"</b>:&nbsp;&nbsp;&nbsp;&nbsp;<span id ='infoWinLat'>"+_marker.marker.getPosition().lat().toFixed(5)+"</span></br>"+
								 												"<b>"+language.ms+"</b>&nbsp;&nbsp;&nbsp;&nbsp;"+_marker.text+"</br>"+
								 												"<b><a style=\"display:none;\" id=\"update_marker_google_btn\" href=\"javascript:openUpdateMarkerWin("+_marker.id+");\">"+
								 													"<font color=\"#0000FF\">"+language.xgbj+"</font></a>"+
								 													"<span id='moveMarkerBtn'>&nbsp;&nbsp;"+
								 														"<a href=\"javascript:updateMarkerPosition("+_marker.id+");\">"+
								 															"<font color=\"#0000FF\">"+language.xgwz+"</font></a>&nbsp;&nbsp;|&nbsp;&nbsp;"+
								 														"<a href=\"javascript:calcleupdateMarkerPosition("+_marker.id+");\">"+
								 															"<font color=\"#0000FF\">"+language.qx+"</font></a>"+
								 														"<span style='color:red' id='updatePositionMsg'></span>"+
								 													"</span>"+
								 												"</b>"+
								 											"</div>");

					 });
									
					return marker;
	},
	addMarkerListener : function(_marker){
					 
					 google.maps.event.addListener(_marker.marker, "click", function (e) {
					         menu.hide();
							 markerObject.closeInfowindow();
							 var contentHtml;
							 if(_marker.competence==1){
							 	contentHtml="<div style=\"width:200px;height:auto !important;min-height:15ppx;overflow: hidden;display:block;\"><b>"+language.mc+"</b>&nbsp;&nbsp;&nbsp;&nbsp;"+_marker.title+"</br><b>"+language.jingdu+"</b>:&nbsp;&nbsp;&nbsp;&nbsp;"+_marker.lng.toFixed(5)+"</br><b>"+language.weidu+"</b>:&nbsp;&nbsp;&nbsp;&nbsp;"+_marker.lat.toFixed(5)+"</br><b>"+language.ms+"</b>&nbsp;&nbsp;&nbsp;&nbsp;"+_marker.text+"</br><b><a href=\"javascript:openUpdateMarkerWin("+_marker.id+");\"><font color=\"#0000FF\">"+language.xgbj+"<font></a></b></div>";
							 }else{
							 	contentHtml="<div style=\"width:200px;height:auto !important;min-height:15ppx;overflow: hidden;display:block;\"><b>"+language.mc+"</b>&nbsp;&nbsp;&nbsp;&nbsp;"+_marker.title+"</br><b>"+language.jingdu+"</b>:&nbsp;&nbsp;&nbsp;&nbsp;"+_marker.lng.toFixed(5)+"</br><b>"+language.weidu+"</b>:&nbsp;&nbsp;&nbsp;&nbsp;"+_marker.lat.toFixed(5)+"</br><b>"+language.ms+"</b>&nbsp;&nbsp;&nbsp;&nbsp;"+_marker.text+"</br></div>";
							 }
							 
							 markerObject.infowindow = new google.maps.InfoWindow({ 
							     content:contentHtml,
							     maxWidth:200
							 }); 
							 closeVehicleInfoWindow();
							 markerObject.infowindow.open(map,this);
					 });
					 
	},
	deleteMarker : function(_id){
					
					for(var i=0;i<this.markerids.length;i++){
						if(_id==this.markerids[i]){
							this.markerids.remove(i);
							break;
						}
					}
					this.markerArr[_id].marker.setMap(null);
					if(this.markerArr[_id].area!=null){
						this.markerArr[_id].area.setMap(null);
					}
					
					if(markerObject.infowindow != null){
						markerObject.infowindow.close();
					}
					
					if(this.markerArr[_id].lable){
						this.markerArr[_id].lable.setMap(null);
						this.markerArr[_id].lable = null;
					}
					
					this.markerArr[_id]=null;
	},
	closeInfowindow : function(){
					if(this.infowindow!=null){
					 	this.infowindow.close();
					 	if(this.infowindow.id){
					 		calcleupdateMarkerPosition(this.infowindow.id);
					 	}
					 }
	}, 
	clear : function(){
	
	}
}

function getMarkerJson(){
		$.ajax({
	        type: "POST",
	        dataType: "json",
	        async:true,
	        url: "json/markerAction_getMarker.action",
	        success: function(json) {		         
		         if (json.flag==true) {
	         		 markerObject.markerJson=json;		        	 					           				
                 }else{
                 	alert(json.msg);
                 }
	        },
	        error: function() {}
	   });	
}
function getAllMarkerGroupJson(){
		$.ajax({
	        type: "POST",
	        dataType: "json",
	        async:true,
	        url: "json/markerAction_getMarkerGroup.action",
	        success: function(json) {		         
		         if (json.flag==true) {
	         		 allMarkerGroupJson=json;		        	 					           				
                 }else{
                 	alert(json.msg);
                 }
	        },
	        error: function() {}
	   });	
}
function deleteMarker(id){
		
		markerObject.closeInfowindow();
		
		if(window.confirm(language.sfscbz)){
			if(markerObject.markerArr[id].competence==1){
				$.ajax({
			        type: "POST",
			        dataType: "json",
			        async:false,
			        url: "json/markerAction_delMarker.action",
			        data: {"markerID":id},
			        success: function(json) {		         
				         if (json.flag==true) {
				                  markerObject.deleteMarker(id);
				                  deleteMarkerGroupTreeNode(id);			
		                 }else{
		                 	alert(json.msg);
		                 }
			        },
			        error: function() {}
			   });	
			}else{
				alert(language.qxts);
			}
		}
}

function addMarker_Area(){
		$("#addMarkerButton").attr("disabled","disabled");
		var title,desc,icon,lat,lng,groupid,leftlat,leftlng,rigthlat,rigthlng,bzType,customerNum;
		title=$("#markertitle").val();
		desc=$("#markerdesc").val();
		if (isChrome) {
        	icon=$("#markerImagesrc").css("backgroundImage").split("(")[1].split(")")[0];
		}else{
			icon=$("#markerImagesrc").css("backgroundImage").split("\"")[1];
		}
		lat=$("#markerlat").val();
		lng=$("#markerlng").val();
		groupid=$("#markerGroupId").val();
		leftlat=$("#leftlat").val();
		leftlng=$("#leftlng").val();
		rigthlat=$("#rigthlat").val();
		rigthlng=$("#rigthlng").val();
		bzType=$('input[name="bzType"]:checked').val();
		customerNum=$("#customerNum").val();
		if(title.length==0){
			$("#addmarkermsg").text(language.btbnwk);
			$("#addmarkermsg").css("color","red");
			$("#addMarkerButton").removeAttr("disabled");
			return;
		}else{
			$("#addmarkermsg").css("color","rgb(153, 153, 153)");
		}
		if(desc.length>150){
			$("#addmarkermsg").text(language.msbndy150gz);
			$("#addmarkermsg").css("color","red");
			$("#addMarkerButton").removeAttr("disabled");
			return;
		}
		
		
		var getcustomerNums = getcustomerNum_vlaues();
		
		if( customerNum.length > 0 && ($.inArray(customerNum, getcustomerNums) < 0)){
		
			if(!window.confirm(language.yytwtjdkhh)){
				$("#addMarkerButton").removeAttr("disabled");
				return;
			}
		}
		
		$.ajax({
	        type: "POST",
	        dataType: "json",
	        async:true,
	        url: "json/markerAction_addOrUpdateUserMarker.action",
	        data:{"title":title,"text":desc,"icon":icon,"lat":lng,"lng":lat,"groupid":groupid,"leftLat":leftlat,"leftLon":leftlng,"rightLat":rigthlat,"rightLon":rigthlng,"radius":markersize,"bzType":bzType,"customerNum":getcustomerNums.join("/"),"mapType":2},
	        success: function(json) {		         
		         if (json.flag==true){
		        	     $("#addMarkerButton").removeAttr("disabled");
		         		 if(typeof json.data[0].id=="number" && typeof json.data[0].lat2=="number" && typeof json.data[0].lng2=="number" && json.data[0].icon.length!=0){
			         		 //$("#markerContentWin").fadeOut("fast");
			         		 
			         		
				 			
					 		 markerObject.markerArr[json.data[0].id]={};
						  	 markerObject.markerArr[json.data[0].id].competence=json.data[0].competence;		
						  	 markerObject.markerArr[json.data[0].id].title=json.data[0].title;
						  	 markerObject.markerArr[json.data[0].id].text=json.data[0].text;
						  	 markerObject.markerArr[json.data[0].id].icon=json.data[0].icon;
						  	 markerObject.markerArr[json.data[0].id].lng=json.data[0].lat2;
						  	 markerObject.markerArr[json.data[0].id].lat=json.data[0].lng2;
						  	 markerObject.markerArr[json.data[0].id].blng=json.data[0].blat;
						  	 markerObject.markerArr[json.data[0].id].blat=json.data[0].blng;
						  	 markerObject.markerArr[json.data[0].id].groupid=json.data[0].groupid;
						  	 markerObject.markerArr[json.data[0].id].id=json.data[0].id;
						  	 markerObject.markerArr[json.data[0].id].customerNum=json.data[0].markcode;
						  	 markerObject.markerArr[json.data[0].id].isShow=true;
						  	 
						  	 var marker=markerObject.addMarker(json.data[0].id,json.data[0].lng2,json.data[0].lat2,json.data[0].icon);
						  	 markerObject.markerArr[json.data[0].id].marker=marker;
						  	 
						  	 //markerObject.markerArr[json.data[0].id].area=markerArea;
						  	 
						  	 markerObject.markerArr[json.data[0].id].areaRadius=markersize;
						  	 markerObject.markerArr[json.data[0].id].bzType=json.data[0].bzType;
						  	  
						  	 markerObject.addMarkerListener(markerObject.markerArr[json.data[0].id]);	
							 
							 markerRefreshObject.addMarkerGroup(json.data[0].groupid);//若标注树上没有标注组自动添加标注组
							 
							 if(json.data[0].userMarkerArea!=null&&json.data[0].userMarkerArea.leftLat!=0 &&json.data[0].userMarkerArea.leftLon!=0 &&json.data[0].userMarkerArea.rightLat!=0 &&json.data[0].userMarkerArea.rightLon!=0 &&json.data[0].userMarkerArea.markerRadius!=0){
						  		 if(json.data[0].userMarkerArea.g_leftLat!=0 &&json.data[0].userMarkerArea.g_leftLon!=0 &&json.data[0].userMarkerArea.g_rightLat!=0 &&json.data[0].userMarkerArea.g_rightLon!=0 &&json.data[0].userMarkerArea.markerRadius!=0){
						  			 markerObject.markerArr[json.data[0].id].area=drawMarkerArea(new google.maps.LatLng(json.data[0].userMarkerArea.g_leftLat,json.data[0].userMarkerArea.g_leftLon),new google.maps.LatLng(json.data[0].userMarkerArea.g_rightLat,json.data[0].userMarkerArea.g_rightLon));
						  		 }else{
						  			 markerObject.markerArr[json.data[0].id].area=drawMarkerArea(new google.maps.LatLng(json.data[0].userMarkerArea.leftLat,json.data[0].userMarkerArea.leftLon),new google.maps.LatLng(json.data[0].userMarkerArea.rightLat,json.data[0].userMarkerArea.rightLon));
							  	 	 
						  		 }
						  		 markerObject.markerArr[json.data[0].id].area.setMap(null);
						  	 	 markerObject.markerArr[json.data[0].id].areaRadius=json.data[0].userMarkerArea.markerRadius;
						  	 }
							 
							 addMarkerGroupTreeNode(json.data[0].id,json.data[0].groupid,json.data[0].title);
							
							$("#markerId").attr("value",json.data[0].id);
							
							 clearAreaLagLng();
							 
							 markerObject.markerJson.data.push(json.data[0]);
						  	 markerObject.markerJson.totalcount = markerObject.markerJson.data.length;
							 
							 if($("#bzcheckbox").is(":checked")){
						  	 	//markerObject.markerArr[json.data[0].id].lable = new myLableMarker(map,"<div class=\"iconTheStyle\" style=\"background:#f5fcb8;  font-size:12px; color:#000000; font-weight:bold; white-space:nowrap; border:1px solid #666666;\" >"+json.data[0].title+"</div>",marker.getPosition(),json.data[0].id);						  	 
						  	 }
							 
							 if(mapType==1){
							 		MarkerBD.removePolygon();
									openMarker(json.data[0].id, false);
							 }
						  	 
						  	 var curnode=treeObj.getNodeByParam("id",json.data[0].id);
						  	 
						  	 if(curnode != null){
						  	 	treeObj.checkNode(curnode, true, false, false);
						  	 }
							
							 if(selectImage!=null){
						   		 selectImage.attr("class","unselected");
						   		 selectImage=$("#selectImage");//用于保存当前选中的标记图标
				    			 selectImage.attr("class","selected");
			    			 }	 
					     } 
		         		 $("#closecmarkerWin").click();
					  	 $("#addMarkerButton").removeAttr("disabled");
                 }else{
                 	if(json.msg!="10001"){
	                 	$("#addmarkermsg").text(json.msg);
						$("#addmarkermsg").css("color","red");
					}else{
						$("#addmarkermsg").text(language.bzmbncf);
						$("#addmarkermsg").css("color","red");
					}$("#addMarkerButton").removeAttr("disabled");
                 }
	        },
	        error: function() {$("#addMarkerButton").removeAttr("disabled");}
	   });		   
}

function openUpdateMarkerWin(markerId){
	
	$("#updateMarkerButton").removeAttr("disabled");
	
	$("#updateMarkerButton").show();
	$("#addMarkerButton").hide();
	
	var curMarkerObject=markerObject.markerArr[markerId];
	
	/*$("#addMarkerGroupSelect").hide();
	$("#markerGroupId").val(curMarkerObject.groupid);*/
	
	addMarkerGroupSelect();
	
	$("#addMarkerGroupSelect").show();
	
	$("#markerGroupId").val(curMarkerObject.groupid);
	
	$(".marker_group_option a").each(function(){
		
		if($(this).attr("name") == curMarkerObject.groupid ){
			
			$("#marker_group_option a").parent().siblings(".marker_group_select_txt").text($(this).eq(0).text());
	
			$("#markerGroupId").val($(this).eq(0).attr("name"));
					
			return false;
						
		}
		
	});
	
	$("#markerName").text(language.xgbz);
    
    if(curMarkerObject.marker.getMap()){	              
	    $("#markerlat").val(curMarkerObject.marker.getPosition().lat());
	    $("#markerlng").val(curMarkerObject.marker.getPosition().lng());
    }else{
    	$("#markerlat").val(curMarkerObject.lat);
   		$("#markerlng").val(curMarkerObject.lng);
    }
    
    $("#markertitle").val(curMarkerObject.title);
	$("#markerdesc").val(curMarkerObject.text);
	
	$("#markerImagesrc").css("backgroundImage","url("+curMarkerObject.icon+")"); 
	
	$("#markerId").attr("value",markerId);
	
	$("#customerNum").val('');
	
	initCustomerNum_vlaue(curMarkerObject.customerNum.split("/"))
	
	$("#addmarkermsg").text(language.btbnwk);
    $("#addmarkermsg").css("color","rgb(153, 153, 153)");
    
    if(curMarkerObject.bzType==0){
   		$("#factoryselected").attr("checked","checked");
   	}else{
   		$("#siteselected").attr("checked","checked");
   	}
    
	markersize=curMarkerObject.areaRadius;
	
	if(curMarkerObject.area!=null){
		
		curMarkerObject.area.setMap(null);
		
		markerArea=drawMarkerArea(getAreaSWLatlng(curMarkerObject.lat,curMarkerObject.lng,markersize),getAreaNELatLng(curMarkerObject.lat,curMarkerObject.lng,markersize));	
	
	}else{
	
		markerArea=drawMarkerArea(new google.maps.LatLng(0,0),new google.maps.LatLng(0,0))
	
	}
	
	if( typeof curMarkerObject.areaRadius !="undefined"){
		$( "#markerArea" ).slider( "value", curMarkerObject.areaRadius);
	}else{
		$( "#markerArea" ).slider( "value", 0);
	}
	/*for(var i=0;i<markerGroupJson.totalcount;i++){
		if(markerGroupJson.data[i].id==curMarkerObject.groupid){
			$("#marker_group_option a").parent().siblings(".marker_group_select_txt").text(markerGroupJson.data[i].groupName);
    		$("#markerGroupId").val(curMarkerObject.groupid);
			break;
		}
	}*/
	
	getCLientIdPrefix();

    $("#markerContentWin").show();
    $("#markerContentWin").center();
}

function updateMarker(){
		$("#updateMarkerButton").attr("disabled","disabled");//设置所有的button不可用 
		var id,title,desc,icon,lat,lng,groupid,leftlat,leftlng,rigthlat,rigthlng,bzType,customerNum;
		title=$("#markertitle").val();
		desc=$("#markerdesc").val();
		if (isChrome) {
        	icon=$("#markerImagesrc").css("backgroundImage").split("(")[1].split(")")[0];
		}else{
			icon=$("#markerImagesrc").css("backgroundImage").split("\"")[1];
		}
		lat=$("#markerlat").val();
		lng=$("#markerlng").val();
		groupid=$("#markerGroupId").val();
		id=parseInt($("#markerId").attr("value"));
		leftlat=$("#leftlat").val();
		leftlng=$("#leftlng").val();
		rigthlat=$("#rigthlat").val();
		rigthlng=$("#rigthlng").val();
		bzType=$('input[name="bzType"]:checked').val();
		customerNum=$("#customerNum").val();
		
		if(title.length==0){
			$("#addmarkermsg").text(language.btbnwk);
			$("#addmarkermsg").css("color","red");
			$("#updateMarkerButton").removeAttr("disabled");
			return;
		}else{
			$("#addmarkermsg").css("color","rgb(153, 153, 153)");
		}
		
		if(desc.length>150){
			$("#addmarkermsg").text(language.msbndy150gz);
			$("#addmarkermsg").css("color","red");
			$("#updateMarkerButton").removeAttr("disabled");
			return;
		}
		
		var getcustomerNums = getcustomerNum_vlaues();
		
		if( customerNum.length > 0 && ($.inArray(customerNum, getcustomerNums) < 0)){
		
			if(!window.confirm(language.yytwtjdkhh)){
			
				$("#updateMarkerButton").removeAttr("disabled");
				
				return;
				
			}
			
		}
		
		
		$.ajax({
	        type: "POST",
	        dataType: "json",
	        async:true,
	        url: "json/markerAction_addOrUpdateUserMarker.action",
	        data:{"id":id,"title":title,"text":desc,"icon":icon,"lat":lng,"lng":lat,"groupid":groupid,"leftLat":leftlat,"leftLon":leftlng,"rightLat":rigthlat,"rightLon":rigthlng,"radius":markersize,"bzType":bzType,"customerNum":getcustomerNums.join("/"),"mapType":2},
	        success: function(json) {		         
		         if (json.flag==true) {
		         		 markerObject.closeInfowindow();
		         		 //$("#markerContentWin").fadeOut("fast");
		         		 if(typeof json.data[0].id=="number" && typeof json.data[0].lat2=="number" && typeof json.data[0].lng2=="number" && json.data[0].icon.length!=0){
			         		
			         		
			         		 markerObject.deleteMarker(id);
			         		 markerObject.infowindow=null;
			         		 
			         		
							 markerObject.markerArr[json.data[0].id]={};

					  	 	 markerObject.markerArr[json.data[0].id].competence=json.data[0].competence;		
					  	 	 markerObject.markerArr[json.data[0].id].title=json.data[0].title;
					  		 markerObject.markerArr[json.data[0].id].text=json.data[0].text;
					  		 markerObject.markerArr[json.data[0].id].icon=json.data[0].icon;
					  		 markerObject.markerArr[json.data[0].id].lat=json.data[0].lng2;
					  		 markerObject.markerArr[json.data[0].id].lng=json.data[0].lat2;
					  		 markerObject.markerArr[json.data[0].id].blng=json.data[0].blat;
						  	 markerObject.markerArr[json.data[0].id].blat=json.data[0].blng;
					  		 markerObject.markerArr[json.data[0].id].groupid=json.data[0].groupid;
					  		 markerObject.markerArr[json.data[0].id].id=json.data[0].id;
					  		 markerObject.markerArr[json.data[0].id].customerNum=json.data[0].markcode;
						  	 markerObject.markerArr[json.data[0].id].bzType=json.data[0].bzType;
						  	 
						  	 var marker=markerObject.addMarker(id,json.data[0].lng2,json.data[0].lat2,json.data[0].icon);				 			 
					  	 	 markerObject.markerArr[json.data[0].id].marker=marker;
						  	  
						  	 markerObject.markerArr[json.data[0].id].isShow=true;
						  	  
						  	 markerObject.addMarkerListener(markerObject.markerArr[json.data[0].id]);	
						  	 
						  	 
						  	 var curnode=treeObj.getNodeByParam("id",json.data[0].id);
			  	 
						  	 if (curnode!=null) {
						  	 
								curnode.name = json.data[0].title;
								
								treeObj.updateNode(curnode);
								
								
								if(curnode.getParentNode().id != 'g_'+json.data[0].groupid){
								
									var prevParentNode = curnode.getParentNode();
									
									prevParentNode.count = parseInt(prevParentNode.count)-1 ;
									
									if(prevParentNode.count == 0){
										prevParentNode.name = prevParentNode.title;
									}else{
										prevParentNode.name = prevParentNode.title+"("+prevParentNode.count+")";
									}
									
									var curGroupnode=treeObj.getNodeByParam("id",'g_'+json.data[0].groupid);					
									
									if(curGroupnode == null){
									
										//添加标注所属组(若改组已经存在则不操作)
									  	 markerRefreshObject.addMarkerGroup(json.data[0].groupid);
									  	 
										 curGroupnode=treeObj.getNodeByParam("id",'g_'+json.data[0].groupid);
										 
									}
									
									curGroupnode.count = parseInt(curGroupnode.count)+1 ;

									curGroupnode.name = curGroupnode.title+"("+curGroupnode.count+")";
									
									treeObj.moveNode(curGroupnode, curnode, "inner");
									
									treeObj.updateNode(prevParentNode);
									treeObj.updateNode(curGroupnode);
								}				
								
							 }
						  	 
						  	 //deleteMarkerGroupTreeNode(id);	
						  	 //addMarkerGroupTreeNode(json.data[0].id,json.data[0].groupid,json.data[0].title);	
						  	 
						  	 if(json.data[0].userMarkerArea!=null&&json.data[0].userMarkerArea.leftLat!=0 &&json.data[0].userMarkerArea.leftLon!=0 &&json.data[0].userMarkerArea.rightLat!=0 &&json.data[0].userMarkerArea.rightLon!=0 &&json.data[0].userMarkerArea.markerRadius!=0){
						  	 	 markerObject.markerArr[json.data[0].id].area=drawMarkerArea(new google.maps.LatLng(json.data[0].userMarkerArea.leftLat,json.data[0].userMarkerArea.leftLon),new google.maps.LatLng(json.data[0].userMarkerArea.rightLat,json.data[0].userMarkerArea.rightLon));
						  	 	 markerObject.markerArr[json.data[0].id].area.setMap(null);
						  	 	 markerObject.markerArr[json.data[0].id].areaRadius=json.data[0].userMarkerArea.markerRadius;
						  	 }
						  	 
						  	for(var i=0;i<markerObject.markerJson.data.length;i++){
			                	  if(json.data[0].id==markerObject.markerJson.data[i].id){
										markerObject.markerJson.data.remove(i);
										break;
								  }
			                 }
						  	 
						  	 markerObject.markerJson.data.push(json.data[0]);
						  	 
						  	 if($("#bzcheckbox").is(":checked")){
						  	 	if(markerObject.markerArr[json.data[0].id].lable) markerObject.markerArr[json.data[0].id].lable.setMap(null);
						  	 	markerObject.markerArr[json.data[0].id].lable = new myLableMarker(map,"<div class=\"iconTheStyle\" style=\"background:#f5fcb8;  font-size:12px; color:#000000; font-weight:bold; white-space:nowrap; border:1px solid #666666;\" >"+json.data[0].title+"</div>",marker.getPosition());			  	 
						  	 }		  	 
					  	 }	
					  	 
					  	 if(selectImage!=null){
			   		 		selectImage.attr("class","unselected");
			   		 		selectImage=$("#selectImage");//用于保存当前选中的标记图标
	    			 		selectImage.attr("class","selected");
    			 		}	$("#closecmarkerWin").click(); $("#updateMarkerButton").removeAttr("disabled"); 			  	 
                 }else{
                 	if(json.msg!="10001"){
	                 	$("#addmarkermsg").text(json.msg);
						$("#addmarkermsg").css("color","red");
					}else{
						$("#addmarkermsg").text(language.bzmbncf);
						$("#addmarkermsg").css("color","red");
					}$("#updateMarkerButton").removeAttr("disabled");
                 }
	        },
	        error: function() {$("#updateMarkerButton").removeAttr("disabled");}
	   });	
}

function getGroupJson(){
		$.ajax({
	        type: "POST",
	        dataType: "json",
	        async:false,
	        url: "json/markerAction_getUserMarkerGroup.action",
	        success: function(json) {		         
		         if (json.flag==true) {
	         		 markerGroupJson=json;		        	 					           				
                 }else{
                 	alert(json.msg);
                 }
	        },
	        error: function() {}
	   });	
}
function addAllMarker(){
	
	if(typeof map=="undefined"){
		setTimeout('addAllMarker()',500);
		return;
	}
	if(markerObject.markerJson==""){
		setTimeout('addAllMarker()',500);
		return;
	}
	
	var marker,json=markerObject.markerJson;
	
	if(null!=json&&""!=json&&json.totalcount>0){
		for(var i=0;i<json.totalcount;i++){
			
			if(typeof json.data[i].id=="number" && typeof json.data[i].lat2=="number" && typeof json.data[i].lng2=="number" && json.data[i].icon.length!=0 &&json.data[i].lat2!=0&&json.data[i].lng2!=0){			
				 
				
		 		 markerObject.markerArr[json.data[i].id]={};
			  	 
			  	 markerObject.markerArr[json.data[i].id].competence=json.data[i].competence;		
			  	 markerObject.markerArr[json.data[i].id].title=json.data[i].title;
			  	 markerObject.markerArr[json.data[i].id].text=json.data[i].text;
			  	 markerObject.markerArr[json.data[i].id].icon=json.data[i].icon;
			  	 markerObject.markerArr[json.data[i].id].lat=json.data[i].lng2;
			  	 markerObject.markerArr[json.data[i].id].lng=json.data[i].lat2;
			  	 markerObject.markerArr[json.data[i].id].blng=json.data[i].blat;
				 markerObject.markerArr[json.data[i].id].blat=json.data[i].blng;
			  	 markerObject.markerArr[json.data[i].id].groupid=json.data[i].groupid;
			  	 markerObject.markerArr[json.data[i].id].id=json.data[i].id;
			  	 markerObject.markerArr[json.data[i].id].bzType=json.data[i].bzType;
			  	 
			  	 markerObject.markerArr[json.data[i].id].customerNum=json.data[i].markcode;
			  	 
			  	 marker=markerObject.addMarker(json.data[i].id,json.data[i].lng2,json.data[i].lat2,json.data[i].icon);
			  	 markerObject.markerArr[json.data[i].id].marker=marker;
			  	 marker.setMap(null);
			  	 
			  	 markerObject.markerArr[json.data[i].id].isShow=false;
			  	  
			  	 markerObject.addMarkerListener(markerObject.markerArr[json.data[i].id]);
			  	 if(json.data[i].userMarkerArea!=null&&json.data[i].userMarkerArea.leftLat!=0 &&json.data[i].userMarkerArea.leftLon!=0 &&json.data[i].userMarkerArea.rightLat!=0 &&json.data[i].userMarkerArea.rightLon!=0 &&json.data[i].userMarkerArea.markerRadius!=0){
			  	 	 if(json.data[i].userMarkerArea.g_leftLat!=0 &&json.data[i].userMarkerArea.g_leftLon!=0 &&json.data[i].userMarkerArea.g_rightLat!=0 &&json.data[i].userMarkerArea.g_rightLon!=0 &&json.data[i].userMarkerArea.markerRadius!=0){
			  			markerObject.markerArr[json.data[i].id].area=drawMarkerArea(new google.maps.LatLng(json.data[i].userMarkerArea.g_leftLat,json.data[i].userMarkerArea.g_leftLon),new google.maps.LatLng(json.data[i].userMarkerArea.g_rightLat,json.data[i].userMarkerArea.g_rightLon));
			  		 }else{
			  			 markerObject.markerArr[json.data[i].id].area=drawMarkerArea(new google.maps.LatLng(json.data[i].userMarkerArea.leftLat,json.data[i].userMarkerArea.leftLon),new google.maps.LatLng(json.data[i].userMarkerArea.rightLat,json.data[i].userMarkerArea.rightLon));
				  	 	 
			  		 }

			  	 	markerObject.markerArr[json.data[i].id].area.setMap(null);
			  	 	markerObject.markerArr[json.data[i].id].areaRadius=json.data[i].userMarkerArea.markerRadius;
			  	 }
		  	 }
		}

	}
}
var menu=null;
function addMarkerMenu(){
	if(typeof map=="undefined"){
		setTimeout('addMarkerMenu()',500);
		return;
	}
	menu = new MenuControl(map);
    menu.sender = map;
     google.maps.event.addListener(map, "rightclick",
	    function(e) {
	    	closeRectangShape();
	    	closeDistance();
	    	$("#closeGroupWin").click();
			$("#closecmarkerWin").click();
			$("#closeSelectMarkerPhotoWin").click();
	        if (menu.isEnable) {
	            menu.coordinate = {
	                point: e.pixel,
	                latlng: e.latLng
	            };
	            menu.container.style.left = e.pixel.x + "px";
	            menu.container.style.top = e.pixel.y + "px";
	            menu.show("map");
	    	}
    }); 
    
     if(usertype =="0" || usertype=="1" || usertype=="2" || usertype=="-1"  || usertype=="10"){ 
    
		    menu.addItem(new MenuItem({
		        text: language.tjbj,
		        icon: "",
		        groupName: "map",
		        handler: function(coor) { 
		        
		        		$("#customerNum").val("");
    			 
    					$("#customerNumListOutCanvas").html("");
		        		
		               	$("#addMarkerButton").removeAttr("disabled");
		        		$("#addMarkerGroupSelect").show();
		        		addMarkerGroupSelect();
		        		$("#markerName").text(language.tjbz);
		
		                $("#markerlat").val(coor.latlng.lat());
		                $("#markerlng").val(coor.latlng.lng());
		                $("#markertitle").val("");
						$("#markerdesc").val("");
						$("#addmarkermsg").text(language.btbnwk);
					    $("#addmarkermsg").css("color","rgb(153, 153, 153)");
					    
						if($("#marker_group_option a").length!=1){
							$("#marker_group_option a").parent().siblings(".marker_group_select_txt").text($(".marker_group_option a").eq(0).text());
				            $("#markerGroupId").val($(".marker_group_option a").eq(0).attr("name"));
			            }
			            
			            $("#markerImagesrc").css("backgroundImage","url(http://vip4.exlive.cn/mi/p/f/2/green.gif)");
			            	                       
			            markerArea=drawMarkerArea(getAreaSWLatlng(coor.latlng.lat(),coor.latlng.lng(),500),getAreaNELatLng(coor.latlng.lat(),coor.latlng.lng(),500));
						
						$("#markerArea" ).slider( "value", 500 );
						
						$("#addMarkerButton").show();
						$("#updateMarkerButton").hide();
						
						getCLientIdPrefix();
						
		                $("#markerContentWin").show();
		                $("#markerContentWin").center();
		                
		        }
		    }));
	   }
    menu.addItem(new MenuItem({
        text: language.fdyj,
        groupName: "map",
        handler: function(coor) {
            map.setZoom(map.getZoom() + 1);
        }
    }));
    menu.addItem(new MenuItem({
        text: language.sxyj,
        groupName: "map",
        handler: function(coor) {
            map.setZoom(map.getZoom() - 1);
        }
    }));  
}

function addMarkerGroupSelect(){

    //获取标注组Json集
	 getGroupJson();
	 $(".marker_group_select_box").unbind("click")
    if(markerGroupJson==null){
		setTimeout("addMarkerGroupSelect()",500);
		return;
	}
	var optionStr="<a name=\"0\">--"+language.xzfz+"--</a>"; 
	for(var i=0;i<markerGroupJson.totalcount;i++){
		if(typeof markerGroupJson.data[i] !="undefined"){
			optionStr+="<a name=\""+markerGroupJson.data[i].id+"\">"+markerGroupJson.data[i].groupName+"</a>";
		}
	}
	optionStr+="<a name=\"-1\" style=\"color:rgb(153,153,153);\">"+language.tjbjz+"</a>";
	document.getElementById("marker_group_option").innerHTML=optionStr;

	$("#marker_group_option a").parent().siblings(".marker_group_select_txt").text($(".marker_group_option a").eq(0).text());
	$("#markerGroupId").val($(".marker_group_option a").eq(0).attr("name"));
	//添加标注组开始
	$(".marker_group_select_box").click(function(event){   
		event.stopPropagation();
		$(this).find(".marker_group_option").toggle();
		$(this).parent().siblings().find(".marker_group_option").hide();
	});
	$(document).click(function(event){
		var eo=$(event.target);
		if($(".marker_group_select_box").is(":visible") && eo.attr("class")!="marker_group_option" && !eo.parent(".marker_group_option").length)
		$('.marker_group_option').hide();									  
	});
	$(".marker_group_option a").click(function(){
		var value=$(this).attr("name");
		$(".marker_group_select_txt").text("");
		$("#markerGroupId").val("");
		if(value=="-1"){
		    $("#groupPanel").text(language.tjz);
		    $("#addMarkerGroup").show();
			$("#updateMarkerGroup").hide();
			$("#addMarkerGroup").removeAttr("disabled");
			$("#addGroupContentWin").css("z-index",$("#markerContentWin").css("z-index")+1);
			$("#addMarkerGroupmsg").css("color","rgb(153, 153, 153)");
			$("#markerGroupName").val("");
			$("#addGroupContentWin").show();
            $("#addGroupContentWin").center();
		}else{
			$(this).parent().siblings(".marker_group_select_txt").text($(this).text());
		    $("#markerGroupId").val(value);
		}
		
	 });
	 //添加标注组结束
	
}

function addMarkerGroup(){
        $("#addMarkerGroup").attr("disabled","disabled");
        var groupName=$("#markerGroupName").val();

        if(groupName==""||groupName==null){
        	$("#addMarkerGroupmsg").text(language.zmbnwk);
        	$("#addMarkerGroupmsg").css("color","red");
        	$("#addMarkerGroup").removeAttr("disabled");
        	return;
        }
        
		$.ajax({
	        type: "POST",
	        dataType: "json",
	        async:false,
	        url: "json/markerAction_addOrUpdateUserMarkerGroup.action",
	        data:{"groupName":groupName},
	        success: function(json) {		         
		         if (json.flag==true) {		         				         		
		         
	         		    $(".marker_group_option a").parent().siblings(".marker_group_select_txt").text(json.data[0].groupName);
		    			$("#markerGroupId").val(json.data[0].id); 
		    			var newoption=$("<a name=\""+json.data[0].id+"\">"+json.data[0].groupName+"</a>");
		    			$(".marker_group_option a").eq($(this).size()-2).before(newoption);
		    			
		    			addMarkerGroupTreeGroupNode(json.data[0].id,json.data[0].groupName);
		    			newoption.click(function(){
							    var value=$(this).attr("name");
								$(this).parent().siblings(".marker_group_select_txt").text($(this).text());
							    $("#markerGroupId").val(value);				    							    
						});
						
						markerGroupJson.data.push(json.data[0]);
						allMarkerGroupJson.data.push(json.data[0]);
						 
		    			$("#closeGroupWin").click(); 
		    			$("#addMarkerGroup").removeAttr("disabled");	 					           				
                 }else{
                 	if(json.msg != "10000"){
	                 	$("#addMarkerGroupmsg").text(json.msg);
	        			$("#addMarkerGroupmsg").css("color","red");
        			}else{
        				$("#addMarkerGroupmsg").text(language.zmbncf);
	        			$("#addMarkerGroupmsg").css("color","red");
        			}$("#addMarkerGroup").removeAttr("disabled");
                 }
	        },
	        error: function() {$("#addMarkerGroup").removeAttr("disabled");}
	   });	
}

var selectImage=null;
function getImgURL(el){
	
	$("#markerImagesrc").css("backgroundImage","url("+$(el).attr("src")+")"); 
	
	$("#label-icon-list").hide();
	
	$("#markerImagesrc").attr("class","markerImagesrc");
	
	isopenMarkerselectWin=true;
	
 }

var isopenMarkerselectWin=true;

function openMarkerselectWin(){
	
	if(isopenMarkerselectWin){		
				
		$("#label-icon-list").show();
		
		$("#markerImagesrc").attr("class","markerImagesrc on");
		
		isopenMarkerselectWin=false;
		
		if($("#label-icon-list").children().length == 1){
		
			$("#MarkerImgloading").show();
			
			$.ajax({
		        type: "POST",
		        dataType: "json",
		        url: "markerImgJSON.jsp",
		        success: function(data) {
		        		         
			       TuPian(data);
			        
		        },
		        error: function() {}
	  		 });	
	  		 
	  		 
	  		 
	  		   //$.getScript("http://www.exlive.cn/mi/markerImgJSON.jsp?gpscallback=TuPian",null);	
		}
	}else{	
		$("#label-icon-list").hide();
		$("#markerImagesrc").attr("class","markerImagesrc");
		isopenMarkerselectWin=true;		
	}
}

function TuPian(data){
	var imgs = [];
	if(data!=null){
		for(var i=1;i<data.data.length;i++){
			if(data.data[i][0]=="false"){
				imgs.push("<li style='width: 280px;'><div style='overflow:hidden;background:#999;height:1px;'></div></li>");
			}else{
				imgs.push("<li><img src='http://vip4.exlive.cn/mi/"+data.data[i][2]+"' onclick='getImgURL(this);'/></li>");
			}
		}
	}
	
	$("#label-icon-list").append(imgs.join(""));
	$("#MarkerImgloading").hide();
	
	
}


function closeVehicleInfoWindow(){
	for(var i=0;i<vehicles.length;i++){
          vehicles[i].infowindow.close();
    }
}


//单击时关闭标注和设备弹出框
function mapclickEvent(){

	if(typeof map=="undefined"){
		setTimeout('mapclickEvent()',500);
		return;
	}
	
	google.maps.event.addListener(map, "click", function (e) {
		markerObject.closeInfowindow();
		closeVehicleInfoWindow();
	});
}
/*
function close(){
	$("#biaozhu_open").hide(500);
	$("#biaozhu_close").show(500);
}

function open(){
	$("#biaozhu_close").hide(500);
	$("#biaozhu_open").show(500);
}*/
function close(){
		document.getElementById("biaozhu_open").style.display = "none"
		document.getElementById("biaozhu_close").style.display = "block"
		isopenmarkerPanelOpen=true;
	}
	
	function openMarkerPanel(){
		isopenmarkerPanelOpen=false;		
		document.getElementById("biaozhu_close").style.display = "none"
		document.getElementById("biaozhu_open").style.display = "block"
		
		
		
	}
var isopenmarkerPanelOpen=true;
function openmarkerPanel(type_){
		if(isopenmarkerPanelOpen){
			
			
			
		    document.getElementById("biaozhu_close").style.display = "none"
			document.getElementById("biaozhu_open").style.display = "block"
			
			isopenmarkerPanelOpen=false;

			
			if(type_==1){
			
				electronicFence.tree.hide();
				
			}else{
			
				electronicFence.tree.show();
				
			}
			
		}else{
			
			if((type_ == 1 && !electronicFence.tree.isShow) || (type_ == 2 && electronicFence.tree.isShow)){
				document.getElementById("biaozhu_open").style.display = "none"
				document.getElementById("biaozhu_close").style.display = "block"
				isopenmarkerPanelOpen=true;
			}
			
			if(type_==1){
			
				electronicFence.tree.hide();
				
			}else{
			
				electronicFence.tree.show();
				
			}
				
		}
}

var treeObj = null;

function showMarkerGroupTree(){
	if( markerObject.markerJson==""||allMarkerGroupJson==null){
		setTimeout("showMarkerGroupTree()",500);
		return;
	}
	if(allMarkerGroupJson.totalcount!=0){
		var groupNodeTreeStr="[";
		for(var i=0;i<allMarkerGroupJson.data.length;i++){
			//optionStr+="<a name=\""+markerGroupJson.data[i].id+"\">"+markerGroupJson.data[i].groupName+"</a>";
			if(typeof allMarkerGroupJson.data[i]!="undefined"){
				groupNodeTreeStr+="{ \"id\":\"g_"+allMarkerGroupJson.data[i].id+"\",\"title\":\""+allMarkerGroupJson.data[i].groupName+"\",\"name\":\""+allMarkerGroupJson.data[i].groupName+"\",\"icon\":\""+markerUrl.groupNodeicon+"\",\"count\":\"0\",\"pId\": \"0\"},";
			}
		}
		groupNodeTreeStr=groupNodeTreeStr.substring(0,groupNodeTreeStr.length-1);
	    
	    groupNodeTreeStr="[{\"id\":\"root_g_-1000\",\"open\":\"true\",\"title\":\""+language.yhbz+"\",\"name\":\""+language.yhbz+"\",\"icon\":\""+electronicFenceUrl.allDom+"\",\"pId\": \"-1000\","+
								"\"children\":"+groupNodeTreeStr+"]}]";
								
	    groupNodeTreeStr=$.parseJSON(groupNodeTreeStr);
	    
	    var setting={
	    		callback: {
					onClick: zTreeOnClick,
					onCheck: zTreeOnCheck,
					onRightClick: OnRightClick
				},check: {
					enable: true
				},
				data: {
					simpleData: {
						enable: true,
						idKey: "id"
					}
				},
				view: {
					addHoverDom: addHoverDom,
					removeHoverDom: removeHoverDom
				}		
	    }
		$.fn.zTree.init($("#markerGroupTree"),setting,groupNodeTreeStr);
		treeObj = $.fn.zTree.getZTreeObj("markerGroupTree");
		var parentNode,newNode;
		for(var i=0;i< markerObject.markerJson.data.length;i++){   
			addMarkerGroupTreeNode( markerObject.markerJson.data[i].id, markerObject.markerJson.data[i].groupid, markerObject.markerJson.data[i].title);
		}
	}
}

function addMarkerGroupTreeNode(id,parentId,title){
	    var newNode = [{'id':id,'name':title,"icon":markerUrl.markericon}];
		parentNode=treeObj.getNodeByParam("id","g_"+parentId);
		if(parentNode!=null){
			newNode=treeObj.addNodes(parentNode,newNode,true);
			
			parentNode.count=parseInt(parentNode.count)+1;
			parentNode.name =parentNode.title+"("+parentNode.count+")";
	        treeObj.updateNode(parentNode);			
		}else{
			parentNode=treeObj.getNodeByParam("id","g_0");
			newNode=treeObj.addNodes(parentNode,newNode,true);
			parentNode.count=parseInt(parentNode.count)+1;
			parentNode.name =parentNode.title+"("+parentNode.count+")";
	        treeObj.updateNode(parentNode);	
		}
		
		return newNode;
}
function addMarkerGroupTreeGroupNode(id,title){

		var newNode =null;
		if(treeObj==null){
			var setting={
	    		callback: {
					onClick: zTreeOnClick,
					onCheck: zTreeOnCheck,
					onRightClick: OnRightClick
				},check: {
					enable: true
				},
				data: {
					simpleData: {
						enable: true,
						idKey: "id"
					}
				},
				view: {
					addHoverDom: addHoverDom,
					removeHoverDom: removeHoverDom
				}		
    		}
    		
		   $.fn.zTree.init($("#markerGroupTree"),setting,[{id:"root_g_-1000",open:true,title:language.yhbz,name:language.yhbz,icon:electronicFenceUrl.allDom,pId: -1000,
								children:[{ id:"g_"+id, pId: 0,title: title,count:0,name:title,icon:markerUrl.groupNodeicon}]}]);
		    treeObj = $.fn.zTree.getZTreeObj("markerGroupTree");
		    
		}else{
		
			newNode= [{id:"g_"+id, pId: 0,title: title,count:0,name:title,"icon":markerUrl.groupNodeicon}];
			var parentNode=treeObj.getNodeByParam("id","root_g_-1000");
			
			treeObj.addNodes(parentNode,newNode,true);
		}

		//addHoverDom("markerGroupTree", newNode);
		//removeHoverDom("markerGroupTree", newNode);
		

		
		
	    //treeObj.destroy();
		//showMarkerGroupTree();
}
function deleteMarkerGroupTreeNode(nodeid){
	var curnode=treeObj.getNodeByParam("id",nodeid);
	var parentNode=curnode.getParentNode();
    treeObj.removeNode(curnode);  
    parentNode.count=parseInt(parentNode.count)-1;
    if(parentNode.count==0){
    	parentNode.name =parentNode.title;
    }else{
		parentNode.name =parentNode.title+"("+parentNode.count+")";
    }
    treeObj.updateNode(parentNode);	
}

var showmarkersArr = new Array();
function zTreeOnClick(event, treeId, treeNode) {

	if(!treeNode.isParent){
	
		treeObj.checkNode(treeNode, true, false, false);//选中当前点击的标注
		
		var curmarker=markerObject.markerArr[treeNode.id];
		
		if(curmarker!=null){
			curmarker.isShow=true;
	    }
		
		openMarker(treeNode.id);		
	}	
}

function zTreeOnCheck(event, treeId, treeNode){
    /*if(mapType==2 && map!=undefined){
		if(markerObject.infowindow!=null){
			markerObject.infowindow.close();
		}
	}*/
	if(treeObj == null) return false;
	
	var isParent = false;	
	
	var nodesNoChecked = treeObj.getCheckedNodes(false);
	
	for(var i=0;i<nodesNoChecked.length;i++){
		isParent=nodesNoChecked[i].isParent;
		if(!isParent){
			if(mapType==1 && baidMap!=undefined){
				MarkerBD.hide(nodesNoChecked[i].id);						
			}else{
	   			hideMarker(nodesNoChecked[i].id);
   			}
		}
	}
	
	var nodes = treeObj.getCheckedNodes(true);
	
	for(var i=0;i<nodes.length;i++){
		isParent=nodes[i].isParent;
		if(!isParent){
			if(mapType==1 && baidMap!=undefined){
				MarkerBD.hide(nodes[i].id);
				MarkerBD.open(nodes[i].id, false);									
			}else{
				openMarker(nodes[i].id, false);
   			}
		}
	}
}

function  OnRightClick(event, treeId, treeNode){	
		
		if(!treeNode){
			return;
		}
		
		if(treeNode.id == "root_g_-1000"){
			
		}else if(treeNode.getParentNode().id == "root_g_-1000"){
		
		}else{
		
			MarkerTreeMenu.showRMenu("marker", event.clientX, event.clientY,treeNode);
		}
}

//选中标注树形上的节点
function checkMarkerNode(id){
	if(treeObj != null){
		var curnode = treeObj.getNodeByParam("id", id);
		if(curnode != null && !curnode.checked ){
			treeObj.checkNode(curnode, true, true, true);
		}
	}
}

//取消选中标注树形上的节点
function uncheckMarkerNode(id){

	if(treeObj != null){
		var curnode = treeObj.getNodeByParam("id", id);
		if(curnode != null && curnode.checked ){
			treeObj.checkNode(curnode, false, true, true);
		}
	}
}

function addHoverDom(treeId, treeNode) {
	if(treeNode!=null){
			if (treeNode.parentNode && treeNode.parentNode.id!=1) return;
			var aObj = $("#" + treeNode.tId + "_a");
			if ((treeNode.id+"").indexOf("_")>=0&&treeNode.id.split("_")[0]=="g"&&treeNode.id.split("_")[1]!="0") {
				for(var i=0;i<markerGroupJson.data.length;i++){
					if(typeof markerGroupJson.data[i]!="undefined"){
						if("g_"+markerGroupJson.data[i].id==treeNode.id){
							if ($("#diyBtn_space_"+treeNode.id).length>0) return;
							var editStr = "<span id='diyBtn_space_" +treeNode.id+ "' >&nbsp;</span><span class='button update' id='update_diyBtn_" +treeNode.id+ "' title='"+treeNode.name+"' onfocus='this.blur();'></span>";
							aObj.append(editStr);
							//var delbtn = $("#del_diyBtn_"+treeNode.id);
							var updatebtn = $("#update_diyBtn_"+treeNode.id);
							/*if (delbtn) delbtn.bind("click", function(){
								if(treeNode!=null){
									if(confirm(language.qryscz)){
										deleteMarkerGroup(treeNode.id);
									}
								}
							});*/
							if (typeof updatebtn !="undefined") 
								updatebtn.bind("click", function(){if(treeNode!=null){openupdateGroupWin(treeNode.id);}});
							break;
						}
					}
				}
			}
	}
}

function removeHoverDom(treeId, treeNode) {
		if(treeNode!=null){
			$("#del_diyBtn_"+treeNode.id).unbind().remove();
			$("#update_diyBtn_"+treeNode.id).unbind().remove();
			$("#diyBtn_space_" +treeNode.id).unbind().remove();
		}
}

function deleteMarkerGroup(id){
	
	if(treeObj!=null){
    	var curnode=treeObj.getNodeByParam("id",id);
    	//判断是否不存在
    	if(curnode!=null){
    		//判断是否有子节点
    		if(curnode.children==null || curnode.children.length==0){
    		
	 		       var groupid=parseInt(id.split("_")[1]);
	 		       
		 		   $.ajax({
				        type: "POST",
				        dataType: "json",
				        async:false,
				        url: "json/markerAction_delUserMarkerGroup.action",
				        data:{"groupid":groupid+""},
				        success: function(json) {		         
					         if (json.flag==true) {
				         		 //--删除组
				    			 treeObj.removeNode(curnode);
					 		     
					 		     //--删除json中的组allMarkerGroupJson，markerGroupJson					 		     
					 		     for(var i=0;i<allMarkerGroupJson.data.length;i++){
					 		     	
					 		     	 if(typeof allMarkerGroupJson.data[i]!="undefined" && allMarkerGroupJson.data[i].id==groupid){
					 		     	 	delete allMarkerGroupJson.data[i];
					 		     	 	break;
					 		     	 }
					 		     }
					 		     
					 		     for(var i=0;i<markerGroupJson.data.length;i++){
					 		     	 if( typeof markerGroupJson.data[i]!="undefined" && markerGroupJson.data[i].id==groupid){
					 		     	 	delete markerGroupJson.data[i];
					 		     	 	break;
					 		     	 }
					 		     }
					 		     
					 		     if($("#markerGroupId").attr("value")==groupid+""){
					 		     	$("#marker_group_option a").parent().siblings(".marker_group_select_txt").text($(".marker_group_option a").eq(0).text());
									$("#markerGroupId").val($(".marker_group_option a").eq(0).attr("name"));
					 		     }				 		     
					 		     $("#addMarkerGroupSelect a[name='"+groupid+"']").remove(); 			           				
			                 }else{ 
			                      if( json.msg = "10002" ){
			                      	  alert(language.dqzxybzbnsc);
			                      }else{
			                      	  alert(json.msg);
			                      }
			                 }
				        },
				        error: function() {}
				   });	
	 		    
    		}else{
    			alert(language.dqzxybzbnsc);
    		}
    	}
	}
}

function openupdateGroupWin(id){
	$("#closeGroupWin").click();
	$("#updateMarkerGroup").removeAttr("disabled");
	for(var i=0;i<markerGroupJson.totalcount;i++){
     	 if( typeof markerGroupJson.data[i]!="undefined" && "g_"+markerGroupJson.data[i].id==id){
     	 	 $("#markerGroupName").val(markerGroupJson.data[i].groupName);
     	 	 $("#markerGroupId").val(markerGroupJson.data[i].id);
			break;
     	 }
    }
    $("#groupPanel").text(language.xgz);
    
    $("#updateMarkerGroup").show();
	$("#addMarkerGroup").hide();
	
    $("#addGroupContentWin").css("z-index",$("#markerContentWin").css("z-index")+1);
	$("#addMarkerGroupmsg").css("color","rgb(153, 153, 153)");
	$("#addGroupContentWin").show();
	$("#addGroupContentWin").center();
	
     
}

function updateMarkerGroup(){
$("#updateMarkerGroup").attr("disabled","disabled");
	var groupName=$("#markerGroupName").val();

    if(groupName==""||groupName==null){
    	$("#addMarkerGroupmsg").text(language.zmbnwk);
    	$("#addMarkerGroupmsg").css("color","red");
    	$("#updateMarkerGroup").removeAttr("disabled");
    	return;
    }
	
	var id=$("#markerGroupId").val();
	      
	$.ajax({
	       type: "POST",
	       dataType: "json",
	       async:false,
	       url: "json/markerAction_addOrUpdateUserMarkerGroup.action",
	       data:{"groupid":id,"groupName":groupName},
	       success: function(json) {		         
	         	if(json.flag==true){
	         		 if(json.data!=null&&json.data.length>0){
	         		 	
	         		 	var curnode=treeObj.getNodeByParam("id","g_"+id);
	         		 	
	         		 	if(curnode!=null){
	         		 		curnode.title=json.data[0].groupName;	         		 		
	         		 		if(curnode.count!=0){
	         		 			curnode.name =curnode.title+"("+curnode.count+")";
	         		 		}else{
	         		 			curnode.name =curnode.title;
	         		 		}
	         		 		treeObj.updateNode(curnode);
	         		 	}
	         		 	
		         		for(var i=0;i<allMarkerGroupJson.data.length;i++){
		 		     	
			 		     	 if(typeof allMarkerGroupJson.data[i]!="undefined" && allMarkerGroupJson.data[i].id==parseInt(id)){
			 		     	 	 allMarkerGroupJson.data[i].groupName=json.data[0].groupName;
			 		     	 	 break;
			 		     	 }
			 		     }
			 		     
			 		     for(var i=0;i<markerGroupJson.data.length;i++){
			 		     	 if( typeof markerGroupJson.data[i]!="undefined" && markerGroupJson.data[i].id==parseInt(id)){
			 		     	 	markerGroupJson.data[i].groupName=json.data[0].groupName;
			 		     	 	break;
			 		     	 }
			 		     }
			 		     
			 		     if($("#markerGroupId").attr("value")==id){
			 		     	$("#marker_group_option a").parent().siblings(".marker_group_select_txt").text(json.data[0].groupName);
							$("#markerGroupId").val(json.data[0].id);
			 		     }
			 		     
			 		     $("#addMarkerGroupSelect a[name='"+id+"']").text(json.data[0].groupName);
	         		}
	         		$("#closeGroupWin").click(); 
	         		$("#updateMarkerGroup").removeAttr("disabled");
	         	}else{
	         		if(json.msg != "10000"){
	                 	$("#addMarkerGroupmsg").text(json.msg);
	        			$("#addMarkerGroupmsg").css("color","red");
        			}else{
        				$("#addMarkerGroupmsg").text(language.zmbncf);
	        			$("#addMarkerGroupmsg").css("color","red");
        			}$("#updateMarkerGroup").removeAttr("disabled");
	         	}
	       },
	       error: function() {$("#updateMarkerGroup").removeAttr("disabled");}
	  });	
}


function openMarker(_id, isCenter){
	
	if(mapType==1){
		MarkerBD.hide(_id);
		MarkerBD.open(_id);
	}else{
	
		if(markerObject.infowindow!=null) markerObject.infowindow.close();
		
		var curmarker=markerObject.markerArr[_id];
	    
	    if(curmarker!=null){
	    	
	    	if(isCenter != false){
			    map.setCenter(new google.maps.LatLng(curmarker.lat,curmarker.lng));
				map.setZoom(13);
			}
			
			if(curmarker.marker){
				curmarker.marker.setMap(map);
				if(isCenter != false) google.maps.event.trigger(curmarker.marker, 'click');
				if(curmarker.area) curmarker.area.setMap(map);
				if($("#bzcheckbox").is(":checked")){
					if(curmarker.lable) curmarker.lable.setMap(null);
					curmarker.lable = new myLableMarker(map,"<div class=\"iconTheStyle\" style=\"background:#f5fcb8;  font-size:12px; color:#000000; font-weight:bold; white-space:nowrap; border:1px solid #666666;\" >"+curmarker.title+"</div>",curmarker.marker.getPosition(), _id);			
				}
			}			
	    }
	}
}

function hideMarker(_id){
	
	if(mapType==1){
		MarkerBD.hide(_id);
	}else{
	
		if(markerObject.infowindow!=null) markerObject.infowindow.close();
		
		var curmarker=markerObject.markerArr[_id];
	    
	    if(curmarker!=null){
			
			if(curmarker.marker){
				curmarker.marker.setMap(null);
				if(curmarker.area) curmarker.area.setMap(null);
				if(curmarker.lable)
					curmarker.lable.setMap(null);
					curmarker.lable = null;
			}			
	    }
	}
}

function showMarkerName(element){

	if($("#bzcheckbox").is(":checked")){
		if(mapType==1){
			MarkerBD.showName();
		}else{
			for(var i in markerObject.markerArr){
				if(i != "myUnique" && treeObj.getNodeByParam("id", markerObject.markerArr[i].id).checked){
					if(markerObject.markerArr[i].lable) markerObject.markerArr[i].lable.setMap(null);
					markerObject.markerArr[i].lable = new myLableMarker(map,"<div class=\"iconTheStyle\" style=\"background:#f5fcb8;  font-size:12px; color:#000000; font-weight:bold; white-space:nowrap; border:1px solid #666666;\" >"+markerObject.markerArr[i].title+"</div>",markerObject.markerArr[i].marker.getPosition(), markerObject.markerArr[i].id);			
				}
			}
		}
	}else{
		if(mapType==1){			
			MarkerBD.hideName();
		}else{
			for(var i in markerObject.markerArr)
				if(i != "myUnique" && markerObject.markerArr[i].lable) markerObject.markerArr[i].lable.setMap(null);
		}
	}	
}

function frame(framecontentId,framemovetitleId,closebuttonId){
		$("#"+closebuttonId).click(function(event){
			stopBubble(event);
		   $("#"+framecontentId).fadeOut("fast");
		   if(closebuttonId=="closeGroupWin"){
		   		 var groupName=$(".marker_group_option a").parent().siblings(".marker_group_select_txt");
		   		 var groupId=$("#markerGroupId");
		   		 if(groupName.text()==""&&groupId.val()==""){
		   		 	 groupName.text($(".marker_group_option a").eq(0).text());
		    	     groupId.val($(".marker_group_option a").eq(0).attr("name"));
		   		 }
		   		 
		   		  $("#addMarkerGroupmsg").css("color","rgb(153, 153, 153)");
		   		  $("#addMarkerGroupmsg").text(language.zmbnwk);
		   		   		
		   }                 
		   if(closebuttonId=="closecmarkerWin"){
		   		 
		   		  var curMarkerObject=markerObject.markerArr[$("#markerId").val()];
		   		  
				  if(baidMap != null){			
				  	  if($("#markerId").val() == ""){
				  	  	 MarkerBD.removePolygon();
				  	  }else{
				  	  	 MarkerBD.hide($("#markerId").val());
				  	  	 MarkerBD.open($("#markerId").val(), false);
				  	  }				  	  	
				  }
		   		 
		   		 if(selectImage!=null){
			   		 selectImage.attr("class","unselected");
			   		 selectImage=$("#selectImage");//用于保存当前选中的标记图标
	    			 selectImage.attr("class","selected");   			 
    			 }	

    			 $("#factoryselected").attr("checked","checked");
    			  
    			  isopenMarkerselectWin=false;
    			  openMarkerselectWin();
    			  isopenMarkerselectWin=true;
    			  
    			  if(markerArea!=null){
    			  		markerArea.setMap(null); //删除未添加标注绘制的默认区域
	    			 	markerArea=null;   
    			  }
    			  
    			  var curMarkerObject=markerObject.markerArr[$("#markerId").val()];
    			  
    			  if(curMarkerObject && curMarkerObject.area){
						curMarkerObject.area.setMap(map);
				  }
				  
				  $("#markerId").val("");
    			 
    			  clearAreaLagLng(); 
				  
    			 $("#customerNum").val("");
    			 
    			 $("#customerNumListOutCanvas").html("");
    			 //$("#addcustomerNum_Msg").html("&nbsp;");
		   }
		   if(closebuttonId=="closePasswordWin"){
		   		$("#updatePasswordMsg").css("color","rgb(153, 153, 153)");
		        $("#updatePasswordMsg").text(language.mmbnwk);
		        $("#curPassword").val("");
				$("#newPassword").val("");
				$("#renewPassword").val("");
		   }	   
		});
		$("#"+framemovetitleId).mousedown(function(dom){
					     var top1=$("#"+framecontentId).css("top");
						 var left1=$("#"+framecontentId).css("left");
						 var x=dom.clientX;
						 var y=dom.clientY;
						 var x1=Math.abs(x-parseInt(left1));
						 var y1=Math.abs(y-parseInt(top1));
						 $("body").mousemove(function(dom){
						 	  var x=dom.clientX;
						      var y=dom.clientY;  
						      $("#"+framecontentId).css({"top":y-y1,"left":x-x1});
						 	});
					}).mouseup(function(){
					    $("body").unbind("mousemove"); 	
					});
	}
/*
 *区域
 */
 var markerArea=null;
 var markersize=500;
 function loadAreaSlider(){
  $( "#markerArea" ).slider({
				range : "min",
				max : 5000,
				min : 0,
				value : 500,
				orientation : 'horizontal'
		  });
  $("#markerArea").bind('slidechange', function(event, ui) {
			/*var r=ui.value;
			var t=4;
			var w=100;
			var p=[500,800,1200,1500,2000,3000,5000];//[5000,3000,2000,1000,1500,800,500]
			var u=[0,20,40,60,80,100,120,140];
			for(var s=0,o=u.length-1;s<o;s++){
				if(r>=u[s]&&r<u[s+1]){
					t=s;
					break
				}
				if(r>=140){
					t=6;
					break
				}
			}*/
			markersize=ui.value;
			updateMarkerArea(ui.value,markerArea);
		});
 }

function drawMarkerArea(lefttoplatlng_,rigthbelowlatlng_){
			return rectangle = new google.maps.Rectangle({
				strokeColor: '#0000FF',
				strokeOpacity: 0.8,
				strokeWeight: 2,
				fillColor: '#0000cc',
				fillOpacity: 0.35,
				zIndex:0,
				map: map,
				bounds: new google.maps.LatLngBounds(
				  lefttoplatlng_,
				  rigthbelowlatlng_)
				});  
}

function updateMarkerArea(len_,markerArea_){
	if($("#marker_area_radius_input").val() != len_){
		$("#marker_area_radius_input").val(len_);
	}
	if(mapType==1){
		var pStart = getAreaNELatLng(parseFloat($("#markerlat").val()),parseFloat($("#markerlng").val()),len_);
		var pEnd = getAreaSWLatlng(parseFloat($("#markerlat").val()),parseFloat($("#markerlng").val()),len_);
		
		if($("#markerId").attr("value")==""){
			MarkerBD.updatePolygon(pStart,pEnd);
		}else{
			MarkerBD.updatePolygonById(pStart, pEnd, $("#markerId").val());
		}
	}else{	
		markerArea_.setBounds(new google.maps.LatLngBounds(getAreaSWLatlng(parseFloat($("#markerlat").val()),parseFloat($("#markerlng").val()),len_),getAreaNELatLng(parseFloat($("#markerlat").val()),parseFloat($("#markerlng").val()),len_)));
	}
}

function getAreaNELatLng(lat_,lng_,len_){
	var dlat = len_/111.0/1000.0;
	var dlng = len_/85.567/1000.0;
	$("#rigthlat").val(lat_-dlat);
	$("#rigthlng").val(lng_+dlng);
	return new google.maps.LatLng(lat_-dlat,lng_+dlng);
}
function getAreaSWLatlng(lat_,lng_,len_){
	var dlat = len_/111.0/1000.0;
	var dlng = len_/85.567/1000.0;
	$("#leftlat").val(lat_+dlat);
	$("#leftlng").val(lng_-dlng);
	return new google.maps.LatLng(lat_+dlat,lng_-dlng);
}
function clearAreaLagLng(){
	$("#leftlat").val("");
	$("#leftlng").val("");
	$("#rigthlat").val("");
	$("#rigthlng").val("");
	markersize=500;
}
/*
 *tool
 */
	function showtoolPanel(){
	 	$("#tools_box").show();
	}
	function hidetoolPanel(){
		$("#tools_box").hide();
	}
	
Array.prototype.remove=function(dx){
　　if(isNaN(dx)||dx>this.length){return false;}
　　for(var i=0,n=0;i<this.length;i++){
　　　　if(this[i]!=this[dx]){
　　　　　　this[n++]=this[i]
　　　　}
　　}
　　this.length-=1
}
function initMarkerisShow(){
	if(mapType=="1" && baidMap!=undefined){
		var isParent = false;
		
		if(treeObj != null){
			
			var nodesNoChecked = treeObj.getCheckedNodes(false);
			
			for(var i=0;i<nodesNoChecked.length;i++){
				isParent=nodesNoChecked[i].isParent;
				if(!isParent){			
						updateMarkerIsShow(nodesNoChecked[i].id,false,false);
						hideMarkersBaidu(nodesNoChecked[i].id,false);
				}
			}
			
			
			var nodes = treeObj.getCheckedNodes(true);
			
			var curmarker=null;
			
			for(var i=0;i<nodes.length;i++){
				isParent=nodes[i].isParent;
				if(!isParent){
						updateMarkerIsShow(nodes[i].id,true,false);
						showMarkersBaidu(nodes[i].id,false);
				}
			}
		}
		
	}else{
		zTreeOnCheck(null,null,null);
	}
}

function markerRefresh(id,groupId,eventName,isMarker){//alert("id="+id+",groupId="+groupId+",eventName="+eventName+",isMarker="+isMarker);
					switch(eventName){
						case "add" :    
										if(isMarker){
											markerRefreshObject.addMarker(id);
										}else{
											markerRefreshObject.addMarkerGroup(id);
										}
										
										break;
										
						case "delete" : 
										if(isMarker){
											markerRefreshObject.delMarker(id);
										}else{
											markerRefreshObject.delMarkerGroup(id);
										}
										
										break;
										
						case "update" : 
										if(isMarker){
											markerRefreshObject.updateMarker(id);
										}else{
											markerRefreshObject.updateMarkerGroup(id);
										}
										
										break;
					}
}

var markerRefreshObject = {
	refresh : function (id,groupId,eventName,isMarker){//alert("id="+id+",groupId="+groupId+",eventName="+eventName+",isMarker="+isMarker);
					switch(eventName){
						case "add" :    
										if(isMarker){
											markerRefreshObject.addMarker(id);
										}else{
											markerRefreshObject.addMarkerGroup(id);
										}
										
										break;
										
						case "delete" : 
										if(isMarker){
											markerRefreshObject.delMarker(id);
										}else{
											markerRefreshObject.delMarkerGroup(id);
										}
										
										break;
										
						case "update" : 
										if(isMarker){
											markerRefreshObject.updateMarker(id);
										}else{
											markerRefreshObject.updateMarkerGroup(id);
										}
										
										break;
					}
	},
	addMarker : function(id){
	    if(treeObj!=null && treeObj.getNodeByParam("id",id) == null){
				$.ajax({
			        type: "POST",
			        dataType: "json",
			        async:false,
			        url: "json/markerAction_getMarker.action",
			        data:{"id":id},
			        success: function(json) {		         
				         if (json.flag==true) {
				    			 if(typeof json.data[0].id=="number" && typeof json.data[0].lat2=="number" && typeof json.data[0].lng2=="number" && json.data[0].icon.length!=0){
			         		 
						         		
							 			
								 		 markerObject.markerArr[json.data[0].id]={};
								 		
									  	 markerObject.markerArr[json.data[0].id].competence=json.data[0].competence;		
									  	 markerObject.markerArr[json.data[0].id].title=json.data[0].title;
									  	 markerObject.markerArr[json.data[0].id].text=json.data[0].text;
									  	 markerObject.markerArr[json.data[0].id].icon=json.data[0].icon;
									  	 markerObject.markerArr[json.data[0].id].lng=json.data[0].lat2;
									  	 markerObject.markerArr[json.data[0].id].lat=json.data[0].lng2;
									  	 markerObject.markerArr[json.data[0].id].blng=json.data[0].blat;
						  	 			 markerObject.markerArr[json.data[0].id].blat=json.data[0].blng;
									  	 markerObject.markerArr[json.data[0].id].groupid=json.data[0].groupid;
									  	 markerObject.markerArr[json.data[0].id].id=json.data[0].id;
									  	 markerObject.markerArr[json.data[0].id].customerNum=json.data[0].markcode;
									  	 markerObject.markerArr[json.data[0].id].isShow=false;
									  	 
									  	 markerObject.markerArr[json.data[0].id].area=markerArea;
									  	 markerObject.markerArr[json.data[0].id].areaRadius=markersize;
									  	 markerObject.markerArr[json.data[0].id].bzType=json.data[0].bzType;
									  	 
									  	  var marker=markerObject.addMarker(json.data[0].id,json.data[0].lng2,json.data[0].lat2,json.data[0].icon);
									  	  marker.setMap(null);
									  	  markerObject.markerArr[json.data[0].id].marker=marker;
									  	  
									  	 markerObject.addMarkerListener(markerObject.markerArr[json.data[0].id]);	
									  	 
									  	 if(json.data[0].userMarkerArea!=null&&json.data[0].userMarkerArea.leftLat!=0 &&json.data[0].userMarkerArea.leftLon!=0 &&json.data[0].userMarkerArea.rightLat!=0 &&json.data[0].userMarkerArea.rightLon!=0 &&json.data[0].userMarkerArea.markerRadius!=0){
									  		 if(json.data[0].userMarkerArea.g_leftLat!=0 &&json.data[0].userMarkerArea.g_leftLon!=0 &&json.data[0].userMarkerArea.g_rightLat!=0 &&json.data[0].userMarkerArea.g_rightLon!=0 &&json.data[0].userMarkerArea.markerRadius!=0){
									  			markerObject.markerArr[json.data[0].id].area=drawMarkerArea(new google.maps.LatLng(json.data[0].userMarkerArea.g_leftLat,json.data[0].userMarkerArea.g_leftLon),new google.maps.LatLng(json.data[0].userMarkerArea.g_rightLat,json.data[0].userMarkerArea.g_rightLon));
									  		 }else{
									  			 markerObject.markerArr[json.data[0].id].area=drawMarkerArea(new google.maps.LatLng(json.data[0].userMarkerArea.leftLat,json.data[0].userMarkerArea.leftLon),new google.maps.LatLng(json.data[0].userMarkerArea.rightLat,json.data[0].userMarkerArea.rightLon));
										  	 	 
									  		 }
									  		
									  		
									  		markerObject.markerArr[json.data[0].id].area.setMap(null);
									  	 	 markerObject.markerArr[json.data[0].id].areaRadius=json.data[0].userMarkerArea.markerRadius;
									  	 }
									  	 
									  	 //添加标注所属组(若改组已经存在则不操作)
									  	 markerRefreshObject.addMarkerGroup(json.data[0].groupid);
									  	 
										 addMarkerGroupTreeNode(json.data[0].id,json.data[0].groupid,json.data[0].title);
										 
										 markerObject.markerJson.data.push(json.data[0]);
										 
									  	 markerObject.markerJson.totalcount = markerObject.markerJson.data.length;
									 
				    	        }
						    		  	 
		                 }
			        }
			   });	
		   }
	},
	delMarker : function(id){
							      if(treeObj!=null && treeObj.getNodeByParam("id",id) != null){
							      
					        	 	  markerObject.deleteMarker(id);
					        	 	  
					                  deleteMarkerGroupTreeNode(id);
					                  
					                  for(var i=0;i<markerObject.markerids.length;i++){
											if(id==markerObject.markerids[i]){
												markerObject.markerids.remove(i);
											}
											break;
									  }
									  
					                  for(var i=0;i<markerObject.markerJson.data.length;i++){
					                	  if(id==markerObject.markerJson.data[i].id){
												markerObject.markerJson.data.remove(i);
												break;
										  }
					                	  
					                  }
					                  
					                  markerObject.markerJson.totalcount = markerObject.markerJson.data.length;
				                  	  
				                  	  if(mapType==1){
									 		MarkerBD.hide(id);
									  }
				                  }
				                  
	},
	updateMarker : function(id){
		if(treeObj!=null && treeObj.getNodeByParam("id",id) != null){
			$.ajax({
		        type: "POST",
		        dataType: "json",
		        async:false,
		        url: "json/markerAction_getMarker.action",
		        data:{"id":id},
		        success: function(json) {		         
			         if (json.flag==true) {
	
			         		 if(typeof json.data[0].id=="number" && typeof json.data[0].lat2=="number" && typeof json.data[0].lng2=="number" && json.data[0].icon.length!=0){
				         		
				         		 if(treeObj!=null && treeObj.getNodeByParam("id",id) != null){
				         		 	 
				         		 	 var isShow = treeObj.getNodeByParam("id", id).checked;
				         		 	 
					         		 markerObject.deleteMarker(id);
					         		 markerObject.infowindow=null;
					         		 
					         		 				 			 
									 markerObject.markerArr[json.data[0].id]={};
									 
							  	 	 markerObject.markerArr[json.data[0].id].competence=json.data[0].competence;		
							  	 	 markerObject.markerArr[json.data[0].id].title=json.data[0].title;
							  		 markerObject.markerArr[json.data[0].id].text=json.data[0].text;
							  		 markerObject.markerArr[json.data[0].id].icon=json.data[0].icon;
							  		 markerObject.markerArr[json.data[0].id].lat=json.data[0].lng2;
							  		 markerObject.markerArr[json.data[0].id].lng=json.data[0].lat2;
							  		 markerObject.markerArr[json.data[0].id].blng=json.data[0].blat;
						  	 		 markerObject.markerArr[json.data[0].id].blat=json.data[0].blng;
							  		 markerObject.markerArr[json.data[0].id].groupid=json.data[0].groupid;
							  		 markerObject.markerArr[json.data[0].id].id=json.data[0].id;
							  		 markerObject.markerArr[json.data[0].id].customerNum=json.data[0].markcode;
								  	 markerObject.markerArr[json.data[0].id].bzType=json.data[0].bzType;
								  	  
								  	 markerObject.markerArr[json.data[0].id].isShow=isShow;
								  	 
								  	 var marker=markerObject.addMarker(id,json.data[0].lng2,json.data[0].lat2,json.data[0].icon);
								  	 marker.setMap(isShow?map:null);
							  	 	 markerObject.markerArr[json.data[0].id].marker=marker;
								  	 
								  	 markerObject.addMarkerListener(markerObject.markerArr[id]);	
								  	 
								  	 var curnode=treeObj.getNodeByParam("id",json.data[0].id);
			  	 
						  	 if (curnode!=null) {
						  	 
								curnode.name = json.data[0].title;
								
								treeObj.updateNode(curnode);
								
								
								if(curnode.getParentNode().id != 'g_'+json.data[0].groupid){
								
									var prevParentNode = curnode.getParentNode();
									
									prevParentNode.count = parseInt(prevParentNode.count)-1 ;
									
									if(prevParentNode.count == 0){
										prevParentNode.name = prevParentNode.title;
									}else{
										prevParentNode.name = prevParentNode.title+"("+prevParentNode.count+")";
									}
									
									var curGroupnode=treeObj.getNodeByParam("id",'g_'+json.data[0].groupid);					
									
									if(curGroupnode == null){
									
										//添加标注所属组(若改组已经存在则不操作)
									  	 markerRefreshObject.addMarkerGroup(json.data[0].groupid);
										 curGroupnode=treeObj.getNodeByParam("id",'g_'+json.data[0].groupid);
									}
									
									curGroupnode.count = parseInt(curGroupnode.count)+1 ;

									curGroupnode.name = curGroupnode.title+"("+curGroupnode.count+")";
									
									treeObj.moveNode(curGroupnode, curnode, "inner");
									
									treeObj.updateNode(prevParentNode);
									treeObj.updateNode(curGroupnode);
								}
				
							 }
								  	 
								  	 //deleteMarkerGroupTreeNode(id);	
								  	 //addMarkerGroupTreeNode(json.data[0].id,json.data[0].groupid,json.data[0].title);	
								  	 
								  	 if(json.data[0].userMarkerArea!=null&&json.data[0].userMarkerArea.leftLat!=0 &&json.data[0].userMarkerArea.leftLon!=0 &&json.data[0].userMarkerArea.rightLat!=0 &&json.data[0].userMarkerArea.rightLon!=0 &&json.data[0].userMarkerArea.markerRadius!=0){
								  		 if(json.data[0].userMarkerArea.g_leftLat!=0 &&json.data[0].userMarkerArea.g_leftLon!=0 &&json.data[0].userMarkerArea.g_rightLat!=0 &&json.data[0].userMarkerArea.g_rightLon!=0 &&json.data[0].userMarkerArea.markerRadius!=0){
								  			markerObject.markerArr[json.data[0].id].area=drawMarkerArea(new google.maps.LatLng(json.data[0].userMarkerArea.g_leftLat,json.data[0].userMarkerArea.g_leftLon),new google.maps.LatLng(json.data[0].userMarkerArea.g_rightLat,json.data[0].userMarkerArea.g_rightLon));
								  		 }else{
								  			 markerObject.markerArr[json.data[0].id].area=drawMarkerArea(new google.maps.LatLng(json.data[0].userMarkerArea.leftLat,json.data[0].userMarkerArea.leftLon),new google.maps.LatLng(json.data[0].userMarkerArea.rightLat,json.data[0].userMarkerArea.rightLon));
									  	 	 
								  		 }
								  		 
								  	 	 markerObject.markerArr[json.data[0].id].areaRadius=json.data[0].userMarkerArea.markerRadius;
								  		 if(!isShow){
								  		 	markerObject.markerArr[json.data[0].id].area.setMap(null);
								  	 	 }else{
								  	 	 	markerObject.markerArr[json.data[0].id].area.setMap(map);
								  	 	 }
								  	 }
								  	 	
								  	 if($("#bzcheckbox").is(":checked")){
						  	 			if(markerObject.markerArr[json.data[0].id].lable) markerObject.markerArr[json.data[0].id].lable.setMap(null);
								  	 	markerObject.markerArr[json.data[0].id].lable = new myLableMarker(map,"<div class=\"iconTheStyle\" style=\"background:#f5fcb8;  font-size:12px; color:#000000; font-weight:bold; white-space:nowrap; border:1px solid #666666;\" >"+json.data[0].title+"</div>",marker.getPosition(),json.data[0].id);
								  	 
								  	 }									  	 

								  	for(var i=0;i<markerObject.markerJson.data.length;i++){
					                	  if(json.data[0].id==markerObject.markerJson.data[i].id){
												markerObject.markerJson.data.remove(i);
												break;
										  }
					                 }								  	 
								  	 markerObject.markerJson.data.push(json.data[0]);
						  	 	}	  	 
						  	 }		 			  	 
		        	}
		        }
		   });
	   }
	},
	addMarkerGroup : function(id){
						//查看标注所属组存不存在
	         		 	//不存在查找添加组
	         		 	//存在添加标注
	         		 	if(id != 0 && treeObj != null){
					    	var curnode=treeObj.getNodeByParam("id","g_"+id);
					    	//判断是否不存在
					    	if(curnode==null){
					    	   //查找组
					    	   $.ajax({
								        type: "POST",
								        dataType: "json",
								        async:false,
								        url: "json/markerAction_getUserMarkerGroup.action",
								        data:{"groupid":id},
								        success: function(json) {		         
									         if (json.flag==true) {
									    			
									    			//**************
									    			if(parseInt($("#userId").val()) ==json.data[0].creater ){//判断是否是该用户的组
									    				
									    				if($("#addMarkerGroupSelect a[name='"+id+"']").length<=0){
										    				var newoption=$("<a name=\""+json.data[0].id+"\">"+json.data[0].groupName+"</a>");
										    			
										    				$(".marker_group_option a").eq($(this).size()-2).before(newoption);
										    				
										    				newoption.click(function(){
										    				
															    var value=$(this).attr("name");
																$(this).parent().siblings(".marker_group_select_txt").text($(this).text());
															    $("#markerGroupId").val(value);	
															    			    							    
															});
															markerGroupJson.data.push(json.data[0]);
														}			
									    			}else{									    			    				
									    				allMarkerGroupJson.data.push(json.data[0]);									    				
									    			}
									    			addMarkerGroupTreeGroupNode(json.data[0].id,json.data[0].groupName);			    						 
									         }
									    }
									  });		    	  	
					    	}
					    }
	},
	delMarkerGroup : function(id){
							if(treeObj!=null){
						    	var curnode=treeObj.getNodeByParam("id","g_"+id);
						    	//判断是否不存在
						    	if(curnode!=null){
						    		//判断是否有子节点
						    		if(curnode.children==null || curnode.children.length==0){
						    		
							 		         var groupid=parseInt(id.split("_")[1]);
							 		      
							         		 //--删除组
							    			 treeObj.removeNode(curnode);
								 		     
								 		     //--删除json中的组allMarkerGroupJson，markerGroupJson					 		     
								 		     for(var i=0;i<allMarkerGroupJson.data.length;i++){
								 		     	
								 		     	 if(typeof allMarkerGroupJson.data[i]!="undefined" && allMarkerGroupJson.data[i].id==groupid){
								 		     	 	delete allMarkerGroupJson.data[i];
								 		     	 	break;
								 		     	 }
								 		     }
								 		     
								 		     for(var i=0;i<markerGroupJson.data.length;i++){
								 		     	 if( typeof markerGroupJson.data[i]!="undefined" && markerGroupJson.data[i].id==groupid){
								 		     	 	delete markerGroupJson.data[i];
								 		     	 	break;
								 		     	 }
								 		     }
								 		     
								 		     if($("#markerGroupId").attr("value")==groupid+""){
								 		     	$("#marker_group_option a").parent().siblings(".marker_group_select_txt").text($(".marker_group_option a").eq(0).text());
												$("#markerGroupId").val($(".marker_group_option a").eq(0).attr("name"));
								 		     }
								 		     			 		     
								 		     $("#addMarkerGroupSelect a[name='"+groupid+"']").remove();
								 		      			           										           					 		    
						    		}else{
						    			alert(language.dqzxybzbnsc);
						    		}
						    	}
							}			    
	},
	updateMarkerGroup : function(id){
		$.ajax({
	       type: "POST",
	       dataType: "json",
	       async:false,
	       url: "json/markerAction_getUserMarkerGroup.action",
	       data:{"groupid":id},
	       success: function(json) {		         
	         	if(json.flag==true){
	         		 if(json.data!=null&&json.data.length>0){
	         		 	
	         		 	var curnode=treeObj.getNodeByParam("id","g_"+id);
	         		 	
	         		 	if(curnode!=null){
	         		 		curnode.title=json.data[0].groupName;	         		 		
	         		 		if(curnode.count!=0){
	         		 			curnode.name =curnode.title+"("+curnode.count+")";
	         		 		}else{
	         		 			curnode.name =curnode.title;
	         		 		}
	         		 		treeObj.updateNode(curnode);
	         		 	}
	         		 	
		         		for(var i=0;i<allMarkerGroupJson.data.length;i++){
		 		     	
			 		     	 if(typeof allMarkerGroupJson.data[i]!="undefined" && allMarkerGroupJson.data[i].id==parseInt(id)){
			 		     	 	 allMarkerGroupJson.data[i]=json.data[0];
			 		     	 	 break;
			 		     	 }
			 		     }
			 		     
			 		     for(var i=0;i<markerGroupJson.data.length;i++){
			 		     	 if( typeof markerGroupJson.data[i]!="undefined" && markerGroupJson.data[i].id==parseInt(id)){
			 		     	 	markerGroupJson.data[i]=json.data[0];
			 		     	 	break;
			 		     	 }
			 		     }
			 		     
			 		     if($("#markerGroupId").attr("value")==id){
			 		     	$("#marker_group_option a").parent().siblings(".marker_group_select_txt").text(json.data[0].groupName);
			 		     }
			 		     
			 		     $("#addMarkerGroupSelect a[name='"+id+"']").text(json.data[0].groupName);
			 		     
	         		}
	         		
	         	}
	       },
	       error: function() {}
	  });
	}
}

function updateMarkerPosition(_id){
	
	var _marker = markerObject.markerArr[_id];
	
	
	$.ajax({
	        type: "POST",
	        dataType: "json",
	        async:true,
	        url: "json/markerAction_addOrUpdateUserMarker.action",
	        data:{"id":_id,"lng":ceneterLatlng.lat(),"lat":ceneterLatlng.lng(),"leftLat":LatLngBounds?LatLngBounds.getSouthWest().lat():ceneterLatlng.lng(),"leftLon":LatLngBounds?LatLngBounds.getSouthWest().lng():ceneterLatlng.lat(),"rightLat":LatLngBounds?LatLngBounds.getNorthEast().lat():ceneterLatlng.lng(),"rightLon":LatLngBounds?LatLngBounds.getNorthEast().lng():ceneterLatlng.lat(),"title":_marker.title,"text":_marker.desc,"icon":_marker.icon,"groupid":_marker.groupid,"radius":_marker.markersize,"bzType":_marker.bzType,"customerNum":_marker.customerNum,"mapType":2},	        
	        success: function(json) {		         
		         if (json.flag==true) {
		         
		         	 //markerObject.infowindow.close();
		         	
			  		_marker.lat=json.data[0].lng2;
			  		_marker.lng=json.data[0].lat2;

				  	_marker.areaRadius=json.data[0].userMarkerArea.markerRadius;
         	
		      		$("#moveMarkerBtn").hide();
		      		$("#update_marker_google_btn").show();
		      		
		      		if(curmarkerNameLabe){
						curmarkerNameLabe.setMap(null);
						curmarkerNameLabe = null;
						if($("#bzcheckbox").is(":checked")) _marker.lable = new myLableMarker(map,"<div class=\"iconTheStyle\" style=\"background:#f5fcb8;  font-size:12px; color:#000000; font-weight:bold; white-space:nowrap; border:1px solid #666666;\" >"+json.data[0].title+"</div>",_marker.marker.getPosition(),json.data[0].id);	
					}
		      		
                 }else{
                 	$("#updatePositionMsg").val("*"+json.msg);
                 }
	        },
	        error: function() {}
	   });	
	
	
}

var LatLngBounds = null;
var ceneterLatlng = null;

var curmarkerNameLabe = null;


function calcleupdateMarkerPosition(_id){

	//markerObject.infowindow.close();
	
	var _marker = markerObject.markerArr[_id];
	
	_marker.marker.setPosition(new google.maps.LatLng(_marker.lat,_marker.lng) );
	
	if(_marker.area){
		_marker.area.setBounds(new google.maps.LatLngBounds(
					 			
					 				getAreaSWLatlng(_marker.marker.getPosition().lat(),_marker.marker.getPosition().lng(),_marker.areaRadius),
					 				getAreaNELatLng(_marker.marker.getPosition().lat(),_marker.marker.getPosition().lng(),_marker.areaRadius)
					 			
					 			));
		
	}
	
	$("#infoWinLat").text(_marker.marker.getPosition().lat().toFixed(5));
	$("#infoWinLng").text(_marker.marker.getPosition().lng().toFixed(5));
	
	if(curmarkerNameLabe){
		curmarkerNameLabe.setMap(null);
		curmarkerNameLabe = null;
		if($("#bzcheckbox").is(":checked")) _marker.lable = new myLableMarker(map,"<div class=\"iconTheStyle\" style=\"background:#f5fcb8;  font-size:12px; color:#000000; font-weight:bold; white-space:nowrap; border:1px solid #666666;\" >"+_marker.title+"</div>",_marker.marker.getPosition(),_marker.id);	
	}
	
	$("#moveMarkerBtn").hide();
	
	$("#update_marker_google_btn").show();
	
}



function addEvent(){
	
	var isOpencustomerNumListOutCanvas = false;
	var customerNumBlurEvent = null;
	var customerNumTimeoutEvent = null;
	var isOnAddCustomerNum = false;
	
	$("#customerNum").focus(function(){
	
		/*if(!isOpencustomerNumListOutCanvas){
		
			$("#customerNumListOutCanvas").show();
			
			isOpencustomerNumListOutCanvas = true;
			
		}else{*/
		
			$("#customerNumListOutCanvas").show();
			
			isOpencustomerNumListOutCanvas = true;
		
	});
	
	$("#customerNum").blur(function(){
	
		clearTimeout(customerNumBlurEvent);
	
		customerNumBlurEvent = setTimeout(function(){
		
							if(!isOnAddCustomerNum){
							
								isOpencustomerNumListOutCanvas = false;
								
							}
							
							clearTimeout(customerNumTimeoutEvent);
							
							customerNumTimeoutEvent = setTimeout(function(){
									
									if(!isOpencustomerNumListOutCanvas){
									
										$("#customerNumListOutCanvas").hide();
										
										isOpencustomerNumListOutCanvas = false;
										
										
										//if($("#customerNum").val().lenght == 0){
										//	$("#addcustomerNum_Msg").html("&nbsp;");
										//}
										
									}
									
								},100);
							
						},100);
	});	
	
	$("#customerNum").mouseover(function(){
	
		if($("#customerNumListOutCanvas").is(":visible")){
		
			isOpencustomerNumListOutCanvas = true;
			
		}
		
		
		
	});
	
	$("#customerNum").mouseleave(function(){
		
		isOpencustomerNumListOutCanvas = false;
		
		clearTimeout(customerNumTimeoutEvent);
		
		customerNumTimeoutEvent = setTimeout(function(){
				
				if(!isOpencustomerNumListOutCanvas){
				
					$("#customerNumListOutCanvas").hide();
					
					isOpencustomerNumListOutCanvas = false;
					
					$("#customerNum").blur();
					
					
					//if($("#customerNum").val().lenght == 0){
					//	$("#addcustomerNum_Msg").html("&nbsp;");
					//}

				}
				
			},100);
	});	
	
	
	$("#customerNumListOutCanvas").mouseover(function(){
	
		isOpencustomerNumListOutCanvas = true;
		
	});
	
	$("#customerNumListOutCanvas").click(function(){
	
		isOpencustomerNumListOutCanvas = true;
		
	});
	
	
	$("#addcustomerNum").mouseover(function(){
	
		isOnAddCustomerNum = true;
		
		if($("#customerNumListOutCanvas").is(":visible")){
		
			isOpencustomerNumListOutCanvas = true;
			
		}
		
	});
	
	$("#addcustomerNum").mouseleave(function(){
	
		isOnAddCustomerNum = false;

		isOpencustomerNumListOutCanvas = false;
		
		clearTimeout(customerNumTimeoutEvent);
		
		customerNumTimeoutEvent = setTimeout(function(){
				
				if(!isOpencustomerNumListOutCanvas){
				
					$("#customerNumListOutCanvas").hide();
					
					isOpencustomerNumListOutCanvas = false;
					
					$("#customerNum").blur();
					
					
					//if($("#customerNum").val().lenght == 0){
					//	$("#addcustomerNum_Msg").html("&nbsp;");
					//}

				}
				
			},100);

		
	});
	
	$("#addcustomerNum").click(function(){
		 
		 isOnAddCustomerNum = true;
		
		if($("#customerNumListOutCanvas").is(":visible")){
		
			isOpencustomerNumListOutCanvas = true;
			
		}
		
		var value = $("#customerNum").val();
		
		var customerNum_vlaueList = getcustomerNum_vlaues();
		
		//$("#addcustomerNum_Msg").html("&nbsp;");
		
		if(value.length !=0 && ($.inArray($("#clientId_prefix").val() + value, customerNum_vlaueList) < 0)){
			    
				$("#customerNumListOutCanvas").prepend("<div class='search_item' onmouseover='over(this)' onmouseout='out(this)'><span name='customerNum_vlaue' style='white-space:nowrap;display:inline-block;width:100px; overflow:hidden;text-overflow: ellipsis;' >"+$("#clientId_prefix").val() + value+"</span><span style='float:right;margin-right:5px;margin-top:2px;*margin-right:0px;*margin-top:-12px;display:inline-block;'><a href='javascript:;' onclick='deleteCustomerNumItem(this);'><img style='display:inline-block;' src='gpsonline/image/marker/ico_dele.png'></img></a></span></div>");
				
				$("#customerNum").val("");
				
		}else if(($.inArray($("#clientId_prefix").val() + value, customerNum_vlaueList) >= 0)){
		
				$("#addmarkermsg").text("*客户号已存在");
				$("#addmarkermsg").css("color","red");
				
		}
		
		
				
	});
	
	
	
	
	$("#customerNumListOutCanvas").mouseleave(function(){
		
		isOpencustomerNumListOutCanvas = false;
		
		clearTimeout(customerNumTimeoutEvent);
		
		customerNumTimeoutEvent = setTimeout(function(){
				
				if(!isOpencustomerNumListOutCanvas){
				
					$("#customerNumListOutCanvas").hide();
					
					isOpencustomerNumListOutCanvas = false;
					
					$("#customerNum").blur();
					
					//if($("#customerNum").val().lenght == 0){
					//	$("#addcustomerNum_Msg").html("&nbsp;");
					//}
					
				}
				
			},100);
	});	
	$("#marker_area_radius_input").watch(function(val) {
		
		var input = $("#marker_area_radius_input");
		val = parseInt(val == "" ? 0 : val);
		if(val > 5000) val = 5000;
		
		$("#markerArea" ).slider("value", val);
		
		input.val(val);	
	});
	
	
}

function getcustomerNum_vlaues(){
	var customerNum_vlaueList = [];
		
		$("span[name='customerNum_vlaue']").each(function(){
		
			customerNum_vlaueList.push($(this).text());
			
		});
		
	return 	customerNum_vlaueList;
}

function initCustomerNum_vlaue(valuesArr){

	$("#customerNumListOutCanvas").html("");
	
	for(var i=0;i<valuesArr.length;i++){
		
		if(valuesArr[i].length != 0){
			
			$("#customerNumListOutCanvas").append("<div class='search_item' onmouseover='over(this)' onmouseout='out(this)'><span name='customerNum_vlaue' style='white-space:nowrap;display:inline-block;width:100px; overflow:hidden;text-overflow: ellipsis;' >"+valuesArr[i]+"</span><span style='float:right;margin-right:5px;margin-top:2px;*margin-right:0px;*margin-top:-12px;display:inline-block;'><a href='javascript:;' onclick='deleteCustomerNumItem(this);'><img style='display:inline-block;' src='gpsonline/image/marker/ico_dele.png'></img></a></span></div>");
		
		}
	}
}

function over(el) {
	
						$(el).attr("class","customerNum_item_over");
						
				  }
					
function out(el) {
	
						$(el).attr("class","search_item");
						
				 }				 
			 
function deleteCustomerNumItem(el){
	
	$(el).parent().parent().remove();

}

function getCLientIdPrefix(){

	$.ajax({
	        type: "POST",
	        dataType: "json",
	        async:true,
	        url: "json/markerAction_getClientPrefix.action",
	        success: function(json) {
	        		         
		         if (json.flag==true) {
		         
	         		 $("#clientId_prefix").val(json.data.prefixionStr);
	         		 		        	 					           				
                 }else{
                 
                 	alert(json.msg);
                 	
                 }
	        },
	        error: function() {}
	      });
	   
}


var MarkerTreeMenu = {
		　marker_tree_Menu :null,
		　init : function(){
			this.marker_tree_Menu = $("#marker_tree_Menu");
		 },
		 showRMenu : function(type, x, y,node) {
		 							
						$("#marker_tree_Menu_del").hide();
						$("#marker_tree_Menu_update").hide();
						$("#marker_tree_Menu_bingding").hide();
						$("#marker_tree_Menu").hide();
						$("#marker_tree_Menu ul").hide();
						
						
						
						if(type == "marker"){
							if(markerObject.markerArr[node.id].competence == 1){

								$("#marker_tree_Menu").show();
								$("#marker_tree_Menu ul").show();
							
								//$("#marker_tree_Menu_del").show();								
								//$("#marker_tree_Menu_del").attr("markerId",node.id);
								
								$("#marker_tree_Menu_update").show();								
								$("#marker_tree_Menu_update").attr("markerId",node.id);	
															
								$("#marker_tree_Menu_bingding").show();
								$("#marker_tree_Menu_bingding").attr("markerId",node.id);

							}							
						}
						
						if((y + $("#marker_tree_Menu").height())<$(window).height()){
						
							this.marker_tree_Menu.css({"top":y+"px", "left":x+"px", "visibility":"visible"});
						
						}else{
						
							this.marker_tree_Menu.css({"top":(y-$("#marker_tree_Menu").height())+"px", "left":x+"px", "visibility":"visible"});
						}
						
						$("body").bind("mousedown", MarkerTreeMenu.onBodyMouseDown);
						
		 },
		 hideRMenu : function() {
		 
			if (this.marker_tree_Menu) this.marker_tree_Menu.css({"visibility": "hidden"});
			
			$("body").unbind("mousedown", MarkerTreeMenu.onBodyMouseDown);
			
		 },
		 onBodyMouseDown : function(event){
		 
			if (!(event.target.id == "marker_tree_Menu" || $(event.target).parents("#marker_tree_Menu").length>0)) {
			
				MarkerTreeMenu.marker_tree_Menu.css({"visibility" : "hidden"});
				
			}
			
		},
		del : function(el){
		
			MarkerTreeMenu.hideRMenu();
			deleteMarker($(el).attr("markerId"));		
		},
		update : function(el){
		
			MarkerTreeMenu.hideRMenu();
			var treeNode = treeObj.getNodeByParam("id",$(el).attr("markerId"));

			treeObj.checkNode(treeNode, true, false, false);
		
			if(mapType==1 && baidMap!=undefined){
				MarkerBD.hide(treeNode.id);		
				MarkerBD.open(treeNode.id);						
			}else{
				var curmarker=markerObject.markerArr[treeNode.id];
				
				if(curmarker!=null){
					curmarker.isShow=true;
			    }
				
				openMarker(treeNode.id);
			}
			
			openUpdateMarkerWin($(el).attr("markerId"));
			
		},
		bingding : function(el){
			
			MarkerTreeMenu.hideRMenu();
			$("#markersaveMsg").text("");
			$("#marker_vehicle_binding_ContentWin").show();
			$("#marker_vehicle_binding_ContentWin").center();
			
			showVechileGrouptoMarkerBangDingSelect($(el).attr("markerId"));
			showVechiletoMarkerbangdingTable($(el).attr("markerId"));
			
		}

}


function showVechileGrouptoMarkerBangDingSelect(markerId){
	 $("#marker_vehicle_group").html("");
	 var options =[];
	 var i=0;
	 $.each(equipmentMap, function (k, v) {//迭代每一个组
	 		
	 		if(i<1){
	 			options.push("<option value='"+markerId+"_"+k+"' selected='selected' >"+v.getName()+"</option>");
	 			i++;
	 		}else{
	 			options.push("<option value='"+markerId+"_"+k+"' >"+v.getName()+"</option>");
	 		}	
			
	
	 });
	 
	 $("#marker_vehicle_group").append(options.join(""));
	 
	 options="";
	 
}

function showVechiletoMarkerbangdingTable(markerId){

	$("#saveMarkerBtn").attr("markerId",markerId);
	
	$("#markerBangdingVehicleTitle").text("标注("+treeObj.getNodeByParam("id",markerId).name+")绑定设备");
	
	$("#marker_vehicle_table_content tbody").html("");

	 var groupId= $("#marker_vehicle_group").val();
	 
	 if(groupId.length == 0){
	 
	 	groupId = -1;
	 	
	 }else{
	 
	 	groupId = groupId.split("_")[1];
	 	
	 }
	 
	 

	 if(cartIds.length == 0) return;
	 
	 
	 var curGroupChildsIds = equipmentMap[groupId] ? (equipmentMap[groupId].getChildsIds()) : (new Array());
	 var curGroupChildsIdsLength = curGroupChildsIds.length;
	 
	 var id,curVehicle;
	 
	 var rows=[],options="";
	 
	 
	 
	 var result = getBingdingVehicleFromMarkerData(markerId);
	 
	 var isBingdinged = false;
	 
	 for(i=0;i<curGroupChildsIdsLength;i++) {
	 		
	 		id=curGroupChildsIds[i];	
			
			isBingdinged = false;
			
			for(var j=0;j<result.length;j++){
				
				if(result[j].markId == markerId && result[j].vhcId == id){
				
					isBingdinged = true;
					
					break;
				}
			}
			
			
			
			curVehicle=equipmentObject[id];

				
					if(isBingdinged){
					
						rows.push("<tr name='marker_vechileId_"+result[j].id+"'>" +//onclick='clearCurSelect(this)'
												    "<td align='center' style='width:100px;' name='"+curVehicle.id+"'><span style='white-space:nowrap;display:inline-block;width:100px; overflow:hidden;text-overflow: ellipsis;' title='"+$.trim(curVehicle.vehicleName)+"'>"+$.trim(curVehicle.vehicleName)+"</span></td>"+
												    "<td align='center' style='width:100px;'><select>"+(result[j].inalarm == 0 ?"<option value=\"1\">√</option><option selected=\"selected\" value=\"0\">X</option>":"<option selected=\"selected\" value=\"1\">√</option><option value=\"0\">X</option>")+"</select></td>"+
												    "<td align='center' style='width:100px;'><select>"+(result[j].outalarm == 0 ?"<option value=\"1\">√</option><option selected=\"selected\" value=\"0\">X</option>":"<option selected=\"selected\" value=\"1\">√</option><option value=\"0\">X</option>")+"</select></td>"+
												    "<td align='center' style='width:100px;'><select>"+(result[j].recregion == 0 ?"<option value=\"1\">√</option><option selected=\"selected\" value=\"0\">X</option>":"<option selected=\"selected\" value=\"1\">√</option><option value=\"0\">X</option>")+"</select></td>"+
												    "<td align='center'><input type='text' class='marker_vehicle_table_input'  value='"+(result[j].stopalarmmin==0?"":result[j].stopalarmmin)+"'></input></td>"+									  
												 "</tr>");
												 
					 }else{
					 
					 	rows.push("<tr name=''>" +//onclick='clearCurSelect(this)'
												    "<td align='center' style='width:100px;' name='"+curVehicle.id+"'><span style='white-space:nowrap;display:inline-block;width:100px; overflow:hidden;text-overflow: ellipsis;' title='"+$.trim(curVehicle.vehicleName)+"'>"+$.trim(curVehicle.vehicleName)+"</span></td>"+
												    "<td align='center' style='width:100px;'><select><option selected=\"selected\" value=\"-1\"></option><option value=\"1\">√</option><option value=\"0\">X</option></select></td>"+
												    "<td align='center' style='width:100px;'><select><option selected=\"selected\" value=\"-1\"></option><option value=\"1\">√</option><option value=\"0\">X</option></select></td>"+
												    "<td align='center' style='width:100px;'><select><option selected=\"selected\" value=\"-1\"></option><option value=\"1\">√</option><option value=\"0\">X</option></select></td>"+
												     "<td align='center'><input type='text' class='marker_vehicle_table_input' ></input></td>"+												    
												 "</tr>");
												 
					 }
			
	 }
	 
	 $("#marker_vehicle_table_content tbody").append(rows.join(""));
	 
	 rows=[];
	 
}

function getBingdingVehicleFromMarkerData(markId){
	
	var result = null;
	
	$.ajax({
	        type: "POST",
	        dataType: "json",
	        url: "json/markerAction_getMarkerVehicle.action",
	        data: {markId:markId},
	        async : false,
	        success: function(json) {	
	        	    
	        	    if(json.flag == true && json.data.length > 0){
	        	    
	        	    	result = json.data;

	        	    }      
	        },
	        error: function() {}
	   });	
	   
	   return result != null ? result : new Array();
}

function savebingdingVehicletoMarker(el){

	  $("#saveMarkerBtn").attr("disabled","disabled");//设置所有的button不可用 
	  
	  if($("#marker_vehicle_table_content tbody").html().length == 0){
	  	
	  	$("#markersaveMsg").text(electronicFenceLanguage.qxzybddsb);
	  	
	  	$("#saveMarkerBtn").removeAttr("disabled");//去掉button的disabled属性，使button可用
	  	
	  	return ;
	  	
	  }else{
	  
	  	$("#markersaveMsg").text("");
	  }
	  
	  
	  var markerId = $(el).attr("markerId");
	  
	  var tds = null,vechileId="",inalarm=0,outalarm = 0,recregion=1,stopalarmmin=0,id="";
	  
	  var parmjson = new Array(),markerJson = null;
	  
	   $("#marker_vehicle_table_content tr").each(function(){
	   		id="";
	   		if($(this).attr("name").length!=0){
	   			id=$(this).attr("name").split("_")[2];
	   		}
	   		
	   		tds =$(this).find("td");
	   		vechileId = $(tds[0]).attr("name");	

   			inalarm=$(tds[1]).find("select").val();
   			outalarm=$(tds[2]).find("select").val();
   			recregion=$(tds[3]).find("select").val();
   			stopalarmmin=$(tds[4]).find("input").val();

			
   			
   			if(id.length >0){
   				
   				if((inalarm!=-1 && inalarm !=0) || (outalarm!=-1 && outalarm !=0) || (recregion!=-1 && recregion !=0) || stopalarmmin.length!=0){
   					
   					parmjson.push({id:id,markId : markerId,vhcId : vechileId,inalarm : inalarm==-1?0:inalarm,outalarm : outalarm==-1?0:outalarm,recregion :recregion==-1?0:recregion,stopalarmmin : stopalarmmin.length==0?0:stopalarmmin,type:2});  	
   				
   				}else{
   				
   					parmjson.push({id:id,vhcId : vechileId,type:1});   					
   				
   				}
   				
   			}else{
   				
   				if((inalarm!=-1 && inalarm !=0) || (outalarm!=-1 && outalarm !=0) || (recregion!=-1 && recregion !=0) || stopalarmmin.length!=0){
  				
   					parmjson.push({markId : markerId,vhcId : vechileId,inalarm : inalarm==-1?0:inalarm,outalarm : outalarm==-1?0:outalarm,recregion :recregion==-1?0:recregion,stopalarmmin : stopalarmmin.length==0?0:stopalarmmin,type:0});  					
   				
   				}
   				   				
   			}
   			
	   });
	   
	   
	   if(parmjson.length == 0){
	   
	   		$("#saveMarkerBtn").removeAttr("disabled");//去掉button的disabled属性，使button可用
	   		
	   		return;
	   		
	   }

	   //alert(JSON.stringify(parmjson));
	   //$("#saveMarkerBtn").removeAttr("disabled");
	   //return;
	   //$("#markersaveMsg").text(manager.zztj);
	   
	   
	   $.ajax({
	        type: "POST",
	        dataType: "json",
	        url: "json/markerAction_addOrUpdateMarkerVehicle.action",
	        data: {MarkerVehicleJson:JSON.stringify(parmjson)},
	        async : false,
	        success: function(json) {
	        		
	        		if(json.flag == true){
	        		
	        			$("#markersaveMsg").text(electronicFenceLanguage.bdcg);
	        
	        	    	$("#saveMarkerBtn").removeAttr("disabled");//去掉button的disabled属性，使button可用

	        	    	showVechiletoMarkerbangdingTable(markerId);
	        	    	
	        	    }else{
	        	    	
	        	    	$("#markersaveMsg").text(json.msg);
	        	    	
	        	    	
	        
	        	    	$("#saveMarkerBtn").removeAttr("disabled");//去掉button的disabled属性，使button可用
	        	    	
	        	    }
	        },
	        error: function() {}
	   });	

}