/** 
	logosArchive
	
	@author gjwoodfill@stthomas.edu
	Contains functions for the Logos Archive.
	
*/

// Classes


function Volume(volume, season, month, year, volumeLink, volumeImage) {
	this.volume = volume;
	this.season = season;
	this.month = month;
	this.year = year;
	this.volumeLink = volumeLink;
	this.volumeImage = volumeImage;
}

// class methods


// sorting methods

function sortByYear(a,b){
	// sort years descending, months, ascending
	if(a.year > b.year) {
		return -1;
	}
	if (a.year <  b.year){
		return 1;
	}
	else {  
		if (a.month < b.month)
		{
			return -1;
		}
		else if (a.month > b.month)
		{
			return 1;
		}
		else
		{
			return 0;
		}
	} //else
}

// functions

function displayTable(volumeList)
{

	var currentYear;
	var i = 0;
	// sort the array
	volumeList.sort(sortByYear);
	
	currentYear = 0;
	
	
	
	for (i=0;i<volumeList.length;i++)
	{
		if (currentYear != volumeList[i].year)
		{
			// if the first time around don't close the row
			if (i != 0)
			{	
				document.write("</tr>");
			}
			
			document.write("<tr class=\"archive_tr\">");
			document.write("<td valign=\"top\"><div class=\"year\">"+ volumeList[i].year + "</div></td>") ; 
			
		}
		
		else
		{
			// print out the articles
			
		}
		document.write("<td valign=\"top\"><div class=\"logo_item\"><a href='" + volumeList[i].volumeLink + "'>" + volumeList[i].volumeImage + "</a></div><div class=\"logo_text\">" + "Vol " + volumeList[i].volume + "<br>" + volumeList[i].season ) + "</div>";
		currentYear = volumeList[i].year;
	}
}

// local variables
var volumeList = new Array();
var i = 0;
var tempVolume;
var tempSeason;
var tempMonth;
var tempYear;   
var tempVolumeImage;
var tempVolumeLink;


		

