
/***********************************************************************************************/
/* This file should be used to contain all kinds of useful generic little JavaScript utilities.*/
/***********************************************************************************************/


/**
 * @param anID is the ID of the row to delete
 * @param delpage is the page that will do the deletion (just pass the name, don't need to pass the file extension
 * usage: confirm_delete('somepage',4) will pass 4 to somepage.php (the .php is added inside this function!) AFTER the user clicks "OK".
 * @return always returns true.
 * @author Solomon Shorser
 */
function confirm_delete(anID,delpage)
{
	input_box=confirm("Click OK to delete");
	if (input_box==true){ 
		aStr = delpage+".php?id=" + anID;
		window.location = aStr;
	}
	return true;
}

/**
 * An overload of the above function. It takes an extra parameter and displays it in the confirmation dialogue.
 * @param delobj is the name of the object to be deleted. Should be passed to the function as a string.
 */
function confirm_delete(anID,delobj,delpage)
{
	input_box=confirm("Click OK to delete: "+delobj);
	if (input_box==true){ 
		aStr = delpage+".php?id=" + anID;
		window.location = aStr;
	}
	return true;
}

/*function clear_form(aForm,val)
{
	var elements, i, elm;
	elements = aForm.getElementsByTagName('input');
		for( i=0, elm; elm=elements.item(i++); )
		{
			//alert ('test');
			if (elm.getAttribute('type') == "text")
			{
				elm.value = val;
			}
		}
}*/

/**
 * @param id is the ID for the table row to hide.
 */
function hideTableRow(id)
{
	//Trying to use the "display" property causes problems with Internet Explorer (whatever version I'm using) but it works FINE in Firefox. grrr...
	//document.getElementById(id).style.display="none";
	document.getElementById(id).style.visibility = "hidden";
}

/**
 * makes a table row visible; only has an effect if the row had been previously hidden.
 * @param id is the ID for the table row to show.
 */
function showTableRow(id)
{
	//Trying to use the "display" property causes problems with Internet Explorer (whatever version I'm using) but it works FINE in Firefox. grrr...
	//document.getElementById(id).style.display="table-row";
	document.getElementById(id).style.visibility = "visible";
}

/**
 * opens a URL in a new browser window.
 * @param url is the URL to open.
 */
function newWindowWithURL(url)
{
	window.open(url);
}
