<?php
/*
	Copyright(c) 2010 Shift Tech Inc. All Rights Reserved.
 	http://www.shift-tech.jp/

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

$key = null;
if($_REQUEST["key"]!=null) {
	$key = $_REQUEST["key"];
}
require_once("../../../../app_path.php");
require_once(APP_PATH.'/PcController.php');
require_once(APP_PATH.'/etc/ini.php');
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link href="../../../../admin/css/common.css" rel="stylesheet" type="text/css" media="all">
<link href="../../../../admin/css/content.css" rel="stylesheet" type="text/css" media="all">
<title>bingoサイト管理：</title>
<script src="../../../../js/prototype.js" type="text/javascript"></script>
<script type="text/javascript" src="../../../../admin/js/imgselecter.js"></script>
</head>
<body>
<?php if($key){ ?>
<div id="unitContainerMain" class="unitContainer">
	<div class="unitContentsTtl">
		<h3>マップ</h3>
	</div>
	<!--contents/-->
	<div class="unitContents">
		<div id="tabBox1" class="unitContentsBox">
			<div class="unitFlame" style="height:600px;">
				<div class="unitFlameInner">
				<h4>位置情報</h4>
				<script type="text/javascript" src="http://api.map.yahoo.co.jp/MapsService/js/V1/?appid=<?php echo $key ?>"></script>
				<script type="text/javascript">
				<!--//
				window.onload=function(){
					var dlat = window.opener.document.form.bmap_lat.value;
					var dlng = window.opener.document.form.bmap_lng.value;
				if(dlat==''||dlng=='') {
					dlat = "35.40.39.980";
					dlng = "139.46.13.730";
				}
				
					Ymap = new YahooMapsCtrl("editMap", dlat+","+dlng, 9, YMapMode.Map);
					var point = Ymap.getCenter();
							$("lat").value = point.lat;
							$("lng").value = point.lon;
					Ymap.addEvent(YEventType.MAP_MOVING, function(){
							var point = Ymap.getCenter();
							$("lat").value = point.lat;
							$("lng").value = point.lon;
				        });
				}
				
				function setPoint(){
					if(!window.opener || window.opener.closed){ 
						alert ("親ウインドウが閉じられています");
					}else{
						window.opener.document.form.bmap_lat.value=$("lat").value;
						window.opener.document.form.bmap_lng.value=$("lng").value;
						if (confirm("設定画面へ緯度、経度を反映しました")) {
							window.close();
						}
					}
				}
				//-->
				</script>
					<table border="0" cellpadding="0" cellspacing="0" width="796" class="middle">
						<tr>
							<td><div id="editMap" style="width: 100%; height: 350px; margin: 0 0 10px 0; border: 1px solid #000;">&nbsp;</div></td>
						</tr>
						<tr>
							<td><span class="txtImp">※表示させる施設が地図の中央に来るようマップをドラック移動させてください。</span></td>
						</tr>
						<tr>
							<td>緯度：<input type="text" name="lat" id="lat" value="" class="wr30">&nbsp;&nbsp;経度：<input type="text" name="lng" id="lng" value="" class="wr30"></td>
						</tr>
					</table>
				</div>
				<div class="unitContentsBtn">
				<table>
					<tr>
						<td><input class="bBtnClose" id="BTNclose" name="BTNclose" value="閉じる" type="button" onClick="window.close()" /></td>
						<td><input class="bBtnSave" id="BTNsave" name="BTNsave" value="保存" type="button" onClick="setPoint()" /></td>
					</tr>
				</table>
				</div>
				<!--contents/-->
			</div>
		</div>
	</div>
	<!--/contents-->
</div>
<?php } else { ?>
	API ID、または住所が入力されていません。
<?php } ?>
</body>
</html>