var solutionId = 1;
var currentSolutionId = "";
var currentRole = "";

// Solution parameters :
		// name				- Primary name (used in droplists, menus etc.).  Not necessarily unique
		// title			- Long name used as title on soluton page (name is used if no title provided)
		// id				- Auto generated unqiue identifier
		// roles			- Comma separated list of roles this applies to (finance/hr/it/manager/sales).  Leave empty for all roles
		// industries		- Comma separated list of industries this applies to (leave empty for all industries).  The industries list is built from distinct values in this field.
		// features			- Comma separated list of features this applies to (ra/pf/kpi). Leave empty for all features
		// overview			- First paragraph of text on solution page
		// revenue			- Star rating (1-5) or leave empty
		// productivity		- Star rating (1-5) or leave empty
		// risk				- Star rating (1-5) or leave empty
		// yield			- Star rating (1-5) or leave empty	
		// team				- Star rating (1-5) or leave empty	
		// stakeholder		- Star rating (1-5) or leave empty
		// question1		- Text for bullet-point questions on solutions page
		// question2		- Text for bullet-point questions on solutions page
		// question3		- Text for bullet-point questions on solutions page
		// question4		- Text for bullet-point questions on solutions page
		// casestudy		- If a case study is available, its href should go here

solutions = [
	{"name":"Asset Valuation", 
		"title":"Getting Your Asset Valuation and Re-valuation Right",
		"id":solutionId++,"roles":"","industries":"",
		"overview":"Getting your asset valuation and re-valuation right has a direct and very material impact on earnings.  Get it wrong (particularly if you are a listed company) and there is no forgiveness.  It's a big risk for Boards and Finance guys.  What is needed is a de-risking process - such that if things do go awry, then there can be no question as to the process or effort undertaken to manage the risk.", 
		"risk":"5","stakeholder":"5",
		"question1":"How do you perform asset valuation?  Is it a very manual process?  Are you confident in the accuracy of the process?",
		"question2":"Is the process clear and documented?  Is it easily repeatable, each time you need to do it, do you have to re-invent the wheel?  Will it stand-up to scrutiny or analysis?",
		"question3":"How easy is it to get to the data required to perform asset valuation?  Is the data readily available or do you have to ''reinvent the wheel'' each time looking for it, then perform plumbing to gain access to the data?  When new assets are acquired, how sure are you that they are accounted for automatically?",
		"casestudy":"CALUMO_Case_Study_Aevum.pdf"
	},	
	{"name":"Daily Reporting & Analysis", 
		"id":solutionId++,"roles":"","industries":"Banking",
		"overview":"CALUMO provides a centralised data repository of numerous legacy and operational systems covering HR, CRM, operations and risk in multiple currencies. Data needs to be timely, as the size of transactions means any dealing positions undertaken have large consequences. Analysis may be conducted at detail or helicopter level, with results to be consistent across all levels.", 
		"revenue":"4","productivity":"4","risk":"3","stakeholder":"2",		
		"question1":"How do you consolidate your data?  Is it a very manual process?  Are you comfortable with the accuracy of the process?",
		"question2":"Is the process clear and documented? Is it easily repeatable, each time you need to do it? Will it stand-up to scrutiny or analysis?",
		"question3":"How easy is it to get to the data required for consolidation?  Is the data readily available or do you have to ''reinvent the wheel'' each time looking for it & performing plumbing to gain access to the data? When new accounts, clients, dealers or products are added, how sure are you that they are accounted for automatically?",
		"question4":"How important is it for the solution to be accessible and useable by a wide range of users? How do you distribute the information? How is more detail obtained?"
	},	
	{"name":"Data Consolidation and Reporting", 
		"id":solutionId++,"roles":"manager","industries":"Regulated Government Department",
		"overview":"Environment in operation is highly regulated, both in terms of organisational structure, as well as information captured. CALUMO software allows middle management and end users within LPMA flexibility in analysis conducted. A wide range of disparate data sources are easily overcome with the use of CALUMO and TM1.", 
		"productivity":"5","risk":"2","team":"2","stakeholder":"4",		
		"question1":"How do you consolidate your data?  Is it a very manual process?  Are you comfortable with the accuracy of the process?",
		"question2":"Is the process clear and documented? Is it easily repeatable, each time you need to do it? Will it stand-up to scrutiny or analysis?",
		"question3":"How easy is it to get to the data required for consolidation?  Is the data readily available or do you have to ''reinvent the wheel'' each time looking for it & performing plumbing to gain access to the data? When new accounts are added, how sure are you that they are accounted for automatically?",
		"question4":"How important is it for the solution to be accessible and useable by a wide range of users?"
	},	
	{"name":"Decision-Making Ability", 
		"title":"Improving the decision-making capability",
		"id":solutionId++,"roles":"manager","industries":"Professional Services",
		"overview":"Research shows that organisations spend up to 80% of their time in the logistics of gathering data, and less than 20% of their time in the analysis of that data. Recognising this, CALUMO is able to revolutionise the way that management teams make their decisions. CALUMO customers are now able to make better informed decisions and respond quicker to opportunities as they arise.", 
		"revenue":"3","productivity":"5","risk":"3","yield":"3","team":"4","stakeholder":"4",		
		"question1":"How easy is it to get to the data required to do your job?  Is the data readily available or do you have to ''reinvent the wheel'' each time when looking for it, and performing plumbing to gain access to the data?",
		"question2":"When new systems and processes are developed, or when a new product is added to your sales portfolio for example, how sure are you that your reports and analysis accounts for these automatically?"
	},	
	{"name":"Faculty Load Planning", 
		"title":"Controlled and Straightforward Management of Faculty Loading",
		"id":solutionId++,"roles":"","industries":"Tertiary Education",
		"overview":"Load & revenue planning is - typically - slow, manual, involves little automation and is heavily dependent upon MS Excel sheets, MS Access and other databases. It's difficult to model or perform ''what if's'' in that scenario, and an audit trail is a pipedream. Data sets quickly become unwieldy and faculty staff can quickly get bogged down.", 
		"revenue":"2","productivity":"5","risk":"1","yield":"5","team":"5", 
		"question1":"How do you perform Faculty Loading?  Is it a very manual process or have you been able to automate some of it?  Does it involve a lot of spreadsheets and silos of data?",
		"question2":"Are you able to create a five-year rolling load plan? And a five-year rolling income plan?  How do you perform What-If analysis?",
		"question3":"What happens if there are changes to course dates and times and structures?  Likewise, how do you handle changes to semesters and changes to faculty structures.  Are you able to work on multiple versions of a plan?",
		"question4":"How do you manage reporting? Is it an easy process and what does the process entail?"
	},	
	{"name":"Management Reporting", 
		"title":"Streamlining Your Management Reporting",
		"id":solutionId++,"roles":"finance,manager","industries":"",
		"overview":"Streamlining the production of management reporting is crucial to business operations. Too many times reports are routinely manually created by multiple disparate areas within the same organisation, which invariably leads to there being more than one version of the truth. Too much time is spent in validating, cross checking and questioning the accuracy of the data, instead of consuming the message that the data is intended to convey. Manual creation introduces the possibility of human error and this leads to frustration to the consumers and dissatisfaction for the producers of the reports. The experience and skills required to create these reports often reside in only a few key resources. This is risky, as critical business information may be undeliverable to stakeholders in the event of sickness or staff movements.",
		"productivity":"5","risk":"5","team":"5","stakeholder":"5",		
		"question1":"Are your management reports robust? Are they unquestionably accurate across the board, and do they all internally agree with each other?",
		"question2":"Does your team spend a significant amount of their monthly cycle producing reports instead of providing value-add analysis?",
		"question3":"Are you overly dependent on one (or few) people who are the only ones capable of producing the reports required?"
	},
	{"name":"Planning & Forecasting", 
		"id":solutionId++,"roles":"manager","industries":"",
		"overview":"Planning & Forecasting is a vital process within any organisation.  Getting your future performance measures accurate is critical when the market is moving either up or down, or when any strategic decisions need to be made. Reducing the time and pain it takes to perform this task is critical to both stakeholder and team satisfaction. Frustrated staff can make error which can change results. It is a tricky task to collate data from many disparate locations from people whose skill level at entering data into financial models may vary (some staff may only use Excel at Budget time). Additionally due to the complexity of some planning requirements, a more robust solution is called for.",
		"productivity":"5","risk":"5","team":"5","stakeholder":"5",		
		"question1":"Do you find consolidations of budgets/forecasts a lengthy and time consuming process?",
		"question2":"Do you find that you are having to make too many assumptions in your planning/forecasting purely as you do not have the computing power or resources to get the accuracy you need?",
		"question3":"Are you finding it difficult to get planning/forecasting data to be entered by remote users whose area of expertise is not with Excel?",
		"question4":"Would you like to perform more regular planning cycles but are reluctant to give the length of the current process?"
	},	
	{"name":"Reporting, Budgeting & Forecasting", 
		"title":"Streamlining Month End Reporting, Budgeting & Forecasting Processes",
		"id":solutionId++,"roles":"manager,finance","industries":"Manufacturing,Chemicals",
		"overview":"Gathering data from multiple disparate systems from around the world and consolidating this information is a time-consuming process.  Under the pressures of month-end, there is little time to get things wrong, review and make adjustments and report to the Board.  We can put in place a system that fully automates the data gathering, consolidation and reporting process, so that Head Office finance staff (including the CFO) can review the numbers.  Adjustments can be made in source systems, and reflected in consolidated reports within the hour.", 
		"productivity":"5", "risk":"4", "team":"5", "stakeholder":"3",		
		"question1":"How do you consolidate financial data from multiple disparate systems and make necessary adjustments?",
		"question2":"Is the month-end consolidation & reporting exercise fully automated and are you able to repeat the process quickly to allow for late adjustments?",
		"question3":"How much time is spent managing the forecasting & budgeting process?  Is this a process that staff dread?  How much time is spent consolidating the information?"
	},	
	{"name":"Sales & Margin Performance", 
		"title":"Achieving The Corporate Mission With Regard To Sales And Margin Performance",
		"id":solutionId++,"roles":"manager","industries":"Manufacturing",
		"overview":"As a global manufacturer, achievement of sales targets, whilst maintaining margin is essential to achieving the corporate mission and market guidance. The challenge is increased during an economic downturn, where margins are easily lost to competitive pricing pressure and trade discounts given to stimulate sales. Having access to reliable sales information by market and product on a daily and weekly basis enables decisions to be taken quickly to implement market and product strategies", 
		"revenue":"1","productivity":"3","team":"1","stakeholder":"5",		
		"question1":"What is the time lag between making sales and you receiving data to your desktop? How is that information provided? Do you have trust in the completeness of global market data?",
		"question2":"How quickly can you disseminate data to produce ''root cause'' information? Do variances to forecast or mission come with a full explanation? Can you decide quickly where to focus attention to achieve positive change in performance?",
		"question3":"How many people are involved in the process to gather and report sales and margin information? Is the information available in a single repository? Are reports emailed or provided in an appropriate format which makes it easy to review no matter where you are?"
	},	
	{"name":"Scorecards & Dashboards", 
		"id":solutionId++,"roles":"manager","industries":"",
		"overview":"Modern management is regularly overwhelmed with the volume of data available. Reducing the amount of data they need to consume and letting them focus on the critical messages from data will lead to better decisions. Additionally increasing the avenues that the information may be accessed, will mean that busy management staff can access their results when it suits them and they will not be restricted to looking at printed output of having to be in the office.", 
		"revenue":"1","productivity":"3","team":"1","stakeholder":"5",		
		"question1":"Do you have busy managerial staff needing to consume large amounts of data on a regular basis? Do you find that the message is being lost or ignored in their in-tray?",
		"question2":"Are you printing or emailing your operational/management reporting?",
		"question3":"Do your management staff find it hard focus on the critical issues, lost in the excessive detail of the report?",
		"question4":"Are your management repots historically based? Are you simply reporting on history and not looking forward?"
	},
	{"name":"Scorecards & Dashboards (Government Utilities)", 
		"title":"Scorecards & Dashboards (Government Utilities)",
		"id":solutionId++,"roles":"manager","industries":"Utilities,Government",
		"overview":"Users of data are not ''technically literate'' and are time ''poor''. It is essential any solution provides accurate, timely and easily digestible information. Further drill through analysis to lower levels are required for those instances when further information is required. Users are spread over a wide area so any solution must be distributed.", 
		"productivity":"5","risk":"1","stakeholder":"5",		
		"question1":"How do you consolidate your data?  Is it a very manual process?  Are you comfortable with the accuracy of the process?",
		"question2":"Is the process clear and documented? Is it easily repeatable, each time you need to do it? Will it stand-up to scrutiny or analysis?",
		"question3":"How easy is it to get to the data required for consolidation?  Is the data readily available or do you have to ''reinvent the wheel'' each time looking for it & performing plumbing to gain access to the data? When new accounts are added, how sure are you that they are accounted for automatically?",
		"question4":"How important is it for the solution to be accessible and useable by a wide range of users? How do you distribute the information? How is more detail obtained?"
	},	
	{"name":"", 
		"title":"",
		"id":solutionId++, "roles":"", "industries":"", "features":"",
		"overview":"", 
		"revenue":"", "productivity":"", "risk":"", "yield":"", "team":"", "stakeholder":"",		
		"question1":"",
		"question2":"",
		"question3":"",
		"question4":"",
		"casestudy":""
	}
];

function getRoleFromPage() {
	var currentPageName = currentPath.substring(currentPath.lastIndexOf('/'));
	if (currentPageName.indexOf('_finance')>0) {
		return "finance";
	}
	if (currentPageName.indexOf('_hr')>0) {
		return "hr";
	}
	if (currentPageName.indexOf('_it')>0) {
		return "it";
	}
	if (currentPageName.indexOf('_managers')>0) {
		return "manager";
	}
	if (currentPageName.indexOf('_sales')>0) {
		return "sales";
	}	
	return "";
}

function buildScenarios() {
	var container = $('#scenarios');
	var role = currentRole == "" ? getRoleFromPage() : currentRole;
	for (index in solutions) {
		if (isItemInCollection(role,solutions[index].roles)) {
			var solution = solutions[index];
			var href = "";
			if (solution.overview!="" && currentSolutionId != solution.id) {
				href = "href='solutions.html?id=" + solutions[index].id + ";role=" + role + "' ";
			}
			container.append("<a " + href + (href!="" ? " class='link'" : "") + ">" + solution.name + "</a>");
		}
	}
}

function isItemInCollection(item, collection) {
	// Returns true if value is in comma separated collection, or if collection is empty
	if (collection==null || collection=='')
		return true;
	var text = ',' + collection + ','; // Surround with commas to prevent partial matching
	return text.indexOf(',' + item + ',')>=0;
} 

function populateContent() {
	currentRole = "";
	currentSolutionId=0;
	var params = unescape(location.search.substring(1)).split(';');
	for (index in params) {
		var param = params[index].substr(0,params[index].indexOf('='));
		var value = params[index].substr(params[index].indexOf('=')+1);
		if (param=='id') {
			currentSolutionId = value;
		}
		else if (param=='role') {
			currentRole=value;
		}
	}
	
	for (index in solutions) {
		if (solutions[index].id == currentSolutionId) {
			$('#dynamicContent .title').text(solutions[index].title==null ? solutions[index].name : solutions[index].title);
			$('#dynamicContent .overview').text(solutions[index].overview);
			
			setStars($('#dynamicContent .revenue'),solutions[index].revenue);
			setStars($('#dynamicContent .productivity'),solutions[index].productivity);
			setStars($('#dynamicContent .risk'),solutions[index].risk);
			setStars($('#dynamicContent .yield'),solutions[index].yield);
			setStars($('#dynamicContent .team'),solutions[index].team);
			setStars($('#dynamicContent .stakeholder'),solutions[index].stakeholder);
			if (solutions[index].question1!='') { $('#dynamicContent .question1').text(solutions[index].question1)};
			if (solutions[index].question2!='') { $('#dynamicContent .question2').text(solutions[index].question2)};
			if (solutions[index].question3!='') { $('#dynamicContent .question3').text(solutions[index].question3)};
			if (solutions[index].question4!='') { $('#dynamicContent .question4').text(solutions[index].question4)};
			
			if (solutions[index].casestudy!=null) {
				$('.caseStudy').attr('href','pdf/'+solutions[index].casestudy);
			}
			else {
				$('.caseStudy').hide();
			}			
			
			$('.question1:empty,.question2:empty,.question3:empty,.question4:empty').hide();
			break;
		}
	}
}

function setStars(element,stars) {
	if (Number(stars)==0 || isNaN(Number(stars))) {
		element.hide();
	}
	else {
		element.width(16 * Number(stars))
		element.parent().addClass('grayStars');
		element.siblings('.na').hide();
	}
}
