/*This controller supplies the data and functionality required for "next"
"previous" buttons to work and also for the breadcrumb that exists on top
of the view window. It basically gives the HTML access to what the current
page is and the pages after, so you can build a breadcrumb dynamically. It
also handles routing in the App*/

formApp.controller('NavController', ['$scope', '$location', '$timeout', 'Navigation',
	function($scope, $location, $timeout, Navigation) {

	// $scope.startForm = function() {
	// 	Navigation.init();
	// 	$scope.nextPage();
	// 	Navigation.updateView();
	// }
	/*When the Start Form button is pushed it sets all
	the variables needed to implement the functionality
	from a simple array, since Navigation is a service it
	acts as a singleton so Navigation.<any method> will run
	once and only once. */

	$scope.showNav = function () {
		return Navigation.navButtonControl();
	}
	/*This function returns a boolean value, the next and previous
	buttons should only be shown when you're not on the first page
	(the start page) and when you're not on the last page (it will be
	replaced by a submit button)*/

	$scope.nextPage = function() {
		Navigation.setButtons(Navigation.getNextPageIndex());
		Navigation.updateView();
	}

	$scope.previousPage = function() {
		Navigation.setButtons(Navigation.getPreviousPageIndex());
		Navigation.updateView();
	}
	/*This function updates the state of the next and previous
	buttons and calles updateView to change the view to the
	current page*/

	$scope.currentPageString = function () {
		return Navigation.getCurrentPage();
	}
	/*Returns the Camelified string of the current page of the form you're on*/

	$scope.nextPageString = function () {
		return Navigation.getNextPage();
	}
	/*Returns the Camelified string of the next page in the form. This relies
	on the current page being correct.*/

	$scope.previousPageString = function () {
		return Navigation.getPreviousPage();
	}
	/*Returns the Camelified string of the previous page in the form.
	This relies on the current page being correct.*/

	$scope.reset = function () {
		return Navigation.reset();
	}
	/*Sets all variables to NULL in the service and
	redirects to login page */

}]);