// Resource arrays
var projects=new Array();

// Reset the projects
function resetProjects()
{
	resetImages();
	projects=new Array();
}

// Project
function Project(title,text)
{
	this.title=title;
	this.text=text;
}

// Add a project to the relevant position
function addProject(title,text,pos,filename,alt)
{
	if (projects[pos]==null)
		projects[pos]=new Project(title,text);
	if (filename!=null && filename!="")
		addImage(filename,alt,pos);
}

// List the projects
function listProjects()
{
	stopAllIntervals();

	var html="";

	for (i in projects)
	{
		html +=	'<div id="'+i+'Container">'
		+		'<a href="#" onclick="openProject(\''+i+'\');return false;">'
		+			projects[i].title
		+		'</a>'
		+	'</div>';
	}

	document.getElementById('projects').innerHTML=html;
}

// Open a project
function openProject(id)
{
	var html=	'<a href="#" onclick="closeProject(\''+id+'\');return false;">'
		+		projects[id].title
		+	'</a><br/><br/>';

	var project=projects[id];
	html+=	'<div class="adjustable" id="'+id+'" style="width:670px;" align="justify">'
	+		'<b>'+project.title+'</b><br/><br/>'
	+		'<div class="floatRight">'
	+			'<img class="slideshow" id="'+id+'Slideshow" src="images/blank.jpg" alt=""/>'
	+		'</div>'
	+		project.text
	+	'</div>';

	document.getElementById(id+"container").innerHTML=html;
	
	runSlideshow(id+'Slideshow',id);
}

// Close a project
function closeProject(id)
{
	var html=	'<a href="#" onclick="openProject(\''+id+'\');return false;">'
		+			projects[id].title
		+		'</a>';
		

	document.getElementById(id+"container").innerHTML=html;

	stopSlideshow(id)
}