// JavaScript Document
var mb_dirty = false;
function getDirty() {return mb_dirty;}
function setDirty() {mb_dirty = true;}
function setClean() {mb_dirty = false;}

function checkDirty()
{
	if (mb_dirty)
		return("You have made changes to one or more fields on this page. If you continue, you will lose your changes.");
}
function checkCollectionDirty()
{
	alert(event.srcElement);
	if (mb_dirty)
		return(confirm("You have made changes to one or more fields on this page. If you continue, you will lose your changes."));
	else
		return true;
}
function submitForm()
{
	if (!ValidatorOnSubmit()) 
		return false;
	else
		setClean();
}
function setDataInputFields(fname)
{
	// loop through the elements in the specified form
	for (var i=0; i < document.forms[fname].elements.length; i++)
	{
		var obj = document.forms[fname].elements[i];
		switch (obj.type)
		{
			case "text":
				obj.onchange = setDirty; break;
			case "textarea":
				obj.onchange = setDirty; break;
			case "select-one":
				obj.onclick = setDirty; break;
			case "checkbox":
				obj.onclick = setDirty; break;
		} 
	}
	// set the form to clean the form out
	document.forms[fname].onsubmit = submitForm;
}
