<?

if (!isset($_SESSION)) //判斷是否已經開啟SESSION
{
	header("Cache-control:private");
session_start();}//開起SESSION}
$mAccount=$_SESSION['mAccount'];

require_once("../db.php");

include("../function.php");
check_login();
$mId=$_SESSION['mId'];
if($mId!=''){
?>


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>JUME(Join You And Me)揪咪揪團活動網</title>

<!-- Include Core Datepicker Stylesheet -->		
<link rel="stylesheet" href="style/ui.datepicker.css" type="text/css" media="screen" title="core css file"/>
<link href="../member/style/add_activity.css" rel="stylesheet" type="text/css" media="screen" />
<SCRIPT LANGUAGE="JavaScript" src="../jQuery/TbxLenLimit.js"></SCRIPT>
 <script type="text/javascript" src="../jQuery/jquery-1.2.6.js"></script>
 <script type="text/javascript" language="javascript" src="insert_js.js"></script>
  <script src="http://maps.google.com/maps?file=api&amp;v=2&amp;key=ABQIAAAA-fZzs3imoScYLbCOBKQlzRTDQbFKLWBUv-hmAr6_O3aN5ZraihS617SXs678fe0xileB-cptWVBJ5w"
      type="text/javascript"></script>

</head>
<body onunload="GUnload()">
<div id="header">
<? include("../member/header2.php"); ?>
</div>

<div id="content">

<form method="post" action="add_activity_action.php" enctype="multipart/form-data" id="act_form" name="restauForm" onsubmit="return valid_add();">

<center>
<div id="raisedetail" >
&nbsp;
<table border="0" id="temp">
<!-- <tr align="left">
    <td> 活動名稱</td>
    
	<td><input id='nameFie' type="text" size="30" name="markerName" onfocus='clickField(this.id);' style='color:#666'
						></input>
				<div style='color:#03152f; display:block' id='reply_night'
						value=""></div></td>
  </tr>
 -->
  <tr align="left">
    <th scope="row" class="must">活動名稱</th>
    <td><input type="text" name="aName" size="45" maxlength="35">(建議30字以內)</td>
  </tr>
  <tr align="left">
  	<th scope="row" class="must">活動時間</th>
  	<td><input type="text" size="10" name="start_date" value="" id="start_date"/> to <input type="text" size="10" name="end_date" value="" id="end_date"/></td> 
  </tr>
  <!--
    <tr align="left">
    <th scope="row" class="must">場地</th>
    <td><input type="text" name="aPlace" size="45" maxlength="20">(建議20字以內)</td>
  </tr>
  -->
  <tr align="left">
    <th scope="row" class="must">地址</th>
    <td><input id='addFie' type="text" size="45" name="markerAddress"  onKeyDown="toPosition(this.value)"	style='color:#666'
				onfocus='clickField(this.id);' ></input>
				<div id='replyAddCheck' style='color:#03152f; display:block' ></div>
    </td>
  </tr>
<tr>
	<td colspan="2" >
    
	
	<div id="map" style=" width:500px; height:500px;margin: 0px auto;"></div>
  <script type="text/javascript">
  
        var map = new GMap2(document.getElementById("map"));
        //map.setCenter(new GLatLng(23.6, 121.1419), 15);
		var point=new GLatLng(22.626083, 120.265768);
		map.setCenter(point, 14);
		map.addControl(new GSmallMapControl());
	    map.addControl(new GMapTypeControl());
		marker=new GMarker(point,{draggable: true});
		drag();
		
		map.addOverlay(marker);
		marker.openInfoWindowHtml("<br>可以拖曳我定位或是輸入地址唷 <br>^.&lt; ");
		//map.enableScrollWheelZoom(); 
	 /*
		map.addControl(new GMapTypeControl());
		map.addControl(new GSmallMapControl());
		*/
		geocoder = new GClientGeocoder();
		 //]]>
   </script>
	
  </td>
</tr>


  <tr align="left">
    <th>圖片上傳</th>
   <td ><input type="file"  name="picture" size="40"> <br>建議大小為寬250*高300

	         <!--
			 <div id="file"></div>
						<div align="right" >
						  <input type="button" value="更多檔案" onClick="add()">
						<input type="button" value="移除檔案" onClick="subtract()">
		  </div>-->	  </td>
  </tr>
  <!--
    <tr align="left">
    <th>主辦單位</th>
    <td><input type="text" name="host" size="30" maxlength="20">(建議20字以內)</td>
  </tr>
  -->
    <tr id="con">
    <th colspan="2" >活動內容</th>
  </tr>
  <tr>
    <td colspan="2">超過將會被截掉喔~<textarea name="content" cols="65" rows="14" MaxLen="1000" class="ShowLen"></textarea></td>
  </tr>
  <tr align="left">
  <!--
    <th>活動費用</th>
    <td><input type="text" name="fees" size="10" maxlength="10"></td>
  </tr>
  -->
  <tr align="left">
    <th>類別</th>
    <td><input type="radio" name="aType" value="1" checked>Shopping
	    <input type="radio" name="aType" value="2">Party
		<input type="radio" name="aType" value="3">Food
		<input type="radio" name="aType" value="4">Travel
		<input type="radio" name="aType" value="5">Sports
		<input type="radio" name="aType" value="6">Educate</td>
  </tr>
  <!--
  <tr align="left">
    <th>網站</th>
    <td><input type="text" name="website" size="40" maxlength="30"><a href="http://0rz.tw/" target="_blank">(點此縮網址)</a></td>
  </tr>
  <tr align="left">
    <th>聯絡電話</th>
    <td><input type="text" name="aPhone" size="20" maxlength="15"></td>
  </tr>
  -->
  <input type="hidden" value="" name="rId"></input>
				<input type="hidden"  name="lng" value='120.265768'></input>
				<input type="hidden"  name="lat" value='22.626083'></input>
			
  
  
</table>
<!--
<input type='button' value='送出' class="bu" onclick='checkBeforeSubmit();'>-->
<input type="submit" name="Submit" value="送出" />

<div id="invDiv" name='invDiv' style='display:none'></div>
		<input id='ln' type='text' style='display:none' value='22.626083'></input>
		<input id='la' type='text' style='display:none' value='120.265768'></input>
</center>
</form>
</div><!--end raisedetail-->
<!--end content-->


<div id="footer">   
  <div id="footer-in" align="center">
   <p>版權資訊</p>
    <p>國立中山大學  資訊管理學系  揪咪揪團網 <a href="mailto:jumemis@yahoo.com.tw">揪咪團隊<img src="../mail/send email.gif" border="0"/></a> 版權所有  Taiwan All Rights Reserved</p> 
  </div><!-- end #footer-in -->
</div><!-- end #footer -->
</body>
</html>


<script type="text/javascript" src="js/ui.datepicker.js"></script>

<script type="text/javascript"> 
$("#start_date").datepicker({ 
   beforeShow: customRange,
    dateFormat:"yy-mm-dd",
    minDate:"0",
	showOn: "both", 
    buttonImage: "style/pickup.gif", 
    buttonImageOnly: true 
});
$("#end_date").datepicker({ 
beforeShow: customRange,
    dateFormat:"yy-mm-dd",
  	 minDate:"0",
    showOn: "both", 
    buttonImage: "style/pickup.gif", 
    buttonImageOnly: true 
});
function customRange(input) { 
var tm=$("#start_date").datepicker("getDate");
var tm_2=$("#end_date").datepicker("getDate");
if(input.id == "end_date" && tm != null){
return {minDate: $("#start_date").datepicker("getDate") }
}

  if(input.id == "start_date" && tm_2 != null){
return { maxDate: $("#end_date").datepicker("getDate")  }
} 
	/*,maxDate: (input.id == "start_date" ? $("#end_date").datepicker("getDate") : null)}; */
} 

  function valid_add()
	{
		var msg = "";	
		//alert(msg);
		var x;
		
        formobj = window.document.getElementById("act_form");
        
         if (formobj.aName.value == ""){
    msg += "請輸入活動名稱\n";
        }

		
		if (formobj.start_date.value == "")
        {
        	  msg += "請輸開始時間\n";
        }
		if (formobj.end_date.value == "")
        {
        	  msg += "請輸結束時間\n";
        }
		if (formobj.end_date.value < formobj.start_date.value )
        {
        	  msg += "時間輸入錯誤\n";
        }
		
		if (formobj.markerAddress.value == "")
        {
        	  msg += "請輸入地址\n";
        }
		if (formobj.content.value == "")
        {
        	  msg += "請輸入活動內容\n";
        }
			/*
			if (formobj.fees.value == "")
        {
        	  msg += "請輸入手機\n";
        }*/
		if(checkFile_act()==false){
		msg += "僅限上傳JPG或GIF或PNG \n";
		
		}
		
	
		/*if(formobj.aPhone.value!=""){
 if(isNaN(formobj.aPhone.value)){
		msg += "電話錯誤\n";
			  
		}
		}
		if(formobj.fees.value!=""){
		 if(isNaN(formobj.fees.value)){
		msg += "費用錯誤\n";
			  
		}
		}
		*/
		if (msg != "")
        {
            alert(msg);
            return false;
        }
        else
        {
			
			return true;
			
        }
		
   }
   
		//這裡控制要檢查的項目，true表示要檢查，false表示不檢查    
 var isCheckImageType = true;  //是否檢查圖片副檔名    
 var isCheckImageWidth = true;  //是否檢查圖片寬度    
 var isCheckImageHeight = true;  //是否檢查圖片高度    
 var isCheckImageSize = true;  //是否檢查圖片檔案大小    
   
 var ImageSizeLimit = 100000;  //上傳上限，單位:byte    
 var ImageWidthLimit = 400;  //圖片寬度上限    
 var ImageHeightLimit = 300;  //圖片高度上限    
   
 function checkFile_act() {    
     var f = window.document.getElementById("act_form"); 
	
     var re = /\.(jpg|gif|png)$/i;  //允許的圖片副檔名  
     if(f.picture.value!=''){  
     if (isCheckImageType && !re.test(f.picture.value)) { 
	return false;
         /*alert("只允許上傳JPG或GIF影像檔"); 
         return false;   */
     /*} else { 
     	 document.mr.submit(); 
     
     }
    } else { 
     document.mr.submit()	; 
     return true;*/
     }   
 }    
 }
 function checkImage() {    
     if (isCheckImageWidth && this.width > ImageWidthLimit) {    
         showMessage('寬度','px',this.width,ImageWidthLimit);    
     } else if (isCheckImageHeight && this.height > ImageHeightLimit) {    
         showMessage('高度','px',this.height,ImageHeightLimit);    
     } else if (isCheckImageSize && this.fileSize > ImageSizeLimit) {    
         showMessage('檔案大小','kb',this.fileSize/1000,ImageSizeLimit/1000);            
     } else {    
         document.mr.submit();    
     }    
 }    
 function showMessage(kind,unit,real,limit) {    
     var msg = "您所選擇的圖片kind為 real unit\n超過了上傳上限 limit unit\n不允許上傳！"    
     alert(msg.replace(/kind/,kind).replace(/unit/g,unit).replace(/real/,real).replace(/limit/,limit));    
 }    
	
	

/*
var count = 1;
function add()
{
	var i;
	var code = "";
	for(i=0;i<count;i++)
	{
		code = code + '<input type="file" size="40" class="multi" accept="gif|jpg"  name="picture[]" />' + '<br />';	
	}
	document.getElementById("file").innerHTML = code;
	count++;
}
	
function subtract()
{
	if(count>1)
	{
		count--;
	}
	var i;
	var code = "";
	for(i=0;i<count-1;i++)
	{
		code = code + '<input type="file" size="40" name="picture[]" />' + '<br />';	
	}
	document.getElementById("file").innerHTML = code;
}*/
</script>
<?

}else{echo "請先登入";}
?>
