<!-- THIS IS THE MASTER DETAILS TEMPLATE FOR CHALLENGES -->
<?php 

global $website_title;
$website_title = "New Post! - " . $project['title'];

global $website_description;
$website_description = $project['description'];

global $website_image;
$website_image = "/". $project['main_img'];

include 'views/_header_blog.tpl.php'; 

?>

<?php
//	if (isset($msg)) {
//		echo "<center><b>$msg</b></center><br /><br />";
//	}
//require_once '3rdparty/phpqrcode/qrlib.php';
if (isset($_GET['clear']) && $_GET['clear']==1) {
	//echo "yes!";
	if (isset($_COOKIE['PHPSESSID'])) {
		unset($_COOKIE['PHPSESSID']);
		setcookie('PHPSESSID', '', -1, '/');
		unset($_COOKIE["PHPSESSID"]);
		session_destroy();	
		//setcookie("cookie_name", "", time() - 1, "/");
	}
}

// Start a new session in case it hasn't already been started on the including page
//if (!isset($_SESSION)) {
//	@session_start();
//}
	
?>
<!-- THIS IS THE OFFICIAL FLIPMOB DETAILS OVERVIEW PAGE -->
<link rel="stylesheet" href="/static/css/connect-nearme.css"/>
<link href="//code.google.com/apis/maps/documentation/javascript/examples/default.css" rel="stylesheet" type="text/css" />
<!--<script src="//maps.googleapis.com/maps/api/js?v=3.exp&libraries=places&key=AIzaSyAgYK3ytwWRRFM3OHhKQ88Uezpt3i-4NQI"> </script>-->

<script src="https://maps.google.com/maps/api/js?libraries=geometry&sensor=true&key=AIzaSyCSsor1E1STB_jcqIGYc2ljfGBya5z5ULA"> </script>

<script src="/static/js/gmaps.oms.min.js"> </script>
<script type="text/javascript" src="/static/js/people-nearme.js"> </script>

<script type="text/javascript">
	var people_near_me = null;

	function init_map()
	{
		people_near_me = new PeopleNearMe(); people_near_me.initialize();
	}
	google.maps.event.addDomListener(window, 'load', init_map);
</script>

<style type="text/css">
	.hidden { display:none; }
	p {
		font-family: Montserrat,'Open Sans',Raleway,Oswald,Helvetica,Verdana,sans-serif;
	}
	.newblue a, .newblue a:link, .newblue a:visited, .newblue a:active {
		color: #00A1FE;
	}
	.newblue a:hover {
		/* color:#00a4ff;*/ /* new blue hover color */
		color: #3679E7; /* old blue */
	}
	#wrapper {
		background: #f7f7f7;
	}
	div.spacer {
		padding-top: 57px;
	}
	h3.rs.title-inside {
		/*line-height:1.3em;*/
	}
	h2.rs.group-title, h3.rs.title-inside {
		text-align: left;
		color: #000;
		text-shadow: 0px -1px 0px #fff;
		font-size: 40px;
		line-height: 50px;
		text-transform: inherit;
		font-family: 'Open Sans',Raleway,Montserrat,Oswald,Helvetica,sans-serif;
		font-weight: 300;
		margin-bottom: 10px;
		padding-top: 10px;
		padding-left: 0px;
	}
	.project-detail .project-title {
		font-size: 40px;
		line-height: 50px;
		padding-bottom: 10px;
		font-weight: 300;
		text-shadow:0px 1px 0px #fff;
	}
	h1 { font-size: 48px; line-height: 58px;
		margin-bottom:10px;
		
		font-weight:600; text-transform: none;
		font-family: Montserrat,'Open Sans',Helvetica,Verdana,sans-serif
	}
	h1.rs, h2.rs,
	.box-gray {
		/*background:#f7f7f7;*/
		border-radius: 4px;
		-moz-border-radius: 4px;
		-webkit-border-radius: 4px;
		box-shadow: 0 1px 3px rgba(0,0,0,0.1), 0 0 2px rgba(255,255,255,0.1) inset, 0 1px 2px rgba(255,255,255,0.2) inset;
		-moz-box-shadow: 0 1px 3px rgba(0,0,0,0.1), 0 0 2px rgba(255,255,255,0.1) inset, 0 1px 2px rgba(255,255,255,0.2) inset;
		-webkit-box-shadow: 0 1px 3px rgba(0,0,0,0.1), 0 0 2px rgba(255,255,255,0.1) inset, 0 1px 2px rgba(255,255,255,0.2) inset;
	}
	a.btn.btn-red {
		display:block;
		max-width:363px !important;
		padding:17px 25px;
		font-size:15px;
	}
	button.btn.btn-buck-project a, .btn a, button.btn a, input[type="button"].button.btn a,
	button.btn.btn-red.add-dispute.btn-buck-project, #wrapper > div.layout-2cols > div.sidebar.grid_4 > div.project-runtime > div > button.btn.btn-green.proposal-status-trigger.btn-buck-project {
		color: #fff !important;
	}
	button.btn-buck-project {
		color: #fff;
	}
	input[type=checkbox] {
		transform: scale(1.5);
	}
	.box-gray h3, h3 {
		font-size: 17px;
		font-weight: 600;
		text-transform: uppercase;
		font-family: Montserrat,'Open Sans',Raleway,Oswald,Helvetica,Verdana,sans-serif;
		margin-bottom: 5px;
	}
	.hidden {
		display: none;
	}
	.btn-charcoal {
		border-color: #2a3336;
		color: #FFF;
		background: #445359 !important;
		max-width: 200px;
		min-width: 150px;
		margin: 10px;
		height: 40px;
		line-height: 40px;
		font-size: 15px;
		font-weight: 300;
		border-radius: 50px;
		-moz-border-radius: 50px;
		-webkit-border-radius: 50px;
		background: -moz-linear-gradient(top, #445359 0%, #384449 100%);
		background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#445359), color-stop(100%,#384449));
		background: -webkit-linear-gradient(top, #445359 0%,#384449 100%);
		background: -o-linear-gradient(top, #445359 0%,#384449 100%);
		background: -ms-linear-gradient(top, #445359 0%,#384449 100%);
		background: linear-gradient(top, #445359 0%,#384449 100%);
		filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#445359', endColorstr='#384449',GradientType=0 );
	}
/*	.btn-green {
		border-color: #00ed00;
		color: #000;
		background: #00ed00;
		background: -moz-linear-gradient(top, #3fff3f 0%, #00ed00 100%);
		background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#3fff3f), color-stop(100%,#00ed00));
		background: -webkit-linear-gradient(top, #3fff3f 0%,#00ed00 100%);
		background: -o-linear-gradient(top, #3fff3f 0%,#00ed00 100%);
		background: -ms-linear-gradient(top, #3fff3f 0%,#00ed00 100%);
		background: linear-gradient(top, #3fff3f 0%,#00ed00 100%);
		filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#3fff3f', endColorstr='#00ed00',GradientType=0 );
	}*/
	.btn-blue {
		border-color: #000;
		color: #FFF;
		background: #000;
		background: -moz-linear-gradient(top, #222 0%, #000 100%);
		background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#222), color-stop(100%,#000));
		background: -webkit-linear-gradient(top, #222 0%,#000 100%);
		background: -o-linear-gradient(top, #222 0%,#000 100%);
		background: -ms-linear-gradient(top, #222 0%,#000 100%);
		background: linear-gradient(top, #222 0%,#000 100%);
		filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#222', endColorstr='#000',GradientType=0 );
	}
	.btn-blue:hover {
		border-color: #555;
		color: #FFF;
		background: #555;
		background: -moz-linear-gradient(top, #000 0%, #555 100%);
		background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#000), color-stop(100%,#555));
		background: -webkit-linear-gradient(top, #000 0%,#555 100%);
		background: -o-linear-gradient(top, #000 0%,#555 100%);
		background: -ms-linear-gradient(top, #000 0%,#555 100%);
		background: linear-gradient(top, #000 0%,#555 100%);
		filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#000', endColorstr='#555',GradientType=0 );
	}
	.btn {
		border: 0px solid #b6b6b6;
		cursor: pointer;
		text-align: center;
		border-radius: 4px;
		-moz-border-radius: 4px;
		-webkit-border-radius: 4px;
		color: #fff;
		padding: 5px 16px;
		box-shadow: 0 1px 3px rgba(0,0,0,0.1), 0 0 2px rgba(255,255,255,0.1) inset, 0 1px 2px rgba(255,255,255,0.2) inset;
		-moz-box-shadow: 0 1px 3px rgba(0,0,0,0.1), 0 0 2px rgba(255,255,255,0.1) inset, 0 1px 2px rgba(255,255,255,0.2) inset;
		-webkit-box-shadow: 0 1px 3px rgba(0,0,0,0.1), 0 0 2px rgba(255,255,255,0.1) inset, 0 1px 2px rgba(255,255,255,0.2) inset;
		display: inline-block;
		*
		display: inline;
		*
		zoom: 1;
	}
	.btn-black {
		border-color: #000;
		color: #FFF;
		background: #000 !important;
		max-width: 200px;
		min-width: 150px;
		margin: 10px;
		height: 50px;
		line-height: 50px;
		font-size: 15px;
		font-weight: 300;
		border-radius: 50px;
		-moz-border-radius: 50px;
		-webkit-border-radius: 50px;
		background: -moz-linear-gradient(top, #445359 0%, #384449 100%);
		background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#445359), color-stop(100%,#384449));
		background: -webkit-linear-gradient(top, #445359 0%,#384449 100%);
		background: -o-linear-gradient(top, #445359 0%,#384449 100%);
		background: -ms-linear-gradient(top, #445359 0%,#384449 100%);
		background: linear-gradient(top, #445359 0%,#384449 100%);
		filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#445359', endColorstr='#384449',GradientType=0 );
	}
	.btn-black:hover {
		background: #444;
	}
	#joinBlock {
		width:69%; 
		padding-right: 1%;
	}
	a.btn-join-white.loginpop, a.btn-join-white.loginpop:active, a.btn-join-white.loginpop:link, a.btn-join-white.loginpop:visited, a.btn-join-white, a.btn-join-white:active, a.btn-join-white:link, a.btn-join-white:visited {
		display: block;
		border: 3px solid #eee;
		color: #333;
		background:none;
		width: 100%;
		text-align: center;
		margin: 0 auto;
		height: 44px;
		line-height: 44px;
		font-size: 17px;
		font-weight: 500;
		border-radius: 6px;
		-moz-border-radius: 6px;
		-webkit-border-radius: 6px;
	}
	a.btn-join-white.loginpop:hover {
		background: #9affda;
	}		
	a.btn-join-black.loginpop, a.btn-join-black.loginpop:active, a.btn-join-black.loginpop:link, a.btn-join-black.loginpop:visited {
		display:block;
		border:#000;
		color: #FFF;
		background: #000;
		width: 100%;
		text-align:center;
		margin: 0 auto;
		height: 50px;
		line-height: 50px;
		font-size: 17px;
		font-weight: 400;
		border-radius: 6px;
		-moz-border-radius: 6px;
		-webkit-border-radius: 6px;
	}
	a.btn-join-black.loginpop:hover {
		background:#333;	
	}	
	.claim-btn a, .claim-btn a:link, .claim-btn a:active, .claim-btn a:visited {
		display:inline-block;
		color: #eee;
		border:1px solid #dad8db; 
		max-width: 200px;
		min-width: 70px;
		height: 35px;
		line-height: 35px;
		font-size: 15px;
		font-weight: 300;
		border-radius: 6px;
		-moz-border-radius: 6px;
		-webkit-border-radius: 6px;
		text-align:center;
		background: #000;
		background: -moz-linear-gradient(top, #222 0%, #000 100%);
		background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#222), color-stop(100%,#000));
		background: -webkit-linear-gradient(top, #222 0%,#000 100%);
		background: -o-linear-gradient(top, #222 0%,#000 100%);
		background: -ms-linear-gradient(top, #222 0%,#000 100%);
		background: linear-gradient(top, #222 0%,#000 100%);
		filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#222', endColorstr='#000',GradientType=0 );
	}
	/** cool blue 00A1FE --**/
	.claim-btn a:hover {
		color:#fff;
		background: #555;
		background: -moz-linear-gradient(top, #000 0%, #555 100%);
		background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#000), color-stop(100%,#555));
		background: -webkit-linear-gradient(top, #000 0%,#555 100%);
		background: -o-linear-gradient(top, #000 0%,#555 100%);
		background: -ms-linear-gradient(top, #000 0%,#555 100%);
		background: linear-gradient(top, #000 0%,#555 100%);
		filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#000', endColorstr='#555',GradientType=0 );
	}
	#current_user_id,
	#current_user_status {
		display: none;
	}
	.nav-tabs > li {
		width:50%;
	}
	.nav-tabs > li  > a {
		text-align:center;
	}
	.property-price {
		color: #005184;
		font-weight: bold;
	}

	.appointment-row {
		position: relative;
	}
	.appointment-row .media-body {
		width: 50%;
	}
	.appointment-approval-wrapper {
		padding-top: 10px;
		position: relative;
		/*right: 25px;
		top: 15px;*/
		height: 64px;
	}
	.appointment-approval-wrapper .action {
		float: left;
		margin-left: 0px;
		margin-right: 5px;
	}
	.halfdiv {
		float: left;
		width: 50%;
		display: inline-block;
	}
	.login-form span {
		display: inline-block;
		width: 120px;
	}
	.map-canvas {
		width: 100%;
	}
	#deal-marker {
		display: none;
	}
	button.btn {
		color: #eee;
	}
	button.btn-buck-project {
		display: block;
	width: 100%;
	font-weight: normal;
	}
	span.lbl {
		font-weight: normal;
	font-size: 12px;
	}

	.leftcell {
		background: none;
		float: left;
		width: 150px;
		margin: 0;
		height: 30px;
		line-height: 30px;
		margin-bottom: 3px;
		font-weight: 600;
		color: #bbb;
	}
	.rightcell {
		background: none;
		position: relative;
		float: none;
		overflow: hidden;
		height: 30px;
		line-height: 30px;
		max-width: 850px;
		margin-bottom: 3px;
		text-align: left;
		font-size: 17px;
	}

	.circle {
		display: inline-block;
		height: 20px;
		line-height: 20px;
		width: auto;
		padding: 5px 20px;
		-webkit-border-radius: 50px;
		-moz-border-radius: 50px;
		border-radius: 50px;
		background: #eee;
		text-align: center;
		font-size: 14px;
		color: #000;
		font-weight: 300;
		margin: 10px;
	}

	.circle:hover {
		background: #1a99fc;
		color: #fff;
	}

	.roundedcorners {
		border-radius: 4px;
		-moz-border-radius: 4px;
		-webkit-border-radius: 4px;
	}
	#errordiv_chipin, #errordiv_withdraw {
		display: none;
		margin-top: 0px !important;
	}
	#errordiv, #errordiv_chipin, #errordiv_withdraw {
		margin: 0;
	}

	#errordiv a, #errordiv a:active, #errordiv a:visited,
	#errordiv_chipin a, #errordiv_chipin a:active, #errordiv_chipin a:visited,
	#errordiv_withdraw a, #errordiv_withdraw a:active, #errordiv_withdraw a:visited {
		background: #21bb29;
		color: #eee;
		border-radius: 50px;
		-moz-border-radius: 50px;
		-webkit-border-radius: 50px;
		padding: 3px 25px;
		font-weight: 800;
		box-shadow: rgba(0, 0, 0, 0.1) 0px 4px 12px;
		-webkit-box-shadow: rgba(0, 0, 0, 0.1) 0px 4px 12px;
		-moz-box-shadow: rgba(0, 0, 0, 0.1) 0px 4px 12px;
	}

	#errordiv a:hover, #errordiv_chipin a:hover, #errordiv_withdraw a:hover {
		color: #fff;
		background: #26e12f;
	}

	.project-short {
		margin-bottom: 10px;
	}
	/*  textarea#chipin_message.roundedcorners */
	textarea#pleaselogin.roundedcorners {
		width: 56%;
		/*background: red !important;*/
	}
	
	.progressbar {
		-webkit-border-radius: 50px;
		-moz-border-radius: 50px;
		border-radius: 50px;
		background: #ddd;
		text-align: center;
		display: block;
		color: #ddd;
		height: 10px;
		overflow: hidden;
		padding: 0;
		-moz-transition: all 0.3s ease 0s;
		-webkit-transition: all 0.3s ease 0s;
		-o-transition: all 0.3s ease 0s;
		-ms-transition: all 0.3s ease 0s;
		transition: all 0.3s ease 0s;
		text-transform: uppercase;
		letter-spacing: 2px;
		font-size: 8px;
		font-weight: 300;
	}
	
	a#enternow {
		background: #000;
		color:#bbb;
		width:auto;
		padding:5px 15px 7px;
		font-size:15px;
		-webkit-border-radius: 50px;
		-moz-border-radius: 50px;
		border-radius: 50px;
		text-shadow:0px 0px 0px;
	}
	a#enternow:hover { color:#fff; }
	.userinfo, .agotime { display:inline; }
	.scrollup {
		bottom: 102px !important;
	}
	a.tribtn {
		float:left; display:inline; width:31.33%; margin:0 1%; text-align:center;
		box-sizing: border-box; -webkit-box-sizing: border-box;
		-moz-box-sizing: border-box; background:#f7f7f7; color:#dd1000;
		webkit-box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1), 0 0 2px rgba(255, 255, 255, 0.1) inset, 0 1px 2px rgba(255, 255, 255, 0.2) inset;
		border-radius: 4px; -moz-border-radius: 4px; -webkit-border-radius: 4px;
	}
	a.tribtn:hover {
		background:#ec5843;
		color:#fff;
	}
	.nav-tabs > li > a { font-size: 17px; }
	.project-short .top-project-info {
		padding: 0px 0px 0px;
	}
	.big-thumb .content-info-short .thumb-img {
		float: none;
		width: auto;
		padding: 0px;
	}
	.content-info-short .thumb-img { margin-top: 0px; }
	
	.layout-2cols { padding-top:15px; }
	
	.rslides img  {
		max-height:420px;
	}
	
	.content-info-short .thumb-img img {
		
	}

	.btn-o, .btn-oo a, input[type="submit"].btn-o, input#checkoutandpay.btn-o, a.btn-o {
		color: #FFF;
		text-transform: uppercase;
		font-weight: 700;
		background: #0297CF;
		color: #fff;
		border: 1px solid #0088bb;
		padding: 15px 10px;
		width: 100% !important;
		max-width:700px !important;
		display: inline-block;
		font-family: 'Open Sans', Montserrat,Arial,sans-serif;
		font-size: 14px;
		-webkit-border-radius: 3px;
		-moz-border-radius: 3px;
		border-radius: 3px;
	}

	.btn-o:hover, input#checkoutandpay.btn-o:hover, a.btn-o:hover {
		background: #00a5e4;
	}
	
	.darkoverlay {
		position: fixed;
		top: 0;
		left: 0;
		width: 100%;
		height: 100%;
		z-index: 50;
		background: rgba(0, 0, 0, 0.75);
	}	
	
	.fa-chevron-down.open {
		transform: rotate(180deg);
		transition: transform .3s linear;
	}
	.fa-chevron-down {
		transform: rotate(0deg);
		transition: transform .3s linear;
	}

	/* ########################################################################## */
	/* #####################         MOBILE STYLING         ##################### */
	/* ########################################################################## */

	/* ######################### */
	/*     Browser Min-Width     */
	/* ######################### */

	@media (max-width: 786px) {
		.layout-2cols {
			width: 100%;
			padding:15px 10px 0 !important;
			-webkit-box-sizing: border-box;
			-moz-box-sizing: border-box; box-sizing: border-box;
		}
		.topbackarrow { display:none; }
	}

	/* ######################### */
	/*     Browser Min-Width     */
	/* ######################### */

	@media (max-width: 586px) {
		div.spacer {
			padding-top: 53px;
		}
		.scrollup {
			bottom: 102px !important;
		}
		.layout-2cols { padding-top:7px; }
		.near-me-wrapper {
			margin-top: 0px !important;
		}
		.halfdiv {
			width: 100%;
			display: block;
		}
		#joinBlock {
			width: 67%;
			padding-right: 3%;
		}
		.rslides img  {
			max-height: 210px;
		}
		.project-short .top-project-info {
			padding: 0px 0px 0px;
		}
		.nav-tabs > li > a {
			color: #5c666b;
			font-weight: 600;
			font-size: 13px;
			padding: 9px 7px;
			border-radius: 4px 4px 0 0;
			-webkit-border-radius: 4px 4px 0 0;
			-moz-border-radius: 4px 4px 0 0;
		}
		#errordiv, #errordiv_chipin {
			margin-top: 12px;
		}
		.project-detail .project-title {
			font-size: 28px;
			line-height: 38px;
			padding-bottom: 10px;
			font-weight: 400;
			text-shadow:0px 1px 0px #fff;
		}
		h2.rs.project-title {
			padding-left: 10px;
			padding-right: 10px;
			/*line-height:47px;*/
		}
		h2.rs.group-title, h3.rs.title-inside {
			text-align: left;
			color: #111;
			text-shadow: 0px -1px 0px #fff;
			font-size: 25px;
			line-height: 33px;
			text-transform: inherit;
			font-family: 'Open Sans',Raleway,Montserrat,Oswald,Helvetica,sans-serif;
			font-weight: 400;
			margin-bottom: 15px;
			padding-top: 0px;
			padding-left: 0px;
		}
		.editor-content p {
			font-weight: 400 !important;
		}
		.big-thumb .content-info-short .thumb-img {
			float: none;
			width: auto;
			padding: 0px;
		}
		.content-info-short .thumb-img {
			margin-top: 0px;
		}
		.project-short {
			margin-bottom: 10px;
		}
		.project-detail .editor-content, .project-detail .tab-pane-inside {
			padding: 15px 15px;
		}
		.project-detail .project-btn-action {
			padding: 10px 10px;
		}
		.btn-black, .btn-black a, a.btn-black {
			max-width: 150px;
		}
		/*  #post_chipin  */
		#chipinunlogged {
			/*display: block !important;
			width: 100% !important;
			margin: 15px auto !important;
			font-weight: 300;
			color: #fff;*/

			/*		float:left; width:17%; min-width:70px; margin-top: 5px;
			height:40px; margin-bottom: 15px; text-align:center; padding-left:10px;
			padding-right:10px;*/
		}
		/*   textarea#chipin_message.roundedcorners */
		textarea#pleaselogin.roundedcorners {
			width: 69%;
			float: right !important;
			margin-right: 0 !important;
			/*background: blue !important;*/
		}
		.agotime {
			display: block; width:100%; margin-top:-5px;
		}
	}

	/* ######################### */
	/* Landscape phones and down */
	/* ######################### */
	@media (max-width: 480px) {
		div.spacer {
			padding-top: 54px;
		}
		.near-me-wrapper {
			margin-top: 0px !important;
		}
		.halfdiv {
			width: 100%;
			display: block;
		}
		.project-short .top-project-info {
			padding: 0px 0px 0px;
		}
		/* or .nav > li > a */
		.nav-tabs > li > a {
			font-weight: 600;
			font-size: 13px;
		}
		/* textarea#chipin_message.roundedcorners */
		textarea#pleaselogin.roundedcorners {
			width: 65%;
			float: right !important;
			margin-right: 0 !important;
			/*background: green !important;*/
		}
	}
	
	/* ######################### */
	/* Landscape phones and down */
	/* ######################### */
	@media (max-width: 375px) {
		#pleaselogintojoin, #joinmob {
			font-size:14px;
		}
	}
	
</style>

<!--<form action="/challenge/comment/<?= $project['id']; ?>" method="post">
	<label style="margin-left: 5px; margin-top: 5px; font-weight:300;
		font-family:Montserrat,Raleway,'Open Sans',Helvetica,sans-serif">Your
		Comment/Question/Message :</label><br />
	<textarea class="roundedcorners" name="message" id="comment_message"
        style="width: 95%; margin-left:5px; height:100px; margin-top: 5px;
		border:1px solid #ccc; padding:15px; font-size:17px;
		line-height:25px; -webkit-box-sizing: border-box; 
		-moz-box-sizing: border-box; box-sizing: border-box;
		border-radius: 8px; -moz-border-radius:8px; 
		-webkit-border-radius: 8px;"></textarea><br />

	<button id="post_comment" type="submit" class="btn btn-blue" 
	style="margin-left:10px; margin-top: 15px; margin-bottom: 15px; 
	padding:10px 25px">Post Now</button>
</form>-->

<div style="display:none;">
	<div id="review" class="loginFrm" style="width:100% !important; font-size:17px; 
	font-weight:300;">
		<div class="overlay-bl-bg" style="width:100% !important;"></div>
		<div class="container_12 pop-content" style="background:transparent !important;
		 min-width:300px; max-width:400px;">
			<div class="grid_12" style="">
				<div class="form login-form" style="background:none !important;">
					<form method="post">
						<div class="box-white" style="height:auto; padding-bottom:10px; border:0px; 
						margin-bottom:0px">
							<h4 class="rs title-box" style="text-align:center; margin-bottom:7px;">
								Leave a Comment
							</h4>
							<center>or, ask a question</center>
							<br />
							<div class="form-action">

								<center>
									<input name="project_id" type="hidden" value="<?= $project['id']; ?>" />
									<input name="user_id" type="hidden" value="<?= $_SESSION['user']['id']; ?>" />
									<textarea name="content" class="txt fill-width"
									style="height:100px"></textarea>

								</center>
								<br />
								<p class="rs ta-c" style="margin-bottom:0px; padding-bottom:0px;">
									<button class="btn btn-black btn-submit" type="submit">Submit</button>
								</p>
							</div>
						</div>
					</form>
				</div>
			</div>
			<div class="clear"></div>
		</div>
	</div>

</div>
<!-- END OF ALL LIGHTBOXES -->

<?php
if (isset($_GET['msg']) && $_GET['msg'] =='Withdrawn') {
	echo "<div id='errordiv' style='line-height:25px; text-align:center; background:#ff0000; color:#fff;
	padding:11px 15px; border:0px solid #fff; font-weight:300; font-size:15px;'>
		You have successfully withdrawn.
		&nbsp;<a href='/challenge/$id?ok' style='font-weight:400;'>Ok!</a>
	</div>";
}
?>

<?php
if (isset($_GET['msg']) && $_GET['msg'] =='proposal') {
	echo "<div id='errordiv' style='line-height:25px; text-align:center; background:#ff0000; color:#fff;
	padding:11px 15px; border:0px solid #fff; font-weight:300; font-size:15px;'>
		You have joined this Challenge.
		&nbsp;<a href='/challenge/$id?ok' style='font-weight:400;'>Ok!</a>
	</div>";
}
?>

<!-- //////////////////////////////////////////////////////////////////////// -->
<!-- //////////////////////////    START OF PAGE   ////////////////////////// -->
<!-- //////////////////////////////////////////////////////////////////////// -->

<div id="dark_overlay" style=""></div>
<div style="height:32px; background:none; margin-top:17px; margin-left:17px; overflow:hidden; 
position:absolute; z-index:999999999999;">
	<a href="/category/all" style="float:left;" class="topbackarrow">
	<img src="/static/system/icons/back_arrow_button.png"
	alt="<" style="height:25px; width:25px; margin-top:7px; margin-right:7px;"
	align="left" /></a>
</div>

<div class="layout-2cols" style="">
	<div class="content grid_8">
		<div class="project-detail">
			<?php if (!empty($project['images'])) { ?>
			<div class="project-short big-thumb" style="display:nonex; border-radius:12px; 
				-moz-border-radius:12px; -webkit-border-radius: 12px; overflow:hidden;">
				<div class="top-project-info">
					<div class="content-info-short clearfix">
						<div class="thumb-img">
							<div class="rslides_container">
								<ul class="rslides" id="slider1">
									<?php
									foreach ($project['images'] as $img) {
										if (!empty($img) && $img['type'] == 'image') {
											echo "<li><img src='/{$img['file']}' alt='{$img['title']}'
											style='object-fit:cover; object-position:center center;'
											onerror=\"this.src='/static/system/default_listing_banner.png'\"></li>";
										}
									}
									?>
								</ul>
							</div>
						</div>
					</div>
				</div>
			</div>
			<?php } ?>
			
			<h1>
				<?= $project['title'] ?>
			</h1>
			
			<div style="font-size:18px; line-height:28px;
			font-family: Montserrat,'Open Sans',Helvetica,Verdana,sans-serif;">
				<?= $project['prize'] ?>
			</div>
			<div class="clear"></div>
			<br />
			
			<div class="project-date clearfix" style="text-align:left; font-size:15px;
				line-height:25px;
				font-family: Montserrat,'Open Sans',Helvetica,Verdana,sans-serif;">

				By <a href="/profile/<?= $project['user']['user_slug'] ?>"
					class="be-fc-orange" style="font-size:14px; font-weight:600;
					font-family: Montserrat,'Open Sans',Helvetica,Verdana,sans-serif;"><?= $project['user']['name'] ?></a> | <i class="fa-regular fa-calendar" aria-hidden="true"></i> Published on <span style=""><?= date("F d, Y g:iA T", strtotime($project['timestamp_posted'])) ?></span>
				<span style="float:right;"><i class="fa-regular fa-message"></i>
				<span style="font-weight:700"><?= $project['comments_count'] ?></span> Comments</span>
			</div>
			<br /><br />
			 
			<div style="font-size:17px; line-height:27px; 
			font-family:Montserrat,'Open Sans',Helvetica,Verdana,sans-serif">
				<?= $project['description'] ?>	
			</div>
			<br />
			
			<div style="border-top:3px solid #ccc; width:150px; margin:0 auto;">&nbsp;</div>

			<div class="newblue" style="position:relative; float: none; overflow: hidden; height:auto;
				max-width:820px; background:none; -webkit-box-sizing: border-box;
				-moz-box-sizing: border-box; box-sizing: border-box; margin-top:7px;
				font-size:14px; line-height:20px; font-weight:300; text-align:center;">
				
				<span style="color:#999; font-weight:400">topics:</span>
				<?php
				$tags = explode (",", $project['tags']);
				$allExceptLast = count($tags) - 1;
				$i = 1;
				foreach ($tags as $tag) {
					if (!empty($tag)) {
						echo "<a href='/category/all?search=" . trim($tag) . "' 
						style='font-weight:400' class='be-fc-orange'>" . trim($tag) . "</a> ";
					}
					if ($i <= $allExceptLast ) {
						echo " &bull; ";
					} else {
						echo "";
					}
					$i++;
				}
				?>
			</div>
			<div class="clear"></div>
			<br /><br /><br />
			
			<!-- /////////////////////////////////////////////////////////////////////////////// -->
			<!-- /////////////////////////           COMMENTS           //////////////////////// -->
			<!-- /////////////////////////////////////////////////////////////////////////////// -->
			
			<div style="text-transform: uppercase; font-weight:700; font-size:48px; color:#ccc; 
				font-family:Montserrat,'Open Sans',Helvetica,Verdana,sans-serif;">
				Comments
			</div>
			<div class="clear"></div>
			<br />
			<div class="list-last-post">
				<?php if (isset($_SESSION['user_id']) && isset($_SESSION['loggedin'])) : ?>
				<form action="/blog/comment/<?= $blog['id']; ?>" method="post">
						<label style="margin-left:5px; margin-top:5px;">Your Comment/Message:</label>
						<br />
						<textarea class="roundedcorners" name="message" id="comment_message"
	                        style="width: 95%; margin-left:5px; height:100px;
	                        margin-top: 5px;"></textarea>
						<br /><br />

						<button id="post_comment" type="submit" class="btn btn-blue" 
						style="margin-left:10px; margin-top: 5px; 
						margin-bottom: 15px; float:right;">Post Now</button>
					</form>
			
				<?php else : ?>
					<label style="margin-left: 5px; margin-top: 5px; 
					font-weight:300;">Your Comment/Message:</label>
					<br /><br />
					<div style="float:left; width:50px; margin:0; height:53px; background:none;
				    line-height:55px; text-align:left; margin-right:5px">
						<img src="/static/system/default_avatar.png" alt="User" style="float:left; 
						display:inline-block; border-radius:0px; width:44px; height:44px; 
						border:3px solid #eee; -webkit-border-radius:50px; 
						-moz-border-radius:50px; border-radius:50px;" />
					</div>

					<div style="position:relative; float: none; overflow: hidden; height:55px;
					max-width:820px; background:none; -webkit-box-sizing: border-box;
					-moz-box-sizing: border-box; box-sizing: border-box;">
						<input type="text" placeholder="Join the Conversation..." id="unlogged"
						style="padding:15px;
						font-size:17px; color:#ccc; width:100%; margin:0; box-sizing: border-box;
						-webkit-box-sizing: border-box; -moz-box-sizing: border-box;
						-webkit-border-radius: 8px; -moz-border-radius: 8px; border-radius: 8px;
						border:1px solid #ccc;">
					</div>
					<br />
					<a href="javascript:;" class="btn btn-black" 
						id="unlogged2" style="float:right;">Post Now</a>
					<br />
				<?php endif; ?>
				<div class="clear"></div>

				<?php if (!$_SESSION['loggedin']) : ?>

				<?php endif; ?>
				<br />
				<div id="comments-list" style="-webkit-border-radius: 12px; -moz-border-radius: 12px;
					border-radius: 12px; overflow:hidden;">

					<?php include ("comments.tpl.php"); ?>

				</div>
			
			</div>
			
			<!-- /////////////////////////////////////////////////////////////////////////////// -->
			<!-- /////////////////////////         END COMMENTS         //////////////////////// -->
			<!-- /////////////////////////////////////////////////////////////////////////////// -->
			
			<?php //echo "<pre>" . print_r($_COOKIE) 
				//. "<br /><br /><pre>" .
				//print_r($_SESSION)
			?>

			<!--<a href="/challenge/<?= $project['id'] ?>?clear=1">Clear Cache</a>-->

			<div class="clear"></div>
			<!--<br /><br /><br />-->

		</div><!-- end of project-detail -->
	</div><!--end: .content grid_8 -->
	
	<!-- /////////////////////////////////////////////////////////////////////////////////// -->
	<!-- ///////////////////////////      RIGHT SIDEBAR AREA      ////////////////////////// -->
	<!-- /////////////////////////////////////////////////////////////////////////////////// -->	
	<div class="sidebar grid_4" style="background:none;">
		
		<!--******************************************************
		FAVORITES
		*******************************************************-->
		<div class="favorite-data" data-uid="<?= $_SESSION['user_id'] ?>"
            data-pid="<?= $project['id'] ?>" data-type="listings">
			<?php if ($is_favorited_project) : ?>
			<a class="btn btn-red btn-buck-project toggle-favorite" href="#">
				<span style="font-weight:normal;"><i class="fa fa-star"></i> 
				Remove Favorite &raquo;</span>
			</a>
			<?php else
				: ?>
			<a class="btn btn-red btn-buck-project toggle-favorite" href="#">
				<span style="font-weight:normal;"><i 
				class="fa fa-star"></i> Add Favorite &raquo;</span>
			</a>
			<?php endif; ?>
		</div>
		<!--******************************************************
		END FAVORITES
		*******************************************************-->
		<!-- https://fantasytrivia.com/pay/?mID=4&cID=300&mE=sillystats@gmail.com&eP=0.25 -->

<!--		<a class="btn btn-green review btn-buck-project" href="/challenges/all"
				style="display:block; font-size:15px; padding:15px; font-weight:400;">
			Join this Challenge
			<i class="fa fa-angle-right" aria-hidden="true"></i>
		</a>-->
		<br />
		<a class="btn btn-gray review btn-buck-project" href="/category/all"
			style="display:block; font-size:15px; padding:15px; font-weight:400; 
			text-transform: none;">
			Back to Categories <i class="fa fa-angle-right" aria-hidden="true"></i>
		</a>
		<br />
		
		<div class="box-gray" style="margin-top:10px; padding-bottom: 15px;">

			<div style="font-size:17px; line-height:25px; font-weight:300;">
				<span style="font-weight:600">SHARE THIS</span> POST/ARTICLE
			</div>
			
			<div style="font-size:11px; margin-left:20px; margin-bottom:5px; margin-top:10px;">
				click to copy instantly
			</div>
			<textarea style="width:90%; max-width:400px; height:24px;
					margin-bottom:3px; font-size:15px; text-align:left; margin:0 auto;
					padding:15px 15px 12px; border:2px solid #00A1FE;
					-moz-border-radius: 50px; border-radius: 50px; -webkit-border-radius: 50px;
					background:#fff; color:#00A1FE; font-weight:500;"
					rows="3"
					onclick="this.focus();this.select()">https://base.basepages.com/blog/<?= $project['id'] ?></textarea>

			<br /><br />
			<div style="display:none; font-weight:300; font-size:11px; line-height:17px;">
				Note: r = referral + your ID &amp; s = solution + the Solution ID
			</div>
			<div class="clear"></div>
		</div>

		<div class="project-runtime">

			<div class="box-gray" style="margin-bottom:0px;
					font-family: Montserrat,'Open Sans',Helvetica,Verdana,sans-serif !important;">
				<div class="project-date clearfix">
					<span class="val">
					<i class="fa-regular fa-calendar"></i> <span class="fw-b" 
					style="font-family: Montserrat,'Open Sans',Helvetica,Verdana,sans-serif !important;">Created: </span></span> <span style="float:right;"><?= date("g:iA m/d/y", strtotime($project['timestamp_posted'])) ?></span>
				</div>

				<?php if ($_SESSION['loggedin']) : ?>

				<?php if ($project['user']['id'] == $_SESSION['user_id']) : ?>
				<!--<a class="btn btn-blue btn-buck-project" 
				href="/project/invite/<?= $project['id'] ?>">
					Invite users &raquo;
				</a>-->
				<?php endif; ?>

				<!-- FAVS / FAVORITES WAS HERE -->

				<span id="data-project-status" style="display:none;"><?= $project['status'] ?></span>
				<span id="data-project-id" style="display:none;"><?= $project['id'] ?></span>
				<span id="data-current-user" style="display:none;"><?= $_SESSION['user_id'] ?></span>

				<a class="btn btn-blue review btn-buck-project" href="#review">
					Ask Question &raquo;
				</a>

				<?php endif; /* logged_in */ ?>
				
				<?php
				if ($project['user_id'] == $_SESSION['user_id'] || $_SESSION['user']['is_admin']==1)
					: ?>
				<!-- red button -->
				<!--<a class="btn btn-red btn-buck-project" href="/blog/<?= $project['id'] ?>/edit">
					<span style="font-weight:normal;">Edit Post &raquo;</span>
				</a>-->
				<!-- EDIT BUTTONS HOLDER -->
				<div style="background:none; height:50px; line-height:50px;">
				
					<a class="tribtn" href="/blog/<?= $project['id'] ?>/edit">
						<span style="font-weight:normal;">Edit &raquo;</span>
					</a>
					<a class="tribtn" href="/blog/<?= $project['id'] ?>?delete=<?= $project['id'] ?>"><span style="font-weight:normal;">Delete &raquo;</span>
					</a>
					<a class="tribtn" href="/blog/<?= $project['id'] ?>?duplicate=<?= $project['id'] ?>"><span style="font-weight:normal;">Duplicate &raquo;</span>
					</a>	
				</div>
				<?php endif; ?>
			
			</div>
		</div><!--end: .project-runtime -->

		<br />
		<div class="project-author">
			<div class="box-gray" style="margin-bottom:0px; border-bottom:0px !important;">
				<h3 class="title-box">Created by</h3>
				<div class="media newblue" style="border-bottom:0px !important;">
					<a href="/profiles/<?= $project['user']['user_slug'] ?>" class="thumb-left"
						style="-webkit-border-radius: 50px;
						-moz-border-radius: 50px; border-radius: 50px;">
						<img src="<?= getThumb($project['user']['image']) ?>" 
						onerror="this.src='/static/system/default_avatar.png'"
						alt="<?= $project['user']['name'] ?>" style="-webkit-border-radius: 50px; 
						-moz-border-radius: 50px; border-radius: 50px;" />
					</a>

					<div class="media-body" style="display:nonex; border-bottom:0px !important;">
						<h4 class="rs pb10">
							<a href="/profile/<?= $project['user']['user_slug'] ?>"
								class="be-fc-orange fw-b" style="font-size:17px;
								font-family: Montserrat,'Open Sans',Helvetica,Verdana,sans-serif;"><?= $project['user']['name'] ?></a>
						</h4>
						<p class="rs"><?= $project['user']['location'] ?></p>
						<p class="rs fc-gray"><?= $project['user']['project_count'] ?> Challenges</p>
						<p class="rs fc-gray"><?= $project['user']['reviews_count'] ?> Comments</p>
						<!--<p class="rs fc-gray">Ave: <?= $project['user']['avg_rating_given'] ?></p>-->
					</div>
					<div class="clear"></div>
				</div>
				<div class="author-action" style="display:none;">
					<!--                         <a class="btn btn-blue" href="#">Buy Credits</a> -->
					<a class="btn btn-white" href="/profiles/<?= $project['user']['user_slug'] ?>">See full bio</a>
				</div>
			</div>
		</div><!--end: .project-author -->
		<div class="clear clear-2col"></div>

		<br />
		
<!--		<?php if ($_SESSION['user_id']) : ?>
			<div class="project-runtime">
				<div class="box-gray" style="margin:0px;">
					<a class="btn btn-blue review btn-buck-project" href="#review" style="margin:0;">
						Leave Comment &raquo;
					</a>
				</div>
			</div>
		<?php else : /* logged_in */ ?>
			<div class="project-runtime">
				<div class="box-gray" style="margin:0px;">
					<a class="btn btn-blue btn-buck-project" id="pleaselogin3" style="margin:0;">
						Leave Comment &raquo;
					</a>
				</div>
			</div>		
		<?php endif; /* logged_in */ ?>-->
		
		<div class="box-gray" style="margin-top:10px; display:none;">
			<h3 style="font-size:2em; line-height:2em; font-family:Montserrat; padding-top:0px; 
			margin-top:-10px; padding-bottom:0px; margin-bottom:0px; text-transform:uppercase; 
			font-weight:300; color:#ccc;">

				Recent Comments

			</h3>

			<!-- <div class="form login-form" style="background:none !important;">
			<form method="post" style="margin-block-end: 0em;">
			<div class="form-action" style="padding:0;">
			<center>
			<input name="project_id" type="hidden" value="<?= $project['id']; ?>" />
			<input name="user_id" type="hidden" value="<?= $_SESSION['user']['id']; ?>" />
			<textarea name="content" class="txt fill-width"
			style="height:100px; margin-bottom:5px;"></textarea>
			</center>

			<p class="rs ta-c" style="margin-bottom:0px; padding-bottom:0px;">
			<button class="btn btn-black btn-submit" type="submit">Submit</button>
			</p>
			</div>
			</form>
			</div>
			<div class="clear"></div>
			<br />-->

			<div style="border-top:3px solid #ccc; width:150px; margin:0 auto;">&nbsp;</div>

			<!--<div id="comments-list2" class="newblue" style="overflow:hidden;">-->
				<!--<?php include ("comments.tpl.php"); ?>-->

				<!--<?php
				echo "<pre>";
				print_r($project['comments']); ?>-->

			<!--</div>-->
		</div><!-- BOX GRAY ENDS -->
		<div class="clear"></div>
		
		<br />
		<center><a href="javascript:top.frames.location.reload();"
		class="refresh" style="color:#ccc; font-weight:800; font-size:17px;">
		<i class="fa fa-refresh" aria-hidden="true"></i> Refresh</a></center>

		<!--<div class="clear"></div>-->
	</div><!--end: .sidebar -->
	<div class="clear"></div>
</div>
<br /><br />
<!--/////////////////////////////////////////////////////////// -->
<!-- END OF GENERAL PAGE -->
<!--/////////////////////////////////////////////////////////// -->

<!-- PAGEVIEWS -->
<div class="" style="text-align:center; padding:0 0 20px 0; font-weight:300; font-size:14px;">

	<div style="float:left; width:50%; background:none; text-align:right;">
		<div style="padding:0px">
			<img src="/static/system/icons/counter_icon.png" alt="i" align="absmiddle"
			style="height:20px; margin-bottom: 2px; margin-right: 2px;">
			<span class="val"><span class="fw-b"><?= number_format($pageviews,0,'',','); ?></span>
				Pageviews</span>
		</div>
	</div>
	<div style="float:left; width:50%; background:none; text-align:left;">
		<div style="padding:0px">
			<img src="/static/system/icons/counter_icon.png" alt="i" align="absmiddle"
			style="height:20px; margin-bottom: 2px; margin-left:11px; margin-right: 2px;">
			<span class="val"><span class="fw-b"><?= number_format($uniqueviews,0,'',','); ?></span>
				Uniques</span>
		</div>
	</div>
	<div class="clear"></div>
	<br /><br /><br /><br />
</div>
<!-- PAGEVIEWS ENDS -->
<br /><br />

<?php include 'views/_footer_m.tpl.php'; ?>

<!-- /////////////////////////////////////////////////////////////////////////////////// -->
<!-- ///////////////////////////      FIXED BOTTOM AREA      /////////////////////////// -->
<!-- /////////////////////////////////////////////////////////////////////////////////// -->	
	 
<div style="position:fixed; bottom:0; left:0; right:0; min-height:55px; width:100%; color:#000; 
background:rgba(255,255,255,.75); font-size:17px; line-height:45px; padding:10px 15px 10px; text-align:center; box-sizing: border-box; -webkit-box-sizing: border-box; -moz-box-sizing: border-box;
font-family:Montserrat,'Open Sans',Helvetica,Verdana,sans-serif; z-index:9999999999999999999;
backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px) saturate(100%) contrast(60%) brightness(130%); -webkit-box-shadow: 0px -4px 3px rgba(50, 50, 50, 0.15); -moz-box-shadow: 0px -4px 3px rgba(50, 50, 50, 0.15); box-shadow: 0px -4px 3px rgba(50, 50, 50, 0.15);"> 
	
	<span style="float:left;"><a href="/category/all" style="outline:none;">
		<i class="fa-solid fa-list" aria-hidden="true"></i> Categories</a></span>
	
	<span style="float:right;"><a href="javascript:;" id="openCats" style="outline:none;">
		<i class="fa-regular fa-calendar" aria-hidden="true"></i> Leave Comment</a></span>
		
	<div class="clear"></div>
</div><!-- FIXED BOTTOM AREA ENDS HERE -->

<!-- /////////////////////////////////////////////////////////////////////////////////// -->
<!-- ///////////////////////////       SLIDE UP MODAL        /////////////////////////// -->
<!-- /////////////////////////////////////////////////////////////////////////////////// -->

<!-- #################################### -->
<!-- ####      SLIDE UP MODAL       ##### -->
<!-- #################################### -->
<!-- margin-bottom:-45px; z-index: 9999 from profile page -->
<div id="categories_slide_up" style="display:none; z-index: 51; position:fixed; bottom:0; left:0; 
width:100%; height:350px; background:#fff; -webkit-border-radius: 7px; -moz-border-radius: 7px; 
border-radius: 7px; webkit-box-shadow: 0 -3px 9px rgb(0 0 0 / 90%); box-shadow: 0 -3px 9px rgb(0 0 0 / 90%);">

	<!-- ################################### -->
	<!-- #######  TOP MODAL BAR AREA ####### -->
	<!-- ################################### -->
	<div style="height:50px; background:none;">
		<div style="height:30px; width:220px; line-height:50px; background:none; font-size:19px; 
		line-height:30px; font-weight:600; color:#ddd; float:left; padding-left:15px; 
		margin-top:10px;">
			COMMENT
		</div>

		<div style="float:right; margin-right:5px; margin-top:10px; width:30px; height:30px; 
		text-align:center; padding:5px; background:none;" id="closeCats">
			<a href="#" class="closeCats" style="color:#fff;"><img 
			src="/static/system/icons/close_x_black.png" style="height:25px;" /></a>
		</div>
	</div>

	<!-- ################################### -->
	<!-- #######     COMMENT FORM    ####### -->
	<!-- ################################### -->
	<div style="padding: 0px 20px 25px; overflow:auto; max-height:330px;">
		
		<?php if (isset($_SESSION['loggedin']) && isset($_SESSION['user']['id'])) { ?>
			<div style="font-family:Montserrat,'Open Sans',sans-serif; text-align:left; 
			margin-top:7px; margin-bottom:11px; font-size:17px; color:#000">
				<form action="/blog/comment/<?= $blog['id']; ?>" method="post">
					<label style="margin-left:5px; margin-top:5px;">Your Comment/Message:</label>
					<br />
					<textarea class="roundedcorners" name="message" id="comment_message"
                        style="width: 100%; min-height:100px; margin-top: 5px;
						-webkit-box-sizing: border-box; -moz-box-sizing: border-box; 
						box-sizing: border-box; border:1px solid #ccc;"></textarea>
					<br /><br />

					<button id="post_comment" type="submit" class="btn btn-black" 
					style="margin-left:10px; margin-top: 5px; 
					margin-bottom: 15px; float:right;">Post Now</button>
				</form>			
			</div>
					
		<?php } else { ?>
			<div style="font-family:Montserrat,'Open Sans',sans-serif; text-align:center; 
			margin-top:7px; margin-bottom:11px; font-size:17px; color:#000">
				<label style="margin-left: 5px; margin-top: 5px; 
				font-weight:300;">Your Comment/Message:</label>
				<br /><br />
				<div style="float:left; width:50px; margin:0; height:53px; background:none;
			    line-height:55px; text-align:left; margin-right:5px">
					<img src="/static/system/default_avatar.png" alt="User" style="float:left; 
					display:inline-block; border-radius:0px; width:44px; height:44px; 
					border:3px solid #eee; -webkit-border-radius:50px; 
					-moz-border-radius:50px; border-radius:50px;" />
				</div>

				<div style="position:relative; float: none; overflow: hidden; height:55px;
				max-width:1820px; background:none; -webkit-box-sizing: border-box;
				-moz-box-sizing: border-box; box-sizing: border-box;">
					<input type="text" placeholder="Join the Conversation..." id="unlogged"
					style="padding:15px;
					font-size:17px; color:#ccc; width:100%; margin:0; box-sizing: border-box;
					-webkit-box-sizing: border-box; -moz-box-sizing: border-box;
					-webkit-border-radius: 8px; -moz-border-radius: 8px; border-radius: 8px;
					border:1px solid #ccc;">
				</div>
				<br />
				<a href="javascript:;" class="btn btn-black" 
					id="unlogged2" style="float:right;">Post Now</a>
				<br />
			</div>
		<?php } ?>

		<br /><br /><br /><br /><br /><br />
	</div>
	<div style="display:none; position:absolute; bottom:0; left:0; width:30px; height:30px; 
	float:left; text-align:center; padding:10px; background:none;" id="closeCats">
		<a href="#" class="closeCats" style="color:#fff;"><img 
		src="/static/system/icons/close_x_black.png" style="height:25px;" /></a>
	</div>
</div>	

<script>
	$(".review").fancybox({
		'hideOnContentClick': true
	});
	$(".req").fancybox({
		'hideOnContentClick': true
	});
	$(".proposal").fancybox({
		'hideOnContentClick': true
	});

	var nextImage = new Image();
	var unlockedLock = '/static/images/icons/unlocked_icon_sm_loop.gif';
	nextImage.src = unlockedLock;

	$('form').submit(function () {
		window.onbeforeunload = function () { }
	});

	$('.unlock, .click-to-rate').click(function () {
		review_id = $(this).attr('review_id');
		lock_img = $(this).find('img');
		el = $(this).parent().parent().parent();

		$.ajax({
			type: 'POST',
			data: {
				'unlock-review': review_id
			},
			success: function (d) {
				try {
					d = JSON.parse(d);
				} catch (err) {
					if (d == 'notenough') {
						$.fancybox({
							'href' : '#notEnough'
						});
					}
					return;
				}

				if (lock_img.length > 0) {
					lock_img.attr('src', unlockedLock);
					timeoutDuration = 3570;
				} else {
					timeoutDuration = 100;
				}

				setTimeout(function () {
					el.find('.description').html(d.text);
					$('.accepted-reviews').prepend(el);

					$('#unlockedReview .review').html(d.text);
					$('#unlockedReview .poster').html(d.user.name);
					$('#unlockedReview [name=review_id]').val(d.id);

					$('#unlocked_count').html(parseInt($('#unlocked_count').html())+1);
					$('#reviews_count').html(parseInt($('#reviews_count').html())-1);

					$('.tabbable .nav-tabs li')[2].click();
					$.fancybox({
						'autoScale': true,
						'transitionIn': 'elastic',
						'transitionOut': 'elastic',
						'speedIn': 500,
						'speedOut': 300,
						'autoDimensions': true,
						'centerOnScroll': true,
						'href' : '#unlockedReview'
					});

					$(".fancybox-overlay, .fancybox-close").unbind('click');
					$(".fancybox-close").remove();

					$(".fancybox-overlay").bind('click', function (e) {
						if (e.target.className == 'fancybox-overlay fancybox-overlay-fixed') {
							$('#required').show();
						}
					})

					window.onbeforeunload = confirmExit;
					function confirmExit()
					{
						return "Please leave a rating before closing the page. Thank you!";
					}

					setTimeout('$(".fancybox-close").remove();', 500);
				}, timeoutDuration);
			}
		})
	});

	$(".deny-candidate-trigger").click(function(e) {
		e.preventDefault();

		var aid    = $(this).parent(".toggle-appointment-status").attr("data-aid");
		var status = $(this).parent(".toggle-appointment-status").attr("data-status");

		$.ajax({
			url: "/challenge/ajaxToggleProposalStatus",
			type: "post",
			data: {
				aid: aid,
				status: status
			},
			success: function(d) {
				var d = eval(d);

				if (d == 1)
					$(".appointment-approval-wrapper[rel='" + aid + "']").html("<p style='color:#02B502;'>This candidate was hired!</p>");
				else
					$(".appointment-approval-wrapper[rel='" + aid + "']").html("<p style='color:#f00;'>This candidate was rejected!</p>");
			}
		});

		return false;
	});

	// register popin for properties details
	$(".hire-candidate-trigger").each(function() {
		var href = $(this).attr("href");
		$(this).fancybox({
			'autoDimensions': true,
			'transitionIn': 'elastic',
			'transitionOut': 'elastic',
			'speedIn': 500,
			'speedOut': 300,
			'centerOnScroll': true,
			'type': 'ajax',
			'href': href,
			onComplete: function() {
				$(".fancybox-wrap").css("top", "110px");
			}
		});
	});

	$(".proposal-status-trigger").each(function() {
		var href = $(this).attr("href");
		$(this).fancybox({
			'autoDimensions': true,
			'transitionIn': 'elastic',
			'transitionOut': 'elastic',
			'speedIn': 500,
			'speedOut': 300,
			'centerOnScroll': true,
			'type': 'ajax',
			'href': href,
			onComplete: function() {
				$(".fancybox-wrap").css("top", "110px");
			}
		});
	});

	$(".add-dispute").each(function() {
		var href = $(this).attr("href");
		$(this).fancybox({
			'autoDimensions': true,
			'transitionIn': 'elastic',
			'transitionOut': 'elastic',
			'speedIn': 500,
			'speedOut': 300,
			'centerOnScroll': true,
			'type': 'ajax',
			'href': href,
			onComplete: function() {
				$(".fancybox-wrap").css("top", "110px");
			}
		});
	});

	$(".view-proposal").each(function() {
		var href = $(this).attr("href");
		$(this).fancybox({
			'hideOnContentClick': true,
			'autoDimensions': true,
			'transitionIn': 'elastic',
			'transitionOut': 'elastic',
			'speedIn': 500,
			'speedOut': 300,
			'centerOnScroll': true,
			'type': 'ajax',
			'href': href,
			onComplete: function() {
				$(".fancybox-wrap").css("top", "110px");
			}
		});
	});
</script>

<script type="text/javascript">
	$(document).ready(function() {
		//alert('doc ready works!');
		
		var standalone = window.navigator.standalone,
		userAgent = window.navigator.userAgent.toLowerCase(),
		//safari = /safari/.test( userAgent ),
		safari = /^((?!chrome|android).)*safari/i.test(navigator.userAgent);
		ios = /iphone|ipod|ipad/.test( userAgent );
		android = (window.matchMedia('(display-mode: standalone)').matches);

		//if (android == true) {}

		if (window.navigator.standalone == true) {
			//alert("You're using our Hybrid App!");
			// Super small phones
			if ($(window).width() <= 375) {
			}
			// iPad Portrait
			if ($(window).width() == 768) {
				//alert("You're using our Hybrid App!");
			}
			if ($(window).width() >= 1024) {
				//alert("You're using our Hybrid App and this is probably an iPad!");
			}
		} else {
			//alert('Not stand-alone');
			// NOT STAND-ALONE
			if ( ios ) {
				if ( !standalone && !safari ) {
					//alert("You're using the Native App.");
				};
				if ( !standalone && safari ) {
					//alert("You're using Mobile Safari.");
					// iPad Portrait
					//if ($(window).width() == 768) {
					//	alert("You're using our iPad upright version!");
					//}
				};
			} else {
				//alert("You're using desktop");
				if (safari) {
					//alert('Desktop AND Safari');
				} else {
					//alert('Desktop, but NOT Safari');
					//document.querySelector(".applepayblock").classList.add("hidden");
					//document.querySelector(".applepayalt").classList.remove("hidden");
					$(".applepayblock").addClass("hidden");
					$(".applepayalt").removeClass("hidden");
				}
			}
		}
		
		/////////////////////////////////

		$('#chevron_pp').click(function () {
			//alert('pp clicked');
			$("#chevron_pp").toggleClass('fa-chevron-down fa-chevron-down open');
			$("#moredetails").toggle();
		});

		$('#chevron_ppp').click(function () {
			//alert('ppp clicked');
			$("#chevron_pp").toggleClass('fa-chevron-down fa-chevron-down open');
			$("#moredetails").toggle();
		}); 
		
		// MODAL SLIDE UP
		$('#openQRTip,#closeQRTip').click(function () {
			//$("#dark_overlay").toggle("darkoverlay");
			$("#dark_overlay").toggleClass('darkoverlay');
			$('#bottom_qr_tip').slideToggle({
				direction: "up"
			}, 300);
			$(this).toggleClass('closeQRTip');
			//
		}); // end click

		// CATEGORIES SLIDE UP
		$('#openCats,#closeCats').click(function () {
			//$("#dark_overlay").toggle("darkoverlay");
			$("#dark_overlay").toggleClass('darkoverlay');
			$('#categories_slide_up').slideToggle({
				direction: "up"
			}, 50);
			$(this).toggleClass('closeCats');
			//
		}); // end click 
		
		$("#joinmob").click(function() {  // your submit button id
			//var isValid = document.querySelector('#myform')
			//if (isValid.checkValidity())
				$(".loading").show();
				setTimeout(function() { 
					//$(".loading").hide(); 
					$("#joinmob").hide();
					$("#openCats").hide();
				}, 1500);
				setTimeout(function() {
					$("#showyouvejoined").show(); 
					$("#showyouvejoined2").show(); 
				}, 1500);
				//$("#joinmob").hide(); 
				//$("#showyouvejoined").show(); 
		});
		
		$("#reserveform").click(function(e) {
			// $("#entercode").keyup(function(e){
			//$("#apply-ref").click(function(e){
			e.preventDefault();

			//alert('Reserve Clicked');
		});
		
		$("#chipin_amount").blur(function() {	
			var pledgeAmt = $("#chipin_amount").val();
			var minPledge = $("#chipin_minimum").val();
			// FIRST LET'S MAKE SURE IT COMPLIES WITH THE FREE PLEDGES
			
			if (parseInt(pledgeAmt) < parseInt(minPledge)) {
				alert('You must pledge a minimum of $' + minPledge + ' to reserve a spot.');
			}
			//alert('Pledge Amount: ' + pledgeAmt + ' Pledge Min. Required: ' + minPledge);
			
//			var yourBal = $("#your_balance").val();
//			if (pledgeAmt.length==0) {
//				alert('Please enter an amount to escrow first.');
//				$('#chipin_escrow').prop('checked', false); // Unchecks it
//				return false;
//			} else {
//				//alert('evaluate....');
//				if (parseInt(pledgeAmt) > parseInt(yourBal)) {
//					alert('Oooops, you don\'t have enough to escrow that amount.');
//					$('#chipin_escrow').prop('checked', false); // Unchecks it
//					return false;
//				} else {
//					if ($('#chipin_escrow').is(':checked')) {
//						$('#chipin_escrow').prop('checked', true);
//					} else {
//						$('#chipin_escrow').prop('checked', false); // Checks it
//					}
//					//$('#chipin_escrow').prop('checked', true); // Checks it
//					//alert('Good to go');
//				}
//			}
			//alert('Escrow checked! Your balance: ' + yourBal + ' and Escrow Amount: ' + escrowAmt);
			return true;			
		});
		
		// this is the Escrow Checkbox
		$("#chipin_escrow").click(function() {
			var escrowState = $('#chipin_escrow').prop('checked'); // true
			//var escrowAmt = $("#chipin_amount").val();
			var escrowAmt = $("#chipin_escrowamt").val();
			var yourBal = $("#your_balance").val();
			
			//e.preventDefault();
//			if ($('#chipin_escrow').is(':checked')) {
//				$('#chipin_escrow').prop('checked', true); // Checks it
//				//alert('Checked');
//				//$('#chipin_escrow').prop('checked', false);
//			} else {
//				$('#chipin_escrow').prop('checked', false);
//				//alert('Not checked');
//				//$('#chipin_escrow').prop('checked', true); // Checks it
//			}
			
			if (escrowState == true){	
				if (escrowAmt < 0) {
					alert('Oooops, you cannot enter negative amounts');
				}
				if(escrowAmt.length==0) {
					alert('Please enter an amount to escrow first or uncheck the Escrow checkbox.');
					//$('#chipin_escrow').prop('checked', false); // Checks it
					return false;
				} else {
					if (parseInt(escrowAmt) > parseInt(yourBal)) {
						alert('Oooops, you don\'t have enough to escrow that amount.');
						return false;
					} else {
						//var newBal = yourBal - escrowAmt;
						//var formattedBal = "$" + newBal.toLocaleString();
						//$(".mybal").html(formattedBal);
//						if ($('#chipin_escrow').is(':checked')) {
//							$('#chipin_escrow').prop('checked', true);
//						} else {
//							$('#chipin_escrow').prop('checked', false); // Checks it
//						}
						//alert('Good to go');
					}	
				}
			} else {
				//alert('evaluate....');	
			}
			//$('#chipin_escrow').prop('checked', true); // Checks it
			//alert('Escrow checked! Your balance: ' + yourBal + ' and Escrow Amount: ' + escrowAmt);
			//return true;
		});
		
	//////////////////////////////////////////////////////////////////////////////
	// EDIT PLEDGE / CONTRIBUTION FIELDS  
	//////////////////////////////////////////////////////////////////////////////
		
	// ESCROW CHECKBOX
		$('body').on( 'click', '.cancelbtn', function () {
			//alert('Clicked Cancel');
			$("#editSubmit").hide();
			$(".escrowCh").hide();
			$("#reserveAmt").hide();
			$("#escrowAmount").hide();
			$("#editText").hide();
			$(".escrowlabel").hide();
			$(".cancelbtn").hide();
		});
		
		$(".escrowChXXX").change(function() {
			alert('Escrow eval...');
		});
		
		$("#unlogged,#unlogged2").click(function() {
			alert('Please login first...');
			return false;
		});

		$("#pleaselogin,#pleaselogin2,#pleaselogin3,#chipinunlogged").click(function() {
			// $("#entercode").keyup(function(e){
			//$("#apply-ref").click(function(e){
			alert('Please login first...');
		});
		$("#pleaselogintojoin,#pleaselogintovote").click(function() {
			// $("#entercode").keyup(function(e){
			//$("#apply-ref").click(function(e){
			alert('Please login to join this mob or vote it up...');
		});
		// ~ LINE 355
		$("#reserveformunlogged,#reserveformunlogged2").click(function() {
			// $("#entercode").keyup(function(e){
			//$("#apply-ref").click(function(e){

			alert('Please login...');
			resmsg = "Please login...";
			$('.reservemsgunlogged').html('<center style="color:#29CE29; font-weight:500; font-size:15px">' + resmsg + '</center>');
			$('.reservemsgunlogged2').html('<center style="color:#29CE29; font-weight:500; font-size:15px">' + resmsg + '</center>');
			$('.reservemsgunlogged').delay(500).fadeOut('slow');
			$('.reservemsgunlogged2').delay(500).fadeOut('slow');
		});

		$(".more").click(function () {
			$(".morediv").slideToggle(0, function () {
			});
		});

		$(".review").fancybox({
			'hideOnContentClick': true
		});

		//	$(".req").fancybox({
		//		'hideOnContentClick': true
		//	});

		//	$('form').submit(function () {
		//	    window.onbeforeunload = function () { }
		//	});

		$(".toggle-favorite").click(function(e) {
			e.preventDefault();

			user_id   = $(this).parent(".favorite-data").attr("data-uid");
			object_id = $(this).parent(".favorite-data").attr("data-pid");
			type      = $(this).parent(".favorite-data").attr("data-type");

			$.ajax({
				url: "/challenge/ajaxToggleFavorite",
				type: "post",
				data: {
					uid: user_id,
					pid: object_id,
					type: type
				},
				success: function(d) {
					var d = eval(d);
					var t = "";
					if (d == -1)
						return false;

					if (d == 1) {
						// favorite added
						$(".toggle-favorite").removeClass("btn-blue");
						$(".toggle-favorite").addClass("btn-red");
						t = "<i class='fa fa-star'></i> Remove Favorite &raquo;";
					} else {
						// favorite removed
						$(".toggle-favorite").removeClass("btn-red");
						$(".toggle-favorite").addClass("btn-blue");
						t = "<i class='fa fa-star'></i> Add Favorite &raquo;";
					}
					$(".toggle-favorite span").html(t);
				}
			});

			return false;
		});

		$(".datepicker").datetimepicker({
			hours24: true,
			format: 'm/d/y',
			formatTime: 'H:i',
			datepicker: true,
			timepicker: false,
			timepickerScrollbar: true,
			step: 30
		});

	});
	///////////////////////////////////////////////
	// DOCUMENT READY ENDS
	///////////////////////////////////////////////
</script>

<script>
	//$(".about").fancybox({
	//  'hideOnContentClick': true
	//});

	//$('form').submit(function () {
	//	window.onbeforeunload = function () { }
	//});

	$("#post_comment").click(function(e) {
		e.preventDefault();

		//var pid = $("#project_id_val").val();
		//alert('PID: ' + pid);

		$.ajax({
			url: "/challenge/comment/<?= $project['id'] ?>",
			//url: "/project/comment/" + pid,
			type: "post",
			data: {message: $("#comment_message").val()},
			success:function(d) {
				var c_id = d;
				updateCommentsList(c_id);
				$("#comment_message").val('');
				$("#comment_message").html('');
			},
			complete: function(d) {
				$('#comments_count').load(document.URL +  ' #comments_count');
			}
		});
		return false;
	});

	$("#post_comment2").click(function(e) {
		e.preventDefault();

		//var pid = $("#project_id_val").val();

		$.ajax({
			url: "/challenge/comment/<?= $project['id'] ?>",
			//url: "/project/comment/" + pid,
			type: "post",
			data: {message: $("#comment_message2").val()},
			success:function(d) {
				var c_id = d;
				updateCommentsList(c_id);
				$("#comment_message2").val('');
				$("#comment_message2").html('');
			},
			complete: function(d) {
				$('#comments_count').load(document.URL +  ' #comments_count');
			}
		});
		return false;
	});

	$("#post_requirement").click(function(e) {
		e.preventDefault();

		//var pid = $("#project_id_val").val();

		$.ajax({
			url: "/challenge/submitRequirement/<?= $project['id'] ?>",
			//url: "/project/comment/" + pid,
			type: "post",
			data: {reward: $("#requirement_descrip").val(), sort: $("#sort_requirement").val()},
			success:function(d) {
				var c_id = d;
				//updateCommentsList(c_id);
				$("#requirement_descrip").val('');
				$("#requirement_descrip").html('');
				$("#sort_requirement").val('');
				$("#sort_requirement").html('');
			},
			complete: function(d) {
				//alert('Requirement Submitted');

				//$('#comments_count').load(document.URL +  ' #comments_count');
				//setTimeout('$(".fancybox-close").remove();', 500);
			}
		});
		return false;
	});
	
	// JOIN THIS CHALLENGE
	$("#post_chipin,#joinmob").click(function(e) {
		//alert('It\'s alive!');
		//return false;
		e.preventDefault(); 

		var pledgeAmt = $('#chipin_amount').val(); // in cents
		var pledgeMin = $('#chipin_minimum').val(); // in cents
		var yourBalance = $("#your_balance").val(); // in cents
		var escrowAmt = $("#chipin_escrowamt").val(); // in cents
		var chipinmult = $("#chipin_mult").val();
		var currCF = $('#currCF').val(); // crowd-funding so far? (I don't think we use any more)
		var currGoal = $('#currGoal').val(); // I don't think we use this one any more either
		var newCF = parseInt(currCF) + parseInt(pledgeAmt);
		var newPerc = ((newCF/currGoal)*100).toFixed(2); // use to update progress bar
//		alert('My balance: ' + yourBalance + ' and Reserve Amount: ' + pledgeAmt);
//		return false;
		if (parseInt(pledgeAmt) > parseInt(yourBalance)) {
			alert('Oooops. You don\'t have enough to join this Challenge. Please load funds.');
			return false;
		}
		//alert('Pledge: ' + pledgeAmt + ' CurrCF: ' + currCF +  ' and CurrGoal: ' + currGoal + ' and New Percentage: ' + newPerc);
		//return false;
		var escrowState = $('#chipin_escrow').prop('checked'); // true
		//var escrowState = $('.escrowCh').prop('checked'); // true
		//if ($('.escrowCh').is(':checked')) {
		var escrowed = 0;
		
		//alert('Escrow Checkbox: ' + escrowState);
		
//		if (parseInt(pledgeAmt) == 0 || pledgeAmt.length == 0) {
//			alert('The Reserve Amount must meet minimum of $' + pledgeMin + '. No commitment required. Auto-filling the minimum Reserve Amount, simply Withdraw to undo.');	
//			$('#chipin_amount').val(pledgeMin);
//			//return false;
//		}
//		
//		if (parseInt(pledgeAmt) < parseInt(pledgeMin)) {
//			alert('The Reserve Amount must meet minimum of $' + pledgeMin + '. No commitment required. Auto-filling the minimum Reserve Amount, simply Withdraw to undo.');
//			$('#chipin_amount').val(pledgeMin);
//			//return false;			
//		}
		
		if (escrowState == true) {
			//alert('Escrow checked!');
			if (escrowAmt.length==0) {
				alert('Please enter an amount to escrow first.');
				return false;
			}
			if (parseInt(escrowAmt) > parseInt(yourBalance)) {
				alert('Oooops, you don\'t have enough to escrow that amount.');
				$('.escrowCh').prop('checked', false); // Unchecks it
				return false;
			} else {
				escrowed = 1;
			}
		} else {
			//alert('Escrow NOT checked');
		}

		$.ajax({
			url: "/challenge/chipin/<?= $project['id'] ?>",
			type: "post",
			data: {comment: $("#chipin_message").val(), rating: $("#chipin_amount").val(), escrow: escrowed, escrowAmt: escrowAmt, chipinmult: chipinmult},
			success:function(d) {
				//alert(d); // shows the insert record ID
				var co_id = d;
				updateChipinsList(co_id);
				$("#chipin_message").val('');
				$("#chipin_message").html('');
				$("#chipin_amount").val('');
				$("#chipin_amount").html('');
				$("#chipin_escrowamt").html('');
			},
			complete: function(d) {
				//$("#contributions_count").load('/')}, 1000);
				$('#chipins_count').load(document.URL +  ' #chipins_count');
				$('#chipins_count2').load(document.URL +  ' #chipins_count2');
				//$('#crowdfund_status_div').load(document.URL +  ' #crowdfund_status');
				$('#crowdfund_stats_div').load(document.URL +  ' #crowdfund_stats_div');
				//$('#pbr').load(document.URL +  ' #pbr');
				$('#pbr').css('width', newPerc + '%'); 
				$("#errordiv_chipin").delay(200).fadeIn().delay(500).fadeOut('slow');
				$('.myBal').load(document.URL +  ' .myBal');
				//setTimeout(function() {
				//$("#bottomtray").delay(500).fadeIn();
				//$("#bottomtray").show();
				//$(".my-element").delay(5000).fadeIn();
				// }, 500);
			}
		});
		return false;
	});

	$("#post_chipins").click(function() {
		$("#errordiv_chipin").delay(200).fadeIn();
		//$("#bottomtray").show();
		//$(".my-element").delay(5000).fadeIn();
	});

	$("#okchipin").click(function() {
		$("#errordiv_chipin").hide();
	});

	$("#okwithdraw").click(function() {
		$("#errordiv_withdraw").hide();
	});
	
	$("#enternow,#votenow").click(function(e) {
		e.preventDefault();
		//alert('Coming Soon!');
		
		var prjID 	= $("#project_id_value").val();
		var userID 	= $("#user_id_value").val();
		var credits = $("#credits_value").val();
		
		if (!userID) {
			alert('Please make sure you\'re logged in.');
			return false;
		}
		
		if (credits < 1) {
			alerts('Oooops, you don\'t have enough Entry Tickets to enter.');
		}
		//alert('PID: ' + prjID + ' UserID: ' + userID + ' Credits: ' + credits);
		
		$.ajax({
			url: "/challenge/enternow",
			type: "post",
			data: {
				uid: userID,
				pid: prjID
			},
			success:function(response) {
				//alert('D is: ' + data);
				//alert(response);
				//var json = JSON.stringify(response);
				//alert(json);

//				if (is_joined) {
//					$(".join-group").removeClass("btn-blue");
//					$(".join-group").addClass("btn-red");
//					$(".join-group span.lbl").html("Unfollow &raquo;");
//				} else {
//					$(".join-group").removeClass("btn-red");
//					$(".join-group").addClass("btn-blue");
//					$(".join-group span.lbl").html("Follow &raquo;");
//				}

			},
			complete: function(d) {
				//alert(d);
				//var json = JSON.stringify(d);
				//alert(json);
				//alert('Complete Entry');
				//$('#groupmembers').load(document.URL +  ' #groupmembers');
				$('#myentries').load(document.URL +  ' #myentries');
				$('#raisedsofar').load(document.URL +  ' #raisedsofar');
				$('#etotal1').load(document.URL +  ' #etotal1');
				$('#etotal2').load(document.URL +  ' #etotal2');
				$('#etotal3').load(document.URL +  ' #etotal3');
				$('#pbr').load(document.URL +  ' #pbr');
				$('.myBal').load(document.URL +  ' .myBal');
				//$('.myBal2').load(document.URL +  ' .myBal2');
				$('#myCreds').load(document.URL +  ' #myCreds');
			}
		});
		return false;
	});

	function updateCommentsList(greenify_id){
		$.ajax({
			url: '/challenge/commentlist/<?= $project['id'] ?>',
			success: function (d) {
				$('#comments-list').html(d);
				$('#comments-list2').html(d);

				//if (typeof greenify_id != 'undefined') {
				//	$(".comment[data-comment-id='" + greenify_id + "']").css('background-color', '#0f0');
				//	setTimeout(function() {
				//		$(".comment[data-comment-id='" + greenify_id + "']").css('background-color', '#fff');
				//	}, 5000);
				//}
			}
		});
	}

	function maincommentReply(el){
		$('.commentThreadReply').remove();

		var comment_id = $(el).attr('comment_id');
		var project_id = $(el).attr('project_id');
		//var comment_id = 4;
		//var feature_id = 2;

		//alert('Project ID: ' + project_id);
		//return false;

		cFrm = $("<form>", {class: "commentThreadReply"});
			cFrm.submit(function (e) {
				e.preventDefault();
				//alert('worked');

				$.ajax({
					url: '/challenge/addComment/',
					type: 'post',
					data: $(this).serialize(),
					success: function () {
						//alert('Comment Reply worked...');
						//reloadComment(feature_id);
						updateCommentsList(project_id);
					}
				});
			});
			cFrm.append("<textarea name='content' style='margin:5px 0; width:90%; padding:10px;' rows='1' placeholder='Write a comment/reply...'></textarea>");
			cFrm.append("<input type='hidden' name='parent_id' value='" + comment_id + "' />");
			cFrm.append("<input type='hidden' name='project_id' value='" + project_id + "' /><br />");
			cFrm.append("<input type='submit' />");

			$(el).parent().after(cFrm);
		}

		function editContribution(el){
			$('.commentThreadReply').remove();
			var pid = $("#project_id_val").val();

			var chipin_id = $(el).attr('chipin_id');
			var chipin_amount = $(el).attr('chipin_amount');
			var chipin_content = $(el).attr('chipin_content');
			//alert('Comment: ' + chipin_content);
			//return false;
			var chipinEscrow = $(el).attr('chipinEscrow');
			var chipinEscAmt = $(el).attr('chipinEAmt');
			//alert('Escrow: ' + chipinEscrow + ' Escrow Amount: ' + chipinEscAmt);
			//return false;
			var checkedState = '';
			
			if (chipinEscrow == 1) {
				checkedState = "checked='checked'";
			} else {
				checkedState = '';
			}
			//var chipin_content =  $('.chipin_content').val();
			//alert('Content: ' + chipin_content + ' and Amount: ' + chipin_amount);

			//var comment_id = 4;

			//alert('Project ID: ' + project_id);
			//return false;

			cFrm = $("<form>", {class: "commentThreadReply"});
				cFrm.submit(function (e) {
					e.preventDefault();
					//alert('worked');
					// addComment
					$.ajax({
						url: '/challenge/editContr/',
						type: 'post',
						data: $(this).serialize(),
						success: function (data) {
							//alert(data);
							//alert('Comment Reply worked...');
							updateChipinsList();
						},
						complete: function(d) {
							//$("#contributions_count").load('/')}, 1000);
							//$('#crowdfund_status_div').load(document.URL +  ' #crowdfund_status');
							$('#crowdfund_stats_div').load(document.URL +  ' #crowdfund_stats_div');
							$('.myBal').load(document.URL +  ' .myBal');
						}
					});
				});
				cFrm.append("<textarea name='comment' id='editText' style='margin:5px 0; width:100%; padding:10px;' rows='2' placeholder=''>" + chipin_content + "</textarea>");
				cFrm.append("<input class='txt' type='hiddenx' name='rating' id='reserveAmt' style='max-width:60px; padding:10px; margin:0 7px 7px 0;' value='" + chipin_amount + "' />");
				cFrm.append("<input class='txt' type='hiddenx' name='escrowAmt' id='escrowAmount' style='max-width:60px; padding:10px; margin:0 11px 7px 0;' value='" + chipinEscAmt + "' />");
				cFrm.append("<input class='txt' type='hidden' name='prevamt' id='prevAmount' style='padding:10px; margin:0 7px 7px 0; background:#ddd; border:0px;' value='" + chipin_amount + "' />");
				cFrm.append("<input class='txt' type='hidden' name='id' style='padding:10px; margin:0 7px 7px 0;' value='" + chipin_id + "' />");
				cFrm.append("<input class='txt' type='hidden' name='project_id' style='padding:10px; margin:0 7px 7px 0;' value='" + pid + "' />");
				cFrm.append("<input type='checkbox' name='escrow' " + checkedState + " class='escrowCh' id='escrowCheckbox-" + chipin_id + "' style='margin:-2px 5px 0 0;' /> <span class='escrowlabel'>Escrow</span> ");
				cFrm.append("<input class='btn btn-blue' id='editSubmit' type='submit' style='padding:10px; margin:0 7px 7px 2px;' value='Update' />");
				cFrm.append("<input class='btn btn-blue cancelbtn' id='' type='cancel' style='padding:10px; margin:0 0px 7px 0; width:55px' value='Close' />");

				$(el).parent().after(cFrm);
			}
			// #editSubmit, .escrowCh, #escrowedAmt, #editText
			function updateChipinsList(greenify_id)
			{
				var pid = $("#project_id_val").val();

				$.ajax({
					url: '/challenge/chipinlist/' + pid,
					success: function (d) {
						//alert(d);
						//alert('PID: ' + pid);
						$('#chipins-list').html(d);

						//if (typeof greenify_id != 'undefined') {
						//	$(".comment[data-comment-id='" + greenify_id + "']").css('background-color', '#0f0');
						//	setTimeout(function() {
						//		$(".comment[data-comment-id='" + greenify_id + "']").css('background-color', '#fff');
						//	}, 5000);
						//}
					}
				})
			}

			function tick()
			{
				//updateCommentsList();
				//setTimeout(tick, 2000);

				//	setTimeout(function() {
				//		tick();
				//	}, 1000);
			}

			$(document).ready(function() {
				tick();
			});
</script>

<!-- NO COMMITMENT FUNDS -->
<div style="display:none;">
	<div id="applepay" style="max-width:560px;">
		<div class="overlay-bl-bg"></div>
		<div class="container_6 pop-contentXXXX" style="background:none !important;">
			<div class="" style="background:none !important;">
				<div class="formXXX login-formXXX">
					<!-- CONTENT CONTAINER STARTS HERE -->
					<div class="box-white" style="border:0px; min-width:250px; max-height:300px;
					height:auto; padding:0px; background:none !important; margin-top:-30px !important;">

						<div style="background:#fff; float:left; padding:25px; color:#444; 
						font-size:16px; font-weight:300; font-weight:normal; line-height:24px;
						text-align:left; font-family: Montserrat,'Open Sans',sans-serif;">

							<h2 style="text-align:center; margin:0 auto 10px; line-height:25px; 
							font-size:17px; max-width:400px;
							font-family: Montserrat,'Open Sans',sans-serif; font-weight:700;">
								<!--If you aren&rsquo;t part of the 1%, then FlipMob was made for YOU-->
								USING APPLE PAY
							</h2>
							
							Apple Pay is usually works on all iPhones, iPads, Mobile Safari and 
							Desktop Safari.
							<br />
							<div style="color:#888; font-size:14px; line-height:19px; margin-top:10px">
								Note: if Apple Pay doesn&rsquo;t load then try deleting your cache 
								(for phones or desktops). Usually you can do this by site 
								(ie. fantasytrivia.com). Then, close the browser window and 
								refresh the screen a couple of times and the page should load (and
								the Apple Pay button appear).
							</div>
						</div>
					</div>
					<div class="clear"></div>
				</div>
			</div>
		</div>
	</div>
</div>

<!--<link rel="stylesheet" href="/static/rateit/rateit.css"/>
<script src="/static/rateit/jquery.rateit.min.js"> </script>
<script type="text/javascript" src="//s7.addthis.com/js/300/addthis_widget.js#pubid=undefined"> </script>
<link rel="stylesheet" href="/static/css/jquery.datetimepicker.css"/>
<script src='/static/js/jquery.datetimepicker.js'> </script>-->