/* JavaScript Document: validateSingleSweep.js

	Change Log:

	Date		Programmer			Proj/Issue/SubTask	Description
	----		----------			------------------	-----------
	11/18/2006	Adrian J. Moreno	8	4189	4338	added displayTableRow(), common submit button message functions
	01/03/2007	Adrian J. Moreno	8	4189	5500	added doSubmit()
	03/08/2007	Adrian J. Moreno	8	4189	6126	added changeBgColor(); updated doSearching()
*/

// dHTML MicroAPI found at http://www.quirksmode.org/
var DHTML = (document.getElementById || document.all || document.layers);

function getObj(name)
{
  if (document.getElementById) { this.obj = document.getElementById(name); this.style = document.getElementById(name).style; }
  else if (document.all) { this.obj = document.all[name]; this.style = document.all[name].style; }
  else if (document.layers) { this.obj = document.layers[name]; this.style = document.layers[name]; }
}
/* Common document object functions */
/*
@function 	= 	showObject()
@purpose 	= 	alter the visibility of an object
@parameters = 	objID: ID; flag: 0 = hidden, 1 = visible
@returns	= 	void
@usage		=	showObject("someID", x)
*/
function showObject(objID, flag) { if (!DHTML) return; var x = new getObj(objID); x.style.visibility = (flag) ? 'visible' : 'hidden'; }
/*
@function 	= 	displayObject()
@purpose 	= 	alter the display of an object
@parameters = 	objID: ID; flag: 0 = none, 1 = block
@returns	= 	void
@usage		=	displayObject("someID", x)
*/
function displayObject(objID, flag) { if (!DHTML) return; var x = new getObj(objID); x.style.display = (flag) ? 'block' : 'none' }
/*
@function 	= 	displayTableRow()
@purpose 	= 	alter the display of a table row
@parameters = 	objID: ID; flag: 0 = none, 1 = ''; MSIE 6 doesn't support the CSS property "table-row"
@returns	= 	void
@usage		=	displayTableRow("someID", x)
*/
function displayTableRow(objID, flag) { if (!DHTML) return; var x = new getObj(objID); x.style.display = (flag) ? '' : 'none'; }
/*
@function 	= 	setMessage()
@purpose 	= 	Changes the text/HTML inside a named element
@parameters = 	objID: ID; msg: string
@returns	= 	void
@usage		=	setMessage("someID", "someText")
*/
function setMessage(objID, msg) { if (!DHTML) return; var x = new getObj(objID); x.obj.innerHTML = msg; }
/*
@function 	= 	enableObject()
@purpose 	= 	Sets a message on and/or enables a specified form element
@parameters = 	formID: ID of a form element; flag: 0 = disabled, 1 = enabled; msg: string
@returns	= 	void
@usage		=	enableObject("someFormID", x, "someText")
*/
function enableObject(formID, flag, msg) { if (!DHTML) return; var x = new getObj(formID); x.obj.value = msg; x.obj.disabled = (flag) ? "" : "disabled"; }
/*
@function 	= 	setDivTitle()
@purpose 	= 	changes the content of the title attribute on a <div>
@parameters = 	divID: ID of a <div>; msg: string
@returns	= 	void
@usage		=	setDivTitle("someDivID", "someText")
*/
function setDivTitle(divID, msg) { if (!DHTML) return; var x = new getObj(divID); x.obj.title = msg; }
function changeStyle(objID, styleName, styleValue) { if (!DHTML) return; var x = new getObj(objID); x.style[styleName] = styleValue; }
function errorLabel(lblID, flag) { if (flag == 1) { document.getElementById(lblID).className = "message"; } else { document.getElementById(lblID).className = ""; } }
/*
@function 	= 	showHint()
@purpose 	= 	changes the absolute position of a hidden <div> relative to the parent object and displays the div;
@parameters = 	divID: ID of a <div>
@returns	= 	void
@usage		=	showHint(this, "someText")
*/
function showHint(obj, divID) { var newX = findPosX(obj); var newY = findPosY(obj); var x = new getObj(divID); x.style.top = newY + 20 +'px'; x.style.left = newX + 20 +'px'; x.style.visibility = ""; }
/*
@function 	= 	hideHint()
@purpose 	= 	changes the <div> to a hidden value;
@parameters = 	divID: ID of a <div>;
@returns	= 	void
@usage		=	hideHint("someText")
*/
function hideHint( divID ) { var x = new getObj(divID); x.style.visibility = "hidden"; }
function findPosX(obj) { var curleft = 0; if (obj.offsetParent) { while (obj.offsetParent) { curleft += obj.offsetLeft; obj = obj.offsetParent; } } else { if (obj.x) { curleft += obj.x; } } return curleft; }
function findPosY(obj) { var curtop = 0; if (obj.offsetParent) { while (obj.offsetParent) { curtop += obj.offsetTop; obj = obj.offsetParent; } 	} else { if (obj.y) { curtop += obj.y; } } return curtop; }
/* deletes the specified row (rI) from a specified table (id) */
function deleteTableRow(tableID, rI) { document.getElementById(tableID).deleteRow(rI) }

function changeBgColor(id, bgColor, txtColor)
{
	document.getElementById(id).style.color = txtColor;
	document.getElementById(id).style.backgroundColor = bgColor;
}

/* Common Sumbit button message functions */
/*
@function 	= 	doFoo()
@purpose 	= 	changes the text on a button
@parameters = 	id: id of the button;
@returns	= 	void
@usage		=	doFoo("someID")
*/
function doUpdatesRequired(id) { enableObject( id, 0, "Updates Required" ); }
function doContinue(id) { enableObject( id, 1, "Continue" ); }
function doProcessing(id) { enableObject( id, 0, "Processing" ); }
function doSearchPolicy(id) { changeBgColor(id, "#6699CC", "#FFFFFF"); enableObject( id, 1, "Search for a policy" ); }
function doSearching(id) { changeBgColor(id, "#FFFF99", "#6699CC"); enableObject( id, 0, "Searching" ); }
function doCannotProcess(id) { enableObject( id, 0, "Request cannot be processed" ); }
function doSubmitPayment(id) { enableObject( id, 1, "Submit Payment"); }
function doSubmit(id) { enableObject( id, 1, "Submit"); }
function doAuthorize(id) { enableObject( id, 1, "Authorize"); }
function doSubmitting(id) { enableObject( id, 1, "Submitting"); }
function doLoading(id) { enableObject( id, 1, "Loading"); }