	var googlemap = null;	
	var deffaultAddr="台北市中正區忠孝西路一段66號";
    var defaultCity="台北市";
	var defaultDistrict="中正區";
    var geocoder = null;
	var side_bar_html = "";
    var gmarkers = [];
    var htmls = [];
    var i = 0;    
    // arrays to hold variants of the info window html with get direction forms open
    var to_htmls = [];
    var from_htmls = [];
	
    var appid = "oIt7WfHV34E2zeAtXxCtyFMJWAIoI3HDb2rBjs57ZKSoDH6ebtxX0IiZnQ8ihb7m8SMO";
    var pipeurl = "http://pipes.yahoo.com/pipes/pipe.run?_id=6d023b101b9afccd59ed9b284cbe54f3&_render=json&version=v0.1&appid=" + appid;
	/**
*
*  Base64 encode / decode
*  http://www.webtoolkit.info/
*
**/
 
var Base64 = {
 
	// private property
	_keyStr : "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",
 
	// public method for encoding
	encode : function (input) {
		var output = "";
		var chr1, chr2, chr3, enc1, enc2, enc3, enc4;
		var i = 0;
 
		input = Base64._utf8_encode(input);
 
		while (i < input.length) {
 
			chr1 = input.charCodeAt(i++);
			chr2 = input.charCodeAt(i++);
			chr3 = input.charCodeAt(i++);
 
			enc1 = chr1 >> 2;
			enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);
			enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);
			enc4 = chr3 & 63;
 
			if (isNaN(chr2)) {
				enc3 = enc4 = 64;
			} else if (isNaN(chr3)) {
				enc4 = 64;
			}
 
			output = output +
			this._keyStr.charAt(enc1) + this._keyStr.charAt(enc2) +
			this._keyStr.charAt(enc3) + this._keyStr.charAt(enc4);
 
		}
 
		return output;
	},
 
	// public method for decoding
	decode : function (input) {
		var output = "";
		var chr1, chr2, chr3;
		var enc1, enc2, enc3, enc4;
		var i = 0;
 
		input = input.replace(/[^A-Za-z0-9\+\/\=]/g, "");
 
		while (i < input.length) {
 
			enc1 = this._keyStr.indexOf(input.charAt(i++));
			enc2 = this._keyStr.indexOf(input.charAt(i++));
			enc3 = this._keyStr.indexOf(input.charAt(i++));
			enc4 = this._keyStr.indexOf(input.charAt(i++));
 
			chr1 = (enc1 << 2) | (enc2 >> 4);
			chr2 = ((enc2 & 15) << 4) | (enc3 >> 2);
			chr3 = ((enc3 & 3) << 6) | enc4;
 
			output = output + String.fromCharCode(chr1);
 
			if (enc3 != 64) {
				output = output + String.fromCharCode(chr2);
			}
			if (enc4 != 64) {
				output = output + String.fromCharCode(chr3);
			}
 
		}
 
		output = Base64._utf8_decode(output);
 
		return output;
 
	},
 
	// private method for UTF-8 encoding
	_utf8_encode : function (string) {
		string = string.replace(/\r\n/g,"\n");
		var utftext = "";
 
		for (var n = 0; n < string.length; n++) {
 
			var c = string.charCodeAt(n);
 
			if (c < 128) {
				utftext += String.fromCharCode(c);
			}
			else if((c > 127) && (c < 2048)) {
				utftext += String.fromCharCode((c >> 6) | 192);
				utftext += String.fromCharCode((c & 63) | 128);
			}
			else {
				utftext += String.fromCharCode((c >> 12) | 224);
				utftext += String.fromCharCode(((c >> 6) & 63) | 128);
				utftext += String.fromCharCode((c & 63) | 128);
			}
 
		}
 
		return utftext;
	},
 
	// private method for UTF-8 decoding
	_utf8_decode : function (utftext) {
		var string = "";
		var i = 0;
		var c = c1 = c2 = 0;
 
		while ( i < utftext.length ) {
 
			c = utftext.charCodeAt(i);
 
			if (c < 128) {
				string += String.fromCharCode(c);
				i++;
			}
			else if((c > 191) && (c < 224)) {
				c2 = utftext.charCodeAt(i+1);
				string += String.fromCharCode(((c & 31) << 6) | (c2 & 63));
				i += 2;
			}
			else {
				c2 = utftext.charCodeAt(i+1);
				c3 = utftext.charCodeAt(i+2);
				string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));
				i += 3;
			}
 
		}
 
		return string;
	}
 
}
	
	// Create some custom icons
      
     // This icon uses the same shape as the default Google marker
     // So we can use its details for everything except the image 
     //TYPE 1
     var restaurantIcon = new GIcon();
     restaurantIcon.image = "http://maps.google.com/mapfiles/kml/pal2/icon32.png";
     restaurantIcon.shadow = "http://maps.google.com/mapfiles/kml/pal2/icon32s.pn";
     restaurantIcon.iconSize = new GSize(32,32);
     restaurantIcon.shadowSize = new GSize(56,32);
     restaurantIcon.iconAnchor = new GPoint(16,32);
     restaurantIcon.infoWindowAnchor = new GPoint(16,0);
     //restaurantIcon.infoShadowAnchor = new GPoint(18, 25);
     restaurantIcon.transparent = "http://www.google.com/intl/en_ALL/mapfiles/markerTransparent.png";
          
     //TYPE 2
     var departmentstoreIcon = new GIcon();
     departmentstoreIcon.image = "http://maps.google.com/mapfiles/kml/pal3/icon18.png";
     departmentstoreIcon.shadow = "http://maps.google.com/mapfiles/kml/pal3/icon18s.png";
     departmentstoreIcon.iconSize = new GSize(32,32);
     departmentstoreIcon.shadowSize = new GSize(56,32);
     departmentstoreIcon.iconAnchor = new GPoint(16,32);
     departmentstoreIcon.infoWindowAnchor = new GPoint(16,0);
     //departmentstoreIcon.infoShadowAnchor = new GPoint(18, 25);
     departmentstoreIcon.transparent = "http://www.google.com/intl/en_ALL/mapfiles/markerTransparent.png";
        
     //TYPE 3     
     var bankIcon = new GIcon();
     bankIcon.image = "http://maps.google.com/mapfiles/kml/pal5/icon39.png";
     bankIcon.shadow = "http://maps.google.com/mapfiles/kml/pal5/icon39s.png";
     bankIcon.iconSize = new GSize(32,32);
     bankIcon.shadowSize = new GSize(56,32);
     bankIcon.iconAnchor = new GPoint(16,32);
     bankIcon.infoWindowAnchor = new GPoint(16,0);
     //bankIcon.infoShadowAnchor = new GPoint(18, 25);
     bankIcon.transparent = "http://www.google.com/intl/en_ALL/mapfiles/markerTransparent.png";
     
     //TYPE 4     
     var postofficeIcon = new GIcon();
     postofficeIcon.image = "http://maps.google.com/mapfiles/kml/pal2/icon58.png";
     postofficeIcon.shadow = "http://maps.google.com/mapfiles/kml/pal2/icon58s.png";
     postofficeIcon.iconSize = new GSize(32,32);
     postofficeIcon.shadowSize = new GSize(56,32);
     postofficeIcon.iconAnchor = new GPoint(16,32);
     postofficeIcon.infoWindowAnchor = new GPoint(16,0);
     //postofficeIcon.infoShadowAnchor = new GPoint(18, 25);
     postofficeIcon.transparent = "http://www.google.com/intl/en_ALL/mapfiles/markerTransparent.png";
     
     
     //TYPE 5
     var otherIcon = new GIcon();
     otherIcon.image = "http://maps.google.com/mapfiles/kml/pal2/icon47.png";
     otherIcon.shadow = "http://maps.google.com/mapfiles/kml/pal2/icon47s.png";
     otherIcon.iconSize = new GSize(32,32);
     otherIcon.shadowSize = new GSize(56,32);
     otherIcon.iconAnchor = new GPoint(16,32);
     otherIcon.infoWindowAnchor = new GPoint(16,0);
     otherIcon.transparent = "http://www.google.com/intl/en_ALL/mapfiles/markerTransparent.png";
     
     //TYPE 6:room
     var roomIcon = new GIcon();
     roomIcon.image = "http://maps.google.com/mapfiles/kml/pal3/icon48.png";
     roomIcon.shadow = "http://maps.google.com/mapfiles/kml/pal3/icon48s.png";
     roomIcon.iconSize = new GSize(32,32);
     roomIcon.shadowSize = new GSize(56,32);
     roomIcon.iconAnchor = new GPoint(16,32);
     roomIcon.infoWindowAnchor = new GPoint(16,0);
     roomIcon.transparent = "http://www.google.com/intl/en_ALL/mapfiles/markerTransparent.png";	
     	
     //TYPE 7:office
     var officeIcon = new GIcon();
     officeIcon.image = "http://maps.google.com/mapfiles/kml/pal3/icon21.png";
     officeIcon.shadow = "http://maps.google.com/mapfiles/kml/pal3/icon21s.png";
     officeIcon.iconSize = new GSize(32,32);
     officeIcon.shadowSize = new GSize(56,32);
     officeIcon.iconAnchor = new GPoint(16,32);
     officeIcon.infoWindowAnchor = new GPoint(16,0);
     officeIcon.transparent = "http://www.google.com/intl/en_ALL/mapfiles/markerTransparent.png";
     
     //TYPE 8:sell
     var sellIcon = new GIcon();
     sellIcon.image = "http://maps.google.com/mapfiles/kml/pal5/icon10.png";
     sellIcon.shadow = "http://maps.google.com/mapfiles/kml/pal5/icon10s.png";
     sellIcon.iconSize = new GSize(32,32);
     sellIcon.shadowSize = new GSize(56,32);
     sellIcon.iconAnchor = new GPoint(16,32);
     sellIcon.infoWindowAnchor = new GPoint(16,0);
     sellIcon.transparent = "http://www.google.com/intl/en_ALL/mapfiles/markerTransparent.png";
     
     //TYPE 9:store
     var storeIcon = new GIcon();
     storeIcon.image = "http://maps.google.com/mapfiles/kml/pal2/icon14.png";
     storeIcon.shadow = "http://maps.google.com/mapfiles/kml/pal2/icon14s.png";
     storeIcon.iconSize = new GSize(32,32);
     storeIcon.shadowSize = new GSize(56,32);
     storeIcon.iconAnchor = new GPoint(16,32);
     storeIcon.infoWindowAnchor = new GPoint(16,0);
     storeIcon.transparent = "http://www.google.com/intl/en_ALL/mapfiles/markerTransparent.png";
     
   //TYPE 10: search1
     var s1Icon = new GIcon();
     s1Icon.image = "http://maps.google.com/mapfiles/kml/pal3/icon0.png";
     s1Icon.shadow = "http://maps.google.com/mapfiles/kml/pal3/icon0s.png";
     s1Icon.iconSize = new GSize(32,32);
     s1Icon.shadowSize = new GSize(56,32);
     s1Icon.iconAnchor = new GPoint(16,32);
     s1Icon.infoWindowAnchor = new GPoint(16,0);
     s1Icon.transparent = "http://www.google.com/intl/en_ALL/mapfiles/markerTransparent.png";
     
   //TYPE 11: search2
     var s2Icon = new GIcon();
     s2Icon.image = "http://maps.google.com/mapfiles/kml/pal3/icon1.png";
     s2Icon.shadow = "http://maps.google.com/mapfiles/kml/pal3/icon1s.png";
     s2Icon.iconSize = new GSize(32,32);
     s2Icon.shadowSize = new GSize(56,32);
     s2Icon.iconAnchor = new GPoint(16,32);
     s2Icon.infoWindowAnchor = new GPoint(16,0);
     s2Icon.transparent = "http://www.google.com/intl/en_ALL/mapfiles/markerTransparent.png";
     
   //TYPE 12: search3
     var s3Icon = new GIcon();
     s3Icon.image = "http://maps.google.com/mapfiles/kml/pal3/icon2.png";
     s3Icon.shadow = "http://maps.google.com/mapfiles/kml/pal3/icon2s.png";
     s3Icon.iconSize = new GSize(32,32);
     s3Icon.shadowSize = new GSize(56,32);
     s3Icon.iconAnchor = new GPoint(16,32);
     s3Icon.infoWindowAnchor = new GPoint(16,0);
     s3Icon.transparent = "http://www.google.com/intl/en_ALL/mapfiles/markerTransparent.png"; 
     
   //TYPE 13: search4
     var s4Icon = new GIcon();
     s4Icon.image = "http://maps.google.com/mapfiles/kml/pal3/icon3.png";
     s4Icon.shadow = "http://maps.google.com/mapfiles/kml/pal3/icon3s.png";
     s4Icon.iconSize = new GSize(32,32);
     s4Icon.shadowSize = new GSize(56,32);
     s4Icon.iconAnchor = new GPoint(16,32);
     s4Icon.infoWindowAnchor = new GPoint(16,0);
     s4Icon.transparent = "http://www.google.com/intl/en_ALL/mapfiles/markerTransparent.png"; 
     
   //TYPE 14: search5
     var s5Icon = new GIcon();
     s5Icon.image = "http://maps.google.com/mapfiles/kml/pal3/icon4.png";
     s5Icon.shadow = "http://maps.google.com/mapfiles/kml/pal3/icon4s.png";
     s5Icon.iconSize = new GSize(32,32);
     s5Icon.shadowSize = new GSize(56,32);
     s5Icon.iconAnchor = new GPoint(16,32);
     s5Icon.infoWindowAnchor = new GPoint(16,0);
     s5Icon.transparent = "http://www.google.com/intl/en_ALL/mapfiles/markerTransparent.png";
     
   //TYPE 15: search6
     var s6Icon = new GIcon();
     s6Icon.image = "http://maps.google.com/mapfiles/kml/pal3/icon5.png";
     s6Icon.shadow = "http://maps.google.com/mapfiles/kml/pal3/icon5s.png";
     s6Icon.iconSize = new GSize(32,32);
     s6Icon.shadowSize = new GSize(56,32);
     s6Icon.iconAnchor = new GPoint(16,32);
     s6Icon.infoWindowAnchor = new GPoint(16,0);
     s6Icon.transparent = "http://www.google.com/intl/en_ALL/mapfiles/markerTransparent.png"; 
    
   //TYPE 16: search7
     var s7Icon = new GIcon();
     s7Icon.image = "http://maps.google.com/mapfiles/kml/pal3/icon6.png";
     s7Icon.shadow = "http://maps.google.com/mapfiles/kml/pal3/icon6s.png";
     s7Icon.iconSize = new GSize(32,32);
     s7Icon.shadowSize = new GSize(56,32);
     s7Icon.iconAnchor = new GPoint(16,32);
     s7Icon.infoWindowAnchor = new GPoint(16,0);
     s7Icon.transparent = "http://www.google.com/intl/en_ALL/mapfiles/markerTransparent.png"; 
    
   //TYPE 17: search8
     var s8Icon = new GIcon();
     s8Icon.image = "http://maps.google.com/mapfiles/kml/pal3/icon7.png";
     s8Icon.shadow = "http://maps.google.com/mapfiles/kml/pal3/icon7s.png";
     s8Icon.iconSize = new GSize(32,32);
     s8Icon.shadowSize = new GSize(56,32);
     s8Icon.iconAnchor = new GPoint(16,32);
     s8Icon.infoWindowAnchor = new GPoint(16,0);
     s8Icon.transparent = "http://www.google.com/intl/en_ALL/mapfiles/markerTransparent.png"; 
    
   //TYPE 18: search9
     var s9Icon = new GIcon();
     s9Icon.image = "http://maps.google.com/mapfiles/kml/pal3/icon16.png";
     s9Icon.shadow = "http://maps.google.com/mapfiles/kml/pal3/icon16s.png";
     s9Icon.iconSize = new GSize(32,32);
     s9Icon.shadowSize = new GSize(56,32);
     s9Icon.iconAnchor = new GPoint(16,32);
     s9Icon.infoWindowAnchor = new GPoint(16,0);
     s9Icon.transparent = "http://www.google.com/intl/en_ALL/mapfiles/markerTransparent.png"; 
    
   //TYPE 19: search10
     var s10Icon = new GIcon();
     s10Icon.image = "http://maps.google.com/mapfiles/kml/pal3/icon17.png";
     s10Icon.shadow = "http://maps.google.com/mapfiles/kml/pal3/icon17s.png";
     s10Icon.iconSize = new GSize(32,32);
     s10Icon.shadowSize = new GSize(56,32);
     s10Icon.iconAnchor = new GPoint(16,32);
     s10Icon.infoWindowAnchor = new GPoint(16,0);
     s10Icon.transparent = "http://www.google.com/intl/en_ALL/mapfiles/markerTransparent.png" 
     
	function detailPageLoad(addr,markerLat,markerLng,itemType,itemId) {
      if (GBrowserIsCompatible()) {   	  
      	//alert('~~addr~'+addr+'~~lat~'+markerLat+'~~lng~'+markerLng);		
		googlemap = new GMap2(document.getElementById("google_map"));       
		geocoder = new GClientGeocoder(); //set up for address input
		googlemap.addControl(new GSmallMapControl());
		googlemap.addControl(new GMapTypeControl());
        showDetailPageAddress(addr,markerLat,markerLng,itemType,itemId);   //address ready to a coordinator   
      	
      }
    }
	
	
	function showDetailPageAddress(address,markerLat,markerLng,itemType,itemId) {  		
		//set lat, lng to the page
		document.getElementById('CurMarkerLat').innerHTML=markerLat;
		document.getElementById('CurMarkerLng').innerHTML=markerLng;
		//create marker here
		var point = new GLatLng(markerLat,markerLng);
		googlemap.setCenter(point, 15);			
		var marker = createClickableMarker(point,address,6);            
		googlemap.addOverlay(marker);            
      }
	
	function moveMap(addr,markerLat,markerLng,itemType,itemId){
		clear();
		$('submenu').empty();
		$('map-items').empty();
		$('map-items').setStyle('display','none');
		document.getElementById('CurMarkerLat').innerHTML=markerLat;
		document.getElementById('CurMarkerLng').innerHTML=markerLng;
		//create marker here
		var point = new GLatLng(markerLat,markerLng);
		googlemap.panTo(point);
		//googlemap.setCenter(point, 15);			
		var marker = createClickableMarker(point,addr,6);            
		googlemap.addOverlay(marker);     
	}
			
    function load() {
      if (GBrowserIsCompatible()) {       	
        googlemap = new GMap2(document.getElementById("google_map"));
        geocoder = new GClientGeocoder(); //set up for address input  
		googlemap.addControl(new GSmallMapControl());
		googlemap.addControl(new GMapTypeControl());
        showAddress(defaultCity,defaultDistrict,deffaultAddr,'','','','');   //address ready to a coordinator   
      	defaultMarker=true;
      }
    }    
    
    function showBizAddress(lat,lon,info,iconType) {     	       	
        if(lat!=''&&lon!='')//when lat, ang exist
        {
        	//alert('lat, lng not null');   	
        	//create marker here
        	var point = new GLatLng(lat,lon);    	
        	//googlemap.setCenter(point, 15); 
			googlemap.panTo(new GLatLng(lat,lon));
        	var marker = createClickableMarker(point,info,iconType);  
        	gmarkers.push(marker);
	        googlemap.addOverlay(marker); 
        }        
    }
    
	function showADAddress(city,district,info,markerLat,markerLng,itemType,itemId) { 
    	document.getElementById('CurMarkerCity').innerHTML=city;	
    	document.getElementById('CurMarkerDistrict').innerHTML=district;       	
        if(markerLat!=''&&markerLng!='')//when lat, ang exist
        {        	
        	//set lat, lng to the page
        	document.getElementById('CurMarkerLat').innerHTML=markerLat;
        	document.getElementById('CurMarkerLng').innerHTML=markerLng;
        	//create marker here
        	var point = new GLatLng(markerLat,markerLng);    	
        	//googlemap.setCenter(point, 15); 
			googlemap.panTo(new GLatLng(markerLat,markerLng));
        	var marker = createClickableMarker(point,Base64.decode(info),null);               	
	        googlemap.addOverlay(marker); 
        }        
    }
	
    //fromObjId: map will disappear
    //toObjId: map will appear    
    //itemType: room, office, sell or store
    //itemId: this item's table ID    
    function showAddress(city,district,address,markerLat,markerLng,itemType,itemId) { 
    	document.getElementById('CurMarkerCity').innerHTML=city;	
    	document.getElementById('CurMarkerDistrict').innerHTML=district;       	
        if(markerLat!=''&&markerLng!='')//when lat, ang exist
        {
        	//set lat, lng to the page
        	document.getElementById('CurMarkerLat').innerHTML=markerLat;
        	document.getElementById('CurMarkerLng').innerHTML=markerLng;
        	//create marker here
        	var point = new GLatLng(markerLat,markerLng);    	
        	googlemap.setCenter(point, 15);        	
        	var marker = createClickableMarker(point,address,6);               	
	        googlemap.addOverlay(marker); 
        }
        else
        {    	
        	
	    	if (geocoder) {    		
		      	geocoder.getLatLng(		      		
		      		address,
		      		function(point) {
		      	      if (!point) {        
		      	      	alert("Google 找不到 " + address);      
		      	      } 
		      	      else 
		      	      {  		      	      	
		      	      	var getLat=point.lat();
		      	      	var getLng=point.lng();
		      	      	document.getElementById('CurMarkerLat').innerHTML=getLat;
        				document.getElementById('CurMarkerLng').innerHTML=getLng;		      	      	      		
		      	      	googlemap.setCenter(point, 15);    	      	       
			      	    var marker = createClickableMarker(point,address,6);
					    googlemap.addOverlay(marker);        	
		      	      	
		      	      	      	      	     
		      	      }    
		      		}      		 
		      	);
		      }
      	}
    }    
    
    function GetLatLng(city, district, address, lat, lng){
    	if(document.getElementById(city).value==''){
    		alert('請選擇縣市');
    		return false;
    	}
    	if(document.getElementById(district).value==''){
    		alert('請選擇鄉鎮區');
    		return false;
    	}
    	if(document.getElementById(address).value==''){
    		alert('請填寫地址');
    		return false;
    	}
    		
    	var completeAddr=document.getElementById(city).value+
    					 document.getElementById(district).value+
    					 document.getElementById(address).value;
    	var geocoderLocal = new GClientGeocoder();
    	if (geocoderLocal) {    		
	      	geocoderLocal.getLatLng(
	      		completeAddr,
	      		function(point) {
	      	      if (!point) {        
	      	      	alert(completeAddr + " 不存在");      
	      	      } 
	      	      else 
	      	      {  
	      	      	var getLat=point.lat();
	      	      	var getLng=point.lng();
	      	      	//alert('~~lat~~'+getLat+'~~lng~~'+getLng);
	      	      	document.getElementById(lat).value=getLat;
       				document.getElementById(lng).value=getLng;
       				alert(completeAddr+"確認通過");       				      	      		      	      	
	      	      }
	      	     }
	      	  );
	    }
    }  
    
	
    function GetLongAddressLatLng(city, district, street,lane,aisle,no1,no2,floor1, lat, lng){
    	if(document.getElementById(city).value==''){
    		alert('請選擇縣市');
    		return false;
    	}
    	if(document.getElementById(district).value==''){
    		alert('請選擇鄉鎮區');
    		return false;
    	}
    	if(document.getElementById(street).value==''){
    		alert('請填寫地址');
    		return false;
    	}
    	var cityV="",districtV="",laneV="",aisleV="",no="",floor="";
    	if(document.getElementById(city).value=='新竹市'||document.getElementById(city).value=='嘉義市')
    	{
    		cityV=document.getElementById(city).value;
    		districtV="";
    	}
    	else
    	{
    		cityV=document.getElementById(city).value;
    		districtV=document.getElementById(district).value;
    	}
    	if(document.getElementById(lane).value!='')	
    		lanV=document.getElementById(lane).value+"巷";    	
    	if(document.getElementById(aisle).value!='')	
    		lanV=document.getElementById(aisle).value+"弄";    	
    	if(document.getElementById(no1).value!=''&&document.getElementById(no2).value!='')	
    		no=document.getElementById(no1).value+"號之"+document.getElementById(no2).value;
    	else if(document.getElementById(no1).value!=''&&document.getElementById(no2).value=='')
    		no=document.getElementById(no1).value+"號";    	
    	if(document.getElementById(floor1).value!='')	
    		floor=document.getElementById(floor1).value+"樓";
    	var completeAddr=cityV+    					 
    					 document.getElementById(street).value+
    					 laneV+aisleV+no+floor;
    	//alert(completeAddr);				 
    	var geocoderLocal = new GClientGeocoder();
    	if (geocoderLocal) {    		
	      	geocoderLocal.getLatLng(
	      		completeAddr,
	      		function(point) {
	      	      if (!point) {      
	      	    	var addr_error = document.getElementById('addr_error');
       				var addr_correct = document.getElementById('addr_correct');
       				if(addr_error && addr_correct)
       				{
       					addr_error.style.display="block";
       					addr_correct.style.display="none";
       				}  
	      	      	alert(completeAddr + " 不存在");      
	      	      } 
	      	      else 
	      	      {  
	      	      	var getLat=point.lat();
	      	      	var getLng=point.lng();
	      	      	//alert('~~lat~~'+getLat+'~~lng~~'+getLng);
	      	      	document.getElementById(lat).value=getLat;
       				document.getElementById(lng).value=getLng;
       				var addr_error = document.getElementById('addr_error');
       				var addr_correct = document.getElementById('addr_correct');
       				if(addr_error && addr_correct)
       				{
       					addr_error.style.display="none";
       					addr_correct.style.display="block";
       				}
       				alert(completeAddr+"確認通過");       				      	      		      	      	
	      	      }
	      	     }
	      	  );
	    }
    }  
    
	
    function trim(stringToTrim) {
		return stringToTrim.replace(/^\s+|\s+$/g,"");
	}  
    
    function showStores(type,lat,lng){
    	var latV=trim(document.getElementById(lat).innerHTML);
    	var lngV=trim(document.getElementById(lng).innerHTML); 
    	//alert('lat~~~'+latV+'~~lng~~'+lngV);
    	//~~~~~~~~servlet here to query and generate XML
    	getStoreXML('/servlet/QueryStores?lat='+latV+'&lng='+lngV+'&type='+type);    	  	
    } 
    	
	
	var icons = [];
    icons[0] = restaurantIcon;
    icons[1] = departmentstoreIcon;
    icons[2] = bankIcon;
    icons[3] = postofficeIcon;
    icons[4] = otherIcon;
    icons[5] = roomIcon;
    icons[6] = officeIcon;
    icons[7] = sellIcon;
    icons[8] = storeIcon;
    icons[9] = s1Icon;
    icons[10] = s2Icon;
    icons[11] = s3Icon;
    icons[12] = s4Icon;
    icons[13] = s5Icon;
    icons[14] = s6Icon;
    icons[15] = s7Icon;
    icons[16] = s8Icon;
    icons[17] = s9Icon;
    icons[18] = s10Icon;
	
	function createClickableMarker(point,html,icontype) {		
		var marker;		
		if(!icontype)
			marker = new GMarker(point);
		else
        	marker = new GMarker(point,icons[icontype-1]);
        GEvent.addListener(marker, "mouseover", function() {        	
          marker.openInfoWindowHtml(html);
        });
        // save the info we need to use later for the side_bar
        //gmarkers[i] = marker;
        //i++;
		
        return marker;
      }
	
	function clear() {
		while (gmarkers.length > 0) {
			marker = gmarkers.pop();
			googlemap.removeOverlay(marker);
		}	
	}
	
      
