
function coralName (text) {
	this._name = text;
}

function coralScientificName (text) {
	this._scientificName = text;
}

function coralCareRating (text) {
	this._careRating = text;
}

function coralDescription (text) {
	this._description = text;
}

function coralImage (text) {
	if (text.substr(0, 4) == 'http') {
		this._image = text;
	}
	else {
		this._image = this._imgDir + text;
	}
}

function coralBigImage (text, width, height) {
	if (text.substr(0, 4) == 'http') {
		this._bigImage = text;
	}
	else {
		this._bigImage = this._imgDir + text;
	}
	this._bigImageWidth  = width;
	this._bigImageHeight = height;
}

function coralDisplay () {
	var out = '<div class="coral"><table><tr>';
	if (this._image) {
		if (!this._bigImage) {
			this._bigImage = this._image.replace(/_sm[.]/, '.');
			this._bigImageWidth  = 600;
			this._bigImageHeight = 400;
		}
		out += '<td class="coralimage"><a ' +
			'href="' + this._bigImage + '" ' +
			'onclick="javascript:return popimage(\'' +
			this._bigImage + '\',' + this._bigImageWidth +
			',' + this._bigImageHeight + ')"><image border="0" ' +
			'title="Click to Enlarge" src="' +
			this._image + '" /></a></td><td class="coralname">';
	}
	else {
		out += '<td class="widecoralname" colspan="2">';
	}
	if (this._name) {
		out += '<p class="coralname">' +
			this._name + '</p>';
	}
	if (this._scientificName) {
		out += '<p class="coralscientificname">' +
			this._scientificName + '</p>';
	}
	out += '</td></tr><tr><td colspan="2">';
	if (this._description) {
		out += '<p class="coraldescription">' +
			this._description + '</p>';
	}
	out += '</td></tr><tr valign="bottom"><td colspan="2">';
	if (this._careRating) {
		out += '<p class="coralcarerating">Care Rating: ' +
			this._careRating + '</p>';
	}
	out += '</td></tr></table></div>';
	document.write(out);
}

function Coral () {
	this._imgDir = 'images/corals/';

	this._name           = '';
	this._scientificName = '';
	this._careRating     = '';
	this._description    = '';
	this._image          = '';
	this._bigImage       = '';

	this.name           = coralName;
	this.scientificName = coralScientificName;
	this.careRating     = coralCareRating;
	this.description    = coralDescription;
	this.image          = coralImage;
	this.bigImage       = coralBigImage;

	this.display        = coralDisplay;
}

