var NumProjectsToDisplay = 4;
var projects = new Array(new Project('Atlantic Superstore','projects/feature_atlanticsuperstore.jpg','s_project_atlanticsuperstore.html'),
			 new Project('Architectural Renderings','projects/feature_ramarrenderings.jpg','s_project_ramarrenderings.html'),
			 new Project('Bedford/Sackville Sewer Study','projects/feature_bedfordsackvilletrunk.jpg','s_project_bedfordsackvilletrunk.html'),
			 new Project('Bridgewater Waste Water','projects/feature_bridgewaterwastewaterassessment.jpg','s_project_bridgewaterwastewaterassessment.html'),
			 new Project('Canadian Tire','projects/feature_canadiantire.jpg','s_project_canadiantire.html'),
			 new Project('Climate Change Adaptation','projects/feature_climatechange.jpg','s_project_climatechange.html'),
			 new Project('Bathurst Revitalization Study','projects/feature_downtownbathurst.jpg','s_project_downtownbathurstrevitalization.html'),
			 new Project('Design Drawing Portfolio','projects/feature_renderingportfolio.jpg','s_project_renderingportfolio.html'),
			 new Project('Halifax Airport Development Plan','projects/feature_halifaxairportdevplan.jpg','s_project_halifaxairportdevplan.html'),
			 new Project('H.R.M. Parking Strategy','projects/feature_hrmparkingstrategy.jpg','s_project_hrmparkingstrategy.html'),
			 new Project('North Dartmouth Trunk Sewer','projects/feature_northdartmouthtrunksewer.jpg','s_project_northdartmouthtrunksewer.html'),
			 new Project('Sherwood Golf Course','projects/feature_sherwoodgolfcourse.jpg','s_project_sherwoodgolfcourse.html'),
			 new Project('South Colchester High','projects/feature_southcolchesterhighschool.jpg','s_project_southcolchesterhighschool.html'),
			 new Project('Wind Energy Master Plan','projects/feature_windenergymasterplan.jpg','s_project_windenergymasterplan.html'),
			 new Project('Village of New Maryland','projects/feature_newmaryland.jpg','s_project_newmaryland.html'));
function Project(name, image, link)
{
	this.name = name;
	this.image = image;
	this.link = link;
}

function GetRandomNumber()
{
	var rndNumber = (Math.round((Math.random()*(projects.length -1))));
	return rndNumber;
}

function WriteProjects()
{
	var UsedProjects = new Array();

	for(var i=0;i<NumProjectsToDisplay;i++)
	{
		var iRndNum;
		do
		{
			iRndNum = GetRandomNumber();
		}
		while(IsInArray(iRndNum,UsedProjects))
		UsedProjects[i] = iRndNum;
	}
	for(i=0;i<UsedProjects.length;i++)
	{
		// Write out the items
		document.writeln("<td width='188' bgcolor='#E5E0D2' background='" + projects[UsedProjects[i]].image + "' valign='middle'>");
	        document.writeln("  <a class='smalllink' href='" + projects[UsedProjects[i]].link + "'>");
        	document.writeln("   <div style='width: 188px; cursor: pointer; padding-top: 58px; text-align: center; valign: middle;'>");
	        document.writeln("    <span class='smalllink'><b>" + projects[UsedProjects[i]].name + "</b></span>");
        	document.writeln("   </div>");
	        document.writeln("  </a>");
        	document.writeln(" </td>");
		if(i!=(UsedProjects.length -1))
		{
	        	document.writeln("<td width='1' bgcolor='#32381C'><img src='images/1x1_spacer.gif' width='1' height='72'></td>");
		}
		else
		{
			document.writeln("<td width='5' bgcolor='#32381C'><img src='images/fade_band2.gif' width='5' height='72'></td>");
		}
		
	}
}

function IsInArray(iNum, arToCheck)
{
	var ReturnVal = false;
	for(i=0;i<arToCheck.length;i++)
	{
		if(arToCheck[i] == iNum)
		{
			ReturnVal = true;
			break;
		}
	}
	return ReturnVal;
}
