	$(function(){
		var viewArr=[['北京欢乐谷','北京欢乐谷','bjhlg','10011','北京'],['焦作云台山','焦作云台山','jzyts','1004108','焦作'],['四川九寨沟','四川九寨沟','jzg','1005132','阿坝州'],['深圳世界之窗','深圳世界之窗','szsjzc','1004403','深圳'],['杭州西湖','杭州西湖','zjxh','1003301','杭州'],['江西庐山','江西庐山','ls','1003604','九江'],['番禺百万葵园','番禺百万葵园','pybwky','1004401','广州'],['常州中华恐龙园','常州中华恐龙园','zhkly','1003204','常州'],['温州雁荡山','温州雁荡山','yds','1003303','温州'],['珠海海泉湾度假城','珠海海泉湾度假城','zhhqw','1004404','珠海']];
		$('#cust_name').searchInfo({type:'mp',initData:viewArr,width:'462',callback:function(item){
			$('#cust_id').val($.trim(item[2]));
			$('#prov_id').val($.trim(item[3]));
		}});//有回调方法
		initMap();
		initMonth();
		$('#tmp_area_name').searchInfo({type:'jd',width:'200',callback:function(item){$('#sel_area_name').val($.trim($('#tmp_area_name').val()));}});//有回调方法
		var ip_area=$.cookie('startadd');
		var zxs='10011,10012,10031,10066,10071,10072,10073';
		if(ip_area==null || ip_area.length<5){
			ip_area='';
		}else if(ip_area.length>5){
			ip_area=ip_area.substring(0,5);	
		}
		if(ip_area.substring(0,3)!='100')ip_area='';
		if(ip_area==''){
			$('#show_area').html('全国');
		}else{
			$('#show_area').html(getAreaName(ip_area));
		}
		//外部事件绑定
		$('#cust_name').bind('focus',function(){custFocus();});
		$('#cust_name').bind('blur',function(){custBlur();});
		$('#mon_1').bind('click',function(){monthChg(document.getElementById('mon_1'),1);});
		$('#mon_2').bind('click',function(){monthChg(document.getElementById('mon_2'),2);});
		$('#mon_3').bind('click',function(){monthChg(document.getElementById('mon_3'),3);});
		$('#mon_4').bind('click',function(){monthChg(document.getElementById('mon_4'),4);});
		$('#mon_5').bind('click',function(){monthChg(document.getElementById('mon_5'),5);});
		$('#mon_6').bind('click',function(){monthChg(document.getElementById('mon_6'),6);});
		$('#mon_7').bind('click',function(){monthChg(document.getElementById('mon_7'),7);});
		$('#mon_8').bind('click',function(){monthChg(document.getElementById('mon_8'),8);});
		$('#mon_9').bind('click',function(){monthChg(document.getElementById('mon_9'),9);});
		$('#mon_10').bind('click',function(){monthChg(document.getElementById('mon_10'),10);});
		$('#mon_11').bind('click',function(){monthChg(document.getElementById('mon_11'),11);});
		$('#mon_12').bind('click',function(){monthChg(document.getElementById('mon_12'),12);});
		$('#qll_ctit').bind('mouseover',function(){goCenter();});
		$('#info_name').bind('focus',function(){zhutiFocus();});
		$('#info_name').bind('blur',function(){zhutiBlur();});
	});

	function areaClick(area_id,area_name){
		for(var i=1;i<=13;i++){
			$('#month_'+i).html('');
		}	
		$('#show_area').html(area_name);
		$.ajax({
			   type: "POST",
			   url: "/www2009/ajax/wyqll_topview_ajax.jsp",
			   data: "month="+curMonth+"&area_id="+area_id,
			   beforeSend:function(){
			   		$("#month_0").html(loadstr);
			   },
			   success: function(msg){
			   		$("#month_0").html('');
			   		$("#month_"+curMonth).html(msg);
			   }
		 });
		 closeAreaDialog();
	}
	function closeAreaDialog(){
		if($('#selectArea').css('display')=='block')
			$('#selectArea').css({display:'none'});
	}
	function showAreaDialog(e){
		if($('#selectArea').css('display')=='block'){
			$('#selectArea').css({display:'none'});						
		}else{
			var a=e.srcElement || e.target;
			var off=$(a).offset();
			var h=a.offsetHeight;
			$('#selectArea').css({display:'block'});
			$('#selectArea').css({top:off.top+h+11+'px',left:off.left-55+'px',position:'absolute'});
		}
	}
	function clearPoint(){
		maplet.clearOverlays();
	}
	function addPoint(lon,lat,img){
	    maplet.addOverlay(new MMarker(   
	        new MPoint(lon,lat),   
	        new MIcon(img,27,37)
	    	)
	    );
	}
	function addPointObj(obj){
		maplet.addOverlay(
			obj
	    );
	}
	var maplet = null;
	var mark = [];
	var curMonth=0;
	//初始化地图。
	function initMap() {
		maplet = new Maplet("mapbar");
		maplet.centerAndZoom(new MPoint(105.99841, 39.00865), 1);
		maplet.addControl(new MStandardControl());
		maplet.showOverview(true, false);
		maplet.setAutoZoom();
		avBubble.width = 250;
		avBubble.height = 125;
	}
	function goCenter(){
		maplet.centerAndZoom(new MPoint(105.99841, 39.00865), 1);
	}
	function initMonth(){
		var s_today = new Date();
		var m =s_today.getMonth()+1;
		document.getElementById('mon_'+m).className="qll_mon";
		$.ajax({
			   type: "POST",
			   url: "/www2009/ajax/wyqll_topview_ajax.jsp",
			   data: "month="+m,
			   beforeSend:function(){
			   		if(curMonth!=0)
			   			$("#month_"+curMonth).css({display:'none'});
			   		$("#month_0").html(loadstr);
			   },
			   success: function(msg){
			   		$("#month_0").html('');
			   		$("#month_"+m).css({display:'block'});
			   		$("#month_"+m).html(msg);
			   		curMonth=m;
			   }
		 });
	}
	
	function monthChg(obj,month){
		if(obj.className=='qll_mon'){
			return;
		}
		if(curMonth==month){
			return;
		}
		var tmp=$('.qll_mon');
		if(tmp){
			tmp.removeClass('qll_mon');
			tmp.addClass('qll_moff');
		}
		obj.className="qll_mon";
		var t_area_name=$.trim($('#show_area').html());
		if($.trim($("#month_"+month).html())==''){
			$.ajax({
				   type: "POST",
				   url: "/www2009/ajax/wyqll_topview_ajax.jsp",
				   data: "month="+month+"&area_name="+t_area_name,
				   beforeSend:function(){
				   		if(curMonth!=0)
				   			$("#month_"+curMonth).css({display:'none'});
				   		$("#month_0").html(loadstr);
				   },
				   success: function(msg){
				   		$("#month_0").html('');
				   		$("#month_"+month).css({display:'block'});
				   		$("#month_"+month).html(msg);
				   		curMonth=month;
				   }
			 });
		}else{
			clearPoint();
			var cur_mark=mark[month];
			for(var i=0;i<cur_mark.length;i++){
				  maplet.addOverlay(cur_mark[i]);
			}
			$("#month_"+curMonth).css({display:'none'});
			$("#month_"+month).css({display:'block'});
			curMonth=month
		}
	}	
	
	function custBlur(){
		if($('#cust_name').val()==''){
			$('#cust_name').val('请输入景点名称，可以使用拼音...');
		}
	}
	function custFocus(){
		if($('#cust_name').val()=='请输入景点名称，可以使用拼音...'){
			$('#cust_name').val('');
		}
	}
	function zhutiBlur(){
		if($('#info_name').val()==''){
			$('#info_name').val('主题关键字...');
		}
	}
	function zhutiFocus(){
		if($('#info_name').val()=='主题关键字...'){
			$('#info_name').val('');
		}
	}
	function chk(){
		if($.trim($('#cust_name').val())=='请输入景点名称，可以使用拼音...'){
			alert('请输入景区名称！');
			return;
		}
		document.f1.submit();
	}
	function query(){
		if ($.trim($('#info_name').val())=="" || $.trim($('#info_name').val())=="主题关键字..."){
			alert('请输入要查询的专题关键字');
			return;
		}
		document.search.submit();
	}
	var tmp_img;
	var tmp_ori_img;
	function markShow(mar){
		maplet.centerAndZoom(new MPoint(mar.pt.lon, mar.pt.lat), 7);
		var url=mar.icon.imgUrl;
		mar.setIcon(new MIcon(url.replace('red','org'),27,37));
		/*
		tmp_ori_img=mar;
		var tmp_icon=new MIcon(url.replace('red','org'),27,37);
		tmp_img=new MMarker(   
	        new MPoint(mar.pt.lon, mar.pt.lat),   
	        tmp_icon
	    	);
		maplet.addOverlay(tmp_img);
		tmp_icon.hilite();
		maplet.removeOverlay(tmp_ori_img);
		*/
	}
	function markHide(mar){
		var url=mar.icon.imgUrl;
		mar.setIcon(new MIcon(url.replace('org','red'),27,37));
		//maplet.addOverlay(tmp_ori_img);
		//maplet.removeOverlay(tmp_img);
	}
	function tagChg(val){
		if($.trim(val)=='')return;
		document.location.target='_blank';
		document.location.href="/www2009/area/list_ent_view.jsp?tag_id="+val;
	}
	function searchBus(type,city,lon,lat,spos,epos,cg){
		if(type==0){
			if(cg=='0'){
				location.href="/www2009/traffic/map.jsp?area_name="+escape(city)+"&arriveLatlon="+lon+","+lat+"&startPos="+escape(spos)+"&arrivePos="+escape(epos)+"&type="+type;
			}else if(cg=='1'){
				location.href="/www2009/traffic/map.jsp?area_name="+escape(city)+"&startLatlon="+lon+","+lat+"&startPos="+escape(spos)+"&arrivePos="+escape(epos)+"&type="+type;
			}				
		}else if(type==1){
			if(cg=='0'){
				location.href="/www2009/traffic/map.jsp?area_name="+escape(city)+"&arriveCity="+escape(city)+"&arriveLatlon="+lon+","+lat+"&startPos="+escape(spos)+"&arrivePos="+escape(epos)+"&type="+type;
			}else if(cg=='1'){
				location.href="/www2009/traffic/map.jsp?area_name="+escape(city)+"&arriveCity="+escape(city)+"&startLatlon="+lon+","+lat+"&startPos="+escape(spos)+"&arrivePos="+escape(epos)+"&type="+type;
			}	
		}
	}
	function searchZb(city,lon,lat,custclass,pos){
		location.href="/www2009/traffic/map.jsp?area_name="+escape(city)+"&startLatlon="+lon+","+lat+"&custclass="+custclass+"&startPos="+escape(pos)+"&type=3";
	}