/* funds component, write logic of funds module in this class */
var equities = new Component("positionDetail/equities");
app.registerComponent(equities);
equities.on( "load", function(){
	var self = this;
	url = "asset/position/" + app.selectBpKey + "?asOfDate=" + app.selectDateValue + "&assetClass1=Equities";
	return equities.render(
			"template/positionDetail_equities.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();
				
				//set the color of table base on odd or even
//				$.each($(".oddEvenColor"), function() {
//					var id = $(this).attr("id");
//					console.log("id = " + id);
//					if(id % 2 != 0) {
//						$(this).css({"border" : "5px solid", "color" : "#C1C182"});
//					}
//				});
				
				trackAction("EquitiesPosition - View");
    		}); 
	
});

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

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