function part(name, type, number, year, qty, condition, price, notes)
{
	this.name = name;
	this.number = number;
	this.year = year;
	this.qty = qty;
	//this.stockDate = stockDate;
	this.condition = condition;
	this.price = price;
	this.notes = notes;
	this.template = document.getElementById("partTemplate");
	this.target = document.getElementById("target");
  this.compare = function(arg1, arg2)
	{
		var cOut = 0;
		if ( arg1 == null ) {
			cOut = 1;
		}
		else if ( arg2 == null )
		{
			cOut = 1;
		}
		else if ( arg1.name < arg2.name )
		{
			cOut = -1;
		}
		else if ( arg1.name > arg2.name )
		{
			cOut = 1;
		}
		return cOut;
	}
	this.show = function()
	{
		var thumb = function() {
		    return (window.imageList || {})[number.replace(/\s/g, '_')] ? ['<img class="icon" src="http://thebusco.appspot.com/thumb?n=', number.replace(/\s/g, '_') ,'&h=16&w=20" />'].join('') : ''
    };
    var sTemplate = this.template.innerHTML.replace(/!--CoMmEnT--/g, "");
		sTemplate = sTemplate.replace(/{__name__}/, name);
		sTemplate = sTemplate.replace(/{__number__}/, number);
		sTemplate = sTemplate.replace(/{__year__}/, year);
		sTemplate = sTemplate.replace(/{__qty__}/, qty);
		sTemplate = sTemplate.replace(/{__condition__}/, condition);
		sTemplate = sTemplate.replace(/{__price__}/, price);
		sTemplate = sTemplate.replace(/{__notes__}/, notes);
		sTemplate = sTemplate.replace(/{__thumb__}/, thumb());
		var color = "white";
		if( alt )
		{
			color = "#eeeeee";
		}
		alt = !alt;
		sTemplate = sTemplate.replace(/{__color__}/g, color);
		targetBuffer += sTemplate;
		//this.target.insertAdjacentHTML2("beforeEnd", sTemplate)// += "<!--CoMmEnT-->"
		//document.getElementById("target").innerHTML = document.getElementById("target").innerHTML.replace(/<!--CoMmEnT-->/, "<!--CoMmEnT-->" + sTemplate)
	}
}
part.showThumb = function(thead) {
  var icon = thead.getElementsByTagName('img')[0];
  if(icon) {
    var tbody = thead.nextSibling;
    var thumb = icon.cloneNode(true);
    thumb.src = thumb.src.replace(/(w|h)\=\d+/g, '$1=150');
    thumb.className = 'thumb';
    thumb.onclick = part.showBig;
    var td = tbody.rows[0].cells[0];
    td.replaceChild(thumb, td.firstChild);
  }
};
part.showBig = function() {
  var big = this.cloneNode(true);
  big.src = big.src.replace(/(w|h)\=\d+/g, '$1=640');
  big.className = 'big';
  big.onclick = function() {
    this.parentNode.removeChild(this);
  };
  var body = document.body;
//  body.appendChild(big, body.firstChild);
  this.parentNode.appendChild(big, this);
};
