horseshow_diary_auto_table.prototype = new auto_table;
horseshow_diary_auto_table.constructor = horseshow_diary_auto_table;
horseshow_diary_auto_table.prototype.display_html_table = horseshow_diary_display_html_table;
horseshow_diary_auto_table.prototype.new_td = horseshow_diary_table_new_td;

function horseshow_diary_auto_table()
{
	this.public = true;
}

function horseshow_diary_table_new_td(text, index)
{

	var td = document.createElement("td");
	if (text != undefined)
	{
		if (text.indexOf("SQL_DATE") == 0 )
		{
			var sbd = new SB_Date();
			sbd.fromSQL(text.substr(8));
			text =  sbd.get_date_string();
		}

		text = text.replace(/\|n/g, " ");
	}
	else
		text = "";

	td.innerHTML = text;
	td.id = this.table_name + "_" + index;
    setClassAttribute(td, "showtable_td");
	return td;
}


function horseshow_diary_display_html_table()
{
	var i=0; 
	var sbd = new SB_Date();
	for (i=0; i < this.ar_filtered.length; i++)
	{
		if (i >= this.max_rows)
		{
			var tr = document.createElement("tr");
			setClassAttribute(tr, "auto_table_tr");

			tr.id = this.table_name + "_" + i;

			var td = this.new_td("", i);

			if (this.ar_filtered[i]['closing_soon'])
				td.innerHTML = '<img src="../images/btn_closing.gif" alt="Closing soon!" width="45" height="24"/>';
			else
				td.innerHTML = "";
			tr.appendChild(td);

			sbd.fromSQL(this.ar_filtered[i]['date'].substr(8));
			td = this.new_td(sbd.get_date_string(), i);
			tr.appendChild(td);

			td = this.new_td(this.ar_filtered[i]['name'], i);
			tr.appendChild(td);

			if (this.public)
				td = this.new_td('<a href="javascript:nothing()"><img src="../images/btn_more_detail.gif" class = "horseshow_auto_table_td" alt="More information on this show" width="51" height="16" id = "' + this.table_name + '_more_' + i + '"/></a>', i);
			else
			{
				if (this.ar_filtered[i]['membership_level'] <= 2)
					td = this.new_td('<a href="javascript:nothing()"><img src="../images/btn_more_detail.gif"  class = "horseshow_auto_table_td" alt="More information on this show" width="51" height="16" id = "' + this.table_name + '_more_' + i + '"/></a>', i);
				else
					td = this.new_td("", i);
			}


			tr.appendChild(td);
			if (this.ar_filtered[i]['pdf'] == 1)
				td = this.new_td('<a href="../pdf/' +this.ar_filtered[i]['pdf_filename'] + '"><img src="../images/btn_dl_pdf.gif" alt="Download show schedule" width="58" height="22" id = "' + this.table_name + '_pdf_' + i + '"/></a>', i);
			else
				td = this.new_td("", i);
			tr.appendChild(td);

			if ((this.ar_filtered[i]['membership_level'] == 3) )
		    	td = this.new_td('<a href="javascript:nothing()"><img src="../images/btn_enter.gif"  class = "horseshow_auto_table_td" alt="Enter online here!" width="55" height="24" id = "' + this.table_name + '_enter_' + i + '"/></a>', i);
			else			
				td = this.new_td("", i);
			
			td.id = this.table_name + "_enter_" + i;

			tr.appendChild(td);
			
			this.tableBody.appendChild(tr);			
		}
		else
		{
			var tr = gbi(this.table_name + "_" + i);
			var elem = tr.firstChild;
			if (this.ar_filtered[i]['closing_soon'])
				elem.innerHTML = '<img src="../images/btn_closing.gif" alt="Closing soon!" width="45" height="24"/>';
			else
				elem.innerHTML = "";
			elem = elem.nextSibling;

			sbd.fromSQL(this.ar_filtered[i]['date'].substr(8));
			elem.innerHTML = sbd.get_date_string();

			elem = elem.nextSibling;
			elem.innerHTML = this.ar_filtered[i]['name'];
			elem = elem.nextSibling;

			if (this.ar_filtered[i]['membership_level'] <= 2)
				elem.innerHTML = '<img src="../images/btn_more_detail.gif" class = "horseshow_auto_table_td" alt="More information on this show" width="51" height="16"  id = "' + this.table_name + '_more_' + i + '"/>';
			else
				elem.innerHTML = "";

			elem = elem.nextSibling;
			if (this.ar_filtered[i]['pdf'] == 1)
				elem.innerHTML = '<img src="../images/btn_dl_pdf.gif" alt="Download show schedule" width="58" height="22"  id = "' + this.table_name + '_pdf_' + i + '"/>';
			else
				elem.innerHTML = "";
	
			elem = elem.nextSibling;
			if ((this.ar_filtered[i]['membership_level'] == 3) )
				elem.innerHTML = '<img src="../images/btn_enter.gif" class = "horseshow_auto_table_td" alt="Enter online here!" width="55" height="24"  id = "' + this.table_name + '_enter_' + i + '"/>';
			else
				elem.innerHTML = "";

		}
	}

	this.current_rows = this.ar_filtered.length;
		
	for (i=0; i < this.current_rows; i++)
	{
	    setTableDisplay(this.table_name + "_" + i);
	}
	for (i=this.current_rows; i < this.max_rows; i++)
		gbi(this.table_name + "_" + i).style.display = "none";

	if (this.max_rows < this.current_rows)
		this.max_rows = this.current_rows;

	for (index=0; index < this.ar_filtered.length; index++)
		gbi(this.table_name + "_" + index).style.backgroundColor = '#ffffff';

}
