var cashMovement = new Component("positionDetail/cashMovement");
app.registerComponent(cashMovement);

cashMovement.on("load",function(){
	var self = this;
	return this.render(
			"template/cashMovement.html",
			"mainContent",
			"cash/movement/"+app.selectBpKey+"?asOfDate="+app.selectDateValue
	).done(function(template,data){
		self.initDateSelect();
		
		var count = 0;
		$.each(data.data.result.movements, function(portfolioNo, value){
			//set the netAssetValue
			getNetAssetValue(app.selectBpKey, portfolioNo, count);
			count++;
		});
		
		//set the height of tableScrollDiv adjust the window's height
		setPositionDetailPageScrollHeight();
		
		trackAction("CashMovement - View");
		
	});
});


cashMovement.initDateSelect = function(){
	var self = this;
	$("#cashMovementSelectId").val(app.selectDateValue);
	$("#cashMovementSelectId").die();
	$("#cashMovementSelectId").live("change",function(){
//		var selectDate = $(this).val();
//		app.selectDateValue =  selectDate;
//		cashMovement.trigger("load");
		app.trigger("changeAsOfDate", self.id, $("option:selected", this).html());
		trackAction("CashMovement - ChangeDate");
	});
};