<div id="viewPortfolio">

	<div class="breadcrumbRight">&nbsp;</div>
	<div id="breadcrumb" msgid="titleMoneyAccount">Money Account</div>
	
	<div id="masterContent">
		<div id="pageTitle" class="content" msgid="titleMoneyAccount">Money Account</div>
		<div id="date" class="content">
			<table>
				<tr>
					<td class="setDateTd">
						<span class="asOfDate" msgid="publicDate">As of Date</span>
						<select
							id="moneyAccountSelectId" class="AsOfDate dropDownStyle">
							{{each(i,selectDate) app.user.asOfDate}}
						  		<option>${selectDate}</option>
							{{/each}}
						</select>
					</td>
					<td class="tdDateLine">
						<div class="dateLine"></div>
					</td>
				</tr>
			</table>
		</div>
		
	{{if (meta.errorType) != null}}
		<div class="content">The request fail, ErrorMessage:${meta.errorMessage}</div>
	{{else}}
		<div id="">
			<div id="moneyAccountContent" class="content">
			{{each(i, portfolioNumber) getKeyArray(data.result.cashPosition)}}
				<table id=positionDTable class="positionDT" style="margin-top:0px;">
					<tr>
						<td colspan="5" class="netAssetValueTd" style="text-align: left;">
							<span msgid="publicAccountNumber">Account Number:</span> ${app.selectBpKey}<span style="margin-left: 20px;"></span>
							<span msgid="publicPortfolioNumber">Portfolio Number:</span> ${portfolioNumber}<span style="margin-left: 20px;"></span>
							<span msgid="publicNetAssetValues">Net Asset Value:</span> <span id="netAsset${i}"></span>
							<br/>
							<span msgid="publicPortfolioName">Portfolio Name:</span> ${data.result.portfolio[portfolioNumber].portfolioName}
						</td>
					<tr>
	        		<tr>
	            		<th style="text-align:left; text-indent: 6px; width:158px;">
	            			<span msgid="pDetailDescription">Description</span>
	            		</th>
	            		{{if data.result.portfolio[portfolioNumber].hasMetalCcy == true }}
	            			<th>
	            				<span msgid="pDetailUnitRroOunces">Unit(Troy Ounces)</span>
	            			</th>
	            		{{else}}
	            			<th></th>
	            		{{/if}}
	                	<th>
	                		<span msgid="pDetailValueCurrency">Value (in original currency)</span>
	                	</th>
	                	<th>
	                		<span msgid="pDetailValue">Value</span> (${data.result.portfolio[portfolioNumber].refCcy})
	                	</th>
	                	<th>
	                		<span msgid="pDetailAllocation">Allocation %</span>
	                	</th>
	         		</tr>
	         		{{each(x, class1Types) getKeyArray(data.result.cashPosition[portfolioNumber])}}
	         			<tr class="category_t1_l1"><td colspan="5" class="class1Category">${class1Types}</td></tr>
		         		{{each(j, types) getKeyArray(data.result.cashPosition[portfolioNumber][class1Types])}}
			         		<tr class="category_t1_l2"><td colspan="5" style="text-align:left;">${types}</td></tr>
			         		{{each(k, typesData) getKeyArray(data.result.cashPosition[portfolioNumber][class1Types][types])}}
			         		{{if k%2==1 }}
			         		<tr class="even">
			         		{{else}}
			         		<tr class="odd">
			         		{{/if}}
			         			<td style="text-align:left;"><div style="word-wrap: break-word; width: 158px;overflow:hidden;">${data.result.cashPosition[portfolioNumber][class1Types][types][typesData].ccy}</div></td>
			         			<!--Logic 
			         				if has "unit" header, do the Logic2
			         				else no show the "unit" value though it have "unit" value
			         					 just show the value
			         			 -->
			         			{{if data.result.portfolio[portfolioNumber].hasMetalCcy == true }}
				         			<!--Logic2
				         				1\if hasMetalCcy is true, then the value is 'N/A' and display the unit value in unit field
										2\if hasMetalCcy is false, then the unit is "" ,and the value field show the value
				         			 -->
				         			{{if data.result.cashPosition[portfolioNumber][class1Types][types][typesData].hasMetalCcy == true }}
				         				<td>${data.result.cashPosition[portfolioNumber][class1Types][types][typesData].unit}</td>
				         				<td>N/A</td>
				         			{{else}}
				         				<td></td>
				         				<td>${formatMoney(data.result.cashPosition[portfolioNumber][class1Types][types][typesData].value)}</td>
				         			{{/if}}
			         			{{else}}
			         				<td></td>
			         				<td>${formatMoney(data.result.cashPosition[portfolioNumber][class1Types][types][typesData].value)}</td>
			         			{{/if}}
			         			<td>
			         				${data.result.cashPosition[portfolioNumber][class1Types][types][typesData].refValue}
			         			</td>
			         			<td>
			         				${formatMoney(data.result.cashPosition[portfolioNumber][class1Types][types][typesData].allocation)}
			         			</td>
			         		</tr>
			         		{{/each}}
	         			{{/each}}
		         		<tr class="total">
		         			<td msgid="pDetailTotal" style="font-weight:bold;text-align:left;">Total</td>
		         			<td colspan="2"></td>
		         			<td>
		         				<p><b>${formatMoney(data.result.portfolio[portfolioNumber].refValueTotal)}</b></p>
	         					<p>${formatMoney(data.result.portfolio[portfolioNumber].refValueAccrIntTotal)}</p>
		         			</td>
		         			<td><b>${formatMoney(data.result.portfolio[portfolioNumber].totalPercentage)}</b></td>
		         		</tr>
	         		{{/each}}
	         </table>
	         
	         <p>&nbsp;</p>
	         {{/each}}
	         
			
	         {{if getKeyArray(data.result.cashPosition).length == 0}}
	         	<div>There is no record for the selected date</div>
	         {{else}}
	         	<p>&nbsp;</p>
	         	<!-- Notes -->
			 	<div id="notes"></div>
	         {{/if}}
			</div>
		</div>
		
	{{/if}}
		
		<div class="footer">
			<img src="images/layout/bkg-content-base-right.gif?version=|||xxx|||">
		</div>
	</div>
</div>