	function WISIsInt(value)
	{
		//instead of regular expressions
		var retVal = true;
		
		if(value.length <= 0)
		{
			retVal = false;
			return retVal;
		}
		
		for(i=0; i<value.length; i++)
		{
			var temp = value.charAt(i);
			var tempint = parseInt(temp);
			if(isNaN(tempint) == true)
			{
				if(((temp == "-") && (i == 0)) || ((temp == "+") && (i == 0)))
				{
					continue;
				}
				else
				{
					retVal = false;
					return retVal;
				}				
			}
		}
		
		return retVal;
	}
	
	function WISIsFloat(value)
	{
		//instead of regular expressions
		var retVal = true;
		var decimalcount = 0;
		
		if(value.length <= 0)
		{
			retVal = false;
			return retVal;
		}
		
		for(i=0; i<value.length; i++)
		{
			var temp = value.charAt(i);
			var tempint = parseInt(temp);
			if(isNaN(tempint) == true)
			{
				if(((temp == "-") && (i == 0)) || ((temp == "+") && (i == 0)))
				{
					continue;
				}
				else if((temp == ".") && (decimalcount == 0))
				{
					decimalcount++;
					continue;
				}
				else
				{
					retVal = false;
					return retVal;
				}				
			}
		}
		
		return retVal;
	}
	
	function ccDate(source, arguments)
	{
		var dtDate = arguments.Value;
		
		arguments.IsValid = true;
		
		if((dtDate.length < 4) || (dtDate.length > 10))
		{
			arguments.IsValid = false;
			return;
		}
		else
		{
			var strMonth;
			var strDay;
			var strYear;
			var nIndex1, nIndex2, nTempIndex;
			var aDate;
			
			nIndex1 = dtDate.indexOf("-");
			nIndex2 = dtDate.indexOf("/");
			
			if((nIndex1 == -1) && (nIndex2 == -1))
			{
				arguments.IsValid = false;
				return;
			}
			else if(nIndex1 > 0)
			{
				aDate = dtDate.split("-");
				
				//Validation conasp:TableRowol ensures three parts.
				strMonth = aDate[0];
				strDay = aDate[1];
				strYear = aDate[2];
				
				var nDay;
				var nMonth;
				var nYear;
				
				if(strMonth.substring(0,1) == "0") strMonth = strMonth.substr(1,strMonth.length-1);
				if(strDay.substring(0,1) == "0") strDay = strDay.substr(1,strDay.length-1);
				
				nDay = parseInt(strDay);
				nMonth = parseInt(strMonth);
				nYear = parseInt(strYear);
				
				if(nDay > 31)
				{
					arguments.IsValid = false;
					return;					
				}
				if ((nMonth == 1 || nMonth == 3 || nMonth == 5 || nMonth == 7 || nMonth == 8 || nMonth == 10 || nMonth == 12)) 
				{
					if(nDay > 31 || nDay < 1)
					{
						arguments.IsValid = false;
						return;	
					}
				}
				else if ((nMonth == 4 || nMonth == 6 || nMonth == 9 || nMonth == 11)) 
				{
					if (nDay > 30 || nDay < 1)
					{
						arguments.IsValid = false;
						return;	
					}
				}
				else if (nMonth == 2) 
				{
					if (nDay < 1) 
					{
						arguments.IsValid = false;
						return;
					}
					if (LeapYear(nYear) == true) 
					{
						if (nDay > 29)
						{
							arguments.IsValid = false;
							return;
						}
					}
					else 
					{
						if (nDay > 28) 
						{
							arguments.IsValid = false;
							return;
						}
					}
				}
				else
				{
					arguments.IsValid = false;
					return;
				}
			}
			else if(nIndex2 > 0)
			{
				aDate = dtDate.split("/");
				
				//Validation control ensures three parts.
				strMonth = aDate[0];
				strDay = aDate[1];
				strYear = aDate[2];
				
				var nDay;
				var nMonth;
				var nYear;
				
				if(strMonth.substring(0,1) == "0") strMonth = strMonth.substr(1,strMonth.length-1);
				if(strDay.substring(0,1) == "0") strDay = strDay.substr(1,strDay.length-1);
				
				nDay = parseInt(strDay);
				nMonth = parseInt(strMonth);
				nYear = parseInt(strYear);
									
				if(nDay > 31)
				{
					arguments.IsValid = false;
					return;					
				}
				if ((nMonth == 1 || nMonth == 3 || nMonth == 5 || nMonth == 7 || nMonth == 8 || nMonth == 10 || nMonth == 12)) 
				{
					if(nDay > 31 || nDay < 1)
					{
						arguments.IsValid = false;
						return;	
					}
				}
				else if ((nMonth == 4 || nMonth == 6 || nMonth == 9 || nMonth == 11)) 
				{
					if (nDay > 30 || nDay < 1)
					{
						arguments.IsValid = false;
						return;	
					}
				}
				else if (nMonth == 2) 
				{
					if (nDay < 1) 
					{
						arguments.IsValid = false;
						return;
					}
					if (LeapYear(nYear) == true) 
					{
						if (nDay > 29)
						{
							arguments.IsValid = false;
							return;
						}
					}
					else 
					{
						if (nDay > 28) 
						{
							arguments.IsValid = false;
							return;
						}
					}
				}
				else
				{
					arguments.IsValid = false;
					return;
				}
			}
			else
			{
				arguments.IsValid = false;
				return;
			}
						
		}
	}
	
	function ccDate2(dtDate)
	{
		var dtDate = dtDate;
		
		var retVal = true;
		
		if((dtDate.length < 4) || (dtDate.length > 10))
		{
			
			retVal = false;
			return retVal;
		}
		else
		{
			var strMonth;
			var strDay;
			var strYear;
			var nIndex1, nIndex2, nTempIndex;
			var aDate;
			
			nIndex1 = dtDate.indexOf("-");
			nIndex2 = dtDate.indexOf("/");
			
			
			if((nIndex1 == -1) && (nIndex2 == -1))
			{
				retVal = false;
				return retVal;
			}
			else if(nIndex1 > 0)
			{
				aDate = dtDate.split("-");
				
				//Validation conasp:TableRowol ensures three parts.
				strMonth = aDate[0];
				strDay = aDate[1];
				strYear = aDate[2];
				
				var nDay;
				var nMonth;
				var nYear;
				
				if(strMonth.substring(0,1) == "0") strMonth = strMonth.substr(1,strMonth.length-1);
				if(strDay.substring(0,1) == "0") strDay = strDay.substr(1,strDay.length-1);
				
				nDay = parseInt(strDay);
				nMonth = parseInt(strMonth);
				nYear = parseInt(strYear);
				
				if(nDay > 31)
				{
					retVal = false;
					return retVal;					
				}
				if ((nMonth == 1 || nMonth == 3 || nMonth == 5 || nMonth == 7 || nMonth == 8 || nMonth == 10 || nMonth == 12)) 
				{
					if(nDay > 31 || nDay < 1)
					{
						retVal = false;
						return retVal;	
					}
				}
				else if ((nMonth == 4 || nMonth == 6 || nMonth == 9 || nMonth == 11)) 
				{
					if (nDay > 30 || nDay < 1)
					{
						retVal = false;
						return retVal;	
					}
				}
				else if (nMonth == 2) 
				{
					if (nDay < 1) 
					{
						retVal = false;
						return retVal;
					}
					if (LeapYear(nYear) == true) 
					{
						if (nDay > 29)
						{
							retVal = false;
							return retVal;
						}
					}
					else 
					{
						if (nDay > 28) 
						{
							retVal = false;
							return retVal;
						}
					}
				}
				else 
				{
					retVal = false;
					return retVal;
				}
			}
			else if(nIndex2 > 0)
			{
				aDate = dtDate.split("/");
				
				//Validation control ensures three parts.
				strMonth = aDate[0];
				strDay = aDate[1];
				strYear = aDate[2];
				
				var nDay;
				var nMonth;
				var nYear;
				
				if(strMonth.substring(0,1) == "0") strMonth = strMonth.substr(1,strMonth.length-1);
				if(strDay.substring(0,1) == "0") strDay = strDay.substr(1,strDay.length-1);
				
				nDay = parseInt(strDay);
				nMonth = parseInt(strMonth);
				nYear = parseInt(strYear);
																	
				if(nDay > 31)
				{
					retVal = false;
					return retVal;					
				}
				if ((nMonth == 1 || nMonth == 3 || nMonth == 5 || nMonth == 7 || nMonth == 8 || nMonth == 10 || nMonth == 12)) 
				{
					if(nDay > 31 || nDay < 1)
					{
						retVal = false;
						return retVal;	
					}
				}
				else if ((nMonth == 4 || nMonth == 6 || nMonth == 9 || nMonth == 11)) 
				{
					if (nDay > 30 || nDay < 1)
					{
						retVal = false;
						return retVal;	
					}
				}
				else if (nMonth == 2) 
				{
					if (nDay < 1) 
					{
						retVal = false;
						return retVal;
					}
					if (LeapYear(nYear) == true) 
					{
						if (nDay > 29)
						{
							retVal = false;
							return retVal;
						}
					}
					else 
					{
						if (nDay > 28) 
						{
							retVal = false;
							return retVal;
						}
					}
				}
				else
				{
					retVal = false;
				}
			}
			else
			{
				retVal = false;
				return retVal;
			}
						
		}
		
		return retVal;
	}
	
	function LeapYear(nYear) 
	{
		if (nYear % 100 == 0) 
		{
			if(nYear % 400 == 0) 
			{ 
				return true;
			}
		}
		else 
		{
			if((nYear % 4) == 0) 
			{
				return true;
			}
		}
        return false;
	}
	
	function DateFormat(vDateName, vDateValue, e)  
	{
		var strSeperator = "/"; 
			
		// vDateName = object name
		// vDateValue = value in the field being checked
		// e = event
		
		var whichCode = (window.Event) ? e.which : e.keyCode;
		var nLen = vDateValue.length;
		var control = window.event.ctrlKey;
	 
		if ((whichCode > 47 && whichCode < 58) || (whichCode >= 96 && whichCode <= 105))
		{
			if (nLen == 2)  
			{
				vDateName.value = vDateValue+strSeperator;
			}
			else if (nLen == 5)  
			{
				vDateName.value = vDateValue+strSeperator;
			}
			return true;
		}
		else if(whichCode == 84) //"t" -- automatically fill in with today's date
		{
			var objDate = new Date();
			var strDay = objDate.getDate();
			
			if((strDay >=0) && (strDay < 10))
			{
				strDay = "0" + strDay;
			}
			var strDate = (objDate.getMonth() + 1) + strSeperator + strDay + strSeperator + objDate.getUTCFullYear();
			vDateName.value = "";
			vDateName.value = strDate;
			window.event.returnValue = null;
			
		}
		else if(whichCode == 66) //"b" -- automatcally fill in with beginning of month
		{
			var objDate = new Date();
			var strDate = (objDate.getMonth() + 1) + strSeperator + "01" + strSeperator + objDate.getUTCFullYear();
			vDateName.value = "";
			vDateName.value = strDate;
			window.event.returnValue = null;
		}
		else if(whichCode == 8 || whichCode == 37 || whichCode == 39) //backspace
		{
			return;
		}
		else if(whichCode == 190 || whichCode == 110) //decimal point
		{
			return;
		}
		else if(whichCode == 46) // delete
		{
			return;
		}
		else if(whichCode == 9) //tab
		{
			return;
		}
		else if((control == true) && (whichCode == 67))
		{
			//copy
			return;
		}
		else if((control == true) && (whichCode == 86))
		{
			//paste
			var clipb = clipboardData.getData("Text");
			
			var ccRet = ccDate2(clipb)
			if(ccRet == undefined)
			{
				ccRet = false;
			}
			
			if(ccRet == false)
			{
				window.event.returnValue = null;
			}
		}
		else
		{
			window.event.returnValue = null; // otherwise, discard character
		}
	}
	
	
	function NumericFormat(vName, vValue, e)  
	{
		// vName = object name
		// vValue = value in the field being checked
		// e = event
		
		// Get ASCII value of key that user pressed
		var key = window.event.keyCode;
		var control = window.event.ctrlKey;
				
		//Do not allow more than one decimal point
		if((key == 190) || (key == 110)) //decimal point
		{
			var nDecimalIndex1 = vValue.indexOf(".");
			if(nDecimalIndex1 >= 0)
			{
				window.event.returnValue = null; // otherwise, discard
			}
		}
		else
		{
			// Was key that was pressed a numeric character (0-9)?
			if (key > 47 && key < 58) 
			{
				return; // if so, do nothing
			}
			else if(key >= 96 && key <= 105)
			{
				return; // keypad numbers
			}
			else if(key == 8 || key == 37 || key == 39) //backspace, forward arrow
			{
				return;
			}
			else if(key == 190 || key == 110) //decimal point
			{
				return;
			}
			else if(key == 46) // delete
			{
				return;
			}
			else if(key == 9) //tab
			{
				return;
			}
			else if((key == 109) || (key == 189 && window.event.shiftKey == false)) //minus
			{
				var nLen = vValue.length;
				if(nLen > 1)
				{
					window.event.returnValue = null;
				}
				else
				{
					return;
				}
			}
			else if((key == 107) || (key == 187 && window.event.shiftKey == true)) //plus sign
			{
				var nLen = vValue.length;
				if(nLen > 1)
				{
					window.event.returnValue = null;
				}
				else
				{
					return;
				}
			}
			else if((control == true) && (key == 67))
			{
				//copy
				return;
			}
			else if((control == true) && (key == 86))
			{
				//paste
				var clipb = clipboardData.getData("Text");
				
				var parse = parseFloat(clipb);
				parse = parse.toString();
												
				if((isNaN(parse) == false) && ((parse.length == clipb.length) || ((parse.charAt(0) == '0') && (parse.length == clipb.length + 1))))
				{
					//there are some unobvious checks here because parseFloat will prepend a zero to a number that begins with a decimal point (i.e: .123, .234, etc)
					var nValueDecimalIndex = vValue.indexOf(".");
					var nParseDecimalIndex = parse.indexOf(".");
					
					if((nValueDecimalIndex >= 0) && (nParseDecimalIndex >= 0))
					{
						//more than one decimal point
						window.event.returnValue = null;
					}
				}
				else 
				{
					window.event.returnValue = null;
				}
			}
			else
			{
				window.event.returnValue = null; // otherwise, discard character
			}
		}	
	}

	function IntFormat(vName, vValue, e)  
	{
		// vName = object name
		// vValue = value in the field being checked
		// e = event
		
		// Get ASCII value of key that user pressed
		var key = window.event.keyCode;
		var control = window.event.ctrlKey;
		
		//Do not allow more than one decimal point
		// Was key that was pressed a numeric character (0-9)?
		if (key > 47 && key < 58)
		{ 
			return; // if so, do nothing
		}
		else if(key >= 96 && key <= 105)
		{
			return; // keypad numbers
		}
		else if(key == 8 || key == 37 || key == 39) //backspace
		{
			return;
		}
		else if(key == 46) // delete
		{
			return;
		}
		else if(key == 9) //tab
		{
			return;
		}
		//Use next statements to allow for plus/minus signs
		else if((key == 109) || (key == 189 && window.event.shiftKey == false)) //minus
		{
			var nLen = vValue.length;
			if(nLen > 1)
			{
				window.event.returnValue = null;
			}
			else
			{
				return;
			}
		}
		else if((key == 107) || (key == 187 && window.event.shiftKey == true)) //plus sign
		{
			var nLen = vValue.length;
			if(nLen > 1)
			{
				window.event.returnValue = null;
			}
			else
			{
				return;
			}
		}
		else if((control == true) && (key == 67))
		{
			//copy
			return;
		}
		else if((control == true) && (key == 86))
		{
			//paste
			var clipb = clipboardData.getData("Text");
			
			var parse = parseInt(clipb);
			parse = parse.toString();
											
			if((isNaN(parse) != false) || (parse.length != clipb.length))
			{
				window.event.returnValue = null;
			}
		}
		else
		{
			window.event.returnValue = null; // otherwise, discard character
		}
			
	}
	
	function PositiveIntFormat(vName, vValue, e)  
	{
		// vName = object name
		// vValue = value in the field being checked
		// e = event
		
		// Get ASCII value of key that user pressed
		var key = window.event.keyCode;
		var control = window.event.ctrlKey;
		
		//Do not allow more than one decimal point
		// Was key that was pressed a numeric character (0-9)?
		if (key > 47 && key < 58)
		{ 
			return; // if so, do nothing
		}
		else if(key >= 96 && key <= 105)
		{
			return; // keypad numbers
		}
		else if(key == 8 || key == 37 || key == 39) //backspace
		{
			return;
		}
		else if(key == 46) // delete
		{
			return;
		}
		else if(key == 9) //tab
		{
			return;
		}
		//Use next statements to allow for plus/minus signs
		//else if((key == 109) || (key == 189 && window.event.shiftKey == false)) //minus
		//{
		//	return;
		//}
		else if((key == 107) || (key == 187 && window.event.shiftKey == true)) //plus sign
		{
			var nLen = vValue.length;
			if(nLen > 1)
			{
				window.event.returnValue = null;
			}
			else
			{
				return;
			}
		}
		else if((control == true) && (key == 67))
		{
			//copy
			return;
		}
		else if((control == true) && (key == 86))
		{
			//paste
			var clipb = clipboardData.getData("Text");
			
			var parse = parseInt(clipb);
			parse = parse.toString();
											
			if((isNaN(parse) != false) || (parse.length != clipb.length))
			{
				window.event.returnValue = null;
			}
		}
		else
		{
			window.event.returnValue = null; // otherwise, discard character
		}
			
	}
	
	function DateFormatEx(vDateName, vDateValue, e)  
	{
		//This version is for special enhanced grids
		
		var strSeperator = "/"; 
			
		// vDateName = object name
		// vDateValue = value in the field being checked
		// e = event
		
		var whichCode = (window.Event) ? e.which : e.keyCode;
		var nLen = vDateValue.length;
	 
		if ( (whichCode > 47 && whichCode < 58 ) || (whichCode >= 96 && whichCode <= 105))
		{
			if (nLen == 2)  
			{
				var objDN = document.getElementById(vDateName);
				objDN.value = vDateValue+strSeperator;
			}
			else if (nLen == 5)  
			{
				var objDN = document.getElementById(vDateName);
				objDN.value = vDateValue+strSeperator;
			}
			return true;
		}
		else if(whichCode == 84) //"t" -- automatically fill in with today's date
		{
			var objDN = document.getElementById(vDateName);
			var objDate = new Date();
			var strDay = objDate.getDate();
			
			if((strDay >=0) && (strDay < 10))
			{
				strDay = "0" + strDay;
			}
			var strDate = (objDate.getMonth() + 1) + strSeperator + strDay + strSeperator + objDate.getUTCFullYear();
			objDN.value = "";
			objDN.value = strDate;
			window.event.returnValue = null;
			
		}
		else if(whichCode == 66) //"b" -- automatcally fill in with beginning of month
		{
			var objDate = new Date();
			var objDN = document.getElementById(vDateName);
			var strDate = (objDate.getMonth() + 1) + strSeperator + "01" + strSeperator + objDate.getUTCFullYear();
			objDN.value = "";
			objDN.value = strDate;
			window.event.returnValue = null;
		}
		else if(whichCode == 8 || whichCode == 37 || whichCode == 39) //backspace
		{
			return;
		}
		else if(whichCode == 190 || whichCode == 110) //decimal point
		{
			return;
		}
		else if(whichCode == 46) // delete
		{
			return;
		}
		else if(whichCode == 9) //tab
		{
			return;
		}
		else
			window.event.returnValue = null; // otherwise, discard character
	}
	
	function IsValidUSZip(zip)
	{
		var retVal = true;
		
		if(zip.length < 5 || zip.length > 10)
		{
			retVal = false;
			return retVal;
		}
		
		for(i=0; i < zip.length; i++)
		{
			var temp = zip.charAt(i);
			var tempint = parseInt(temp);
			if(isNaN(tempint) == true)
			{
				if((temp == "-") && (i == 5))
				{
					continue;
				}
				else
				{
					retVal = false;
					return retVal;
				}				
			}
		}
		
		return retVal;
	}
		
	function ZipFormat(vName, vValue, vCountryName, e)  
	{
		// vName = object name
		// vValue = value in the field being checked
		// e = event
		if(vCountryName.value == "USA")
		{
			var nLen = vValue.length;
			var strSeperator = "-";
			var control = window.event.ctrlKey;
			
			// Get ASCII value of key that user pressed
			var key = window.event.keyCode;
						
			// Was key that was pressed a numeric character (0-9)?
			if ((key > 47 && key < 58) || (key >= 96 && key <= 105))
			{ 
				if (nLen == 5)  
				{
					vName.value = vValue + strSeperator;
				}	
				return; //if so, do nothing
			}
			else if(key == 8 || key == 37 || key == 39) //backspace
			{
				return;
			}
			else if(key == 46) //delete
			{
				return;
			}
			else if(key == 9) //tab
			{
				return;
			}
			else if((control == true) && (key == 67))
			{
				//copy
				return;
			}
			else if((control == true) && (key == 86))
			{
				var clipb = clipboardData.getData("Text");
			
				var ccRet = IsValidUSZip(clipb)
				if(ccRet == undefined)
				{
					ccRet = false;
				}
				
				if(ccRet == false)
				{
					window.event.returnValue = null;
				}
			}
			else
			{
				window.event.returnValue = null; // otherwise, discard character
			}
		}		
	}
	
	function IsValidUSPhone(phone)
	{
		var retVal = true;
		
		if(phone.length < 8 || phone.length > 13)
		{
			retVal = false;
			return retVal;
		}
		
		if(phone.length == 8)
		{
			for(i = 0; i<phone.length; i++)
			{
				var temp = phone.charAt(i);
				var tempint = parseInt(temp);
				if(isNaN(tempint) == true)
				{
					if((temp == "-") && (i == 3))
					{
						continue;
					}
					else
					{
						retVal = false;
						return retVal;
					}				
				}
			}
		}
		else if(phone.length == 13)
		{
			for(i = 0; i<phone.length; i++)
			{
				var temp = phone.charAt(i);
				var tempint = parseInt(temp);
				if(isNaN(tempint) == true)
				{
					if((temp == "(") && (i == 0))
					{
						continue;
					}
					else if((temp == ")") && (i == 4))
					{
						continue;
					}
					else if((temp == "-") && (i == 8))
					{
						continue;
					}
					else
					{
						retVal = false;
						return retVal;
					}				
				}
			}
		
		}
		else
		{
			retVal = false;
			return retVal;
		}
		
		return retVal;
	}
	
	function PhoneFormat(vName, vValue, vCountryName, e)  
	{
		// vName = object name
		// vValue = value in the field being checked
		// e = event
		if(vCountryName.value == "USA")
		{
			var nLen = vValue.length;
			var strSeperator = "-";
			
			// Get ASCII value of key that user pressed
			var key = window.event.keyCode;
			var control = window.event.ctrlKey;
			var shift = window.event.shiftKey;
			
			//alert(key);			
			// Was key that was pressed a numeric character (0-9)?
			if ((shift == false) && (((key > 47 && key < 58) || (key >= 96 && key <= 105)) && (nLen < 13)))
			{ 
				if (nLen == 3)  
				{
					vName.value = '(' + vValue + ')'; //strSeperator;
				}
				else if(nLen == 8)
				{
					vName.value = vValue + strSeperator; //strSeperator;
				}
				return; // if so, do nothing
			}
			else if(key == 8 || key == 37 || key == 39) //backspace
			{
				return;
			}
			else if(key == 46) // delete
			{
				return;
			}
			else if(key == 9) //tab
			{
				return;
			}			
			else if((control == true) && (key == 67))
			{
				//copy
				return;
			}
			else if((control == true) && (key == 86))
			{
				//paste
				var clipb = clipboardData.getData("Text");
			
				var ccRet = IsValidUSPhone(clipb)
				if(ccRet == undefined)
				{
					ccRet = false;
				}
				
				if(ccRet == false)
				{
					window.event.returnValue = null;
				}
			}
			else
			{
				window.event.returnValue = null; // otherwise, discard character
			}
			
		}		
	}

	function PhoneFormatAllCountries(vName, vValue, e)  
	{
		// vName = object name
		// vValue = value in the field being checked
		// e = event
		var nLen = vValue.length;
		var strSeperator = "-";
		
		// Get ASCII value of key that user pressed
		var key = window.event.keyCode;
					
		//Do not allow more than one decimal point
		// Was key that was pressed a numeric character (0-9)?
		if (((key > 47 && key < 58) || (key >= 96 && key <= 105)) && (nLen < 13))
		{ 
			if (nLen == 3)  
			{
				vName.value = '(' + vValue + ')'; //strSeperator;
			}
			else if(nLen == 8)
			{
				vName.value = vValue + strSeperator; //strSeperator;
			}
			return; // if so, do nothing
		}
		else if(key == 8 || key == 37 || key == 39) //backspace
			return;
		else if(key == 46) // delete
			return;
		else if(key == 9) //tab
			return;
		else
			window.event.returnValue = null; // otherwise, discard character
		
	}

	
	function IsValidAccount(account)
	{
		var retVal = true;
		
		if(account.length > 7 || account.length <= 0)
		{
			retVal = false;
			return retVal;
		}
		
		//at most one decimal point
		var nValueDecimalIndex = account.indexOf(".");
		if(nValueDecimalIndex == 0)
		{
			retVal = false;
			return retVal;
		}
		else if(nValueDecimalIndex < 4)
		{
			retVal = false;
			return retVal;
		}
		else if(nValueDecimalIndex >= 4)
		{
			var nValueDecimalIndex2 = account.indexOf(".",nValueDecimalIndex + 1);
			if(nValueDecimalIndex2 >= 0)
			{
				retVal = false;
				return retVal;
			}
		}
		
		for(i=0; i < account.length; i++)
		{
			var temp = account.charAt(i);
			var tempint = parseInt(temp);
			if((isNaN(tempint) == true) && (temp != "."))
			{
				retVal = false;
				return retVal;
			}
		}
				
		return retVal;
	}
	
	function AccountFormat(vName, vValue, e)  
	{
		// vName = object name
		// vValue = value in the field being checked
		// e = event
		var nLen = vValue.length;
		var strSeperator = ".";
		
		// Get ASCII value of key that user pressed
		var key = window.event.keyCode;
		var control = window.event.ctrlKey;
		
		//Do not allow more than one decimal point
		// Was key that was pressed a numeric character (0-9)?
		if (((key > 47 && key < 58) || (key >= 96 && key <= 105)) && (nLen <= 6))
		{ 
			if (nLen == 4)  
			{
				vName.value = vValue + strSeperator;
			}	
			return; // if so, do nothing
		}
		else if(key == 8 || key == 37 || key == 39) //backspace
		{
			return;
		}
		else if(key == 46) // delete
		{
			return;
		}
		else if(key == 9) //tab
		{
			return;
		}
		else if((control == true) && (key == 67))
		{
			//copy
			return;
		}
		else if((control == true) && (key == 86))
		{
			var clipb = clipboardData.getData("Text");
			var validAccount = IsValidAccount(clipb);
			if(validAccount == false)
			{
				window.event.returnValue = null;
			}
		}
		else
		{
			window.event.returnValue = null; // otherwise, discard character
		}
			
	}
	
	function DatePicker(thisForm,thisControl)
	{
		//get the pagename and send it as a querystring param
		var strURL = document.URL;
		var aStrings = strURL.split("/");
					
		//get the last two items.  They are:  the page, the its folder
		var strPage1 = aStrings[aStrings.length - 1];
		var nDot = strPage1.indexOf(".",0);
		strPage1 = strPage1.substring(0,nDot);
		var strPage = aStrings[aStrings.length - 2] + "." + strPage1;
		
		var url = "../Forms/CExpansionForm.aspx?page=" + strPage + "&fn=" + thisForm + "&id=" + thisControl;
		var w   = 220;
		var h   = 230; 
		if (document.all)
		{
			var xMax = screen.width;
			var yMax = screen.height;
		}
		else
		{
			var xMax = 640;
			var yMax = 480;
		}
		
		if (w>xMax) w = xMax * .9;
		if (h>yMax) h = yMax * .9;
		var l = (xMax - w)/2, t = (yMax-h)/2;
		handle_PUH = window.open(url,"Date",'screenX='+l+',left='+l+',screenY='+t+',top='+t+',toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,fullscreen=0,width='+w+',height='+h);
	}
	
	function GenPicker(thisForm,thisControl,thisType)
	{
		//get the pagename and send it as a querystring param
		var strURL = document.URL;
		var aStrings = strURL.split("/");
					
		//get the last two items.  They are:  the page and its folder
		var strPage1 = aStrings[aStrings.length - 1];
		var nDot = strPage1.indexOf(".",0);
		strPage1 = strPage1.substring(0,nDot);
		var strPage = aStrings[aStrings.length - 2] + "." + strPage1;
		
		var url = "../Forms/CGenExpansionForm.aspx?page=" + strPage + "&type=" + thisType + "&fn=" + thisForm + "&id=" + thisControl;
		var w   = 600;
		var h   = 400; 
		if (document.all)
		{
			var xMax = screen.width;
			var yMax = screen.height;
		}
		else
		{
			var xMax = 640;
			var yMax = 480;
		}
		
		if (w>xMax) w = xMax * .9;
		if (h>yMax) h = yMax * .9;
		var l = (xMax - w)/2, t = (yMax-h)/2;
		handle_PUH = window.open(url,"Select",'screenX='+l+',left='+l+',screenY='+t+',top='+t+',toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=yes,resizable=yes,fullscreen=0,width='+w+',height='+h);
	}
	
	function GenPickerIndex(thisForm,thisControl,thisType,nColumnIndex)
	{
		//get the pagename and send it as a querystring param
		var strURL = document.URL;
		var aStrings = strURL.split("/");
					
		//get the last two items.  They are:  the page, and its folder
		var strPage1 = aStrings[aStrings.length - 1];
		var nDot = strPage1.indexOf(".",0);
		strPage1 = strPage1.substring(0,nDot);
		var strPage = aStrings[aStrings.length - 2] + "." + strPage1;
		
		var url = "../Forms/CGenExpansionForm.aspx?page=" + strPage + "&type=" + thisType + "&fn=" + thisForm + "&id=" + thisControl + "&column_index=" + nColumIndex;
		var w   = 600;
		var h   = 300; 
		if (document.all)
		{
			var xMax = screen.width;
			var yMax = screen.height;
		}
		else
		{
			var xMax = 640;
			var yMax = 480;
		}
		
		if (w>xMax) w = xMax * .9;
		if (h>yMax) h = yMax * .9;
		var l = (xMax - w)/2
		var t = (yMax-h)/2;
		handle_PUH = window.open(url,"Select",'screenX='+l+',left='+l+',screenY='+t+',top='+t+',toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=yes,resizable=yes,fullscreen=0,width='+w+',height='+h);
	}
	
	function AccountGenPicker(thisForm,thisControl,thisType)
	{
		//get the pagename and send it as a querystring param
		var strURL = document.URL;
		var aStrings = strURL.split("/");
					
		//get the last two items.  They are:  the page and its folder
		var strPage1 = aStrings[aStrings.length - 1];
		var nDot = strPage1.indexOf(".",0);
		strPage1 = strPage1.substring(0,nDot);
		var strPage = aStrings[aStrings.length - 2] + "." + strPage1;
		
		var url = "../Forms/CGenExpansionFormAccounts.aspx?page=" + strPage + "&type=" + thisType + "&fn=" + thisForm + "&id=" + thisControl;
		var w   = 600;
		var h   = 400; 
		if (document.all)
		{
			var xMax = screen.width;
			var yMax = screen.height;
		}
		else
		{
			var xMax = 640;
			var yMax=480;
		}
		
		if (w>xMax) w = xMax * .9;
		if (h>yMax) h = yMax * .9;
		var l = (xMax - w)/2;
		var t = (yMax-h)/2;
		handle_PUH = window.open(url,"Select",'screenX='+l+',left='+l+',screenY='+t+',top='+t+',toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=yes,resizable=yes,fullscreen=0,width='+w+',height='+h);
	}
	
	
	function CustomerGenPicker(thisForm,thisControl,thisType)
	{
		//get the pagename and send it as a querystring param
		var strURL = document.URL;
		var aStrings = strURL.split("/");
					
		//get the last two items.  They are:  the page and its folder
		var strPage1 = aStrings[aStrings.length - 1];
		var nDot = strPage1.indexOf(".",0);
		strPage1 = strPage1.substring(0,nDot);
		var strPage = aStrings[aStrings.length - 2] + "." + strPage1;
		
		var url = "../Forms/CGenExpansionFormCustomer.aspx?page=" + strPage + "&type=" + thisType + "&fn=" + thisForm + "&id=" + thisControl;
		var w   = 600;
		var h   = 400; 
		if (document.all)
		{
			var xMax = screen.width;
			var yMax = screen.height;
		}
		else
		{
			var xMax = 640;
			var yMax = 480;
		}
		
		if (w>xMax) w = xMax * .9;
		if (h>yMax) h = yMax * .9;
		var l = (xMax - w)/2
		var t = (yMax-h)/2;
		handle_PUH = window.open(url,"Select",'screenX='+l+',left='+l+',screenY='+t+',top='+t+',toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=yes,resizable=yes,fullscreen=0,width='+w+',height='+h);
	}
	
		
	function ShowNotes(strEntityTable, strEntityIDControl, strAltEntityIDControl)
	{
		var strEntityIDValue = "";
		var strAltEntityIDValue = "";

		var bCont1 = false;
		var bCont2 = false;
		
		if(strEntityIDControl.length > 0)
		{	
			strEntityIDValue = document.all(strEntityIDControl).value;
			if(strEntityIDValue.length > 0)
			{
				bCont1 = true;
			}
		}

		if(strAltEntityIDControl.length > 0)
		{				
			strAltEntityIDValue = document.all(strAltEntityIDControl).value;
			if(strAltEntityIDValue.length > 0)
			{
				bCont2 = true;
			}
		}
		
		var url = "../Forms/CNotesForm.aspx?strEntityTable="+strEntityTable+"&strEntityID="+strEntityIDValue+"&strAltEntityID="+strAltEntityIDValue;
		var w   = 580;
		var h   = 600; 
		if (document.all)
		{
			var xMax = screen.width;
			var yMax = screen.height;
		}
		else
		{
			var xMax = 1280;
			var yMax = 1000;
		}
		
		if (w>xMax) w = xMax * .9;
		if (h>yMax) h = yMax * .9;
		var l = (xMax - w)/2, t = (yMax-h)/2;
		
		if((bCont1 == true) || (bCont2 == true))
		{
			handle_PUH = window.open(url,"Notes",'screenX='+l+',left='+l+',screenY='+t+',top='+t+',toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=yes,resizable=yes,fullscreen=0,width='+w+',height='+h);
		}
	}
	
	
	function ShowHelp()
	{
		var strURL = document.URL;
		var aStrings = strURL.split("/");
					
		//get the last two items.  They are:  the page and its folder
		var strPage1 = aStrings[aStrings.length - 1];
		var strFolder = aStrings[aStrings.length - 2];
		var nDot = strPage1.indexOf(".",0);
		strPage1 = strPage1.substring(0,nDot);
		
		var url = "../Forms/CHelpForm.aspx?folder=" + strFolder + "&page=" + strPage1 + ".aspx";
		var w   = 500;
		var h   = 600; 
		if (document.all)
		{
			var xMax = screen.width;
			var yMax = screen.height;
		}
		else
		{
			var xMax = 640;
			var yMax = 480;
		}
		
		if (w>xMax) w = xMax * .9;
		if (h>yMax) h = yMax * .9;
		var l = (xMax - w)/2, t = (yMax-h)/2;
		handle_PUH = window.open(url,'Help','screenX='+l+',left='+l+',screenY='+t+',top='+t+',toolbar=0,titlebar=0,location=0,directories=0,status=0,menubar=0,scrollbars=yes,resizable=yes,fullscreen=0,width='+w+',height='+h);
		
	}
	
	function ShowAppModuleFeatureHelp(strAppModuleID, strFeatureID)
	{
		var url = "../Forms/CHelpForm.aspx?app_module=" + strAppModuleID + "&feature_id=" + strFeatureID;
		var w   = 500;
		var h   = 600; 
		if (document.all)
		{
			var xMax = screen.width;
			var yMax = screen.height;
		}
		else
		{
			var xMax = 640;
			var yMax = 480;
		}
		
		if (w>xMax) w = xMax * .9;
		if (h>yMax) h = yMax * .9;
		var l = (xMax - w)/2, t = (yMax-h)/2;
		handle_PUH = window.open(url,'Help','screenX='+l+',left='+l+',screenY='+t+',top='+t+',toolbar=0,titlebar=0,location=0,directories=0,status=0,menubar=0,scrollbars=yes,resizable=yes,fullscreen=0,width='+w+',height='+h);
	} // ShowAppModuleFeatureHelp

	
	function ShowPopup(folder, page)
	{
		var url = "";
		
		if((folder.length > 0) && (folder != "this"))
		{
			url = "../" + folder + "/";
		}
		
		//make sure there is a querystring as part of the page.
		var bCont = true;
		var nIndex = page.indexOf("=");
		if((nIndex == (page.length-1)) || (nIndex == -1))
		{
			bCont = false;
		}
		else if ((nIndex < (page.length - 2)) && (page.charAt(nIndex + 1) == "&"))
		{
			bCont = false;
		}
		if(bCont == true)
		{
		
			url = url + page;
			var w   = 750;
			var h   = 550; 
			if (document.all)
			{
				var xMax = screen.width;
				var yMax = screen.height;
			}
			else
			{
				var xMax = 640;
				var yMax = 480;
			}
			
			if (w>xMax) w = xMax * .9;
			if (h>yMax) h = yMax * .9;
			var l = (xMax - w)/2, t = (yMax-h)/2;
			handle_PUH = window.open(url,'Form','screenX='+l+',left='+l+',screenY='+t+',top='+t+',toolbar=0,titlebar=0,location=0,directories=0,status=0,menubar=0,scrollbars=yes,resizable=yes,fullscreen=0,width='+w+',height='+h);
		}
	}	
	
	function GridLink(strPage, strTarget)
	{
		var url = "";
		
		//make sure there is a querystring as part of the page.
		
		
		url = strPage;
		var w   = 750;
		var h   = 550; 
		if (document.all)
		{
			var xMax = screen.width;
			var yMax = screen.height;
		}
		else
		{
			var xMax = 640;
			var yMax = 480;
		}
		
		if (w>xMax) w = xMax * .9;
		if (h>yMax) h = yMax * .9;
		var l = (xMax - w)/2, t = (yMax-h)/2;
		if(strTarget.toLowerCase() == "top")
		{
			handle_PUH = window.open(url,'Form','screenX='+l+',left='+l+',screenY='+t+',top='+t+',toolbar=0,titlebar=0,location=0,directories=0,status=0,menubar=0,scrollbars=yes,resizable=yes,fullscreen=0,width='+w+',height='+h);
		}
		else if(strTarget == "")
		{
			location.href = strPage;
		}
		
	}

	function KeyCopy(sourcecontrol, copycontrol)
	{
		var objControl = document.getElementById(copycontrol);
		var objSource = document.getElementById(sourcecontrol);
		if((objControl != null) && (objSource != null))
		{
			objControl.value = objSource.value;
					
		}
	}

	function checkCR() 
	{
		var evt  = event;//(evt) ? evt : ((event) ? event : null);
		var node = evt.srcElement;
		
		if ((evt.keyCode == 13) && (node.type == "text")) 
		{
			return false;
		}
	}
	
	document.onkeypress = checkCR;

	var defCellWidth = 50;
	var actResizeCell;
	var actCellID = '';
	var actMousePos = 0;
	var actLeftBorder = 0;
	var cellIndex = -1;
	var cellTable = null;

	function sMod(theCell)
	{
		if(actCellID != '')
		{
			releaseMove();
		}
		
		actCellID = theCell.id;
		
		if(theCell.width == '')
		{
			theCell.width = defCellWidth;
		}
		
		actResizeCell = theCell;
		actLeftBorder = event.x - event.offsetX;
		document.body.attachEvent("onmousemove", doResizeCell);
		document.body.attachEvent("onmouseup", releaseMove);
		theCell.style.cursor = "e-resize";
		cellTable = findTable();
		cellIndex = actResizeCell.cellIndex;//findIndex(actResizeCell.id);
		
	}
			
	function releaseMove()
	{
		if(actResizeCell != null)
		{
			actCellID = '';
			actResizeCell.style.cursor = "auto";
			actResizeCell = null;
			actLeftBorder = 0;
			cellIndex = -1;
			return false;
		}
	}
		
	function findTable()
	{
		var objP1 = actResizeCell.parentElement;
		while((objP1 != null) && (objP1.tagName != "TABLE"))
		{
			objP1 = objP1.parentElement;
		}
		if((objP1 != null) && (objP1.tagName == "TABLE"))
		{
			return objP1;
		}
		else
		{
			return false;
		}	
		
	}

	function doResizeCell(event)
	{
		if(!actResizeCell)
		{
			return false;
		}
		
		var nLen = event.x - actLeftBorder;
		if(nLen > 0)
		{
			actMousePos = actResizeCell.width;
			
			var objT = cellTable;
			
			for(i=0; i<objT.rows.length; i++)
			{
				if(objT.rows(i).cells.length > cellIndex)
				{
					var objC = objT.rows(i).cells(cellIndex);
					objC.width = nLen;
					
					var objSpan2 = objC.getElementsByTagName("span");
					if(objSpan2 != null)
					{
						//var objS1 = objC.childNodes(0);
						var objChild = objC.childNodes(0);
						if((objChild.tagName == "INPUT") || (objChild.tagName == "SPAN"))
						{
							objC.childNodes(0).style.width = nLen;
						}
						else //if(objChild.tagName == "undefined")
						{
							//objC.childNodes(0).width = nLen;
							//alert(objChild.tagName);
						}
					}
				}
			}
						
		}			
					
	}

