function TripLocation()
{
	this.commentID = 0;
	this.cityID = 0;
	this.locationID = 0;
	this.lat = 0.0;
	this.lon = 0.0;
	this.sortIndex = 100;
	this.showOnMap = 1;
	this.locationName = "";
	this.date = "";
	
	this.parse = TripLocation_parse;
	this.renderSummaryRow = TripLocation_renderSummaryRow;
	this.toString = TripLocation_toString;
}

function TripLocation_parse(raw)
{
	var tokens = raw.split("\t");
	if (tokens.length >= 8)
	{
		this.commentID = parseInt(tokens[0]);
		this.cityID = parseInt(tokens[1]);
		this.locationID = parseInt(tokens[2]);
		this.lat = parseFloat(tokens[3]);
		this.lon = parseFloat(tokens[4]);
		this.showOnMap = parseInt(tokens[5]);
		this.locationName = tokens[6];
		this.date = tokens[7];
		
		return true;
	}

	return false;
}

function TripLocation_renderSummaryRow(tr, rowIndex, rowCount)
{
	var td;
	var img;
	var h;
	var input;
	var a;
	
	// image
	td = document.createElement("TD");
	img = new Image();
	img.src = "/images/comment.gif";
	td.appendChild(img);
	tr.appendChild(td);

	// name
	td = document.createElement("TD");
	h = document.createElement("H2");
	h.appendChild(document.createTextNode(this.locationName));
	td.appendChild(h);
	tr.appendChild(td);
	
	// date input
	td = document.createElement("TD");
	input = document.createElement("INPUT");
	input.setAttribute("type", "text");
	input.setAttribute("name", "date_" + rowIndex);
	input.setAttribute("id", "date_" + rowIndex);
	input.setAttribute("value", this.date);
	input.setAttribute("onchange", "date_change(" + rowIndex + ")");
	input.onchange = new Function ("evt", "date_change(" + rowIndex + ");"  ); 	// for IE
	td.appendChild(input);
	td.appendChild(document.createTextNode(" "));
	a = getImageLink("/Calendar/img/cal.gif", "javascript:showCalendar(" + rowIndex + ");", "Popup Calendar")
	td.appendChild(a);
	tr.appendChild(td);
	
	
	
	// up, down & delete links
	td = document.createElement("TD");
	td.setAttribute("nowrap", "");
	if (rowIndex == 0)
		{ td.appendChild(  getImage("/images/up_disabled.gif")  ); }
	else
		{ td.appendChild(  getImageLink("/images/up.gif", "javascript:moveUp(" + rowIndex + ")", "Move Up")  ); }
	td.appendChild(  getImageLink("/images/delete.gif", "javascript:deleteLocation(" + rowIndex + ")", "Delete")  );
	td.appendChild(  document.createElement("BR")  );
	if (rowIndex == rowCount - 1)
		{ td.appendChild(  getImage("/images/down_disabled.gif")  );}
	else
		{ td.appendChild(  getImageLink("/images/down.gif", "javascript:moveDown(" + rowIndex + ")", "Move Down")  ); }
	
	tr.appendChild(td);
	
	
	
	

}

function getImage(src, title)
{
	var img = new Image();
	img.src = src;
	img.border = 0;
	img.alt = title ? title : "";
	
	return img
}

function getImageLink(src, href, title)
{
	var a = document.createElement("A");
	a.setAttribute("href", href);
	a.title = title ? title : "";
	a.appendChild(getImage(src, title));
	
	return a;
}

function TripLocation_toString()
{

	return this.commentID + "\t"
		+ this.cityID + "\t"
		+ this.locationID + "\t"
		+ this.lat + "\t"
		+ this.lon + "\t"
		+ this.showOnMap + "\t"
		+ this.locationName + "\t"
		+ this.date;
}

