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

securitiesMovement.on("load",function(){
	var self = this;
	return this.render(
			"template/securitiesMovement.html",
			"mainContent",
			"asset/movement/"+app.selectBpKey+"?asOfDate="+app.selectDateValue
	).done(function(template,data){
		self.initSelectEvent();

		var count = 0;
		$.each(data.data.result.securitiesMovement, function(portfolioNo, value){
			//set the netAssetValue
			getNetAssetValue(app.selectBpKey, portfolioNo, count);
			count++;
		});
		self.switchNotesLang();
		//set the height of tableScrollDiv adjust the window's height
		setPositionDetailPageScrollHeight();
		
		trackAction("SecuritiesMovement - View");
	});
	
});

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

securitiesMovement.switchNotesLang = function(){
	//set Notes
	var notes = lang.messages.notes_securities_movement;
	$("#notes").html(notes.replaceAll("\n", "<br>").replaceAll("\t25", "<span style='margin-left: 25px;'></span>")
			.replaceAll("\t", "<span style='margin-left: 20px;'></span>"));
	
};

