// JavaScript Document
//---------------------  File Header  -----------------------
//  onsiteFlagsDisplay.js
//
// Purpose:		set and display general status flags
//
//	Defines:		global variables
//
//	Functions:	setChanged()				Sets the "evaluation changed" flag and displays
//					setUnChanged ()			Resets the changed flag and displays
//					setSaved ()					Sets the form data saved flag and displays
//					setNotSaved ()				Resets the form data saved flag and disiplays
//					setCookieGlobal (name)	sets cookie global pointers and index
//

function setChanged ()
// ----------  Function Header  --------------
//	Name:			setChanged()
//	Purpose:		Sets the global "evaluation Changed" flag
//	Inputs:		none
//	Process:		set the flag
//					update form status
//	Outputs:		global change flag (evalChanged_G)
//	-------------------------------------------	
{
	evalChanged_G = true;
	F_G [changedFldName].value = "Changed";
	F_G.changed.value = "TRUE";
}

function setUnChanged ()
// ----------  Function Header  --------------
//	Name:			setUnChanged ()
//	Purpose:		sets the global "evaluation Changed" flag to false
//	Inputs:		none
//	Process:		set the floag
//					update form status
//	Outputs:		global and form status
//	-------------------------------------------
{
	evalChanged_G = false;
	F_G [changedFldName].value = "Unchanged";
	F_G.changed.value = "FALSE";
}

function setSaved ()
// ----------  Function Header  --------------
//	Name:			setSaved ()
//	Purpose:		sets the global saved flag and updates the screen
//	Inputs:		none
//	Process:		set flag, update screen
//	Outputs:		global and form status
//	-------------------------------------------
{
	evalSaved_G = true;
	F_G [savedFldName].value = "Saved";
	F_G.saved.value = "TRUE";
}

function setNotSaved ()
// ----------  Function Header  --------------
//	Name:			setNotSaved ()
//	Purpose:		resets the global saved flag and updates the screen
//	Inputs:		none
//	Process:		reset the flag, update the screen
//	Outputs:		none
//	-------------------------------------------
{
	evalSaved_G = false;
	F_G [savedFldName].value = "not saved";
	F_G.saved.value = "FALSE";
}

function addEvalNum ()
{
	F_G [numEvalsFldName].value = ++numEvals_G;
}

function subtractEvalNum ()
{
	F_G [numEvalsFldName].value = --numEvals_G;
}

// ==============================  SET COOKIE GLOBAL  ======================================
function setCookieGlobal (cName)
// ----------  Function Header  --------------
//	Name:			setCookieGlobal (cname)
//	Purpose:		set up the global cookie pointer and index
//	Inputs:		cookie name
//	Process:		pre-initialize the globals
//					if setting to null, exit
//					find the cookie
//					set the values
//	Outputs:
//	-------------------------------------------
{
	
	if ((cName == null) || (cName == ""))
	{
		currCookieI_G = null;
		currCookieO_G = null;
		F_G ["currCookie"].value = "";
	}
	else
	{
		F_G ["currCookie"].value = cName;
		for (i=0; i<numCookies_G; i++)
		{
			if (cookieLst_G [i].name == cName)
			{
				currCookieO_G = cookieLst_G [i];
				currCookieI_G = parseInt(currCookieO_G.name.substr(cookieNamePrefix_GS.length, 1));
				return;
			}
		}
	}
}