/* Flashes a table row's cells. */

function pulseTableRow(rowid, opts){
	if(!opts){
		opts = {};
	}
	var row  = $(rowid);
	var cells= row.childNodes;
	for(i=0;i<cells.length;i++){
		if(cells[i].tagName == 'TD'){
			new Effect.Pulsate(cells[i],opts);
		}
	}
	new Effect.Pulsate(row,opts);
}

/* Fades away a table row's cells. */

function fadeTableRow(rowid, opts){
	if(!opts){
		opts = {};
	}
	var row  = $(rowid);
	var cells= row.childNodes;
	for(i=0;i<cells.length;i++){
		if(cells[i].tagName == 'TD'){
			new Effect.Fade(cells[i],opts);
		}
	}
	new Effect.Fade(row,opts);
}

/* Shows a newly created record in a table. */

function showRecord(rowid)
{
	pulseTableRow (
			$(rowid.toString()),
			{duration: 1.0}
		);
}

/* Hides a deleted record in a table. */
/* NEEDS a gotoPrevPage() functions on same page! */

function hideRecord(rowid)
{
	var switching = false; // switch alt styles?
	for (var i = 0; i < allRowIds.length; i++)
	{
		if (allRowIds[i] == rowid) { // row to delete
			if (allRowIds.length == 1) { // only one row?
				fadeTableRow (
						$(rowid),
						{duration: 1.0, from: 1.0, to: 0.0, afterFinish: gotoPrevPage}
					);
			} else { // more than one row - switch alt styles after this
				fadeTableRow (
						$(rowid),
						{duration: 1.0, from: 1.0, to: 0.0}
					);
				switching = true;
			}
		} else {
			if (switching == true) { // switch alt styles
				if (Element.hasClassName($(allRowIds[i].toString()), 'alt') == true) {
					Element.removeClassName($(allRowIds[i].toString()), 'alt');
				} else {
					Element.addClassName($(allRowIds[i].toString()), 'alt');
				}
			}
		}
	}
}
