//define page and configuration data
var pageConfig = {
	masterReport: {
		uri: '/public/Samples/FreshDelivery_Demo/HealthyChoiceProducts',
		container: '#healthy-choices'
	},
	params: {},
	supplyMap: {
		'1': 'None',
		'2': 'Limited',
		'3': 'Good',
		'4': 'High'
	}
};

//load the config and get the script for the configured server instance
$.getJSON('./config/config.json', function(data) {
	$.getScript(data.visualizeJS, function() {
		initPage(data.jrsConfig);
	});
});

//init page and authenticate with JRS
function initPage(jrsConfig) {
	visualize({
		auth: jrsConfig.auth
	}, function(v) {
		loadDashboard(v);
	});
}

//load the dashboard
function loadDashboard(v) {
	window.masterReport = v.report({
		resource: pageConfig.masterReport.uri,
		container: pageConfig.masterReport.container,
		linkOptions: {
			events: {
				"click": function(evt, link) {
					var l = link.parameters;
					$('#ImageLink').html('<img src="img/products/' + (l.product_name) + '.jpg" height="200px">');
					$('#ProductName1').html(l.product_name);
					$('#ProductNameSimple').html(l.product_name.replace(/Hermanos/, '').replace(/Ebony/, ''));
					$('#Group').html(l.product_group);
					$('#AvailSupply').html(pageConfig.supplyMap[l.total_supply] || 'N/A');
					$('#Price').html('$ ' + Number(l.price).toFixed(2).replace(/\d(?=(\d{3})+\.)/g, '$&,'));
					$('#UnitsCase').html(l.total_units_case);
				}
			}
		},
		error: function(err) {
			console.log(err.message);
		}
	});
}

function setFilter(paramId, paramValue) {
	pageConfig.params[paramId] = [paramValue];
	refreshMaster();
}

function resetFilters() {
	pageConfig.params = {};
	refreshMaster();
}

function refreshMaster() {
	window.masterReport.params(pageConfig.params).run();
}

$(function() {
	$("#filterTen").on('click', function() {
		limitResults(10);
	});

	$("#filterReset").on('click', function() {
		resetFilters();
	});
});

@@ -263,16 +263,179 @@
 h'%0A%09%7D%0A%7D;
+%0Avar defProductName = 'Red Pepper';%0Avar defGroup = 'Fresh Vegetables';%0Avar defAvailability = 'Limited';%0Avar defPricePerUnit = '$ 2.88';%0Avar defUnitsPerCase = '14';
 %0A%0A//load
@@ -829,24 +829,316 @@
 hboard(v) %7B%0A
+%09$('#ImageLink').html('%3Cimg src=%22img/products/Ebony ' + defProductName+ '.jpg%22 height=%22200px%22%3E');%0A%09$('#ProductNameSimple').html(defProductName);%0A%09$('#Group').html(defGroup);%0A%09$('#AvailSupply').html(defAvailability);%0A%09$('#Price').html(defPricePerUnit);%0A%09$('#UnitsCase').html(defUnitsPerCase);%0A
 %09window.mast

Fix Healthy Choices page to show default paraemters, thank you Pierre Lambert