<?
putenv("NLS_LANG=TRADITIONAL CHINESE_TAIWAN.AL32UTF8");
header('P3P: CP=CAO PSA OUR');
header ('Content-Type: text/html; charset=utf-8'); 

if (!isset($_SESSION)) //判斷是否已經開啟SESSION
{
session_start();
$mid=$_SESSION['mId'];
$id=$_SESSION['mAccount'];

}//開起SESSION

if($_SESSION['mId']==''){

echo "<script language=javascript>
        	alert('請先登入！');
        	self.parent.tb_remove();
        	</script>";

}
if($mid!=''){


require_once("../function.php");
check_login();

?>
<!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>
<script src='../jQuery/jquery-1.2.6.js' type='text/javascript'></script>
<SCRIPT LANGUAGE="JavaScript" src="../jQuery/TbxLenLimit.js"></SCRIPT>
    <script type="text/javascript">
    	function join_raise() {
 var chk="";
    $("[id='tTraffic'][checked]").each(function() 
{
    chk+=$(this).val()+"-";    
    
})
if(chk==""){
	
		$('#msg_join').html('請選擇交通方式');
	$('#msg_join').fadeIn(200);
	return false;
	}
//alert(chk);
				
	
	
	
	$.ajax({
   type: "POST",
   url: "../raise/join_raise_action.php",
   data: {tMsn: $('#tMsn').val(), tPhone: $('#tPhone').val(),tEmail: $('#tEmail').val(),tTraffic:chk,tElse: $('#tElse').val(), rId: $('#rId').val(), mId: $('#mId').val()},
   beforeSend:function(){
   $('#join_form').fadeOut(200);
   $('.message-loading').fadeIn(200);
    var msg = "";	
		//alert($('#tTraffic').val());
		
		   
      
       
    if ($('#tPhone').val()== ""){
          msg += "請輸入電話\n";
    }else if(isNaN($('#tPhone').val())){
	      	msg += "電話格式錯誤\n";
			  
		}
		if ($('#tEmail').val() == "")
        {
        	  msg += "請輸入E-mail\n";
        }
   
/*
		for(i=0;i<$('#tTraffic').length;i++){
      if(formobj.tTraffic[i].checked==true){
        
        chk += "ok";
			        	  
        }
	}*/
		if (msg != ""  )
        {
        	
            //alert(msg);
       $('#msg_join').html(msg);
    	$('#msg_join').fadeIn(200);
		  $('#join_form').fadeIn(200);
  $('.message-loading').fadeOut(200);
			return false;
         
        }
       
	
	},
  
  complete: function (response) {
								 
	    $('#msg_join').html(response.responseText);
	    $('#msg_join').fadeIn(200);
    	 $('.message-loading').fadeOut(200);
	//alert(msg);
  	
  			alert('加入成功!!');
		location.href="../raise/show_raise_detail.php?rId="+$('#rId').val()+"";
				

}
   });	return false;
  	
 }
	
   
	function selAll(){
	//變數checkItem為checkbox的集合
	var checkItem = document.getElementsByName("tTraffic[]");
	for(var i=0;i<checkItem.length;i++){
		checkItem[i].checked=true;   
		}
	}
	function unselAll(){
		//變數checkItem為checkbox的集合
		var checkItem = document.getElementsByName("tTraffic[]");
		for(var i=0;i<checkItem.length;i++){
			checkItem[i].checked=false;
		}
	}
	function usel(){
	//變數checkItem為checkbox的集合
	var checkItem = document.getElementsByName("tTraffic");
	for(var i=0;i<checkItem.length;i++){
		checkItem[i].checked=!checkItem[i].checked;
		}
	}
	

	
  </script>
</head>

<body>
<? 
$rId=$_GET['rId'];
require_once("../db.php");

$str = oci_parse($conn,"SELECT * FROM MEMBER WHERE MID='$mid'") or die('Insert error');
oci_execute($str);

$row=oci_fetch_object($str)


?>

<div class='message-loading' style='display:none'><img src="../images/loadingAnimation.gif" /> Joining.....</div>
<form id="join_form" name="form1" method="POST" onsubmit="return join_raise();">

<table  align="center" style=" margin: 0px auto;">
<tr class="tr02"><th colspan="2" align="center">請輸入以下資料</th></tr>
  <tr>
    <td class="td02">ID</td>
    <td><?=$id ?></td>
  </tr>
  <!--
  <tr>
    <td class="td02">MSN</td>
    <td><input id="tMsn" name="tMsn" type="text" size="40" maxlength="40" value="<?=$row->mMsn ?>"></td>
  </tr>
  -->
  <tr>
    <td class="td02">聯絡電話</td>
    <td><input id="tPhone" name="tPhone" type="text" maxlength="40" size="40"></td>
  </tr>
  <tr>
    <td class="td02">E-mail</td>
    <td><input id="tEmail" name="tEmail" type="text" maxlength="40" size="40" value="<?=$row->mEmail ?>"></td>
  </tr>
    <tr>
    <td class="td02">交通方式</td>
    <td><input name="tTraffic[]" id="tTraffic" type="checkbox" value="步行">步行
		<input name="tTraffic[]" id="tTraffic" type="checkbox" value="機車">機車
		<input name="tTraffic[]" id="tTraffic" type="checkbox" value="汽車">汽車
		<input name="tTraffic[]" id="tTraffic" type="checkbox" value="自行車">自行車
		<br>
		<input name="tTraffic[]" id="tTraffic" type="checkbox" value="大眾交通工具">大眾交通工具
		<input type="button" value="全選" onclick="selAll();">	
		<input type="button" value="取消全選" onclick="unselAll();"/> 
		
	</td>
  <tr>
    <td class="td02">備註</td>
    <td>限填200字喔~<br>
    	<textarea id="tElse" name="tElse" cols="40" rows="5" maxlength="200" class="ShowLen"></textarea></td>
  </tr>
  <tr >
  	<td colspan="2" align="center"><input type="submit" value="送出"></td>
  </tr>
</table>

<input id="rId" name="rId" type="hidden" value="<?=$rId?>">
<input id="mId" name="mId" type="hidden" value="<?=$mid?>">


</form>
 <div id="msg_join" style='display:none'></div>
</body>
</html>
<?
}else{echo "請先登入";}
?>