/* forex component, write logic of forex module in this class */
var forex = new Component("positionDetail/forex");
app.registerComponent(forex);
forex.on( "load", function(){
	var self = this;
	url = "asset/position/" + app.selectBpKey + "?asOfDate=" + app.selectDateValue + "&assetClass1=FX";
	//url = "asset/position/10263192?asOfDate=5/9/2013&assetClass1=FX";
	return forex.render(
			"template/positionDetail_forex.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++;
				});
				
				self.switchNotesLang();
				//set the height of tableScrollDiv adjust the window's height
				setPositionDetailPageScrollHeight();
				
				trackAction("ForexPosition - View");
				
    		}); 
	
});

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


forex.switchNotesLang = function(){
	//set notes
	var notes = lang.messages.notes_forex;
	$("#notes").html(notes.replaceAll("\n", "<br>"));
	
};
