/* publicationObj.js */

var g_publicationId = 0;

function PublicationObject()
{
	this.id = null;			// just an id
	this.authors = new Array();	// contains the list of authors
	this.name = null;			// name of the Publication
	this.psurl = null;
	this.pdfurl = null;
	this.conference = null;		// the conference in which this Publication was published
	this.year = null;			// the year of publication
	
}

/*
  Parses the string and fills up the values in this object
  The parsing is according to this metric:
  Name # Author1, Author2.. # Conference # Year # pslink # pdflink 
*/
PublicationObject.prototype.createPublication = function(PublicationInfo /* string */)
{
	try
	{
		var values = PublicationInfo.split("#");
		this.name = values[0];
		this.authors = values[1].split(",");
		this.conference = values[2];
		this.year = values[3];
		this.pslink = values[4];
		this.pdflink = values[5];
		this.id = g_publicationId;
		g_publicationId ++ ;
	}
	catch(e)
	{
		//ignoring publication
		//alert("Error in publication: " + PublicationInfo);
	}
}

/*
Adds html to the dom object. The html is the representation of the publication. 
*/
PublicationObject.prototype.addPublicationTo = function(tableId /* domObject */)
{
	var tableObj = elm(tableId);
	var trObj = tableObj.insertRow(tableObj.rows.length);
	var tdObj = trObj.insertCell(trObj.cells.length);
	tdObj.innerHTML += this.year;
	
	
	
	tdObj =trObj.insertCell(trObj.cells.length);
	tdObj.innerHTML += this.name;
	
	tdObj = trObj.insertCell(trObj.cells.length);
	tdObj.innerHTML += this.authors;
	
	tdObj = trObj.insertCell(trObj.cells.length);
	tdObj.innerHTML += this.conference;
	
	
	tdObj = trObj.insertCell(trObj.cells.length);
	
	tdObj.innerHTML += "<a href="+this.pslink + "> PS </a> | <a href = " + this.pdflink +" > PDF </a>";
	
	var gentimeObj = elm("gentime");
	var t2 = getTimeStamp();
	gentimeObj.innerHTML = "html code generated in " + (t2 - g_t1 )+ " ms";
	
}