/* funds component, write logic of funds module in this class */
var equitiesSBL = new Component("positionDetail/equitiesSBL");
app.registerComponent(equitiesSBL);
equitiesSBL.on( "load", function(){
	var self = this;
	url = "asset/position/" + app.selectBpKey + "?asOfDate=" + app.selectDateValue + "&assetClass1=Equities%20(SBL)";
	return equitiesSBL.render(
			"template/positionDetail_equitiesSBL.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++;
				});
				
				equitiesSBL.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("SBLEquitiesPosition - View");
    		}); 
	
});

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

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