var FrontMaps_show01 = {

//所属行业
categorys : [], $categorys : {},
initCategoty:function(){
	this.categorys.push(this.$categorys['1000'] = {id : '1000', v1 : i18n_FrontMaps_show_map_label_categoryName1, v2 : '', v3 : ''})
	this.categorys.push(this.$categorys['1010'] = {id : '1010', v1 : i18n_FrontMaps_show_map_label_categoryName2, v2 : '', v3 : ''})
	this.categorys.push(this.$categorys['1020'] = {id : '1020', v1 : i18n_FrontMaps_show_map_label_categoryName3, v2 : '', v3 : ''})
	this.categorys.push(this.$categorys['1030'] = {id : '1030', v1 : i18n_FrontMaps_show_map_label_categoryName4, v2 : '', v3 : ''})
	this.categorys.push(this.$categorys['1040'] = {id : '1040', v1 : i18n_FrontMaps_show_map_label_categoryName5, v2 : '', v3 : ''})
	this.categorys.push(this.$categorys['1041'] = {id : '1041', v1 : i18n_FrontMaps_show_map_label_categoryName6, v2 : '', v3 : ''})
	this.categorys.push(this.$categorys['1050'] = {id : '1050', v1 : i18n_FrontMaps_show_map_label_categoryName7, v2 : '', v3 : ''})
	this.categorys.push(this.$categorys['1051'] = {id : '1051', v1 : i18n_FrontMaps_show_map_label_categoryName8, v2 : '', v3 : ''})
	this.categorys.push(this.$categorys['1090'] = {id : '1090', v1 : i18n_FrontMaps_show_map_label_categoryName9, v2 : '', v3 : ''})
	this.categorys.push(this.$categorys['10A0'] = {id : '10A0', v1 : i18n_FrontMaps_show_map_label_categoryName10})
	this.categorys.push(this.$categorys['10B0'] = {id : '10B0', v1 : i18n_FrontMaps_show_map_label_categoryName11, v2 : '', v3 : ''})
	this.categorys.push(this.$categorys['10C0'] = {id : '10C0', v1 : i18n_FrontMaps_show_map_label_categoryName12, v2 : '', v3 : ''})
	this.categorys.push(this.$categorys['10D0'] = {id : '10D0', v1 : i18n_FrontMaps_show_map_label_categoryName13, v2 : '', v3 : ''})
	this.categorys.push(this.$categorys['10E0'] = {id : '10E0', v1 : i18n_FrontMaps_show_map_label_categoryName14, v2 : '', v3 : ''})
	this.categorys.push(this.$categorys['1110'] = {id : '1110', v1 : i18n_FrontMaps_show_map_label_categoryName15, v2 : '', v3 : ''})
	this.categorys.push(this.$categorys['1210'] = {id : '1210', v1 : i18n_FrontMaps_show_map_label_categoryName16, v2 : '', v3 : ''})
	this.categorys.push(this.$categorys['1230'] = {id : '1230', v1 : i18n_FrontMaps_show_map_label_categoryName17, v2 : '', v3 : ''})
	this.categorys.push(this.$categorys['1250'] = {id : '1250', v1 : i18n_FrontMaps_show_map_label_categoryName18, v2 : '', v3 : ''})
	this.categorys.push(this.$categorys['1270'] = {id : '1270', v1 : i18n_FrontMaps_show_map_label_categoryName19, v2 : '', v3 : ''})
	this.categorys.push(this.$categorys['1260'] = {id : '1260', v1 : i18n_FrontMaps_show_map_label_categoryName20, v2 : '', v3 : ''})
	this.categorys.push(this.$categorys['127F'] = {id : '127F', v1 : i18n_FrontMaps_show_map_label_categoryName21, v2 : '', v3 : ''})
	this.categorys.push(this.$categorys['1280'] = {id : '1280', v1 : i18n_FrontMaps_show_map_label_categoryName22, v2 : '', v3 : ''})
	this.categorys.push(this.$categorys['1380'] = {id : '1380', v1 : i18n_FrontMaps_show_map_label_categoryName23, v2 : '', v3 : ''})
	this.categorys.push(this.$categorys['1480'] = {id : '1480', v1 : i18n_FrontMaps_show_map_label_categoryName24, v2 : '', v3 : ''})
	this.categorys.push(this.$categorys['17FF'] = {id : '17FF', v1 : i18n_FrontMaps_show_map_label_categoryName25, v2 : '', v3 : ''})
	this.categorys.push(this.$categorys['1800'] = {id : '1800', v1 : i18n_FrontMaps_show_map_label_categoryName26, v2 : '', v3 : ''})
	this.categorys.push(this.$categorys['1840'] = {id : '1840', v1 : i18n_FrontMaps_show_map_label_categoryName27, v2 : '', v3 : ''})
	this.categorys.push(this.$categorys['1880'] = {id : '1880', v1 : i18n_FrontMaps_show_map_label_categoryName28, v2 : '', v3 : ''})
	this.categorys.push(this.$categorys['1980'] = {id : '1980', v1 : i18n_FrontMaps_show_map_label_categoryName29, v2 : '', v3 : ''})
	this.categorys.push(this.$categorys['1A80'] = {id : '1A80', v1 : i18n_FrontMaps_show_map_label_categoryName30, v2 : '', v3 : ''})
	this.categorys.push(this.$categorys['1A90'] = {id : '1A90', v1 : i18n_FrontMaps_show_map_label_categoryName31, v2 : '', v3 : ''})
	this.categorys.push(this.$categorys['1AA0'] = {id : '1AA0', v1 : i18n_FrontMaps_show_map_label_categoryName32, v2 : '', v3 : ''})
	this.categorys.push(this.$categorys['1AB0'] = {id : '1AB0', v1 : i18n_FrontMaps_show_map_label_categoryName33, v2 : '', v3 : ''})
	this.categorys.push(this.$categorys['1F00'] = {id : '1F00', v1 : i18n_FrontMaps_show_map_label_categoryName34, v2 : '', v3 : ''})
	this.categorys.push(this.$categorys['1FFF'] = {id : '1FFF', v1 : i18n_FrontMaps_show_map_label_categoryName35, v2 : '', v3 : ''})
	this.categorys.push(this.$categorys['2010'] = {id : '2010', v1 : i18n_FrontMaps_show_map_label_categoryName36, v2 : '', v3 : ''})
	this.categorys.push(this.$categorys['2020'] = {id : '2020', v1 : i18n_FrontMaps_show_map_label_categoryName37, v2 : '', v3 : ''})
	this.categorys.push(this.$categorys['2030'] = {id : '2030', v1 : i18n_FrontMaps_show_map_label_categoryName38, v2 : '', v3 : ''})
	this.categorys.push(this.$categorys['2040'] = {id : '2040', v1 : i18n_FrontMaps_show_map_label_categoryName39, v2 : '', v3 : ''})
	this.categorys.push(this.$categorys['2050'] = {id : '2050', v1 : i18n_FrontMaps_show_map_label_categoryName40, v2 : '', v3 : ''})
	this.categorys.push(this.$categorys['2060'] = {id : '2060', v1 : i18n_FrontMaps_show_map_label_categoryName41, v2 : '', v3 : ''})
	this.categorys.push(this.$categorys['2080'] = {id : '2080', v1 : i18n_FrontMaps_show_map_label_categoryName42, v2 : '', v3 : ''})
	this.categorys.push(this.$categorys['2081'] = {id : '2081', v1 : i18n_FrontMaps_show_map_label_categoryName43, v2 : '', v3 : ''})
	this.categorys.push(this.$categorys['2082'] = {id : '2082', v1 : i18n_FrontMaps_show_map_label_categoryName44, v2 : '', v3 : ''})
	this.categorys.push(this.$categorys['2083'] = {id : '2083', v1 : i18n_FrontMaps_show_map_label_categoryName45, v2 : '', v3 : ''})
	this.categorys.push(this.$categorys['20FF'] = {id : '20FF', v1 : i18n_FrontMaps_show_map_label_categoryName46, v2 : '', v3 : ''})
	this.categorys.push(this.$categorys['2100'] = {id : '2100', v1 : i18n_FrontMaps_show_map_label_categoryName47, v2 : '', v3 : ''})
},

 getCategoryForLabel: function (categoty){

  	for (var i=0, c; c=this.categorys[i]; i++) {
  		if (categoty == c.id) {
  			return c.v1;
  		}
  	}
 },
 
 getCategory: function (doc,categoty){

  	for (var i=0, c; c=this.categorys[i]; i++) {
  		if (categoty == c.id) {
  			$(doc).html(c.v1);
  		}
  	}
 },
// 按照FLAG判断替换STR中那部分的指定字符串
  trim:function (Str , Flag){
		Str	= ""+Str;
		if( Flag == "l" || Flag == "L" )/*trim left side only*/
		{
			RegularExp	= /^\s+/gi;
			return Str.replace( RegularExp,"" );
		}
		else if( Flag == "r" || Flag == "R" )/*trim right side only*/
		{
			RegularExp	= /\s+$/gi;
			return Str.replace( RegularExp,"" );
		}
		else/*defautly, trim both left and right side*/
		{
			RegularExp	= /^\s+|\s+$/gi;
			return Str.replace( RegularExp,"" );
		}
    },
	//判断str是否为空
	 notBlank:function (str) {
	  return str!=null && trim(str)!="";	
	},
	//通过label在地图上显示已经标注过的点
	enterperisemaplabel:function(label) {
	
		var markerOption = new MMarkerOptions();
		var tipOption = new MTipOptions(); 
		tipOption.tipType=HTML_BUBBLE_TIP;    
		tipOption.title="";   
		tipOption.content=this.getMTipOptionsContent(label);//tip内容
		tipOption.tipHeight="200px";
		markerOption.tipOption = tipOption;  
		markerOption.canShowTip= true;  
		var tempimp = new Image();
		if (!/^\s*$/.test(label.label)) {
		    var urlpic = label.label.split("|");
				markerOption.imageUrl=urlpic[0];
				markerOption.imageSize = new MSize(urlpic[1], urlpic[2]);
		} else {
			tempimp.src="/manager/images/map/map_tb1.gif";
			markerOption.imageUrl="/manager/images/map/map_tb1.gif";
			if(tempimp.width==0 || tempimp.height==0)markerOption.imageSize = new MSize(12, 12);
		}
		Mmarker = new MMarker(new MLngLat(label.longitude/100000,label.latitude/100000),markerOption);
		Mmarker.id=label.id;    
		frontMap.addOverlay(Mmarker,true); 

		frontMap.addEventListener(Mmarker,MOUSE_OVER,function(e){frontMap.openOverlayTip(e.overlayId);});
		frontMap.setOverlayEditableById(Mmarker.id,false);
	},
//通过label在地图上显示已经标注过的点
	enterperisemapguide:function(label) {

	  var markerOption = new MMarkerOptions();
		var tipOption = new MTipOptions(); 
		tipOption.tipType=HTML_BUBBLE_TIP;    
		tipOption.title="";   
		tipOption.content=this.getGuideMTipOptionsContent(label);//tip内容
		tipOption.tipHeight="200px";
		markerOption.tipOption = tipOption;  
		markerOption.canShowTip= true;
		var tempimp = new Image();
		if (label.label && !/^\s*$/.test(label.label)) {
				var urlpic = label.label.split("|");
				markerOption.imageUrl=urlpic[0];
				markerOption.imageSize = new MSize(urlpic[1], urlpic[2]);
		} else {
			tempimp.src="/manager/images/map/map_tb2_big.gif";
			if(tempimp.width==0 || tempimp.height==0)markerOption.imageSize = new MSize(49, 31);
			markerOption.imageUrl= "/manager/images/map/map_tb2_big.gif";
		}
		Mmarker = new MMarker(new MLngLat(label.longitude/100000,label.latitude/100000),markerOption);
		Mmarker.id=label.id;     
		frontMap.addOverlay(Mmarker,true); 
		frontMap.addEventListener(Mmarker,MOUSE_OVER,function(e){frontMap.openOverlayTip(e.overlayId);}); 
		frontMap.setOverlayEditableById(Mmarker.id,false);
	},
	//通过HTML显示标注marker的label属性
	getMTipOptionsContent:function(label) { 
	    var category = FrontMaps_show01.getCategoryForLabel(label.category);
      var html = "<table>";
			html += "<tr><td><h5>"+FrontMaps_show01.specialCharConvert(label.corpname)+"</h5></td></tr>";
			html += "<tr><td>"+ i18n_FrontMaps_show_map_label_category +""+category+"</td></tr>";
			html += "<tr><td>"+ i18n_FrontMaps_show_map_label_address +""+label.address+"</td></tr>";
			html += "<tr><td>"+ i18n_FrontMaps_show_map_label_liasion +""+label.liasion+"</td></tr>";
			html += "<tr><td>"+ i18n_FrontMaps_show_map_label_website +"<a href='http://"+label.website+"' target='_blank'>"+label.website+"</a></td></tr>";
			html += "</table>";
      return html;
	},
//通过HTML显示标注marker的label属性
	getLabelMouseOverCallBack:function(marker,label) { 
	    return function(){
	    	var category = FrontMaps_show01.getCategoryForLabel(label.category);
			var html = "<div class='info-pop'>";
			html += "<h5>"+FrontMaps_show01.specialCharConvert(label.corpname)+"</h5><br/>";
			html += "<div class='detail'>";
			html += "<ul>";
			html += "<li><span>"+ i18n_FrontMaps_show_map_label_category +"</span>"+category+"</li>";
			html += "<li><span>"+ i18n_FrontMaps_show_map_label_address +"</span>"+label.address+"</li>";
			html += "<li><span>"+ i18n_FrontMaps_show_map_label_liasion +"</span>"+label.liasion+"</li>";
			html += "<li><span>"+ i18n_FrontMaps_show_map_label_website +"</span><a href='#'>"+label.website+"</a></li>";
			html += "</ul>";
			html += "</div>";
			html += "<p class='bottom'></p>";
			html += "</div>";

			var win = marker.openInfoWinHtml(html);
			win.closeInfoWindowWithMouse();
		};
	},
	
	
	//通过HTML显示标注marker的label属性
	getGuideMouseOverCallBack:function (marker,label) { 
	    return function(){
	    	var html = "<div class='info-pop'>";
			html += "<h5>"+FrontMaps_show01.specialCharConvert(label.name)+"</h5>";
			html += "<div class='detail'>";
			html += "<ul>";		  
			html += "<li><span>"+ i18n_FrontMaps_show_map_label_description1 +"</span>"+label.description+"</li>";
			html += "</ul>";
			html += "</div>";
			html += "<p class='bottom'></p>";
			html += "</div>";
//			var html = "<table>";
//			html += generateInfo(i18n_FrontMap_show_map_label_name, label.name);
//			html += generateInfo(i18n_FrontMap_show_map_label_description1, label.description);
//			html += "</table>";
			var win = marker.openInfoWinHtml(html);
			win.closeInfoWindowWithMouse();
		} ;
	} ,
	//通过HTML显示标注marker的label属性
	getGuideMTipOptionsContent:function (label) { 
			var html = "<table>";
			html += "<tr><td><h5>"+FrontMaps_show01.specialCharConvert(label.name)+"</h5></td></tr>";
			html += "<tr><td>"+ i18n_FrontMaps_show_map_label_description1 +""+label.description+"</td></tr>";
			html += "</table>";
      return html;
	} ,
	//显示name和str中的信息
	generateInfo:function (name, str) {
		str= specialCharConvert(str);
		if (str && !/^\s*$/.test(str)) {
			return "<tr><td style='width:60px'>" + name + ":</td><td style='word-break:break-all; word-wrap:break-word;'>" + str.replace(/</mg, "&lt;").replace(/>/mg, "&gt;") + "</td></tr>";
		}
		return "";
	},
	
	specialCharConvert:function (nodeName){
		return nodeName.replace(/\&#034;/g,"\"").replace(/\&#039;/g,"\'");
	},

//通过longitude,latitude在地图上标注点
    maplabel:function (longitude,latitude) {	
    	frontMap.panTo(new MLngLat(parseInt(longitude)/100000, parseInt(latitude)/100000));
   },
  
	//通过longitude,latitude在地图上标注点
	  mapguide:function (longitude,latitude) {	
	  	frontMap.panTo(new MLngLat(parseInt(longitude)/100000, parseInt(latitude)/100000));
	  },
	//切换城市地图。divid：包含地图组件的DIV。 targetname：目标城市名。 targetid：目标城市ID。
	 changeMapCity:function (divid,targetname,targetid) {
		var oSelect = _getElementById(divid,targetname,targetid);
		var coll = oSelect.options;
		if (coll && coll.length>0) {
			for(i=0;i<coll.length;i++) {
				if (coll[i].selected) {
					var cityName = coll[i].value;
					frontMap.setCenter(new MLngLat(cityName.split(",")[0],cityName.split(",")[1]));
				}
			}	
	    }
	 },
	//初始化地图
	  end:function (longitude, latitude, scale,compId) {
	    if(longitude == null || longitude == '' || latitude == null || latitude == '' || scale == null || scale == '') {
	      longitude = 11639742;
	      latitude = 3990923;
	      scale = 7;
	    }
			frontMap.panTo(new MLngLat(parseInt(longitude)/100000, parseInt(latitude)/100000));
	  },

	show:function (compId){
		var o = document.getElementById("mapInfo");
		var img = document.getElementById("arrow");
		var mapControl = document.getElementById("mapControl");
		if(o.style.display != "none"){//设置显示
			img.src = "/images/maps/map-click-left01.gif";//更换推块图片
			o.style.display = "none";//设置表格隐藏

    	var mapControl = document.getElementById("mapControl");
	    var mapInfo = document.getElementById("mapInfo").offsetWidth;
	    var arrowDiv =  document.getElementById("arrowDiv").offsetWidth;
	    var compForm = document.getElementById(compId).offsetWidth;
			var result = compForm - arrowDiv - 10;
			if(result != 0)
				mapControl.style.width= result + "px";
//			mapControl.className = "";
		}else{
			img.src = "/images/maps/map-click-right01.gif";
			o.style.display = "";
		
	    	var mapControl = document.getElementById("mapControl");
		    var mapInfo = document.getElementById("mapInfo").offsetWidth;
		    var arrowDiv =  document.getElementById("arrowDiv").offsetWidth;
		    var compForm = document.getElementById(compId).offsetWidth;
			var result = compForm - mapInfo - arrowDiv - 25;
			if(result != 0)
				mapControl.style.width=result + "px";
//			mapControl.className = "";
		}
		//this.maps.resizeMapDiv();//重新调整地图
	},
	initMap:function(compId){
	    var mapControl = document.getElementById("mapControl");
	    var mapInfo = document.getElementById("mapInfo").offsetWidth;
	    var arrowDiv =  document.getElementById("arrowDiv").offsetWidth;
	    var compForm = document.getElementById(compId).offsetWidth;
			var result = compForm - arrowDiv - mapInfo - 25;
		
		if(result != 0){
			mapControl.style.width=result + "px";
		}
		//this.maps.resizeMapDiv();//重新调整地图
	}
}
