//	The following routines perform javascript rollover functions for all script files.

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}


function MM_swapImgRestore() 
{ //v3.0
	var lintStartPos;
	
  	var i,x,a=document.MM_sr; 
  	for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) 
  	if(x.src.indexOf("Selected")==-1 && x.src.indexOf("Red")==-1 && x.src.indexOf("Disabled")==-1)
  	{
  		if(x.oSrc.indexOf("Selected")==-1 && x.oSrc.indexOf("Red")==-1 && x.oSrc.indexOf("Disabled")==-1)
  		{  		
  			x.src=x.oSrc;
  		}
  		else
  		{
			var lintStartPos1=x.oSrc.indexOf("Selected");
			var lintStartPos2=x.oSrc.indexOf("Red");
			var lintStartPos3=x.oSrc.indexOf("Disabled");
  			if(lintStartPos1!=-1)
  			{
  				lintStartPos=lintStartPos1;
  			}
  			else if(lintStartPos2!=-1)
  			{
  				lintStartPos=lintStartPos2;
  			}
  			else lintStartPos=lintStartPos3;
  			
  			x.src=x.oSrc.substr(0, lintStartPos) + ".gif";
  		}
	}
}

function MM_swapImage() 
{ //v3.0
	var i,j=0,x,a=MM_swapImage.arguments; 
	document.MM_sr=new Array; 
	for(i=0;i<(a.length-2);i+=3)
	if ((x=MM_findObj(a[i]))!=null)
	{
		document.MM_sr[j++]=x; 
		
		if(!x.oSrc)
		{
			x.oSrc=x.src;
		}
		
		if(x.src.indexOf("Selected")==-1 && x.src.indexOf("Red")==-1 && x.src.indexOf("Disabled")==-1)
		{
			x.src=a[i+2];
		}
	}
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

/******************************************************************************************************/
/*
	Overview:
	FieldPassedEdits determines if a value passed to it meets the criteria specified
	in the subsequent parameters.
	
	Parameters:
	MyField = A value from a form field.
	MyType = A single-character indicating the type of check to perform.
		'a' - Alphabetic characters only (A through Z)
		'n' - Numeric characters only (0 through 9)
		'm' - Alphanumeric characters accepted (no special characters).
	MinLength - A numeric value indicating the minimum number of characters accepted.
	MaxLength - A numeric value indicating the maximum number of characters accepted.
*/
	function FieldPassedEdits(MyField, MyType, MinLength, MaxLength) {
		var alphapattern = /[a-zA-Z]/;
		var numericpattern = /[0-9.]/;
		var mixedpattern = /[a-zA-Z0-9]/;

//		if (!MyField) 
//		{
//			return false;
//		}

		if (MinLength!=undefined) 
		{
			if (MyField.length < MinLength) {
				return false;
			}
		}

		if (MaxLength!=undefined) 
		{
			if (MyField.length > MaxLength) {
				return false;
			} 
		}

		if (MyType == 'a') 
		{
			var MyResult = MyField.match(alphapattern);
		} 
		else if (MyType == 'n') 
		{ 
			var MyResult = IsNumber(MyField);
		} 
		else 
		{
			var MyResult = MyField.match(mixedpattern);
		}

		if (MyResult == null)
		{
			if(MinLength!=undefined)
			{
				if(MinLength==0)
				{
					return true;
				}
				else
				{
					return false;
				}
			}
			else
			{
				return true;
			}
		} 
		return MyResult;
	}
	
/******************************************************************************************************/
/*
	Overview:
	IsDate determines if a value passed to it is an valid date.  It calls 3 separate
	helper functions (validMonth, validDay and validYear) to determine if the component
	parts are valid.
	
	NOTE:	This function expects separate date components.
	
	Parameters:
	MyMonth = A numeric month value.
	MyDay = A numeric day value.
	MyYear = A numeric year value (can be 2 or 4 digits).
*/		
	function IsDate(MyMonth, MyDay, MyYear) {
		if (!MyMonth || !MyDay || !MyYear) {
			return false;
		} else if (!validMonth(MyMonth)) {
			return false;
		} else if (!validDay(MyMonth, MyDay, MyYear)) {
			return false;
		} else if (!ValidYear(MyYear)) {
			return false;
		} else {
			return true;
		}
	}

/******************************************************************************************************/
		
	function validMonth(MyMonth) {
		if (!MyMonth) {
			return false;
		} else if (isNaN(MyMonth)) {
			return false;
		} else if (!inRange(MyMonth, 1, 12)) {
			return false;
		} else {
			return true;
		}
	}

/******************************************************************************************************/
		
	function validDay(MyMonth, MyDay, MyYear) {
		if (!MyDay) {
			return false;
		}
		var monthMax = new Array(0,31,28,31,30,31,30,31,31,30,31,30,31);
		var intMonth = parseInt(MyMonth, 10)
		var maxDays = monthMax[intMonth];
		if (intMonth == 2) {
			if (ItIsALeapYear(MyYear)) {
				maxDays = 29;
			}
		} 
		if (!inRange(MyDay, 1, maxDays)) {
			return false;
		} else {
			return true;
		}
	}

/******************************************************************************************************/
		
	function ValidYear(MyYear) {
		if (!MyYear) {
			return false;
		}
		if (MyYear.length == 4 || MyYear.length == 2) {
			if (IsNumber(MyYear)) {
				if (MyYear >= 1900 && MyYear <= 9999) {
					return true;
				} else return false;
			} else return false;
		} else return false;
	}

/******************************************************************************************************/
		
	function ItIsALeapYear(MyYear) {
		if (MyYear.length == 4) {
			var YearEnd = MyYear.substring(2);
		} else var YearEnd = MyYear.substring(0);
		
		if (YearEnd == '00') {
			if (MyYear % 400 == 0) {
				return true;
			} else return false;
		} else if (MyYear % 4 == 0) {
			return true;
		} else return false;
	}
	
/******************************************************************************************************/
/*
	Overview:
	IsNumber determines is the value passed to is is a numeric value.  It also allows
	for one decimal (ex: 7.2).
	
	Parameters:
	inputStr = Any text string.
*/
	function IsNumber(inputStr) {
		var intCount;
		intCount = 0;
		if (!inputStr) {
			return false;
		}
		for (var i = 0; i < inputStr.length; i++) {
			var oneChar = inputStr.substring(i, i + 1);
			if (oneChar == ".") {
				intCount = intCount + 1;
				if (intCount > 1) return false;
			} else if (oneChar < "0" || oneChar > "9") {
				return false;
			}
		}
		return true
	}

/******************************************************************************************************/
/*
	Overview:
	IsNumberWithNegative determines is the value passed to is is a numeric value.  It also allows
	for one decimal (ex: 7.2) and one negative sign.
	
	Parameters:
	inputStr = Any text string.
*/
function IsNumberWithNegative(inputStr) {
		var intCountPeriod;
		var intCountNegative;
		intCountPeriod = 0;
		intCountNegative = 0;
		if (!inputStr) {
			return false;
		}
		for (var i = 0; i < inputStr.length; i++) {
			var oneChar = inputStr.substring(i, i + 1);
			if (oneChar == ".") {
				intCountPeriod = intCountPeriod + 1;
				if (intCountPeriod > 1) return false; 
			} else if (oneChar == "-") {
				intCountNegative = intCountNegative + 1;
				if (intCountNegative > 1) return false;
			} else if (oneChar < "0" || oneChar > "9") {
				return false;
			}
		}
		return true
	}
/******************************************************************************************************/
/*
	Overview:
	IsInteger determines is the value passed to is is a numeric value.  Does not allow
	a decimal (ex: 7).
	
	Parameters:
	inputStr = Any text string.
*/
	function IsInteger(pstrPassedValue) {

		if(pstrPassedValue >= 48 && pstrPassedValue <= 57)
		{
			return true
		}
		else
		{
			return false
		}
	}
	
/******************************************************************************************************/
			
	function inRange(input, lo, hi) {
		var num = parseInt(input, 10);
		if (num < lo || num > hi) {
			return false;
		} else {
			return true;
		}
	}

/******************************************************************************************************/
		
/*
	Overview:
	SetFieldFocus sets focus and highlights the contents of a field.
	
	Parameters:
	MyField = A reference to a form field object (i.e. textbox, textarea, etc.).
	
*/	
	
function SetFieldFocus(MyField) 
{
	if (MyField) {
		if (MyField.disabled == false) {
			MyField.focus();
			if(MyField.type=="text")
			{
				MyField.select();
			}
		}
	}
}	

/******************************************************************************************************/

function IsValidSSN(SSN1, SSN2, SSN3) {
	if (!SSN1 || !SSN2 || !SSN3) {
		return false;
	} else if (!FieldPassedEdits(SSN1, 'n', 3, 3)) {
		return false;
	} else if (!FieldPassedEdits(SSN2, 'n', 2, 2)) {
		return false;
	} else if (!FieldPassedEdits(SSN3, 'n', 4, 4)) {
		return false;
	} else if (parseInt(SSN1) > 798) {
		return false;
	} else if (SSN1 == '000') {
		return false;
	} else if (SSN2 == '00') {
		return false;
	} else if (SSN1.charAt(0) == '8' || SSN1.charAt(0) == '9') {
		return false;
	} else if (SSN1.charAt(0) == SSN1.charAt(1) && SSN1.charAt(1) == SSN1.charAt(2)) {
		return false;
	} else return true;
}

/******************************************************************************************************/

	function trim(pstrValue) {
	
	     var ichar, icount;
	     //var strValue = this;
	     var strValue = pstrValue;
	     ichar = strValue.length - 1;
	     if (ichar == -1) return strValue;
	     icount = -1;
	     while (strValue.charAt(ichar)==' ' && ichar > icount)
	         --ichar;
	     if (ichar!=(strValue.length-1))
	         strValue = strValue.slice(0,ichar+1);
	     ichar = 0;
	     icount = strValue.length - 1;
	     while (strValue.charAt(ichar)==' ' && ichar < icount)
	         ++ichar;
	     if (ichar!=0)
	     {
	         strValue = strValue.slice(ichar,strValue.length);
	     }	
	         
	     return strValue;
	}

/******************************************************************************************************/

//	OVERVIEW:
//	This function will validate an input string as numeric.  Numeric is defined as any string with numeric digits 0-9,
//	one optional decimal character and one optional minus sign at the beginning of the number.
//
//	It can be called on the "onkeypress" event of a control and will prevent non-numeric
//	characters from being entered.  It will also restrict the text to one decimal (period) character and one minus sign.  
//	
//	PARAMETERS:
//	pstrFieldValue - the form control object reference (i.e. textbox, textarea, button, etc.)
//	pblnAllowNegative - Allow user to enter negative numbers
//
//	IMPORTANT:	This function assumes the keystroke validation is being done from the "onkeypress" and "onkeydown" events.

function CheckForNumber(pstrField, pblnAllowNegative)
{

	var strn="";
	var comma=/,/g;
	var numexp=/^[-+]?\d*\.?\d*$/
	//var currexp=/^\$?([0-9]{1,3},([0-9]{3},)*[0-9]{3}|[0-9]+)(.[0-9][0-9])?$/

	strn=pstrField.value;

	//	Strip out all of the commas...
	strn=strn.replace(comma,"")

	//	If the user is holding down the Shift or Cntl key, then return a false...
	if(event.shiftKey==true || event.ctrlKey==true)
	{
		return false;
	}
	
	//	If the user pressed the <ENTER> key...
	if(window.event.keyCode==13)
	{
//		document.all.hdnNothing.focus();
//		var temp = 'document.all.' + fld.name + '.blur();';
//		eval(temp);
	}
	else
	{
		//	Is the key entered a minus sign?
		if(window.event.keyCode==109 || window.event.keyCode==189)
		{
			if(pblnAllowNegative==true)
			{
				//if( (strn.indexOf("-") != -1) && (document.selection.createRange().text.length != fld.value.length) )	//	Prevent the user from entering more than one minus sign
				if( (strn.indexOf("-") != -1) && (document.selection.createRange().text.indexOf("-") == -1)  )	//	Prevent the user from entering more than one minus sign
				{
					return false;
				}
			}
			else
			{
				return false;
			}
		}

		//	Is the key entered a period?
//		if(window.event.keyCode==110 || window.event.keyCode==190 || window.event.keyCode==46)
		if(window.event.keyCode==110 || window.event.keyCode==190)
		{
			var lstrHighlightedText = document.selection.createRange().text; //	capture highlighted text, if existing period is withing highlighted text then all key since existing period will just get overwritten
			
			if( (strn.indexOf(".") != -1) && (lstrHighlightedText.indexOf(".") == -1) ) //	Prevent the user from entering more than one period
			{
				return false;
			}
		}

		//	If the keycode is NOT a minus, period, left arrow, right arrow, backspace, null or tab...
		if(window.event.keyCode!=109 && window.event.keyCode!=189 && window.event.keyCode!=110 && window.event.keyCode!=46 && window.event.keyCode!=190 && window.event.keyCode!=37 && window.event.keyCode!=39 && window.event.keyCode!=8 && window.event.keyCode!=0 && window.event.keyCode!=9)
		{
			if((window.event.keyCode > 47 && window.event.keyCode < 58) || (window.event.keyCode > 95 && window.event.keyCode < 106))
			{
				return true;
			}
			else
			{
				return false;
			}
		} else return true;
	}
}


/******************************************************************************************************/

//	OVERVIEW:
//	This function will validate an input string as numeric for control array fields.  Numeric is defined as any string with numeric digits 0-9,
//	one optional decimal character and one optional minus sign at the beginning of the number.
//
//	It can be called on the "onkeypress" event of a control and will prevent non-numeric
//	characters from being entered.  It will also restrict the text to one decimal (period) character and one minus sign.  
//	
//	PARAMETERS:
//	fld - the form control object reference (i.e. textbox, textarea, button, etc.)
//	plArrayVal - subsrcript of control array being referenced in fld object
//	pblnAllowNegative = allow negative numbers to be entered
//
//	IMPORTANT:	This function assumes the keystroke validation is being done from the "onkeypress" and "onkeydown" events.

function CheckForNumberInControlArrayFld(fld, plArrayVal, pblnAllowNegative)
{

	var strn="";
	var comma=/,/g;
	var numexp=/^[-+]?\d*\.?\d*$/
	//var currexp=/^\$?([0-9]{1,3},([0-9]{3},)*[0-9]{3}|[0-9]+)(.[0-9][0-9])?$/

	strn=fld.value;

	//	Strip out all of the commas...
	strn=strn.replace(comma,"")

	//	If the user is holding down the Shift or Cntl key, then return a false...
	if(event.shiftKey==true || event.ctrlKey==true)
	{
		return false;
	}

	if(window.event.keyCode==13)
	{
		document.all.hdnNothing.focus();
//		var temp = 'document.all.' + fld.name + '[' + plArrayVal + ']' + '.blur();';
//		eval(temp);
	}
	else
	{
	
		//	Is the key entered a minus sign?
		if(window.event.keyCode==109 || window.event.keyCode==189)
		{
			if(pblnAllowNegative==true)
			{
				if(strn.indexOf("-")!=-1)		//	Prevent the user from entering more than one minus sign
				{
					return false;
				}
			}
			else
			{
				return false;
			}
		}

		//	Is the key entered a period?
		if(window.event.keyCode==110 || window.event.keyCode==190)
		{
			if(strn.indexOf(".")!=-1)		//	Prevent the user from entering more than one period
			{
				return false;
			}
		}

		//	If the keycode is NOT a minus, period, left arrow, right arrow, backspace, null or tab...
		if(window.event.keyCode!=109 && window.event.keyCode!=189 && window.event.keyCode!=110 && window.event.keyCode!=46 && window.event.keyCode!=190 && window.event.keyCode!=37 && window.event.keyCode!=39 && window.event.keyCode!=8 && window.event.keyCode!=0 && window.event.keyCode!=9)
		{
			if((window.event.keyCode > 47 && window.event.keyCode < 58) || (window.event.keyCode > 95 && window.event.keyCode < 106))
			{
				return true;
			}
			else
			{
				return false;
			}
		} else return true;
	}
}


//	OVERVIEW:
//	This function performs validation in conjuction with "CheckForNumber()".  This routine should be called from the "onBlur" event.
//	
//	PARAMETERS:
//
//	MyField - control being validated
//	MyFunction - this is an optional parameter containing a string of functions to execute if this routine evaluates to "true".
//	Display - Optional parameter that will control if an alert is issued if the field is not numeric. (possible values are 'n' or 'y')
//	AllowNegative - Optional parameter that will control if this routine allows a number to be negative.
//
function ValidateNumeric(MyField, MyFunction, Display, AllowNegative)
{

	var numexp=/^[-+]?\d*\.?\d*$/;
	var strn = MyField.value;
	var comma=/,/g;

	//	Strip out all of the commas...
	strn=strn.replace(comma,"")

	if (strn == '-' || strn == '-.' || strn == '.-' || strn == '.')
	{
		if(Display!='n')
		{
			alert('Please enter a numeric value.')
		}
		SetFieldFocus(MyField);
		return false;
	}

	if (numexp.test(strn) == false || strn.length==0 || strn==".")
	{
		if(Display!='n')
		{
			alert('Please enter a numeric value');
		}
		SetFieldFocus(MyField);
		return false;
	}
	else if(AllowNegative=='n')
	{
		if(MyField.value < 0)
		{
			if(Display!='n')
			{
				alert('Please enter a positive number');
			}
			SetFieldFocus(MyField);
			window.event.cancelBubble = true;
			return false;
		}
		else if(MyFunction)
		{
			eval(MyFunction);
			return true;
		}
		else return true;
	}
	else if(MyFunction)
	{
		eval(MyFunction);
		return true;
	}
	else return true;
}

function CheckForInvalidCharacters()
{
	//	Do not allow single quote, double quote or plus sign characters.
	if(window.event.keyCode==222 || window.event.keyCode==43)
	{
		return false;
	}
	else return true;
}

var lastrowselected=new Array;
var lastgridselected = new Array;
var lastclassselected = new Array;
var currentclass;
var RowSelected = new Array;
RowSelected[0]='';
RowSelected[1]='';
var lintRowSelected;
	
function SetRow(pstrGridID, pstrRowID)
{
		var lobjRow = igtbl_getRowById(pstrRowID);
		
		for(var lintCount=0; lintCount<=lobjRow.cells.length-1; lintCount++)
		{
			RowSelected[lintCount] = lobjRow.getCell(lintCount).getValue();
		}
}


function EditKeyDown(pstrGridName, pstrCellID, keyStroke) 
{
/* This function will handle keydown on editable grid cells.
	Please note all valid keystrokes need to return false and invalid need to return true. */
	if(event.shiftKey==true || event.ctrlKey==true)
	{
		return true;
	}
	
	if ((keyStroke < 48 || keyStroke > 57)  && //0-9
		(keyStroke < 96 || keyStroke > 105) &&  //numeric keypad
		(keyStroke < 37 || keyStroke > 40) && //arrow keys
			keyStroke != 110 && //period on numeric pad
			keyStroke != 109 && //minus on numeric pad
			keyStroke != 189 &&  //minus
			keyStroke != 190 &&  //period
			keyStroke != 13 &&  //enter
			keyStroke != 9 &&  //tab
			keyStroke != 27 &&  //escape
			keyStroke != 8 &&  //backspace
			keyStroke != 46) //delete
	{
		return true;
	}
	else return false;
}

function EditCellValue(pstrGridName, pstrCellID, pstrNewValue)
/* This function will handle BeforeCellUpdateHandler on editable grid cells.
	Please note all valid keystrokes need to return false and invalid need to return true. */
/* to set the edited value to actual cell value*/
{
	var lobjCell = igtbl_getCellById(pstrCellID);
	var lobjGrid = igtbl_getGridById(pstrGridName);

	if(IsNumberWithNegative(pstrNewValue,0,true)==false)
	{
		lobjCell.setValue(lobjCell.getValue());
		return true;
	}
	else return false;
}
		
/*	The following functions are no longer needed...I thing
function FindPrefix(pstrPrefix)
{
	var i=0;

	if(lastgridselected.length > 0)
	{
		for(i==0;i<lastgridselected.length;i++)
		{
			if(lastgridselected[i]==pstrPrefix)
			{
				return i;
				break;
			}
		}
	}
	else
	{
		lastgridselected[i]=pstrPrefix;
		return 0;
//		return -1;
	}			
}

function FindLastRowSelected(pstrPrefix)
{

	var i=FindPrefix(pstrPrefix);
	
	if(i!=-1)
	{
		return lastrowselected[i];
	}
	else
	{
		return 0
	}
}


function FindLastClassSelected(pstrPrefix)
{

	var i=FindPrefix(pstrPrefix);
	
	if(i!=-1)
	{
		return lastclassselected[i];
	}
	else
	{
		return ''
	}
}

function SetLastRowSelected(pstrPrefix, plngRowNum)
{

	var i = FindPrefix(pstrPrefix);
	lastrowselected[i]=plngRowNum;
}

function SetLastClassSelected(pstrPrefix, pstrClass)
{

	var i = FindPrefix(pstrPrefix);
	lastclassselected[i]=pstrClass;
}
*/

var lsTempMM;
var lsTempDD;
var lsTempYYYY;

function ParseDate(pstrDate)
{
	var lsEndPos = 0;
	var lsStartPos = 0;
	var lsTempDate = pstrDate;
	
	lsEndPos = lsTempDate.indexOf('/', 1)
	lsTempMM = lsTempDate.slice(0, lsEndPos)
	lsStartPos = lsEndPos + 1
	lsEndPos = lsTempDate.indexOf('/', lsStartPos)
	lsTempDD = lsTempDate.slice(lsStartPos, lsEndPos)
	lsStartPos = lsEndPos + 1
	lsTempYYYY = lsTempDate.slice(lsStartPos)
}

function Round(expr, decplaces)
{
	var str = "" + Math.round(eval(expr) * Math.pow(10,decplaces));
	
	while (str.length <= decplaces)
	{
		str = "0" + str;
	}
	
	var decpoint = str.length - decplaces;
	
	return str.substring(0,decpoint) + "." + str.substring(decpoint,str.length);
}

function RemoveCommas(pstrExp)
{
	var lobjRegexp = /,/g;
	var oldString = new String(pstrExp);
	var newString = new String("");

	//	Strip out all of the commas...
	
	newString = oldString.replace(lobjRegexp, "");
	return newString;
}

function InsertCommas(pstrExp)
{
	var newString="";
	var lintCount=0;
	var lintStartCol = pstrExp.indexOf(".");
	if(lintStartCol != -1)
	{
		var lstrRestOfIt = pstrExp.substr(lintStartCol);
	}
	
	if(lintStartCol!=-1)
	{
		var lstrBeginning = pstrExp.substr(0, pstrExp.length - lstrRestOfIt.length);
	}
	else
	{
		var lstrBeginning = pstrExp;
	}

	var lobjTemp = new Array(20);
	var lintStringCount=20;
	for(var i=lstrBeginning.length; i<=0; i--)
	{
		if(lintCount==3)
		{
			lobjTemp[lintStringCount] = ",";
			lintStringCount = lintStringCount - 1;
			lobjTemp[lintStringCount] = lstrBeginning.substr(i, 1);
			lintStringCount = lintStringCount - 1;
			lintCount = 1;
		}
		else
		{
			lobjTemp[lintStringCount] = lstrBeginning.substr(i, 1);
			lintStringCount = lintStringCount - 1;
		}
	}
}

function FormatNumber(pstrValue, decplaces)
{

	var lstrFoundNegative='false';
	var lstrValue = "" + pstrValue
	
		//	Check For Negative
	if ( lstrValue.substring(0,1) == '-' )
	{
	
		lstrFoundNegative='true';
		lstrValue = lstrValue.substring(1,lstrValue.length);
	}
	
	//	ensure a number was passed, if not just return value passed
	if ( IsNumber(lstrValue) == false || lstrValue == '.')
	{
		return lstrValue;
	}	

	//var str="" + Math.round (eval(lstrValue) * Math.pow(10,decplaces));
	var str="" + Math.round (parseFloat(lstrValue) * Math.pow(10,decplaces));		
	
	while(str.length<=decplaces)
	{
		str="0"+str;
	}
	
	var decpoint = str.length - decplaces;
	if(decplaces!=0)
	{
		var lstrReturnValue = str.substring(0, decpoint) + "." + str.substring(decpoint,str.length);
	}
	else
	{
		var lstrReturnValue = str.substring(0, decpoint);
	}
	
	if(lstrFoundNegative=='true')
	{
		lstrReturnValue = '-' + lstrReturnValue;
	}
	
	return CommaFormatted(lstrReturnValue, decplaces);
}

function CommaFormatted(amount, decplaces)
{

	var minus = '';
		
	//	ensure a number is being passed in, if not exit
	if(isNaN(amount)) { return ''; }
	
	//	remove minus symbol and place in variable that will be concatenated on to the return value
	if(amount < 0) 
	{
		minus = '-'; 
		//amount = Math.abs(amount) + "";
		amount = amount.substring(1,amount.length);	//	remove the '-'
	}
		
	var delimiter = ",";							 // replace comma if desired

	if (parseInt(decplaces) > 0)
	{	
		var a = amount.split('.',parseInt(decplaces))	// split the value by the decimal point
		var d = a[1];									// get the decimal value
		var i = parseInt(a[0]);							// get the integer value
	}
	else
	{
		i = amount;
		d = '';
	}
	
	if(isNaN(i)) { return ''; }		
		
	var n = new String(i);
	var a = [];
		
	while(n.length > 3)
	{
		var nn = n.substr(n.length-3);
		a.unshift(nn);
		n = n.substr(0,n.length-3);
	}
		
	if(n.length > 0) 
	{ 
		a.unshift(n); 
	}
	
	n = a.join(delimiter);
	
	if (d.length < 1) 
	{ 
		amount = n; 
	}
	else 
	{ 
		amount = n + '.' + d; 
	}
	
	amount = minus + amount;
		
	return amount;
}


	
function ResizeGridDiv(pintWidth)
{
	if(window.screen.width > 1024)
	{
		lintDefaultWidth = "98%";
		lintWidth1 = "98.5%";
		lintWidth2 = "98.6%";
		lintWidth3 = "98.7%";
	}
	else
	{
		lintDefaultWidth="98%";
		lintWidth1 = "98.2%";
		lintWidth2 = "98.3%";
		lintWidth3 = "98.5%";
	}

	if(parseInt(pintWidth) > parseInt(800) && parseInt(pintWidth) < parseInt(1000))
	{
		document.all.divGridHeader.style.width=lintWidth1;
		document.all.divGridFooter.style.width=lintWidth1;
	}
	else if(parseInt(pintWidth) > parseInt(1000) && parseInt(pintWidth) < parseInt(1200))
	{
		document.all.divGridHeader.style.width=lintWidth2;
		document.all.divGridFooter.style.width=lintWidth2;
	}
	else if(parseInt(pintWidth) > parseInt(1200))
	{
		document.all.divGridHeader.style.width=lintWidth3;
		document.all.divGridFooter.style.width=lintWidth3;
	}
	else
	{
		document.all.divGridHeader.style.width=lintDefaultWidth;
		document.all.divGridFooter.style.width=lintDefaultWidth;
	}
}

var globalintRowSelected=0;
var globalintLastRowSelected;
		
function SetBorderRow(pRow)
{		
	var lRowID;
			
	if (globalintRowSelected != pRow)
	{
		globalintRowSelected = pRow;
			
		if (globalintLastRowSelected > 0)
		{
			lRowID = 'tblBorder' + globalintLastRowSelected;
			document.all.item(lRowID).border = 0;		
		}
			
		if (globalintRowSelected > 0)
		{
			lRowID = 'tblBorder' + pRow;
			document.all.item(lRowID).border = 1;
			document.all.item(lRowID).borderColor = '#677c99';
		}
			
		globalintLastRowSelected = globalintRowSelected;
	}
}				


function CheckForModalWin(pintLevel)
{

	try
	{
		switch (pintLevel)
		{				
			case '0' :
				if( ( parseFloat(top.frames(1).document.all.gintModalCount.value) > parseFloat(0) ) && ( parseInt(top.frames(1).document.all.gintModalCount.value) != parseInt(pintLevel) ) )
				{			
					top.frames(1).ModalWin[parseFloat(top.frames(1).document.all.gintModalCount.value) - 1].focus();
				}
				break;
					
			case '1' :
				if( (parseFloat(window.opener.top.frames(1).document.all.gintModalCount.value ) > parseFloat(0) ) && ( parseInt(window.opener.top.frames(1).document.all.gintModalCount.value) != parseInt(pintLevel) ))
				{						
					window.opener.top.frames(1).ModalWin[parseFloat(window.opener.top.frames(1).document.all.gintModalCount.value) - 1].focus();					
				}
				break;
				
			case '2' :
				if( parseFloat(window.opener.window.opener.top.frames(1).document.all.gintModalCount.value) > parseFloat(0) && ( parseInt(window.opener.window.opener.top.frames(1).document.all.gintModalCount.value) != parseInt(pintLevel) ))
				{		
					window.opener.window.opener.top.frames(1).ModalWin[parseFloat(window.opener.window.opener.top.frames(1).document.all.gintModalCount.value) - 1].focus();
				}
				break;	
					
			case '3' :
				if( (parseFloat(window.opener.window.opener.window.opener.top.frames(1).document.all.gintModalCount.value) > parseFloat(0)) && ( parseInt(window.opener.window.opener.window.opener.top.frames(1).document.all.gintModalCount.value) != parseInt(pintLevel) ) )
				{		
					window.opener.window.opener.window.opener.top.frames(1).ModalWin[parseFloat(window.opener.window.opener.window.opener.top.frames(1).document.all.gintModalCount.value) - 1].focus();
				}
				break;					
		}	
		
	}
		
	catch(e)
	{
		//	do nothing...
	}
		
	finally
	{
		//	do nothing...
	}		
}

//
//	CheckSQLForMatchingParens - checks passed sql string to make sure all parens have a match
//
function CheckSQLForMatchingParens(pstrCriteriaRowValue)
{

	var lobjCriteria = new Array();
	var lstrParenSearch;
	var lintLeftParenCount = 0;
	var lintRightParenCount = 0;
	var lstrErrMessage='';
	
	if (pstrCriteriaRowValue != '')
	{
	
		lobjCriteria = pstrCriteriaRowValue.split("|||");

		for(var i=0; i<=lobjCriteria.length - 1; i++)
		{
			//	Count LEFT parens - (		
			for(var j=0 ; j <= lobjCriteria[i].length - 1 ; j++)
			{
				lstrParenSearch = lobjCriteria[i].substring(j,j+1);
				
				if ( lstrParenSearch == '(' )
				{
					lintLeftParenCount++;
				}
				else
				{	
					//	a non left paren value has been encountered, exit loop
					break;
				}
			}
			
			//	Count RIGHT parens - )	
			for(var j=lobjCriteria[i].length - 1 ; j >= 0 ; j--)
			{
				lstrParenSearch = lobjCriteria[i].substring(j,j+1);
				
				if ( lstrParenSearch == ')' )
				{
					lintRightParenCount++;
				}
				else
				{	
					//	a non right paren value has been encountered, exit loop
					break;
				}
			}			
		}	
	
		if ( parseInt(lintLeftParenCount) > parseInt(lintRightParenCount) )
		{
			lstrErrMessage = 'There are more left \'(\' parenthesis than right \')\'.  Please check the criteria.';
		}
		else if ( parseInt(lintLeftParenCount) < parseInt(lintRightParenCount) )
		{
			lstrErrMessage = 'There are more right \')\' parenthesis than left \'(\'.  Please check the criteria.';
		}
		else
		{
			lstrErrMessage = '';
		}
		
		if ( lstrErrMessage == '' )
		{
			return true;
		}
		else
		{
			alert(lstrErrMessage);
			return false;
		}			
		
	}
	
}

//	Start of tooltip functions...
			var ns4 = document.layers;
			var ns6 = document.getElementById && !document.all;
			var ie4 = document.all;
			offsetX = 0;
			offsetY = 10;
			var toolTipSTYLE="";
			
			function initToolTips()
			{
			if(ns4||ns6||ie4)
			{
				if(ns4) toolTipSTYLE = document.toolTipLayer;
				else if(ns6) toolTipSTYLE = document.getElementById("toolTipLayer").style;
				else if(ie4) toolTipSTYLE = document.all.toolTipLayer.style;
				if(ns4) document.captureEvents(Event.MOUSEMOVE);
				else
				{
				toolTipSTYLE.visibility = "visible";
				toolTipSTYLE.display = "none";
				}
				document.onmousemove = moveToMouseLoc;
			}
			}
			
			function toolTip(msg, fg, bg)
			{
				if(toolTip.arguments.length < 1) // hide
				{
					if(ns4) toolTipSTYLE.visibility = "hidden";
					else toolTipSTYLE.display = "none";
				}
				else // show
				{
					if(!fg) fg = "#777777";
					if(!bg) bg = "#FFFFFF";
					
					var content =
					'<table border="0" cellspacing="0" cellpadding="1" bgcolor="' + fg + '"><td>' +
					'<table border="0" cellspacing="0" cellpadding="1" bgcolor="' + bg + 
					'"><td align="center"><font face="sans-serif" color="' + fg +
					'" size="-2">&nbsp\;' + msg +
					'&nbsp\;</font></td></table></td></table>';
					
					if(ns4)
					{
						toolTipSTYLE.document.write(content);
						toolTipSTYLE.document.close();
						toolTipSTYLE.visibility = "visible";
					}
					
					if(ns6)
					{
						document.getElementById("toolTipLayer").innerHTML = content;
						toolTipSTYLE.display='block'
					}
					
					if(ie4)
					{
						document.all("toolTipLayer").innerHTML=content;
						toolTipSTYLE.display='block'
					}
				}
			}
			
			function moveToMouseLoc(e)
			{
			if(ns4||ns6)
			{
				x = e.pageX;
				y = e.pageY;
			}
			else
			{
				x = event.x + document.body.scrollLeft;
				y = event.y + document.body.scrollTop;
			}
			toolTipSTYLE.left = x + offsetX;
			toolTipSTYLE.top = y + offsetY;
			return true;
			}		
			
	function ShowHoverText(pobjTDElement)
	{	
		try
		{	
			if (pobjTDElement.children(0).value != '')
			{
				toolTip(pobjTDElement.children(0).value);		
			}
		}
		catch(e)
		{
			//	do nothing...
		}
		finally
		{
			//	do nothing...
		}			
	}

	function HideHoverText()
	{		
		try
		{	
			toolTip();
		}
		catch(e)
		{
			//	do nothing...
		}
		finally
		{
			//	do nothing...
		}		
	}							
//	End of tooltip functions...	-->

	function HighlightLink(pobjLink)
	{
		pobjLink.style.textDecoration = "underline";
	}
	
	function UnHighlightLink(pobjLink)
	{
		pobjLink.style.textDecoration ="none";
		//pobjLink.style.color="#ffffff";
		pobjLink.style.cursor="default";
	}
	
	function UnHighlightSubLink(pobjLink)
	{
		pobjLink.style.textDecoration ="none";
		pobjLink.style.color = "blue";
		
	}
	
	function getCookie(cookie) 
	{ 
		var search = cookie + "="; 
		if (document.cookie.length > 0) 
		{ // if there are any cookies 
			var offset = document.cookie.indexOf(search);
			if (offset != -1) 
			{	
				//Get Cookie
				offset += search.length;
				// set index of beginning of value 
				end = document.cookie.indexOf(";", offset);
				// set index of end of cookie value 
				if (end == -1) 
					end = document.cookie.length; 
				var cookieValue = unescape(document.cookie.substring(offset, end));
				//Get Value
/*				search = key + "="; 
				offset = cookieValue.indexOf(search);
				offset += search.length;
				end = cookieValue.indexOf("&", offset);
				if (end == -1) 
					end = document.cookie.length ;
*/
				return unescape(cookieValue);
				//return unescape(cookieValue.substring(offset, end));
			}
		}
		return "";
	}


function IsNumeric(sText)
{
   var ValidChars = "0123456789.";
   var IsNumber=true;
   var Char;
 
   for (i = 0; i < sText.length && IsNumber == true; i++) 
      { 
      Char = sText.charAt(i); 
      if (ValidChars.indexOf(Char) == -1) 
         {
         IsNumber = false;
         }
      }
   return IsNumber;
   
   }

