function ProjectHandler(projectsObject)
{
	this.allProjects = projectsObject;
	this.selectedProjects = null;
}

ProjectHandler.prototype.getAllProjects = function()
{
	var tempArray = new Array();
	for(proj in this.allProjects)
	{
		this.allProjects[proj].index = tempArray.length;
		tempArray.push(this.allProjects[proj]);
	}
	this.selectedProjects = tempArray;
	this.currentProject = this.selectedProjects[0];
	this.currentProject.projectArray = this.selectedProjects;
	this.currentProject.index = 0;
	return this.selectedProjects;
}

/*ProjectHandler.prototype.getProject = function(projectId)
{
	this.selectedProjects = this.allProjects[projectId];
	this.currentProject = this.selectedProjects[0];
	this.currentProject.projectArray = this.selectedProjects;
	this.currentProject.index = 0;
	return this.selectedProjects;
}*/

ProjectHandler.prototype.getCategory = function(categoryString)
{
	var tempArray = new Array();
	for(proj in this.allProjects)
	{
		if(this.allProjects[proj].category == categoryString)
		{
			this.allProjects[proj].index = tempArray.length;
			tempArray.push(this.allProjects[proj]);
		}
	}
	this.selectedProjects = tempArray;
	this.currentProject = this.selectedProjects[0];
	this.currentProject.projectArray = this.selectedProjects;
	this.currentProject.index = 0;
	return this.selectedProjects;
}

ProjectHandler.prototype.loadNextProject = function()
{
	if(this.currentProject.index < (this.selectedProjects.length - 1))
	{
		this.currentProject = this.selectedProjects[this.currentProject.index+1];
	}
	else
	{
		this.currentProject = this.selectedProjects[0];
	}
	this.loadProject();
	return false;
}

ProjectHandler.prototype.loadPreviousProject = function()
{
	if(this.currentProject.index == 0)
	{
		this.currentProject = this.selectedProjects[this.selectedProjects.length-1];
	}
	else
	{
		this.currentProject = this.selectedProjects[this.currentProject.index-1];
	}
	this.loadProject();
	return false;
}

ProjectHandler.prototype.loadProject = function()
{
	var currentProject = this.currentProject;
	buildViewNav(currentProject);
	//each project only has one Description so we can set that here
	document.getElementById("descriptionTitle").innerHTML = currentProject.descriptionTitle;
	document.getElementById("description").innerHTML = currentProject.description;
	//initialize first view when loading a project
	setCurrentView(0);
	return false;
}

