var depositLoan = new Component("positionDetail/depositLoan");
app.registerComponent(depositLoan);
depositLoan.on( "load", function(){
	var self = this;
	url = "asset/position/" + app.selectBpKey + "?asOfDate=" + app.selectDateValue + "&assetClass1=Deposit%20%26%20Loans";
	//url = "asset/position/21099298?asOfDate=5/9/2013&assetClass1=Deposit%20%26%20Loans";
	return depositLoan.render(
			"template/positionDetail_depositLoan.html", 
    		"mainContent", 
    		url).done(function(template, data) {
				self.buttonEvent();
				
				var count = 0;
				$.each(data.data.result.assetPosition, function(portfolioNo, value){
					//set the netAssetValue
					getNetAssetValue(app.selectBpKey, portfolioNo, count);
					count++;
				});
				
				//set the height of tableScrollDiv adjust the window's height
				setPositionDetailPageScrollHeight();
				
				trackAction("DepositLoansPosition - View");
				
    		}); 
	
});

depositLoan.buttonEvent = function() {
	$("#depositSelectId").val(app.selectDateValue);
	$("#depositSelectId").die();
	$("#depositSelectId").live("change",function(){
//		app.selectDateValue = $("option:selected", this).html();
//		depositLoan.trigger("load");
		app.trigger("changeAsOfDate", "positionDetail/depositLoan", $("option:selected", this).html());
		trackAction("DepositLoansPosition - ChangeDate");
	});
};

