
var View = function() {
}

View.prototype.init = function(model) {
	this.setModulationTableBody(model);
	globalView.addButtonClass();
};

View.prototype.setModulationTableBody = function(model) {
	var rowTemplate = "";
	rowTemplate += "<tr>";
	rowTemplate += "	<td><input id='#id#' type='checkbox' /></td>";
	rowTemplate += "	<td colspan='2'><label for='#id#'>#text#</label></td>";
	rowTemplate += "</tr>";
	
	var profileRowTemplate = "";
	profileRowTemplate += "<tr class='#parent_id#'>";
	profileRowTemplate += "	<td></td>";
	profileRowTemplate += "	<td><input id='#id#' type='checkbox' /></td>";
	profileRowTemplate += "	<td><label for='#id#'>#text#</label></td>";
	profileRowTemplate += "</tr>";
	
	var profileHeaderTemplate = "";
	profileHeaderTemplate += "<tr class='#parent_id#'>";
	profileHeaderTemplate += "	<td></td>";
	profileHeaderTemplate += "	<td colspan='2'><span>#modulationProfiles#</span></td>";
	profileHeaderTemplate += "</tr>";
	
	$("#modulationTableBody").html("");

	for(var i in model.modulationList) {
		$("#modulationTableBody").append(rowTemplate.replace(/#id#/g, model.modulationIdList[i].id).replace(/#text#/g, model.modulationList[i].text));
		if(model.modulationList[i].profiles) $("#modulationTableBody").append(profileHeaderTemplate.replace(/#parent_id#/g, model.modulationIdList[i].id).replace(/#modulationProfiles#/g, model.modulationList[i].text + " <span id='__ML_modulation_settings_profiles'></span>"));
		for(var j in model.modulationList[i].profiles) {
			$("#modulationTableBody").append(profileRowTemplate.replace(/#parent_id#/g, model.modulationIdList[i].id).replace(/#id#/g, j).replace(/#text#/g, model.modulationList[i].profiles[j].text));
		}
	}

	$("#modulationTableBody").append(rowTemplate.replace(/#id#/g, "multimode").replace("#text#", "MultiMode"));
};
