﻿
	// non-digit characters which are allowed in phone numbers
	//var phoneNumberDelimiters = "()- ";
	// Minimum no of digits in an international phone no.
	//var minDigitsInIPhoneNumber = 10;
	
	
	//********************************************
	// Function name  : Temporary1874
	// Parameter      : objObject
	// Return value   : Object
	// Purpose        : Temporary written for 1874 crash
	// Author		  : Vikas Gupta
	//********************************************
	
	function Temporary1874(objObject)
	{
	    if (objObject != null)
            {
                if(objObject.value.length > 3)
                    {
                        objObject.value = objObject.value.substring(0, 3);
                    }
            }
        return objObject;
	}
   
	//********************************************
	// Function name  : CheckSpecialCharachter
	// Parameter      : objField,objFieldCaption
	// Return value   : bool
	// Purpose        : Checking is field contain any special character
	// Author		  : Devanand Chahal
	// Creation Date  : 
	// Changed By	  : 
	// Changed Date   : 
	//********************************************
	function CheckSpecialCharachter( objField, objFieldCaption ) 
	{ 
	   
		var textRE=/^[0-9a-zA-Z\s]*$/;        
		if(!textRE.test(objField.value))
		{
			alert(objFieldCaption + " can not accept special characters.");
			objField.focus();
			return false;
		}	    
		return true;
	}
	  
	//********************************************
    // Function name  : replaceSubstring
    // Parameter      : inputString(operations will be performed on this string) , 
    //                : fromString(String to be replaced from inputString), 
    //                : toString(String to take place of fromString)
    // Return value   : bool
    // Purpose        : Used to replace a string by another string in a specified string.
    // Author		  : Vikas Gupta
    // Creation Date  : 16-May-08
    // Changed By	  : 
    // Changed Date   : 
    //******************************************** 
     
	function replaceSubstring(inputString, fromString, toString) {
       
       var temp = inputString;
       if (fromString == "") {
          return inputString;
       }
       if (toString.indexOf(fromString) == -1) { // If the string being replaced is not a part of the replacement string (normal situation)
          while (temp.indexOf(fromString) != -1) {
             var toTheLeft = temp.substring(0, temp.indexOf(fromString));
             var toTheRight = temp.substring(temp.indexOf(fromString)+fromString.length, temp.length);
             temp = toTheLeft + toString + toTheRight;
          }
       } else { // String being replaced is part of replacement string (like "+" being replaced with "++") - prevent an infinite loop
          var midStrings = new Array("~", "`", "_", "^", "#");
          var midStringLen = 1;
          var midString = "";
          // Find a string that doesn't exist in the inputString to be used
          // as an "inbetween" string
          while (midString == "") {
             for (var i=0; i < midStrings.length; i++) {
                var tempMidString = "";
                for (var j=0; j < midStringLen; j++) { tempMidString += midStrings[i]; }
                if (fromString.indexOf(tempMidString) == -1) {
                   midString = tempMidString;
                   i = midStrings.length + 1;
                }
             }
          } // Keep on going until we build an "inbetween" string that doesn't exist
          // Now go through and do two replaces - first, replace the "fromString" with the "inbetween" string
          while (temp.indexOf(fromString) != -1) {
             var toTheLeft = temp.substring(0, temp.indexOf(fromString));
             var toTheRight = temp.substring(temp.indexOf(fromString)+fromString.length, temp.length);
             temp = toTheLeft + midString + toTheRight;
          }
          // Next, replace the "inbetween" string with the "toString"
          while (temp.indexOf(midString) != -1) {
             var toTheLeft = temp.substring(0, temp.indexOf(midString));
             var toTheRight = temp.substring(temp.indexOf(midString)+midString.length, temp.length);
             temp = toTheLeft + toString + toTheRight;
          }
       } 
       return temp; // Send the updated string back to the user
    } // Ends the "replaceSubstring" function

	//********************************************
	// Function name  : CheckSpecialCharachterWithComma
	// Parameter      : objField,objFieldCaption
	// Return value   : bool
	// Purpose        : Checking is field contain any special character and comma
	// Author		  : Devanand Chahal
	// Creation Date  : 
	// Changed By	  :  
	// Changed Date   : 
	//********************************************
	function CheckSpecialCharachterWithComma( objField, objFieldCaption ) 
	{         
		var textRE=/^[0-9a-zA-Z,\s]*$/;        
		if(!textRE.test(objField.value))
		{
			alert(objFieldCaption + " can not accept special characters except comma.");
			objField.focus();
			return false;
		}	    
		return true;
	}
	 
	 
	//********************************************
	// Function name  : CheckSpecialCharachterWithDU
	// Parameter      : objField,objFieldCaption
	// Return value   : bool
	// Purpose        : Function to check whether field contain any special character Except 'Dot' and 'UnderScore'
	// Author		  : Manu Gupta
	// Creation Date  : 
	// Changed By	  : 
	// Changed Date   : 
	function CheckSpecialCharachterWithDU( objField, objFieldCaption )
	{ 
		// MG: validation modified by using reg exp.--------------------------------------
		var textRE=/^[0-9a-zA-Z._\s]*$/;        
		if(!textRE.test(objField.value))
		{
			alert(objFieldCaption + " can not accept special characters.");
			objField.focus();
			return false;
		}	    
		return true;
	}
	
	//********************************************
	// Function name  : CheckSpecialCharachterWithSQ
	// Parameter      : objField,objFieldCaption
	// Return value   : bool
	// Purpose        : Function to check whether field contain any single quote, if yes the return false.
	// Author		  : Devanand Chahal
	// Creation Date  : 25-05-07
	// Changed By	  : 
	// Changed Date   : 
	function CheckSpecialCharachterWithSQ( objField, objFieldCaption )
	{ 		
		var strValue = objField.value;
		// this exp. will return true if any of the specified specila character found in the string      
        var reg = new RegExp("[<>~|]+"); 
        //var result = reg.test(strValue);
        if(reg.test(strValue) == true)
        {
            alert(objFieldCaption + " can not accept <,>,~,| ");
			objField.focus();
			return false;
        }
		return true;
	}

	//********************************************
	// Function name  : CheckBlankSpace
	// Parameter      : objField,objFieldCaption
	// Return value   : bool
	// Purpose        : Function to check for blank space 
	// Author		  : Vinod Kumar    
	// Creation Date  : 
	// Changed By	  : 
	// Changed Date   : 
	//********************************************
	function CheckBlankSpace(objField, objFieldCaption )
	{ 
		var str = objField.value;
		var arr = str.split(" ");
		if (arr[1] != null)
		{
			alert( objFieldCaption + " can not accept blank space." );
			objField.focus();
			return false;
		}
		return true;
	}

	//********************************************
	// Function name  : CheckLength
	// Parameter      : objField,objFieldCaption,intLessThan, intGreterThan
	// Return value   : bool
	// Purpose        : Function to check that the value's length lies between specifice range
	// Author		  : Vinod Kumar   
	// Creation Date  : 
	// Changed By	  : 
	// Changed Date   : 
	//********************************************
	function CheckLength(objField, objFieldCaption, intLessThan, intGreterThan )
	{   
		var objValue = objField.value; 
		objValue=TrimAll(objValue);          
		if( !(objValue.length >= intLessThan && objValue.length <= intGreterThan) )
		{
			alert(objFieldCaption + " can not be less than " + intLessThan + " characters and greater than " + intGreterThan + " characters.");
			objField.focus();
			return false;
		}     
		return true;
	}

	
	//********************************************
	// Function name  : CheckExactLength
	// Parameter      : objField,objFieldCaption,intLength
	// Return value   : bool
	// Purpose        : Function to check value field against fixed length for length validation  
	// Author		  : Devanand Chahal
	// Creation Date  : 24-11-06
	// Changed By	  : Devanand Chahal
	// Changed Date   : 29-03-07
	//********************************************
	function CheckExactLength(objField, objFieldCaption, intLength )
	{ 
		var objValue = objField.value; 
		objValue=TrimAll(objValue);           
		if( objValue.length !=  intLength)
		{
			alert(objFieldCaption + " can be of " + intLength + " characters only.");
			objField.focus();
			return false;
		}     
		return true;
	}

	//********************************************
	// Function name  : CheckBlank 
	// Parameter      : objField, objFieldCaption
	// Return value   : bool
	// Purpose        : Function to check for blank value
	// Author		  : Vinod Kumar    
	// Creation Date  : 
	// Changed By	  : 
	// Changed Date   : 
	//********************************************
	function CheckBlank(objField, objFieldCaption)
	{ 

		var objValue = objField.value; 
		objValue=TrimAll(objValue);          
		if(objValue.length <= 0 )
		{
		    if (objField.disabled != true)
		    {
			    alert(objFieldCaption + " is mandatory." );
			    objField.focus();
			    return false;
			}
		}
		return true;   
	} 
	
	
		//********************************************
	// Function name  : CheckDateForEqual
	// Parameter      : Dat1,Dat2,objDat1Caption,objDat2Caption
	// Return value   : bool
	// Purpose        : Function to compare two dates  
	// Author		  : Vinod Kumar
	// Creation Date  : 
	// Changed By	  : 
	// Changed Date   :             
	function CheckDateForEqual(Dat1,Dat2,objDat1Caption,objDat2Caption)
	{   
		 var d1=Dat1.split('/');
		 var d2=Dat2.split('/');
		 Date1=new Date(d1[2],d1[1]-1,d1[0]);     
		 Date2=new Date(d2[2],d2[1]-1,d2[0]);    
		 if (Date1 == Date2)     
		 {  
			alert(objDat1Caption + " can't be equal to " +objDat2Caption + ".");  
			return false ;      
		 } 	    
		 return true; 
	}	
	
	//********************************************
	// Function name  : DateValidate
	// Parameter      : Dat1,Dat2,objDat1Caption,objDat2Caption
	// Return value   : bool
	// Purpose        : Function to compare two dates  
	// Author		  : Naveen Nandal
	// Creation Date  : 
	// Changed By	  : 
	// Changed Date   :             
	function DateValidate(Dat1,Dat2,objDat1Caption,objDat2Caption)
	{   
		 var d1=Dat1.split('/');
		 var d2=Dat2.split('/');
		 Date1=new Date(d1[2],d1[1]-1,d1[0]);     
		 Date2=new Date(d2[2],d2[1]-1,d2[0]);    
		 if (Date1 > Date2)     
		 {  
			alert(objDat1Caption + " is greater than " +objDat2Caption + ".");  
			return false ;      
		 } 	    
		 return true; 
	}	
	   //********************************************
	// Function name  : CompareDate 
	// Parameter      : Obj1, Obj2,objDat1Caption,objDat2Caption
	// Return value   : bool
	// Purpose        : Function to compare two dates
	// Author		  : Priyanka
	// Creation Date  : 
	// Changed By	  : 
	// Changed Date   : 
	//********************************************
function CompareDate(Obj1, Obj2,objDat1Caption,objDat2Caption)

	{
		var  ObjValue1 = Obj1.value;
		var  objValue2 = Obj2.value;
		var date1, date2;
		var month1, month2;
		var year1, year2;
		var bFlag;        
		month1= ObjValue1.substring (ObjValue1.indexOf ("/")+1,ObjValue1.lastIndexOf ("/"));
		date1 = ObjValue1.substring (0, ObjValue1.indexOf ("/")); 
		year1 = ObjValue1.substring (ObjValue1.lastIndexOf ("/")+1, ObjValue1.length);
		month2 = objValue2.substring (objValue2.indexOf ("/")+1, objValue2.lastIndexOf ("/"));
		date2=objValue2.substring (0, objValue2.indexOf ("/")); 
		year2 = objValue2.substring (objValue2.lastIndexOf ("/")+1, objValue2.length);
		if (eval(year1) > eval(year2)) 
		{
		bFlag=false; 
		}
		else if (eval(year1) < eval(year2))
		{
		bFlag=true; 
		}
		else if (eval(month1) > eval(month2)) 
		{
		bFlag=false;
		}
		else if (eval(month1) < eval(month2))
		{
		bflag=true;
		}
		else if (eval(date1) > eval(date2))
		{
		bFlag=false;
		}
		else if (eval(date1) < eval(date2))
		{
		bFlag=true; 
		}
				else 

		{
				bFlag=true;

		}
		if(bFlag==false)

		{
		alert(objDat2Caption + " cannot be earlier than " +objDat1Caption);  
		return false;
		}
		else
		return true;
}
	//********************************************
	// Function name  : CheckBlankDropDownBox 
	// Parameter      : objField, objFieldCaption
	// Return value   : bool
	// Purpose        : Function to check whether valid value is selected in the drop down list box
	//                : Zero value is considered as "nothing-selected"
	// Author		  : Vinod Kumar    
	// Changed By	  : 
	// Changed Date   : 
	//********************************************
	function CheckBlankDropDownBox(objField,objFieldCaption)
	{
		if(objField.selectedIndex<=0)
		{
		    if (objField.disabled != true)
		    {
			    alert(objFieldCaption + " is mandatory." );
			    objField.focus();
			    return false;
			}
		}            
		 return true;
	}
	
	//********************************************
	// Function name  : CheckBlankListBox 
	// Parameter      : objField, objFieldCaption
	// Return value   : bool
	// Purpose        : Function to check whether valid value is selected in the  List box
	//                : Zero value is considered as "nothing-selected"
	// Author		  : Vinod Kumar    
	// Changed By	  : 
	// Changed Date   : 
	//********************************************
   function CheckBlankListBox(objField,objFieldCaption)
	{
		if(objField.selectedIndex<0)
		{
			alert(objFieldCaption + " is mandatory." );
			objField.focus();
			return false;
		}            
		return true;
	}
   
	//********************************************
	// Function name  : Check_CheckBox
	// Parameter      : objField,objFieldCaption
	// Return value   : bool
	// Purpose        : Checking CheckBox checked or UnChecked
	// Author		  : Baljeet Kiroriwal
	// Creation Date  : 
	// Changed By	  : 
	// Changed Date   : 
	//********************************************
	function Check_CheckBox(objField,objCaption)
	{
		if(objField.checked == 0)
		{
			alert(objCaption + " is mandatory.");
			objField.focus();
			return false;
		}
		return true;
	}    
		
	 
	//********************************************
	// Function name  : Check_RadioOption
	// Parameter      : objField,objFieldCaption
	// Return value   : bool
	// Purpose        : Checking CheckBox checked or UnChecked
	// Author		  : Created by Kusum  for Checking Radio checked or UnChecked
	// Creation Date  : 
	// Changed By	  : 
	// Changed Date   : 
	//********************************************
	function Check_RadioOption(objField,objCaption)
	{
	        var newDefault = false;
			var isValid
			var options = objField.getElementsByTagName('input');
			//For InActive value is 0 and active value is 1
			for(i=0;i<options.length;i++)
			{
				var opt = options[i];               
				if((opt.checked))
				{    
				    newDefault = true;               				   
				}
			}
			if(newDefault)
			{
			    return true;
			}
			else
			{
			    alert(objCaption + " is mandatory.")
			    objField.focus();
			    return false;
			}
	   
//		if(objField.checked < 0)
//		{
//			alert(objCaption + " is mandatory.");
//			objField.focus();
//			return false;
//		}
//		return true;
	}   
	
	//********************************************
	// Function name  : CheckValidName
	// Parameter      : objField,objFieldCaption
	// Return value   : bool
	// Purpose        : Function to Validate name
	// Author		  : Created by Manu Gupat
	// Creation Date  : 
	// Changed By	  : 
	// Changed Date   : 
	//********************************************
	function CheckValidName( objField, objFieldCaption )
	{
		// MG: modify for using reg exp.--------------------------------------
		var textRE=/^[0-9a-zA-Z.\s-]*$/;        
		if(!textRE.test(objField.value))
		{
			alert(objFieldCaption + " can not accept special characters except '-'.");
			objField.focus();
			return false;
		}	    
		return true; 
 
	}

//********************************************
	// Function name  : CheckValidName
	// Parameter      : objField,objFieldCaption
	// Return value   : bool
	// Purpose        : Function to Validate name
	// Author		  : Created by Manu Gupat
	// Creation Date  : 
	// Changed By	  : 
	// Changed Date   : 
	//********************************************
	function CheckValidNameWithQuotes( objField, objFieldCaption )
	{
		// MG: modify for using reg exp.--------------------------------------
		var textRE=/^[0-9a-zA-Z.\s-']*$/;        
		if(!textRE.test(objField.value))
		{
			alert(objFieldCaption + " can not accept special characters except '-' and single quote.");
			objField.focus();
			return false;
		}	    
		return true; 
 
	}

	//********************************************
	// Function name  : CheckValidPhoneFaxNumber
	// Parameter      : objField,objFieldCaption
	// Return value   : bool
	// Purpose        : Function to Validate name
	// Author		  : Created by Manu Gupat
	// Creation Date  : 
	// Changed By	  : 
	// Changed Date   : 
	//********************************************
	function CheckValidPhoneFaxNumber( objField, objFieldCaption )
	{
		// MG: modify for using reg exp.--------------------------------------
		var textRE=/[\d]{4,15}/;        //^[0-9-+\s]\w{8,15}
		if(!textRE.test(objField.value))
		{
			alert(objFieldCaption + " can accept only numeric values and the length to be between 4 and 15.");
			objField.focus();
			return false;
		}	    
		return true; 
	   
	}

  
	//********************************************
	// Function name  : CheckNumericCharachter
	// Parameter      : objField,objFieldCaption
	// Return value   : bool
	// Purpose        : Checking for numeric field
	// Author		  : Devanand Chahal
	// Creation Date  : 
	// Changed By	  : 
	// Changed Date   : 
	//********************************************
	function CheckNumericCharachter(objField, objFieldCaption )
	{        
		var textRE=/^[0-9]*$/;
		if(!textRE.test(TrimAll(objField.value)))
		{
			alert(objFieldCaption + " can accept positive numeric value only.");
			objField.focus();
			return false;
		}
	  
		return true;
	}
	
	//********************************************
	// Function name  : CheckOnlyAlphaCharachter
	// Parameter      : objField,objFieldCaption
	// Return value   : bool
	// Purpose        : Checking for alpha characters only
	// Author		  : Devanand Chahal
	// Creation Date  : 
	// Changed By	  :  
	// Changed Date   : 
	//********************************************
	function CheckOnlyAlphaCharachter( objField, objFieldCaption )
	{        
		var textRE=/^[a-zA-z]*$/;       
		if(!textRE.test(objField.value))
		{
			alert(objFieldCaption + " can accept only characters[a-z,A-Z]" );
			objField.focus();
			return false;
		}	   
	   
		return true;
	}
	
	
	//********************************************
	// Function name  : CheckOnlyAlphaCharAndSpaces
	// Parameter      : objField, Caption
	// Return value   : bool
	// Purpose        : Checking for alpha characters and white spaces only
	// Author		  : Vikas gupta
	// Creation Date  : 09-May-2007 4:42 PM
	// Changed By	  :  
	// Changed Date   : 
	//********************************************
	function CheckOnlyAlphaCharAndSpaces( objField, Caption )
	{        
		var textRE=/^[a-zA-z ]*$/;
		if(!textRE.test(objField.value))
		{
			alert(Caption + " can accept only characters[a-z,A-Z]" );
			objField.focus();
			return false;
		}	   
	   
		return true;
	}
	
	//********************************************
	// Function name  : CheckOnlyAlphaCharAndSpaces
	// Parameter      : objField, Caption
	// Return value   : bool
	// Purpose        : Checking for alpha characters and white spaces only
	// Author		  : Baljeet Kiroriwal
	// Creation Date  : 09-May-2007 4:42 PM
	// Changed By	  :  
	// Changed Date   : 
	//********************************************
	function CheckOnlyAlphaNumericCharAndSpaces( objField, Caption )
	{        
		var textRE=/^[a-zA-z0-9 ]*$/;
		if(!textRE.test(objField.value))
		{
			alert(Caption + " Can not accept special characters." );
			objField.focus();
			return false;
		}	   
	   
		return true;
	}
	

	
	
	//********************************************
	// Function name  : TrimAll
	// Parameter      : sString
	// Return value   : String
	// Purpose        : Create for removing leading and trailing spaces
	// Author		  : Devanand Chahal
	// Creation Date  : 10-11-06
	// Changed By	  : Devanand Chahal
	// Changed Date   : 29-03-07
	//********************************************
	function TrimAll(sString) 
	{    
		return LTrim(RTrim(sString));	   
	}
	
	
	//********************************************
	// Function name  : LTrim
	// Parameter      : value
	// Return value   : String
	// Purpose        : Removes leading whitespaces
	// Author		  : Devanand Chahal
	// Creation Date  : 10-11-06
	// Changed By	  : Devanand Chahal
	// Changed Date   : 29-03-07
	//********************************************
	function LTrim(value) 
	{    	
		var re = /\s*((\S+\s*)*)/;
		return value.replace(re, "$1");    	
	}    
	//********************************************
	// Function name  : RTrim
	// Parameter      : value
	// Return value   : String
	// Purpose        : Removes ending whitespaces
	// Author		  : Devanand Chahal
	// Creation Date  : 10-11-06
	// Changed By	  : Devanand Chahal
	// Changed Date   : 29-03-07
	//********************************************
	function RTrim(value) 
	{    	
		var re = /((\s*\S+)*)\s*/;
		return value.replace(re, "$1");    	
	}    
	
	//********************************************
	// Function name  : CheckFloatCharachter
	// Parameter      : ctrlval,objCaption
	// Return value   : bool
	// Purpose        : for validating a Float Number
	// Author		  : Baljeet Kiroriwal
	// Creation Date  : 
	// Changed By	  : 
	// Changed Date   : 
	//********************************************
	function CheckFloatCharachter(ctrlval,objCaption)
	{ 
		var FloatValid = /^\d*(\.\d+)?$/;          // Commented and modified by virender/^\d+(\.\d+)?$/;  
		if(ctrlval.value!='' && !(FloatValid.test(ctrlval.value)) )
		{
			alert(objCaption + " can accept only numeric and float."); // Edit by Kusum 
			ctrlval.focus(); // Add by Kusum
			return false;
		}
		return true;
	}    	

	function CheckFloatCharachterWithNegative(ctrlval,objCaption)
	{ 
		var FloatValid = /^[-]?\d*(\.\d+)?$/;          // Commented and modified by virender/^\d+(\.\d+)?$/;  
		if(ctrlval.value!='' && !(FloatValid.test(ctrlval.value)) )
		{
			alert(objCaption + " can accept only numeric and float."); // Edit by Kusum 
			ctrlval.focus(); // Add by Kusum
			return false;
		}
		return true;
	}    	

   
	//********************************************
	// Function name  : EmailCheck 
	// Parameter      : objField, objFieldCaption
	// Return value   : bool
	// Purpose        : Function to check valid E-Mail
	// Author		  : Priyanka Mishra
	// Creation Date  : 
	// Changed By	  : 
	// Changed Date   : 
	//********************************************    
	function EmailCheck(objField,objCaption)
	 {        
		var re=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;
		//var re = /^[a-zA-Z][\w\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$/
		if(objField.value !="")
		{   
			if (!(re.test(objField.value))) 
			{
				alert(objCaption + " is not in correct format.");
				objField.focus();
				return false;
			}
		}
		return true;
	}   

	//********************************************
	// Function name  : CheckAlphaNumericWithBackSlash 
	// Parameter      : objField, objFieldCaption
	// Return value   : bool
	// Purpose        : Function to check whether the value contains characters other than alphanumeric and BackSlash
	// Author		  : Baljeet Kiroriwal
	// Creation Date  : 10/May/2007
	// Changed By	  : 
	// Changed Date   : 
	//******************************************** 
	function CheckAlphaNumericWithBackSlash( objField, objFieldCaption )
	{
		// MG: modify for using reg exp.--------------------------------------
		///^[-]?\d*(\.\d+)?$/
		var textRE=/^[0-9a-zA-Z\\]*$/;        
		if(!textRE.test(objField.value))
		{
			alert(objFieldCaption + " can not accept special characters other than '\\'.");
			objField.focus();
			return false;
		}	    
		return true; 
	}
	
	//********************************************
	// Function name  : CheckAlphaNumeric 
	// Parameter      : objField, objFieldCaption
	// Return value   : bool
	// Purpose        : Function to check whether the value contains characters other than alphanumeric
	// Author		  : Priyanka Mishra
	// Creation Date  : 
	// Changed By	  : 
	// Changed Date   : 
	//******************************************** 
	function CheckAlphaNumeric( objField, objFieldCaption )
	{
		// MG: modify for using reg exp.--------------------------------------
		var textRE=/^[0-9a-zA-Z]*$/;        
		if(!textRE.test(objField.value))
		{
			alert(objFieldCaption + " can not accept special characters.");
			objField.focus();
			return false;
		}	    
		return true; 
	}
   
	//********************************************
	// Function name  : CheckMaxLength 
	// Parameter      : objField, objFieldCaption, intGreterThan
	// Return value   : bool
	// Purpose        : Function to check the maximum length of the value
	// Author		  : Kusum
	// Creation Date  : 
	// Changed By	  : 
	// Changed Date   : 
	//********************************************  
function CheckMaxLength(objField, objFieldCaption, intGreterThan) 
{
		 var objValue = objField.value; 
		 objValue = TrimAll(objValue);     
		   
		if( !(objValue.length <= intGreterThan ) )
		{
			alert(objFieldCaption + " can not accept more than " + intGreterThan + " characters.");
			objField.focus();
			return false;
		}     
		return true;
	
}
//********************************************
	// Function name  : CheckMinLength 
	// Parameter      : objField, objFieldCaption, intGreterThan
	// Return value   : bool
	// Purpose        : Function to check the maximum length of the value
	// Author		  : Naveen
	// Creation Date  : 
	// Changed By	  : rupika
	// Changed Date   : 30 May 2007
	//********************************************  
function CheckMinLength(objField, objFieldCaption, intLesserThan) 
{
		//if(objField.value !='' && TrimAll(objField.value).length < intLesserThan)
		if (TrimAll(objField.value).length < intLesserThan)
		{
			alert(objFieldCaption + " can not accept less than " + intLesserThan + " characters.");
			objField.focus();
			return false;
		}     
		return true;
	
}

	//********************************************
	// Function name  : CheckNumberLimit 
	// Parameter      : objField, objFieldCaption, intLessThan, intGreterThan
	// Return value   : bool
	// Purpose        : Function to check value is lying between specific range
	// Author		  : Virendar Tomar
	// Creation Date  : 
	// Changed By	  : 
	// Changed Date   :  
	//******************************************** 
function CheckNumberLimit(objField, objFieldCaption, intLessThan, intGreterThan) 
{
   var objValue = objField.value; 
   objValue = TrimAll(objValue);
   if(CheckFloatCharachterWithNegative(objField, objFieldCaption))
	  {
		if(objValue.length > 0)   
		{
			if( parseInt(objValue) < intLessThan || parseInt(objValue) > intGreterThan ) 
			{
				alert(objFieldCaption + " can not accept less than " + intLessThan + " and more than " + intGreterThan + ".");
				objField.focus();
				return false;
			}
		} 
	}
	else
	{
	  return false;
	}        
	return true;
}     

	//********************************************
	// Function name  : CheckSpecialCharachterWithH 
	// Parameter      : objField, objFieldCaption 
	// Return value   : bool
	// Purpose        : Function to check value contains aplhabetic characters allowing blank space and hyphen
	// Author		  : Vinod Kumar
	// Creation Date  : 
	// Changed By	  : 
	// Changed Date   : 
	//******************************************** 
	function CheckSpecialCharachterWithH( objField, objFieldCaption )
	{ 
		var arValidCharacter = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 -';
		var isSpecialCharacter = false;
		for( index = 0; index < objField.value.length; index = index + 1 )
		{
			isSpecialCharacter = false;
			for( innerIndex = 0; innerIndex < arValidCharacter.length; innerIndex = innerIndex + 1 )
			{
				if( objField.value.charAt(index) ==  arValidCharacter.charAt(innerIndex) )
				{
					isSpecialCharacter = true;
				}
			}
			if( !isSpecialCharacter )
			{
				alert( objFieldCaption + " can not accept special characters other than hyphen" );
				objField.focus();
				return false;
			}
		}  
		return true;
	} 
	
	 //********************************************
	// Function name  : isInteger 
	// Parameter      : s
	// Return value   : bool
	// Purpose        : Function to check value is integer
	// Author		  : Akmal
	// Creation Date  : 
	// Changed By	  : 
	// Changed Date   : 
	//********************************************
	function isInteger(s)
	{   var i;
		for (i = 0; i < s.length; i++)
		{   
			// Check that current character is number.
			var c = s.charAt(i);
			if (((c < "0") || (c > "9"))) return false;
		}
		// All characters are numbers.
		return true;
	} 
	
////////////    //********************************************
////////////    // Function name  : stripCharsInBag 
////////////    // Parameter      : s, bag
////////////    // Return value   : string
////////////    // Purpose        : Function to check allowed characters in the value
////////////    // Author		  : Akmal
////////////    // Creation Date  : 
////////////    // Changed By	  : 
////////////    // Changed Date   : 
////////////    //********************************************
////////////    function stripCharsInBag(s, bag)
////////////    {   var i;
////////////        var returnString = "";
////////////        // Search through string's characters one by one.
////////////        // If character is not in bag, append to returnString.
////////////        for (i = 0; i < s.length; i++)
////////////        {   
////////////            // Check that current character isn't whitespace.
////////////            var c = s.charAt(i);
////////////            if (bag.indexOf(c) == -1) returnString += c;
////////////        }
////////////        return returnString;
////////////    }
////////////    
////////////    //********************************************
////////////    // Function name  : checkInternationalPhone 
////////////    // Parameter      : strPhone
////////////    // Return value   : string
////////////    // Purpose        : Function to check International Phone number
////////////    // Author		  : Akmal
////////////    // Creation Date  : 
////////////    // Changed By	  : 
////////////    // Changed Date   : 
////////////    //********************************************
////////////    function checkInternationalPhone(strPhone)
////////////    {
////////////        s=stripCharsInBag(strPhone,phoneNumberDelimiters);
////////////        return (isInteger(s) && s.length >= minDigitsInIPhoneNumber);
////////////    }
////////////    
////////////    //********************************************
////////////    // Function name  : ValidatePhone 
////////////    // Parameter      : objPhone, strPhone
////////////    // Return value   : bool
////////////    // Purpose        : Function to check Phone number
////////////    // Author		  : Akmal
////////////    // Creation Date  : 
////////////    // Changed By	  : 
////////////    // Changed Date   : 
////////////    //********************************************
////////////    function ValidatePhone(objPhone, strPhone)
////////////    {
////////////	    if (checkInternationalPhone(objPhone.value)==false)
////////////	    {
////////////		    alert("Please Enter a Valid "+strPhone+" Number[Only 0-9 + () are allowed and Minumum length is 10]")
////////////		    //objphone.value="";
////////////		    objPhone.focus()
////////////		    return false
////////////	    }
////////////	    return true
////////////    }
////////////    
////////////    //********************************************
////////////    // Function name  : ValidatePhone 
////////////    // Parameter      : objPhone
////////////    // Return value   : bool
////////////    // Purpose        : Function to check Phone number
////////////    // Author		  : Akmal
////////////    // Creation Date  : 
////////////    // Changed By	  : 
////////////    // Changed Date   : 
////////////    //********************************************
////////////    function ValidatePhone(objPhone)
////////////    {
////////////	    if (checkInternationalPhone(objPhone.value)==false)
////////////	    {
////////////		    alert("Please enter a valid 10 digit phone/fax/mobile number[Only '0-9' and '()' are allowed].")
////////////		    //objphone.value="";
////////////		    objPhone.focus()
////////////		    return false
////////////	    }
////////////	    return true
////////////    }
	
	//********************************************
	// Function name  : GetRadioSelectedValue 
	// Parameter      : objRdoActive
	// Return value   : bool
	// Purpose        : Function to get selected value of radio button list
	// Author		  : Vinod Kumar
	// Creation Date  : 
	// Changed By	  : 
	// Changed Date   : 
	//********************************************
	 function GetRadioSelectedValue(objRdoActive)
		{   
			var newDefault = false;
			var isValid
			var options = objRdoActive.getElementsByTagName('input');
			//For InActive value is 0 and active value is 1
			for(i=0;i<options.length;i++)
			{
				var opt = options[i];               
				if((opt.checked) && (opt.value == "0"))
				{                   
				   return true;
				}
			}
			return false;
			
		}
		
	//******************************************************************************************************
	// Function name  : CompareDates 
	// Parameter      : DepartDate, ReturnDate, caption
	// Return value   : bool
	// Purpose        : Function to Compare that whether departing date is greater then returning date or not
	// Author		  : Vikas Gupta
	// Creation Date  : 08-May-2007 4:30 PM
	// Changed By	  : 
	// Changed Date   : 
	//*******************************************************************************************************
 
	  
	function CompareDates(DepartDate, ReturnDate, caption)
	{ 
		var str1 = DepartDate.value;
		var str2 = ReturnDate.value;
		
		var arrStr1 = str1.split("/");
		var arrStr2 = str2.split("/");
	   
	  var DepartingDate = new Date(arrStr1[2], arrStr1[1], arrStr1[0]); 
	  var ReturningDate = new Date(arrStr2[2], arrStr2[1], arrStr2[0]); 
	   

	   if(ReturningDate < DepartingDate)
	   {
		  alert(caption + " cannot be earlier than " + '"Departing"' +" date.");
		  return false; 
	   } 
	   else 
	   { 
		 return true;
	   } 
	} 
	
	//******************************************************************************************************
	// Function name  : DepartDateValidation 
	// Parameter      : DepartDate, ServerCurrentDate, caption
	// Return value   : bool
	// Purpose        : Function will check whether departing date is greater then current date or not
	// Author		  : Vikas Gupta
	// Creation Date  : 09-May-2007 10:30 PM
	// Changed By	  : 
	// Changed Date   : 
	//*******************************************************************************************************
 
function DepartDateValidation(DepartDate,ServerCurrentDate,caption)
{
		var arrServerCurrentdate = ServerCurrentDate.split(" ");
		var str1 = DepartDate.value;
		
		var arrStr1 = str1.split("/");
		var arrStr2 = arrServerCurrentdate[0].split("/");

	   
	   var DepartingDate = new Date(arrStr1[2], arrStr1[1], arrStr1[0]); 
	   var ServerDate = new Date(arrStr2[2], arrStr2[1], arrStr2[0]); 
	   
	  
   if (DepartingDate < ServerDate)
	{
		alert(caption + " must be at least 5 days from the current date.");
		return false;
	}
	else
	{
  
		return true;
	}
	   
}
 
		
   //********************************************
	// Function name  : DateValidation 
	// Parameter      : myDate, caption
	// Return value   : bool
	// Purpose        : Function to validate date
	// Author		  : Siddhartha Yadav
	// Creation Date  : 
	// Changed By	  : 
	// Changed Date   : 
	//********************************************
 
 function DateValidation(myDate, caption)
 {
	 var DepDate;
	 var DepDD;
	 var DepMM;
	 var DepYY;
	 var arrDate;
	 DepDate = myDate.value;
	 arrDate = DepDate.split("/");
	 DepDD = arrDate[0];
	 DepMM = arrDate[1];
	 DepYY = arrDate[2];
	 // Add by Kusum
	 if(DepDate.length == 0)
	 {
		return true;
	 }
	 if(isNaN(DepDD) || isNaN(DepMM) || isNaN(DepYY))
	 {
		alert(caption + " is Not a Valid Date.");
		myDate.focus();
		return false;
	 }
	 //added by naveen 
	 if( (DepDD.length !=2) || (DepMM.length != 2) || (DepYY.length !=4) )
	 {
		alert(caption + " is not a valid date. Format should be in dd/mm/yyyy");
		myDate.focus();
		return false;
	 }
	 if (!isValidDate(DepDD,DepMM,DepYY))
	 {
		alert(caption + " is not a valid date. Format should be in dd/mm/yyyy");
		myDate.focus();
		return false;
	 }
	if ((DepYY < "2007") || (DepYY > "2050"))
	{
		alert(caption + " is not a valid date. Date should be between '01/01/2007' and '31/12/2050'");
		myDate.focus();
		return false;
	} 
 
 return true;
 }
 //********************************************
	// Function name  : BirthValidation
	// Parameter      : myDate, caption
	// Return value   : bool
	// Purpose        : Function to validate date
	// Author		  : Naveen Nandal
	// Creation Date  : 
	// Changed By	  : 
	// Changed Date   : 
	//********************************************
 
 function BirthValidation(myDate, caption)
 {
	 var DepDate;
	 var DepDD;
	 var DepMM;
	 var DepYY;
	 var arrDate;
	 DepDate = myDate.value;
	 arrDate = DepDate.split("/");
	 DepDD = arrDate[0];
	 DepMM = arrDate[1];
	 DepYY = arrDate[2];
	 // Add by Kusum
	 if(DepDate.length == 0)
	 {
		return true;
	 }
	 if(isNaN(DepDD) || isNaN(DepMM) || isNaN(DepYY))
	 {
		alert(caption + " is Not a Valid Date.");
		myDate.focus();
		return false;
	 }
	 //added by naveen 
	 if( (DepDD.length !=2) || (DepMM.length != 2) || (DepYY.length !=4) )
	 {
		alert(caption + " is not a valid date. Format should be in dd/mm/yyyy");
		myDate.focus();
		return false;
	 }
	 if (!isValidDate(DepDD,DepMM,DepYY))
	 {
		alert(caption + " is not a valid date. Format should be in dd/mm/yyyy");
		myDate.focus();
		return false;
	 }
	if ((DepYY < "1900") || (DepYY > "2050"))
	{
		alert(caption + " is not a valid date. Date should be between '01/01/1900' and '31/12/2050'");
		myDate.focus();
		return false;
	} 
 
 return true;
 }

   //********************************************
	// Function name  : isValidDate 
	// Parameter      : dd,mm,yyyy
	// Return value   : bool
	// Purpose        : Function to validate date
	// Author		  : Priyanka Mishra
	// Creation Date  : 
	// Changed By	  : 
	// Changed Date   : 
	//********************************************
 function isValidDate(dd,mm,yyyy)
{
  if (mm < 1 || mm > 12)
	 return false;
  if (dd < 1 || dd > 31)
	 return false;
  if (getDaysOfMonth(mm,yyyy) < dd) 
	 return false;
  return true; 
}
	//********************************************
	// Function name  : DateValidation 
	// Parameter      : myDate, caption
	// Return value   : bool
	// Purpose        : Function to validate date
	// Author		  : Siddhartha Yadav
	// Creation Date  : 
	// Changed By	  : 
	// Changed Date   : 
	//********************************************
function isLeapYear (year)
{
   if (((year % 4)==0) && ((year % 100)!=0) || ((year % 400)==0))
	  return (true);
   else
	  return (false);
}
   //********************************************
	// Function name  : DateValidation 
	// Parameter      : myDate, caption
	// Return value   : bool
	// Purpose        : Function to validate date
	// Author		  : Siddhartha Yadav
	// Creation Date  : 
	// Changed By	  : 
	// Changed Date   : 
	//********************************************
function getDaysOfMonth (month, year)
{
   var days;
   if (month==1 || month==3 || month==5 || month==7 || month==8 || month==10 || month==12)
	  days=31;
   else if (month==4 || month==6 || month==9 || month==11) days=30;
   else if (month==2)
   {
	  if (isLeapYear(year)) days=29;
	  else days=28;
   }
   return (days);
}



 
 
	 //********************************************
	// Function name  : FormatAsDecimal 
	// Parameter      : objField, objCaption
	// Return value   : bool
	// Purpose        : Function to truncate a long decimal value up to 2 decimal places 
	// Author		  : Kusum
	// Creation Date  : 
	// Changed By	  : 
	// Changed Date   : 
	//********************************************
  function FormatAsDecimal(objVal) 
   { 
	objVal -= 0; 
	objVal = (Math.round(objVal*100))/100; 
	return (objVal == Math.floor(objVal))? objVal + '.00' : ( (objVal*10 == Math.floor(objVal*10))? objVal + '0' : objVal); 
	} 
	
	
	//********************************************
	// Function name  : CheckBlankCheckBoxList 
	// Parameter      : objField, objCaption
	// Return value   : bool
	// Purpose        : Function to Check Blank for check box list
	// Author		  : Kusum
	// Creation Date  : 
	// Changed By	  : 
	// Changed Date   : 
	//********************************************
	function CheckBlankCheckBoxList(objField, objCaption)
	{
		var arrayOfCheckBoxes= objField.getElementsByTagName("input");
		for(var i=0;i<arrayOfCheckBoxes.length;i++)
		{
			//do as you wish with each arrayOfCheckBoxes[i] element
			if(arrayOfCheckBoxes[i].checked) //would echo the control's ID
			{
			  return true;
			}
		}
		alert(objCaption + " is mandatory!");
		return false;
	}
	
	
	
	
	//********************************************
	// Function name  : CompareNumbers 
	// Parameter      : objNumber1, objNumber2, objNumber1Caption, objNumber2Caption 
	// Return value   : bool
	// Purpose        : Function to compare two numbers
	// Author		  : Virendar
	// Creation Date  : 
	// Changed By	  : 
	// Changed Date   : 
	//********************************************
	
	function CompareNumbers( objNumber1, objNumber2, objNumber1Caption, objNumber2Caption )
	{
		if( CheckNumericCharachter( objNumber1, objNumber1Caption ) && CheckNumericCharachter( objNumber2, objNumber2Caption ) )
		{
			if( parseInt(objNumber2.value) < parseInt(objNumber1.value) )
			{
				alert( objNumber2Caption + " can't be less than " + objNumber1Caption );
				objNumber2.focus(); 
				return false;
			}
		}
		else
		{      
			return false;
		}
		return true;
	} 
	
	
	//********************************************
	// Function name  : Compare Float Numbers 
	// Parameter      : objNumber1, objNumber2, objNumber1Caption, objNumber2Caption 
	// Return value   : bool
	// Purpose        : Function to compare two Float numbers
	// Author		  : Baljeet Kiroriwal
	// Creation Date  : 04/11/2008
	// Changed By	  : 
	// Changed Date   : 
	//********************************************
	//UAT PHASE
	function CompareFloatNumbers( objNumber1, objNumber2, objNumber1Caption, objNumber2Caption )
	{
		if( CheckFloatCharachterWithNegative(objNumber1, objNumber1Caption ) && CheckFloatCharachterWithNegative( objNumber2, objNumber2Caption ) )
		{
			if( parseFloat(objNumber2.value) < parseFloat(objNumber1.value) )
			{
				alert( objNumber1Caption + " can't be more than " + objNumber2Caption);
				objNumber1.focus(); 
				return false;
			}
		}
		else
		{      
			return false;
		}
		return true;
	} 
	
	//********************************************
	// Function name  : CompareNumbers 
	// Parameter      : objNumber1, objNumber2, objNumber1Caption, objNumber2Caption 
	// Return value   : bool
	// Purpose        : Function to compare two numbers for Equal and less
	// Author		  : Devanand Chahal
	// Creation Date  : 
	// Changed By	  : 
	// Changed Date   : 
	//********************************************
	
	function CompareForEqualAndLess( objNumber1, objNumber2, objNumber1Caption, objNumber2Caption )
	{
		if( CheckNumericCharachter( objNumber1, objNumber1Caption ) && CheckNumericCharachter( objNumber2, objNumber2Caption ) )
		{
			if( ( (parseInt(objNumber2.value) > 0 ) || ( parseInt(objNumber1.value) > 0 ) ) && ( parseInt(objNumber2.value) <= parseInt(objNumber1.value) ) )
			{
				alert( objNumber2Caption + " can't be equal or less than " + objNumber1Caption );
				objNumber2.focus(); 
				return false;
			}
		}
		else
		{      
			return false;
		}
		return true;
	} 

   
	   //********************************************
	// Function name  : CheckPositiveNumber 
	// Parameter      : objNumber, objNumberCaption
	// Return value   : bool
	// Purpose        : Function to check value should be greater than zero
	// Author		  : Virendar Tomar
	// Creation Date  : 
	// Changed By	  : 
	// Changed Date   : 
	//********************************************
	function CheckPositiveNumber( objNumber, objNumberCaption )
	{
		if( CheckNumericCharachter( objNumber, objNumberCaption ) )
		{
			if( objNumber.value < 0 )
			{
				alert( objNumberCaption + " can't be less than 0.");
				objNumber.focus();
				return false;
			}
		}
		else
		{
			 return false;
		}  
		return true;
	}
	
	//********************************************
	// Function name  : CheckNaturalNumber 
	// Parameter      : objNumber, objNumberCaption
	// Return value   : bool
	// Purpose        : Function to check value should be greater than zero
	// Author		  : Vinod Kumar
	// Creation Date  : 
	// Changed By	  : 
	// Changed Date   : 
	//********************************************
	
	function CheckNaturalNumber( objNumber, objNumberCaption )
	{
		if( CheckNumericCharachter( objNumber, objNumberCaption ) )
		{
			if( objNumber.value < 0 )
			{
				alert( objNumberCaption + " can't be less than 1.");
				objNumber.focus();
				return false; 
			}
		}
		else
		{
			 return false;
		}        
		return true; 
	}


	function CheckNaturalNumberGreaterThanZero( objNumber, objNumberCaption )
	{
		if((objNumber.value < 0)  || (objNumber.value == 0))
		{
			alert( objNumberCaption + " should be greater than 0.");
			objNumber.focus();
			return false; 
		}
		return true; 
	}


	//********************************************
	// Function name  : CheckOneOfTwo 
	// Parameter      : objNumber, objNumberCaption
	// Return value   : bool
	// Purpose        : Function to check at parallel only one text box can have value 
	// Author		  : Baljeet Kiroriwal
	// Creation Date  : 
	// Changed By	  : 
	// Changed Date   : 
	//********************************************   
  
	function CheckOneOfTwo( objField1, objField2 ,objFieldCaption1, objFieldCaption2 )
	{
			var objField1Value = TrimAll(objField1.value);
			var objField2Value = TrimAll(objField2.value);
			
			if( objField1Value.length == 0 && objField2Value.length == 0)
			{
				alert( "Either " + objFieldCaption1 + " or " + objFieldCaption2 + " is mandatory.");
				objField1.focus();
				return false;
			}
			if( objField1Value.length != 0 && objField2Value.length != 0)
			{
				alert( "Either " + objFieldCaption1 + " or " + objFieldCaption2 + " can have value.");
				objField1.focus();
				return false;
			}
		return true;
	}
	
	//********************************************
	// Function name  : GetListBoxSelectedValue 
	// Parameter      : objListBox, objCaption
	// Return value   : bool
	// Purpose        : Function to get the selected value from the list box
	// Author		  : Kusum Sharma
	// Creation Date  : 
	// Changed By	  : 
	// Changed Date   : 
	//********************************************
	function GetListBoxSelectedValue(objListBox, objCaption)
	{   
   
		if (objListBox.options.length == 0 || objListBox.selectedIndex <= -1 || objListBox.options[objListBox.selectedIndex].value == 0) {
		  alert(objCaption + " is mandatory!"); 
		   objListBox.focus();      
		   return false;
		}
	   return true;
	}
	
   
	//********************************************
	// Function name  : CompareHours 
	// Parameter      : objTime1,objTime2,strCaption1, strCaption2
	// Return value   : bool
	// Purpose        : Function to compare two hours
	// Author		  : Vinod Kumar
	// Creation Date  : 
	// Changed By	  : 
	// Changed Date   : 
	//********************************************
	function CompareHours(objTime1,objTime2,strCaption1, strCaption2)
	{
		var strHourMin1  = objTime1.value;
		var strHourMin2  = objTime2.value
		var strHour1 = strHourMin1.split(':');
		var strHour2 = strHourMin2.split(':');
		
		var strMin1;
		var strMin2;
		if(parseInt(strHour1[0]) > parseInt(strHour2[0]) )
			{
				alert( strCaption1 + " can't be greater than " + strCaption2 );
				objTime1.focus();
				return false;
			}
		else
			 if(parseInt(strHour1[0]) == parseInt(strHour2[0]) )
			 {
				if(strHour1[1] != null && strHour1[1] != "")
					{
						strMin1 = strHour1[1];
					} 
					else
					{
						strMin1 = 0;
					}
				  if(strHour2[1] != null && strHour2[1] != "")
					{
						strMin2 = strHour2[1];
					}  
					else
					{
						strMin2 = 0;
					}
					
					if(parseInt(strMin1) > parseInt(strMin2))
						{
							alert( strCaption1 + " can't be greater than " + strCaption2 );
							objTime1.focus();
							return false;
						}
			 }   
		 return true;
	}
	
	//********************************************
	// Function name  : ValidateTime 
	// Parameter      : objTime
	// Return value   : bool
	// Purpose        : Function to validate time format
	// Author		  : Priyanka Mishra
	// Creation Date  : 
	// Changed By	  : 
	// Changed Date   : 
	//********************************************.
	function ValidateTime(objTime)
	{
		if(objTime.value.length==0)
		{       
			return false;
		}
		if(objTime.value.length<5){              
			 alert("Invalid time format.\nTime format 'hh:mm'");
			 objTime.focus(); 
			 return false;
		}
		if(objTime.value.indexOf("-") != -1)
		{
		    alert("Invalid time, Time can't be negative"); 
		    objTime.focus(); 
				return false;  
		}
		try{
			var arrTime = objTime.value.split(":");
			var vHH =  arrTime[0];
			var vMM =  arrTime[1];               
			if((isNaN(vHH))||(isNaN(vMM))||(vHH>23)||(vMM>59)){
			alert("Invalid time format.\nTime format 'hh:mm'");
			objTime.focus();            
				
				return false;
			}
			else
				return true;    
		}
		catch(err)
		{        
			alert("Invalid time format.\nTime format 'hh:mm'");
			return false;
		}
	}
	
	//********************************************
	// Function name  : IsValidateTime 
	// Parameter      : objTime
	// Return value   : bool
	// Purpose        : Function to validate time format
	// Author		  : Baljeet Kiroriwal
	// Creation Date  : 
	// Changed By	  : 
	// Changed Date   : 
	//********************************************.
	
	function IsValidateTime(objTime)
    {
       
       //var objTime = document.getElementById("<%=txtTime.ClientID%>");
       if(objTime.value.length==0)
	   {       
		    return false;
	   }
       time=objTime.value;
       if (!/\d{2}:\d{2}/.test(time))
       {
            alert('invalid time  format');
            objTime.value='';
            objTime.focus();
            return false;
       }
       time=time.split(':');
       if (time[0] >12 || time[1]>59) 
       {
            alert('invalid time format');
            objTime.value='';
            objTime.focus();
            return false;
       }
       
        return true;
    }
	
	//********************************************
	// Function name  : fixFixed 
	// Parameter      : objFld,objCaption,dec,sep
	// Return value   : bool
	// Purpose        : Function to round off the number to specified numbers
	// Author		  : Naveen Nandal
	// Creation Date  : 
	// Changed By	  : 
	// Changed Date   : 
	//******************************************** 
	function fixFixed(objFld,objCaption,dec,sep)
	{ // fixed decimal fields 
		if(!objFld.value.length||objFld.disabled) return true; // blank fields are the domain of requireValue 
		var val= objFld.value;
		if(typeof(sep)!='undefined') val= val.replace(new RegExp(sep,'g'),'');
		val= parseFloat(objFld.value);
		if(isNaN(val))
		{ // parse error
			alert(objCaption + " must contain a number.");  
			objFld.value=''; 
			objFld.focus();  
			return false;
		}
		  var sign= ( val < 0 ? '-': '' );
		  val= Number(Math.round(Math.abs(val)*Math.pow(10,dec))).toString();
		  while(val.length < dec) val= '0'+val;
		  var len= val.length;
		  val= sign + ( len == dec ? '0' : val.substring(0,len-dec) ) + '.' + val.substring(len-dec,len+1);
		  if(val.length>8)
		  val=val.substring(0,8)
		  objFld.value= val;
		  return true;
	}        
	
	//********************************************
	// Function name  : CheckGreaterThen 
	// Parameter      : objField, objCaption,objGreaterThan
	// Return value   : bool
	// Purpose        : Function to check that the value should be greater than specified value
	// Author		  : Naveen Nandal
	// Creation Date  : 
	// Changed By	  : 
	// Changed Date   : 
	//******************************************** 
	function CheckGreaterThen(objField, objCaption,objGreaterThan)
	{
		if( objField.value*1 > objGreaterThan )
		{
			return true;
		}
		else
		{
			alert( objCaption + " must be greater than " +objGreaterThan);
			objField.focus();
			return false; 
		}
	}

	//********************************************
	// Function name  : DaysBetween 
	// Parameter      : objFromDate, objToDate
	// Return value   : integer
	// Purpose        : Function to calculate no of days between two dates
	// Author		  : Kusum
	// Creation Date  : 
	// Changed By	  : 
	// Changed Date   : 
	//********************************************.  
   function DaysBetween(objFromDate, objToDate) {
   
	   
		var arrDate1 = objFromDate.value.split("/");
		var date1 = new Date(arrDate1[1] + "/" + arrDate1[0] + "/" + arrDate1[2]);
		var arrDate2 = objToDate.value.split("/");
		var date2 = new Date(arrDate2[1] + "/" + arrDate2[0] + "/" + arrDate2[2]);
		// The number of milliseconds in one day
		var ONE_DAY = 1000 * 60 * 60 * 24;

		// Convert both dates to milliseconds
		var date1_ms = date1.getTime();
		var date2_ms = date2.getTime();

		// Calculate the difference in milliseconds
		var difference_ms = Math.abs(date1_ms - date2_ms);
		
		// Convert back to days and return
		return Math.round(difference_ms/ONE_DAY);
	}
	
	
	//********************************************
	// Function name  : AddDays 
	// Parameter      : objDate, days
	// Return value   : Date
	// Purpose        : Function to Add no of days into date
	// Author		  : Kusum    
	// Creation Date  : 
	// Changed By	  : 
	// Changed Date   :  
	//********************************************.  
	function AddDays(objDate, days)
	{
//		var DepDate = objDate.value;
//		var arrDate = DepDate.split("/");
//		var date1 = new Date(arrDate[1] + "/" + arrDate[0] + "/" + arrDate[2]);
//		date1 =  new Date(date1.getTime() + days*24*60*60*1000);
//		var strDate = date1.getDate() + "";
//		var strMonth = (date1.getMonth()+1) + "";
//		if (strDate.length == 1)
//		{
//		  strDate = "0" + strDate;
//		}
//		if (strMonth.length == 1)
//		{
//		  strMonth = "0" + strMonth;
//		}
//		var finalDate = strDate +"/" + strMonth + "/" + date1.getFullYear();
//		return finalDate;
        //Changed by Mudit for Day Light Savings.
		var DepDate = objDate.value;
		var arrDate = DepDate.split("/");
		var date1 = new Date(arrDate[1] + "/" + arrDate[0] + "/" + arrDate[2]);
		
		var y = date1.getFullYear();
		var m = date1.getMonth();
		var d = date1.getDate();
		
		date1 =  new Date(y, m, parseInt(d)+parseInt(days)+"");
		var strDate = date1.getDate() + "";
		var strMonth = (date1.getMonth()+1) + "";
		if (strDate.length == 1)
		{
		  strDate = "0" + strDate;
		}
		if (strMonth.length == 1)
		{
		  strMonth = "0" + strMonth;
		}
		var finalDate = strDate +"/" + strMonth + "/" + date1.getFullYear();
		return finalDate;


	}
	
	//Added by PreetiK for testing purpose
	//Description for Parameters
	//objField : Field to be tested
	//objFieldCaption : Message to be given to the user
	//objIncludeNumbers (True/Flase) : whether to allow numeric values
	//objIncludeAlphabets (True/Flase) : whether to allow alphabets (a-zA-Z) values
	//objIncludeSpace (True/Flase) : whether to allow space
	//objIncludeSpecialChars (specific character Eg: @, #) : input those special characters that you need to allow.
	function CheckSpecialCharachterTest( objField, objFieldCaption, objIncludeNumbers, objIncludeAlphabets, objIncludeSpace,objIncludeSpecialChars ) 
	{      
		//start building the test expression
		var strExpr='^[';
		
		//if Numeric values are allowed then append 0-9
		if (objIncludeNumbers==true)
		{
			strExpr = strExpr + '0-9';
		}
		
		//if character values are allowed then append a-zA-Z
		if (objIncludeAlphabets==true)
		{
			strExpr = strExpr + 'a-zA-Z';
		}				
		if (TrimAll(objIncludeSpecialChars).length!=0)
		{
			strExpr = strExpr + objIncludeSpecialChars;
		}		
		//if spaces are allowed then append character for blank space
		if (objIncludeSpace==true)
		{
			strExpr = strExpr + '\\s';
		}

		//close the expression
		strExpr = strExpr + ']*$';  
		
		//create the pattern out of the string
		var testRE=new RegExp(strExpr);		
				
		alert(testRE.test(objField.value));  

		//check the pattern against the input value
		if(!testRE.test(objField.value))
		{
			//give appropriate message to the user
			alert(objFieldCaption + " can not accept special characters.");
			objField.focus();
			return false;
		}
				
		return true;
	}
	
	   //********************************************
	// Function name  : CheckOnlyAlphaCharachter
	// Parameter      : objField,objFieldCaption
	// Return value   : bool
	// Purpose        : Check for valid URL.
	// Author		  : Devanand Chahal
	// Creation Date  : 
	// Changed By	  :  
	// Changed Date   : 
	//********************************************
	function CheckValidURL( objField, objFieldCaption )
	{     
		var textRE= /^[a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,5}(([0-9]{1,5})?\/.*)?$/ ;   /*'((https?)|(ftp))://([-\w\.]+)+(:\d+)?(/([\w/_\.]*(\?\S+)?)?)?';       */
		if(!textRE.test(objField.value))
		{
			alert(objFieldCaption + " is not a valid URL" );
			objField.focus();
			return false;
		}      
		return true;
	}
	
 //********************************************
	// Function name  : CalRate
	// Parameter      : objSource,objRatePercentage,objTarget
	// Return value   : 
	// Purpose        : Calculate % value of objSource and place the value in objTarget
	// Author		  : Rupika Agarwal
	// Creation Date  : 
	// Changed By	  : 
	// Changed Date   : 
	//********************************************
	
	function CalRate( objSource, objRatePercentage, objTarget)
	{
	  if (objSource !=null && objRatePercentage !=null)
	  {
			if (objRatePercentage.value !="" && objSource.value !="")
			{
				if (CheckNumberLimit(objRatePercentage, 'Percent value', 0, 100))
					objTarget.value =  (objSource.value *  objRatePercentage.value) / 100 ;
			    else
			      return false;
			}
			else
			{
				objTarget.value= objTarget.value;
			}
	  }
	  else
	  {
		  objTarget.value= 0;
	  }
	  return true;
	}
	 //********************************************
	// Function name  : Check_CheckBoxList
	// Parameter      : objField,objCaption
	// Return value   : 
	// Purpose        : Checking any of the CheckBox checked or UnChecked
	// Author		  : Rupika Agarwal
	// Creation Date  : 
	// Changed By	  : 
	// Changed Date   : 
	//********************************************
	 function Check_CheckBoxList(objField,objCaption)
	{
	  var options = objField.getElementsByTagName('input');
		
	  for(i=0;i<options.length;i++)
	  {
		 var opt = options[i];               
		 if(opt.checked)
		 {                   
			return true;
		 }
	  }
	  alert(objCaption + " is mandatory.");
	  objField.focus();
	  return false;
	}
	
	//******************************************************************************************************
	// Function name  : DateValidation_CheckToday 
	// Parameter      : DepartDate, ServerCurrentDate, caption
	// Return value   : bool
	// Purpose        : Function will check whether departing date is greater then current date or not
	// Author		  : Vikas Gupta
	// Creation Date  : 09-May-2007 10:30 PM
	// Changed By	  : 
	// Changed Date   : 
	//*******************************************************************************************************
 
function DateValidation_CheckToday(myDate,ServerCurrentDate,strOperation,caption)
{
		var arrServerCurrentdate = ServerCurrentDate.split(" ");
		var str1 = myDate.value;
		
		var arrStr1 = str1.split("/");
		var arrStr2 = arrServerCurrentdate[0].split("/");

	   
	   var DateToCheck = new Date(arrStr1[2], arrStr1[1], arrStr1[0]); 
	   var ServerDate = new Date(arrStr2[2], arrStr2[1], arrStr2[0]); 
	   
	  
   if (DateToCheck < ServerDate && strOperation == "greator")
	{
		alert(caption + "should be greater than today's date.");
		return false;
	}
   if (DateToCheck > ServerDate && strOperation == "less")
	{
		alert(caption + "should be less than today's date.");
		return false;
	}
	
	else
	{
  
		return true;
	}
	   
}

//******************************************************************************************************
// Function name  : filter 
// Parameter      : filter string, dropdown object to bind	
// Purpose        : Function will populate the items up in dropdown by the text(pattern) 
// Author		  : Vikas Gupta
// Creation Date  : 20-May-09	
//*******************************************************************************************************
function filterList(pattern, list){
	  /*
	  if the dropdown list passed in hasn't
	  already been backed up, we'll do that now
	  */
	  if (!list.bak){
		/*
		We're going to attach an array to the select object
		where we'll keep a backup of the original dropdown list
		*/
		list.bak = new Array();
		for (n=1;n<list.length;n++){
		  list.bak[list.bak.length] = new Array(list[n].value, list[n].text);
		}
	  }

	  /*
	  We're going to iterate through the backed up dropdown
	  list. If an item matches, it is added to the list of
	  matches. If not, then it is added to the list of non matches.
	  */
	  match = new Array();
	  nomatch = new Array();
	  for (n=0;n<list.bak.length;n++){
		//if(list.bak[n][1].toLowerCase().indexOf(pattern.toLowerCase())!=-1){		
		if(list.bak[n][1].substring(0,pattern.length).toLowerCase().indexOf(pattern.toLowerCase())!=-1){
		  match[match.length] = new Array(list.bak[n][0], list.bak[n][1]);
		}else{
		  nomatch[nomatch.length] = new Array(list.bak[n][0], list.bak[n][1]);
		}
	  }

	  /*
	  Now we completely rewrite the dropdown list.
	  First we write in the matches, then we write
	  in the non matches
	  */
		list[0].value = 0;
		list[0].text = "--Select--";
	  for (n=1;n<match.length+1;n++){
		list[n].value = match[n-1][0];
		list[n].text = match[n-1][1];
	  }
	  for (n=1;n<nomatch.length+1;n++){
		list[n+match.length].value = nomatch[n-1][0];
		list[n+match.length].text = nomatch[n-1][1];
	  }

	  /*
	  Finally, we make the 1st item selected - this
	  makes sure that the matching options are
	  immediately apparent
	  */
	  list.selectedIndex=0;
}

	 function filtery(pattern, list){
	  /*
	  if the dropdown list passed in hasn't
	  already been backed up, we'll do that now
	  */
	  if (!list.bak){
		/*
		We're going to attach an array to the select object
		where we'll keep a backup of the original dropdown list
		*/
		list.bak = new Array();
		for (n=1;n<list.length;n++){
		  list.bak[list.bak.length] = new Array(list[n].value, list[n].text);
		}
	  }

	  /*
	  We're going to iterate through the backed up dropdown
	  list. If an item matches, it is added to the list of
	  matches. If not, then it is added to the list of non matches.
	  */
	  match = new Array();
	  nomatch = new Array();
	  for (n=0;n<list.bak.length;n++){
		if(list.bak[n][1].toLowerCase().indexOf(pattern.toLowerCase())!=-1){
		  match[match.length] = new Array(list.bak[n][0], list.bak[n][1]);
		}else{
		  nomatch[nomatch.length] = new Array(list.bak[n][0], list.bak[n][1]);
		}
	  }

	  /*
	  Now we completely rewrite the dropdown list.
	  First we write in the matches, then we write
	  in the non matches
	  */
		list[0].value = 0;
		list[0].text = "--Select--";
	  for (n=1;n<match.length+1;n++){
		list[n].value = match[n-1][0];
		list[n].text = match[n-1][1];
	  }
	  for (n=1;n<nomatch.length+1;n++){
		list[n+match.length].value = nomatch[n-1][0];
		list[n+match.length].text = nomatch[n-1][1];
	  }

	  /*
	  Finally, we make the 1st item selected - this
	  makes sure that the matching options are
	  immediately apparent
	  */
	  list.selectedIndex=0;
}
    //******************************************************************************************************
	// Function name  : CheckMultilineTextBoxMaxLengthTruncateMessage 
	// Parameter      : strReason,objTxt,maxLen
	// Return value   : bool
	// Purpose        : Function will check whether the enetered text in the multiline text box exceeds the 
    //                  specified one and show the truncate message.
	// Author		  : Vikas Gupta
	// Creation Date  : 13-May-08
	// Changed By	  : 
	// Changed Date   : 
	//*******************************************************************************************************


  function CheckMultilineTextBoxMaxLengthTruncateMessage(strReason,objTxt,maxLen)
  {
     if(objTxt.innerHTML.length > maxLen)
        {        
          alert(strReason + ' can not be more then ' + maxLen + ' characters, The data will be truncated.');
          objTxt.innerHTML =  TrimAll(objTxt.innerHTML);
          objTxt.innerHTML = objTxt.innerHTML.substring(0,(maxLen-1));
          return false;        
        }
    return true;    
  }
//******************************************************************************************************
	// Function name  : CheckMultilineTextBoxMaxLength 
	// Parameter      : objTxt,maxLen
	// Return value   : bool
	// Purpose        : Function will check whether the enetered text in the multiline text box exceeds the specified one
	// Author		  : Vinod Kumar
	// Creation Date  : 01-Aug-2007 
	// Changed By	  : 
	// Changed Date   : 
	//*******************************************************************************************************
 function CheckMultilineTextBoxMaxLength(objTxt,maxLen)
        {   
            if(objTxt.value.length > (maxLen-1))
            {        
              objTxt.value =  TrimAll(objTxt.value)  ;
              objTxt.value = objTxt.value.substring(0,(maxLen));          
              return false;        
            }
            return true;
        }
        
        //******************************************************************************************************
	// Function name  : SelectRow
	// Parameter      : rowObject
	// Return value   : void
	// Purpose        : To Highlight the selected row of the datagrid
	// Author		  : Rupika Agarwal
	// Creation Date  : 15-Feb-2008
	// Changed By	  : 
	// Changed Date   : 
	//*******************************************************************************************************
 
 var selectedRow = null;
  var lastRowSelectedClassName =null;
function SelectRow(rowObject)
{

 var color = lastRowSelectedClassName;
if (selectedRow != null)
{
    //selectedRow.className = 'ResultColorRow1';
    selectedRow.className= color;
}
    selectedRow = rowObject;
    lastRowSelectedClassName = selectedRow.className;
    selectedRow.className = 'ColorBgBlue';
}

//********************************************
	// Function name  : DateValidateWithDays
	// Parameter      : Dat1,Days,Dat2,objDat1Caption,objDat2Caption
	// Return value   : bool
	// Purpose        : Function to compare dates
	// Author		  : Rupika Agarwal
	// Creation Date  : 
	// Changed By	  : 
	// Changed Date   :             
	function DateValidateWithDays(Dat1,Days,Dat2,objDat1Caption,objDat2Caption)
	{   
		 var d1=(Dat1.value).split('/');
		 Date1=new Date(d1[2],d1[1]-1,d1[0]);     
		 var d2 = AddDays(Dat2,Days );
		 var d3=(d2).split('/');
		Date2=new Date(d3[2],d3[1]-1,d3[0]);  
		   
		 if (!(Date1 > Date2))
		 {  
			alert(objDat1Caption + " must be atleast " + Days + " days from the " +objDat2Caption + ".");  
			return false ;      
		 } 	    
		 return true; 
	}
	
	
	// Function name  : GetRoundOffValue
	// Parameter      : dblValue,toDecimalPlaces
	// Return value   : float
	// Purpose        : Function to round off values to intended
	// Author		  : Vinod Kumar
	// Creation Date  : 29/05/2008
	// Changed By	  : 
	// Changed Date   :  
    function GetRoundOffValue(dblValue,toDecimalPlaces)
    {        
        //Check the decimal part
        dblValue = parseFloat(dblValue); 
        toDecimalPlaces = parseInt(toDecimalPlaces);
        dblValue = Math.round(dblValue*Math.pow(10,toDecimalPlaces))/Math.pow(10,toDecimalPlaces);    
        
        var strValue = String(dblValue)                                    
        var arrValue = strValue.split('.');
        var strValueAfterDecimal ="00";
        //Check the decimal part
        if(arrValue.length > 1)
        {
            if(arrValue[1].length ==1)
            {
                //Embed extra zero
                strValueAfterDecimal =  arrValue[1] + "0";
            }
            else
            {
                //Value has proper values after decimal digits
                strValueAfterDecimal = arrValue[1];
            }
        }                
        dblValue = arrValue[0]+ "."+ strValueAfterDecimal                     
        return dblValue
    } 	