<script type="text/javascript">
/*-- ------ Map class ------ --*/
var tmpIntroduct="<?php echo($tmpParameters[0]); ?>";
var tmpX="<?php echo($tmpParameters[1]); ?>";
var tmpY="<?php echo($tmpParameters[2]); ?>";
var tmpINITVALUE="<?php echo($tmpParameters[3]); ?>";
var tmpINIT_X="<?php echo($this->sysFileConfig['MapPositionX']); ?>";
var tmpINIT_Y="<?php echo($this->sysFileConfig['MapPositionY']); ?>";
var tmpAUTO="<?php echo($this->sysFileConfig['MapPositionFromZone']); ?>";

var tmpWidth=<?php echo($this->sysFileConfig['MapControlWidth']); ?>;
var tmpHeight=<?php echo($this->sysFileConfig['MapControlHeight']); ?>;
var tmpBoxName="<?php echo ($tmpControl); ?>_Box";

var map_<?php echo ($tmpControl); ?>=null;
var geocoder_<?php echo ($tmpControl); ?>=null;

function showMap_<?php echo ($tmpControl); ?>(){
	document.getElementById(tmpBoxName).style.width=tmpWidth;
	document.getElementById(tmpBoxName).style.height=tmpHeight;
	
	if(GBrowserIsCompatible()) {
		map_<?php echo ($tmpControl); ?> = new GMap2(document.getElementById(tmpBoxName));
		map_<?php echo ($tmpControl); ?>.addControl(new GLargeMapControl());
		map_<?php echo ($tmpControl); ?>.addControl(new GOverviewMapControl());
		if(parseFloat(document.getElementById(tmpX).value)>0 && parseFloat(document.getElementById(tmpY).value)>0){
			var center = new GLatLng(document.getElementById(tmpY).value,document.getElementById(tmpX).value);
		}else if(document.getElementById(tmpINITVALUE+"_X")!=undefined && document.getElementById(tmpINITVALUE+"_Y")!=undefined && tmpAUTO==1){
			if(parseFloat(document.getElementById(tmpINITVALUE+"_X").value)>0 && parseFloat(document.getElementById(tmpINITVALUE+"_Y").value)>0){
				var center = new GLatLng(document.getElementById(tmpINITVALUE+"_Y").value,document.getElementById(tmpINITVALUE+"_X").value);
			}else{
				var center = new GLatLng(tmpINIT_Y,tmpINIT_X);
			}
		}else{
			var center = new GLatLng(tmpINIT_Y,tmpINIT_X);
		}
		map_<?php echo ($tmpControl); ?>.setCenter(center, 8);

		var marker = new GMarker(center, {draggable: true});
		GEvent.addListener(marker, "dragstart", function() {
			map_<?php echo ($tmpControl); ?>.closeInfoWindow();
		});
		GEvent.addListener(marker, "dragend", function() {
			marker.openInfoWindowHtml(document.getElementById(tmpIntroduct).value);
			document.getElementById(tmpX).value=marker.getPoint().x;
			document.getElementById(tmpY).value=marker.getPoint().y;
		});
		map_<?php echo ($tmpControl); ?>.addOverlay(marker);
		
		geocoder_<?php echo ($tmpControl); ?>=new GClientGeocoder();
		document.getElementById("<?php echo ($tmpControl); ?>_SearchBox").className="MapChoose_2";
	}
}

function searchMap_<?php echo ($tmpControl); ?>(pAddress) {
	if(geocoder_<?php echo ($tmpControl); ?>){
		geocoder_<?php echo ($tmpControl); ?>.getLatLng(pAddress,function(point){
			if(!point){
				alert("²»ÄÜ½âÎö:"+pAddress);
			}else{
				map_<?php echo ($tmpControl); ?>.setCenter(point, 13);
				var marker = new GMarker(point,{draggable: true});
				
				GEvent.addListener(marker, "dragstart", function() {
					map_<?php echo ($tmpControl); ?>.closeInfoWindow();
				});
				GEvent.addListener(marker, "dragend", function() {
					marker.openInfoWindowHtml(document.getElementById(tmpIntroduct).value);
					document.getElementById(tmpX).value=marker.getPoint().x;
					document.getElementById(tmpY).value=marker.getPoint().y;
				});
				map_<?php echo ($tmpControl); ?>.addOverlay(marker);
				marker.openInfoWindowHtml(pAddress);
			}
		});
	}
	

}

</script>
