<?php
require_once 'prepare.php';
require_once 'MemberDAO.class.php';
require_once 'MessageDAO.class.php';

session_start();

require_once 'auth.php';

try {
	$me = MemberDAO::getByFBId($fbid);
} catch (Exception $e) {
	header("Location: fb_login.php");exit;
}

/* $basename = basename($_SERVER["REQUEST_URI"]);
if (strlen($basename) > 0) {
	header("Location: /"); exit;
}
 */



$unreadMessage = MessageDAO::getUnreadCount($fbid);
$unreadCount = count($unreadMessage);


//必ずindex.phpからアクセス。jqmはajaxでhtmlを読み込んでDOMツリーに追加する。なので別ファイルのjavascriptは読み込まれない
?><!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>ゆる募</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="//code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.css" />
<script src="//code.jquery.com/jquery-1.11.1.min.js"></script>
<script src="//code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.js"></script>
<script src="main.js?v=<?php echo filemtime("main.js");?>"></script>
<script type="text/javascript">
setTimeout(function() {
	if (typeof AndroidStorage !== 'undefined') {
		window.AndroidStorage.saveFacebookId('<?php echo $fbid;?>');
	}
	if (typeof webkit !== 'undefined'
		&& typeof webkit.messageHandlers !== 'undefined'
			&& webkit.messageHandlers.callbackHandler !== 'undefined') {
		webkit.messageHandlers.callbackHandler.postMessage('<?php echo $fbid;?>');
	}

}, 1000);
</script>



<?php
/*
<div class="card">
<div class="card-image">
<img alt="home" src="test.jpg" />
<div class="banner"></div>
<h2>Name, 29</h2>
</div>
<p>Lorem ipsum...</p>
</div>

*/
?>
</script>
<style>
.card {
  background: #FFF;
  border: 1px solid #AAA;
  box-shadow: 0px 2px 3px 0px #AAA;
  padding: 0px;
  margin-top: 15px;
  margin-right: 7.5px;
  margin-bottom: 15px;
  margin-left: 7.5px;
  overflow: hidden;
  border-radius: 3px;
}

.card h1 {
  margin: 0px;
  padding: 10px;
  padding-bottom: 0px;
}
.card p {
  margin: 0px;
  padding: 10px;
}
.card-image {
  width: 100%;
  padding: 0px;
  margin: 0px;
  background-position: center;
  background-repeat: no-repeat;
  position: relative;
  overflow: hidden;
}
.card-image img {
  width: 100%;
}
.card-image .banner {
  height: 50px;
  width: 50px;
  top: 0px;
  right: 0px;
  background-position: top right;
  background-repeat: no-repeat;
  background-image: url('../images/new.png');
  position: absolute;
}
.card-image h1,
.card-image h2,
.card-image h3,
.card-image h4,
.card-image h5,
.card-image h6 {
  position: absolute;
  bottom: 0px;
  width: 100%;
  color: white;
  background: rgba(0,0,0,0.65);
  margin: 0px;
  padding: 6px;
  border: none;
  font-size: 1em;

}
div.holoPressEffectDiv {
	background-color: #CCCCCC;
}


.ui-popup-hidden { top: -99999px; left: -9999px; visibility: inherit;}





</style>
</head>
<body>
<div data-role="page" id="mainPage">
<div data-role="header" style="overflow:hidden;" data-tap-toggle="false">
<h1>現在募集されているゆる募</h1>
<button class="ui-btn ui-icon-refresh ui-btn-icon-left ui-btn-right" id="refreshButton">更新</button>
</div>
<div role="main" class="ui-content" id="leftColumn">
	<div id="leftColumn">
	</div>





<!-- error message begin -->
<div data-role="popup" id="connectionErrorPopup">
  <p>GPSをONにしてください信に失敗しました</p>
</div>
<!-- error message end -->

</div>
<div data-role="footer" style="overflow:hidden;" data-position="fixed" data-tap-toggle="false">
	<div data-role="navbar">
	<ul>
		<li><a href="#" data-icon="grid" class="ui-btn-active ui-state-persist">周辺のゆる募</a></li>
		<li><a href="message_list.php" data-icon="star"  data-transition="fade" class="ui-btn ui-corner-all ui-shadow ui-btn-inline">会話 <?php if($unreadCount > 0) echo "(".$unreadCount.")";?></a></li>
		<li><a href="my_profile.php" data-icon="gear"  data-transition="fade" class="ui-btn ui-corner-all ui-shadow ui-btn-inline">自分のゆる募</a></li>
	</ul>
	</div>
</div>
</div>

</body>
</html>
