<? 
//========================================
// dehead(config/function/lib) Include
//========================================
include $_SERVER['DOCUMENT_ROOT']."/front/include/dehead.php";

//========================================
// Class Connect
//========================================
$Db = new Db();

$dataKey = array(
'1'=>'들창코',
'2'=>'짧은코',
'3'=>'긴코',
'4'=>'매부리코',
'5'=>'낮은코',
'6'=>'오똑한코',
'7'=>'큰코',
'8'=>'작은코',
'9'=>'휜코',
'10'=>'화살코',
'11'=>'동그란코',
'12'=>'주먹코'
);

$result = $Db->query("SELECT * FROM b_event WHERE code = :code", array( 'code' => addslashes($_GET['code']) ));
if(!$result[0]['usertype']){
//	echo "<script>location.href= './step1.php';</script>";
}
$resultMsg1 = $result[0]['usertype']."인 ".$result[0]['username']."님! ";
$resultMsg2 = $result[0]['resultA']." ".$result[0]['resultB'];

$config[description] = $resultMsg1.$resultMsg2;

include_once("./header.php");
?>
<script>
var uri = "http://<?=$_SERVER[HTTP_HOST].$_SERVER[REQUEST_URI]?>";
var step = 3;
</script>
<body>


	<div id="fbwrap">
		<div id="mainPic3"></div>
		<div id="resultPic">
			<img src="./img/<?=array_search($result[0]['usertype'],$dataKey)?>.png" />
		</div>
		<div class="fbResult">
			<?=$resultMsg1?> <br>
			<?=$resultMsg2?>
		
		</div>
		<a href="javascript:;" class="b_fbshare">공유하기테스트</a>
		<a href="javascript:;" class="fb_share commonLBtn">공유하기</a>
		<a href="javascript:;" class="replay">다시하기</a>
		
	</div>
	
</body>

<script>
$('#fbwrap').hide().fadeIn(800);
$(document).on('click','.replay',function(){
	location.href = "step2.php";
});

$('.b_fbshare').click(function(){
	FB.ui({
	  method: 'share',
	  href: uri,
	}, function(res){
		alert(res.post_id);
//		alert(response);
//		console.log(response);
	});
});


var chkMine = function(){
	if(FBID != undefined){
		if(FBID != '<?=$result[0]['userid']?>'){
//			location.href = "step1.php";
		}else{
			console.log('ok');
		}
	}else{
		setTimeout(chkMine,100);
	}
}
$(function(){
	setTimeout(chkMine,100);
});
</script>
</html>
