﻿// JavaScript Document
    var map = null;
    var geocoder = null;
	var myEventListener=null;

    function initialize() {
      if (GBrowserIsCompatible()) {
        map = new GMap2(document.getElementById("map_canvas"));
        map.setCenter(new GLatLng(39.917, 116.397), 4, G_HYBRID_MAP);
	//map.setCenter(new GLatLng(39.917, 116.397), 4, G_NORMAL_MAP);
        geocoder = new GClientGeocoder();
		//map.addMapType(G_PHYSICAL_MAP);
		map.addControl(new GMapTypeControl());
		map.addControl(new GScaleControl()); 
		map.addControl(new GLargeMapControl());
		map.enableDragging();
		map.enableDoubleClickZoom();
		map.enableContinuousZoom();
		//map.enableScrollWheelZoom();
		enableMarker(true);
		//var myLayer = new GLayer("org.wikipedia.en");
		//map.addOverlay(myLayer);
      }
    }
	
	function enableMarker(bool){
	if (bool==true)
	{
	myEventListener=GEvent.addListener(map, 'click', function(overlay, point) {
		if (overlay) {
			// nothing
		} else {
			map.clearOverlays();
			superPoint = point;
	  		document.getElementById("x_zb").value = point.x + "," + point.y;
	  		document.getElementById("x_lng").value = point.x;
	  		document.getElementById("x_lat").value = point.y;
	  		document.getElementById("x_ZoomLevel").value = map.getZoom();
	  		document.getElementById("x_MapType").value = map.getCurrentMapType().getName();
			var marker = map.addOverlay(new GMarker(point));
			var html = '<div style="width:200px; font-size:13px; line-height:1.5;"><input type=button onclick="javascript: marker.style.display=\'block\';" value=标注该位置><br><br>如果您熟悉红球所指的位置，请点击“标注该位置”按钮标识该位置，以便让其他网友所知晓！<br>您可以在地图熟悉的位置上单击鼠标左键，重新选择标注点！<br><a href=http://www.nanpengyou.com/ target=_blank>点这里，在该地区找老乡</a></div>';
			//var html = '暂停标注';
			map.openInfoWindowHtml(point, html);
		}
	});
	}
	else
	{
	GEvent.removeListener(myEventListener);
	}
	}

    function showAddress(address) {
      if (geocoder) {
        geocoder.getLatLng(
          address,
          function(point) {
            if (!point) {
              alert("搜索不到: " + address);
            } else {
              map.setCenter(point, 13);
              var marker = new GMarker(point);
              map.addOverlay(marker);
              marker.openInfoWindowHtml('<div style="width: 260px; padding-right: 10px"><h3>'+address+'</h3><a href="http://www.52map.com" target=_blank>实景图</a></div>');
            }
          }
        );
      }
    }
	
	function ResetDivSize(){
	divLeft.style.display='none';
	a1.style.display='none';
	a2.style.display='none';
	if (document.mapSearch.divwidth.value<2000){
	map_canvas.style.width=document.mapSearch.divwidth.value;
	}
	else
	{
	alert("宽度不要超过2000");
	}
	if (document.mapSearch.divheight.value<2000){
	map_canvas.style.height=document.mapSearch.divheight.value;
	}
	else
	{
	alert("高度不要超过2000");
	}	
	
	}	
	
	function bookmark(){
	window.external.AddFavorite('http://www.52maps.com/ditu.html', '我爱地图 - 卫星地图');
	}
	
	function Checksubmit2()
{
    if (document.db.x_subject.value=="")
    {
        msg="请填写地标名称，尽量具体，例如某省某市某建筑"
        alert(msg);
         document.db.x_subject.focus();
    return false;
    }
    if (document.db.x_Username.value=="")
    {
        msg="请填写您的网名"
        alert(msg);
         document.db.x_Username.focus();
    return false;
    }
    if (document.db.x_explain.value=="")
    {
        msg=document.db.x_subject.value + "详细说明，多多少少也介绍一点啊\n你可以从Google里搜索一点介绍，复制进来！"
        alert(msg);
         document.db.x_explain.focus();
    return false;
    }

document.db.submit();
document.db.x_subject.value="";
document.db.x_explain.value="";
return true;
}