﻿	// JScript File
	var g_sValidChars = "";


	function ValidateRequired(controlList)
	{
		var returnValue = true;
		var controlToValidate = null;
		var controlListArray = controlList.split(';');
	      
		//loop through controls
		for (i = 0; i < controlListArray.length; i++)
		{
			//get the control
			controlToValidate = document.getElementById(controlListArray[i]);
	        
			//check value
			if (controlToValidate != null)
			{
				if (controlToValidate.value.length == 0)
				{
					controlToValidate.style.backgroundColor = '#FF0A0A'; 
	                
					if (returnValue)
					{
						controlToValidate.focus();
					}
	                                
					returnValue = false;
				}
				else
				{
					controlToValidate.style.backgroundColor = '#FFFFFF'; 
				}
			}
		}
	    
		return returnValue;
	}





	function ValidateRequiredDropDown(controlList)
	{
		var returnValue = true;
		var controlToValidate = null;
		var controlListArray = controlList.split(';');
	      
		//loop through controls
		for (i = 0; i < controlListArray.length; i++)
		{
			//get the control
			controlToValidate = document.getElementById(controlListArray[i]);
	        
			//check value
			if (controlToValidate != null)
			{
				if (controlToValidate.selectedIndex < 1)
				{
					controlToValidate.style.backgroundColor = '#FF0A0A' 
	                
					if (returnValue)
					{
						controlToValidate.focus();
					}
	                                
					returnValue = false;
				}
				else
				{
					controlToValidate.style.backgroundColor = '#FFFFFF'; 
				}
			}
		}
	    
		return returnValue;
	}







	function ValidateRegex(controlList, patern)
	{
		var returnValue = true;
		var controlToValidate = null;
		var controlListArray = controlList.split(';');
	      
		//loop through controls
		for (i = 0; i < controlListArray.length; i++)
		{
			//get the control
			controlToValidate = document.getElementById(controlListArray[i]);
	        
			//check value
			if (controlToValidate != null)
			{
				if (!patern.test(controlToValidate.value))
				{
					controlToValidate.style.backgroundColor = '#FFE0B3' 
	                
					if (returnValue)
					{
						controlToValidate.focus();
					}
	                                
					returnValue = false;
				}
				else
				{
					controlToValidate.style.backgroundColor = '#FFFFFF'; 
				}
			}
		}
	
		return returnValue;
	}


	

	function txtTextbox_OnKeyUp()
	{
		//loop through value
		var value = this.value;
		
		//check value
		if (value.length > 0)
		{
			for(i = 0; i < value.length; i++)
			{
				//check this value
				if (g_sValidChars.indexOf(value.substring(i, (i + 1))) < 0)
				{
					//remove this caracter
					this.value = this.value.substr(0, i);
		            
					//indicate to user that the value is incorrect by changing the color of the background
					this.style.backgroundColor = "#FF0A0A";
			        
					return false;
				}
		        
				this.style.backgroundColor = "#FFFFFF";
			}
		}		
	}
	




	
	
	
	
	
	
	function ColorChange()
	{        
		this.style.backgroundColor = "#FFFFFF";	
	}

	function ValidateRequiredDropDown2(controlList)
	{
		controlToValidate.style.backgroundColor = '#FFFFFF'; 
	}