var isChanged = false;

function carefulClose()
{
	if (isChanged)
	{
		if (confirm("Close without saving?"))
		{
			self.close();
		}
		else
		{
			return void(0);
		}
	}
	else
	{
		self.close();
	}
}

function carefulSubmit()
{
	if (isChanged)
	{
		if (! confirm("Close without saving?"))
		{
			return false;
		}
	}
}

function carefulLink(h)
{
	if (isChanged)
	{
		if (! confirm("Close without saving?  If you click OK, you will loose data. To save your work, click Cancel, scroll down to the bottom of this page, and hit the Save button. "))
		{
			return void(0);
		}
	}
	
	self.location = h;
}

function spsFormChanged()
{
	isChanged = true;
}

var remote = null;
function rs(n,u,w,h) {
  remote = window.open(u, n, 'width=' + w + ',height=' + h +',resizable=yes,scrollbars=yes');
  if (remote != null) {
    if (remote.opener == null)
      remote.opener = self;
    window.name = 'Popup';
    remote.location.href = u;
  }
}

function toggleField(field)
{
	var d = document.getElementById(field);
	var i = document.getElementById(field + "_img");

	if (d != null)
	{
		if (d.style.display == "block")
		{
			d.style.display = "none";
			if (i != null)
			{
				i.src = "/sps/icons/info.gif";
			}
		}
		else
		{
			d.style.display = "block";
			if (i != null)
			{
				i.src = "/sps/icons/info_hi.gif";
			}
		}
	}
}

function toggleFieldSet(field, state)
{
	var d = document.getElementById(field);
	var i = document.getElementById(field + "_img");

	if (d != null)
	{
		if (state)
		{
			d.style.display = "block";
			if (i != null)
			{
				i.src = "/sps/icons/info_hi.gif";
			}
		}
		else
		{
			d.style.display = "none";
			if (i != null)
			{
				i.src = "/sps/icons/info.gif";
			}
		}
	}
}


if (document.images)	{

var about_on=new Image();
about_on.src="/images/banner/subbanner_about_on.gif";
var about_off=new Image();
about_off.src="/images/banner/subbanner_about.gif";

var apply_on=new Image();
apply_on.src="/images/banner/subbanner_apply_on.gif";
var apply_off=new Image();
apply_off.src="/images/banner/subbanner_apply.gif";

var grantee_on=new Image();
grantee_on.src="/images/banner/subbanner_grantee_on.gif";
var grantee_off=new Image();
grantee_off.src="/images/banner/subbanner_grantee.gif";

var contact_on=new Image();
contact_on.src="/images/banner/subbanner_contact_on.gif";
var contact_off=new Image();
contact_off.src="/images/banner/subbanner_contact.gif";

}

function rollon (imgName)	{
	if (document.images)	{
		document.images[imgName].src = "/images/banner/subbanner_" + imgName + "_on.gif";
	}
}

function rolloff (imgName)	{
	if (document.images)	{
		document.images[imgName].src = "/images/banner/subbanner_" + imgName + ".gif";
	}
}
