<% if ( typeof(request) != 'undefined' ) { %> 

<div class="fineart-thecart">
	<h2 class="site-page-title"></h2>

	<div id="messages" class="success">
	<% if ( request['method'] == 'btc' ) { 

		if ( request['confirmed'] ) { %>

			We have received your Bitcoin payment and the transaction <strong>has been confirmed</strong>.

		<% } else { %>

			We have received your Bitcoin payment and are <strong>waiting for network confirmation</strong> of the transaction.

		<% } %>

	<% } else if ( request['method'] == 'credit' ) { %>

		Your credit card was approved.

	<% } %>
	</div>

	<div id="fineart-thecart-items">
		<h3>Your Artwork</h3>

		<% var total=0; %>
		<% for(var i=0; i<cart['products'].length; i++) { %>
			<% var option = cart['products'][i]['post']['options'][cart['products'][i]['option']]; %>

			<div class="fineart-thecart-item" data-id="cart['products'][i]['id']" data-quantity="cart['products'][i]['quantity']" data-price="<%= option['price'] %>" data-option="<%= cart['products'][i]['option'] %>" data-weight="<%= option['weight'] %>" data-width="<%= option['width'] %>" data-length="<%= option['length'] %>" data-height="<%= option['height'] %>">

				<div class="fineart-thecart-thumbnail">
					<img src="<%= cart['products'][i]['post']['image'][0] %>?w=75" />
				</div>

				<div class="fineart-thecart-info">
					<%= cart['products'][i]['post']['title'] %>
					<div class="fineart-thecart-dimensions"><%= cart['products'][i]['post']['details']['width'] %> x <%= cart['products'][i]['post']['details']['height'] %> inches</div>
					<div class="fineart-thecart-medium"><%= cart['products'][i]['post']['details']['medium'] %></div>
					<div><%= option['name'] %></div>
				</div>

				<div class="fineart-thecart-optioninfo">

					<div><span data-id="<%= cart['products'][i]['id'] %>" data-option="<%= cart['products'][i]['option'] %>" class="quantity-field"><%= cart['products'][i]['quantity'] %></span></div>

				</div>

				<br class="clearfix"/>

			</div>
		<% } %>

		<div id="totals" class="fineart-thecart-total">
			<% if ( request['method'] == 'btc' ) { %>
				<div id="totals-total-btc"><%= cart['total_btc'] %> BTC</div>
			<% } else if ( request['method'] == 'credit' ) { %>
				<div id="totals-total-usd"><%= cart['total_usd'] %> USD</div>
			<% } %>				

		</div>

	</div>

	<div id="fineart-thecart-payment">

		<input type="hidden" name="fmethod" id="fmethod" value="<%= request['method'] %>"/>
		<input type="hidden" name="status" id="status" value="<%= cart['status'] %>"/>

		<div id="cart-contact">
			<h3>Shipping Information</h3>

			<div id="shipping-address">
				<input type="hidden" name="fname" id="fname" value="<%= request['name'] %>"/>
				<%= request['name'] %><br/>
				<input type="hidden" name="faddress1" id="faddress1" value="<%= request['address1'] %>"/>
				<%= request['address1'] %>
				<input type="hidden" name="faddress2" id="faddress2" value="<%= request['address2'] %>"/>
				<%= request['address2'] %><br/>
				<input type="hidden" name="fcity" id="fcity" value="<%= request['city'] %>"/>
				<%= request['city'] %>,
				<input type="hidden" name="fstate" id="fstate" value="<%= request['state'] %>"/>
				<%= request['state'] %>
				<input type="hidden" name="zip" id="zip" value="<%= request['zip'] %>"/>
				<%= request['zip'] %><br/>
				<input type="hidden" name="country" id="country" value="<%= request['country'] %>"/>
				<%= request['country'] %><br/>
			</div>

			<div id="contact-information">
				<input type="hidden" name="sip" id="zip" value="<%= request['sip'] %>"/>
				<input type="hidden" name="email" id="email" value="<%= request['email'] %>"/>
				<input type="hidden" name="publickey" id="publickey" value="<%= request['publickey'] %>"/>
				<% if ( request['sip'] ) { %>
					SIP: <%= request['sip'] %><br/>
				<% } %>
				<% if ( request['email'] ) { %>
					Email: <%= request['email'] %>
					<% if ( request['publickey'] ) { %>
						<span id="publickeyshowbutton">(Show Public Key)</span>
						<span id="publickeyhidebutton">(Hide Public Key)</span>
					<% } %>
					<br/>
				<% } %>
			</div>

			<div id="publickeyshow"><%= request['publickey'] %></div>

			<div class="clearfix"></div>
		</div>
	

		<div id="cart-thankyou">
	
			<h3>Thank You</h3>

			<% if ( request['method'] == 'btc' ) { 

				if ( request['confirmed'] ) { %>

					<% if ( request['email'] || request['sip'] ) { %>
						<p>This invoice has been paid. You should here from us when your artwork has shipped. A copy of your receipt will be included in the mail. Please allow 2-3 weeks for delivery.</p>
					<% } else { %>
						<p>This invoice has been paid. A copy of your receipt will be included in the mail. Please allow 2-3 weeks for delivery. </p>
					<% } %>

					<% var confirmation_short = request['confirmation'].substring(0,8) %>
					<p id="confirmation-hash-short"><%= confirmation_short %></p>

					<p>
						<span id="confirmation-hash"><strong>Order Confirmation:</strong> <%= request['confirmation'] %><br/></span>
						<strong>Bitcoin Address:</strong> <%= request['btc_address'] %><br/>
						<strong>Paid:</strong> <%= request['paid_btc'] %> BTC<br/>
						<% var parts = String(request['date']).split(/[- :]/); %>
						<% var date = new Date(Date.UTC(parts[0], parts[1]-1, parts[2], parts[3], parts[4], parts[5])); %>
						<% var date_string = date.toString('dddd, MMMM, yyyy h:mm:ss'); %>
						<strong>Date:</strong> <%= date_string %><br/>
					</p>

				<% } else { %>

					<% if ( request['email'] || request['sip'] ) { %>
						<p>We have received your payment and waiting for confirmation. You should here from us within 2 business days after your order is confirmed, and also when your artwork has shipped. A copy of your receipt will be included in the mail. Please allow 2-3 weeks for delivery.</p>
					<% } else { %>
						<p>We have received your payment and waiting for confirmation. When your order is confirmed a copy of your receipt will be included in the mail. Please allow 2-3 weeks for delivery. </p>
					<% } %>
					<% var confirmation_short = request['confirmation'].substring(0,8) %>
					<p id="confirmation-hash-short"><%= confirmation_short %></p>

					<p>
						<span id="confirmation-hash"><strong>Order Confirmation:</strong> <%= request['confirmation'] %><br/></span>
						<strong>Bitcoin Address:</strong> <%= request['btc_address'] %><br/>
						<strong>Received:</strong> <%= request['received_btc'] %> BTC<br/>
						<strong>Confirmations:</strong> <%= request['confirmations'] %> of <%= request['confirmations_required'] %><br/>
						<% var parts = String(request['date']).split(/[- :]/); %>
						<% var date = new Date(Date.UTC(parts[0], parts[1]-1, parts[2], parts[3], parts[4], parts[5])); %>
						<% var date_string = date.toString('dddd, MMMM, yyyy h:mm:ss'); %>
						<strong>Date:</strong> <%= date_string %><br/>
					</p>

				<% } %>

			<% } else if ( request['method'] == 'credit' ) { %>

				<% if ( request['email'] || request['sip'] ) { %>
					<p>Your credit card has been approved. You should here from us when your artwork has shipped. A copy of your receipt will be included in the mail. Please allow 2-3 weeks for delivery.</p>
				<% } else { %>
					<p>Your credit card has been approved. A copy of your receipt will be included in the mail. Please allow 2-3 weeks for delivery.</p>
				<% } %>

				<% var confirmation_short = request['confirmation'].substring(0,8) %>
				<p id="confirmation-hash-short"><%= confirmation_short %></p>

				<p>
					<span id="confirmation-hash"><strong>Confirmation:</strong> <%= request['confirmation'] %></span><br/>
					<% var parts = String(request['date']).split(/[- :]/); %>
					<% var date = new Date(Date.UTC(parts[0], parts[1]-1, parts[2], parts[3], parts[4], parts[5])); %>
					<% var date_string = date.toString('dddd, MMMM, yyyy h:mm:ss'); %>
					<strong>Date:</strong> <%= date_string %><br/>
					<strong>Credit Card:</strong> **** **** **** <%= request['cc_lastfour'] %><br/>
					<strong>Received:</strong> <%= request['received_usd'] %> USD<br/>
				</p>

			<% } %>

		</div>

		<div id="print-button"><span>Print Document</span></div>

	</div>		

</div>

<% } else { %>

	<p>Missing nessasary information.</p>

<% } %>

<div id="security-notice"><div class="secure-icon"></div><p>This is a secured page and it is accessible only to you for this window of time. You will not be able to return to this information if you close, refresh or navigate away from this page.</p></div>

<%= this.partial({url: templatesurl+'footer.ejs'}) %>




