 /*****************************************************************************************************************
	Purpose:	Script file for common client side validation functions, required for front end validations
	Script:		Javascript	
******************************************************************************************************************/
/*----------------------------------------------------------------------------------------------------------------
	Function:	cmpare_datevalue(dtLow,dtHigh)
	Purpose:	function to compare two date values																 
	Inputs:		dtLow		string		parameter holding the smaller date value to compare					 
				dtHigh		string		parameter holding the larger date value to compare					 
	Returns:	true/false	boolean		parameter returning true or false for output value					 
 ---------------------------------------------------------------------------------------------------------------*/
function cmpare_datevalue(dtLow,dtHigh){
	var dtParm_Low=ChangeFormatDD2MM(dtLow)			//converting date format to mm/dd/yyyy
	var dtParm_High=ChangeFormatDD2MM(dtHigh)		//converting date format to mm/dd/yyyy
	
   	if (Date.parse(dtParm_Low) <= Date.parse(dtParm_High)) {
		return true;
	}
	else {
		alert("To Date Value Less Than From Date")
		return false
	}
}

/*----------------------------------------------------------------------------------------------------------------
	Function:	ChangeFormatDD2MM(SuppliedDate)
	Purpose:	function chnages the date format from dd/mm/yyyy to mm/dd/yyyy
	Returns:	converted date
 ---------------------------------------------------------------------------------------------------------------*/
function ChangeFormatDD2MM(SuppliedDate)
{
	DateReversed = SuppliedDate;
	/* Getting Day Part*/
	if (SuppliedDate.charAt(1) == '/')
		DatePart = SuppliedDate.substring(0,1);
	else {
		if (SuppliedDate.charAt(2) == '/')	{
			DatePart = SuppliedDate.substring(0,2);
		}
	}

	/* Getting Month Part*/
	if (DatePart.length==2)	{	
		if (SuppliedDate.charAt(4) == '/') {   
			position=5;
			MonthPart = SuppliedDate.substring(3,4);
		}
		else {
			if (SuppliedDate.charAt(5) == '/') {	
				position=6;
				MonthPart = SuppliedDate.substring(3,5);
			}
		}
	}
	else {	
		if (SuppliedDate.charAt(4) == '/') {	
			position=5;
			MonthPart = SuppliedDate.substring(2,4);
		}
		else {
			if (SuppliedDate.charAt(3) == '/') {	 
				position=4;
				MonthPart = SuppliedDate.substring(2,3);
			}
		}
	}
		
	/* Getting Year Part*/
	YearPart=SuppliedDate.substring(position,SuppliedDate.length);
	DateReversed = MonthPart + "/" + DatePart + "/" + YearPart
	return DateReversed;
}
/*----------------------------------------------------------------------------------------------------------------
	Function:	AddListItem(strInputValue,strInputText,objFrmName,objSelFieldName)
	Purpose:	function to add new item in the list box
	Inputs:		strInputValue	string		parameter holding the value for option
			strInputText	string		parameter holding the display text for option
			objFrmName	string		parameter holding the name of the form
			objSelFieldName	string		parameter holding the name of selection that gets populated
	Returns:	true/false	boolean		parameter returning true or false for output value

 ---------------------------------------------------------------------------------------------------------------*/

function AddListItem(strInputValue,strInputText,objFrmName,objSelFieldName) {

	if(strInputValue.length > 0) {
		var OselRef=eval("document." + objFrmName + "." + objSelFieldName)
		var ONewOption=document.createElement("Option")
		OselRef.add(ONewOption)
		var OptRef=OselRef.item(OselRef.length-1)
		OptRef.text=strInputText
		OptRef.value=strInputValue
		return true;
	}
	else {
		alert("Please Update Value To Be Added In List")
		return false;
	}	
}


/*----------------------------------------------------------------------------------------------------------------
	Function:	RemoveListItem(objFrmName,objSelFieldName)
	Purpose:	function to add new item in the list box
	Inputs:		objFrmName	string		parameter holding the name of the form
			objSelFieldName	string		parameter holding the name of selection that gets populated
	Returns:	true/false	boolean		parameter returning true or false for output value
 ---------------------------------------------------------------------------------------------------------------*/
function RemoveListItem(objFrmName,objSelFieldName) {
	var LIndex=0
	var OselRef=eval("document." + objFrmName + "." + objSelFieldName)
	var OExistOption=document.createElement("Option")
	LIndex=OselRef.selectedIndex
	if (LIndex>=0) {
		OselRef.remove(LIndex)
		return true;
	}
	else{
		return false;
	}
   }


/*----------------------------------------------------------------------------------------------------------------
	Function:	object_changestate(frmName,objName,selMode)
	Purpose:	function to enable or disable html object
	Inputs:		frmName		string		parameter holding the form name of the html object
				objName		string		parameter holding the name of the html object
				selMode		string		parameter holding sigle character value e:enable, d:disable
	Returns:	-				
 ---------------------------------------------------------------------------------------------------------------*/
function object_changestate(frmName,objName,selMode) {
	var objSel=eval("document."+ frmName + "." + objName)
	if (selMode.toLowerCase()=="e") {
		objSel.disabled=false
	}
	if (selMode.toLowerCase()=="d") {
		objSel.disabled=true
	}
}


/*----------------------------------------------------------------------------------------------------------------
	Function:	object_changestate(frmName,chk1Name,chk2Name,cmdPrint,selName)
	Purpose:	function to enable or disable html object
	Inputs:		frmName		string		parameter holding the form name of the html object
				chk1Name	string		parameter holding the name of first check box object
				chk2Name	string		parameter holding the name of second check box object
				cmdPrint	string		parameter holding the name of print report button
				selName		string		parameter holding the name of printer selection box
	Returns:	-				
 ---------------------------------------------------------------------------------------------------------------*/

function print_consent(frmName,chk1Name,chk2Name,cmdPrint,selName) {
	if ((eval("document."+ frmName + "." + chk1Name + ".checked")==true) && (eval("document."+ frmName + "." + chk2Name + ".checked")==true)) {
		var objSel=eval("document."+ frmName + "." + selName)
		var objPrint=eval("document."+ frmName + "." + cmdPrint)
		objSel.disabled=false
		objPrint.disabled=false
	}
	else{
		var objSel=eval("document."+ frmName + "." + selName)
		var objPrint=eval("document."+ frmName + "." + cmdPrint)
		objSel.disabled=true
		objPrint.disabled=true
	} 
}


/*----------------------------------------------------------------------------------------------------------------
	Function:	reload_page(strPagePath)
	Purpose:	function to reload the required page
	Inputs:		strPagePath	string		parameter holding the path and name of page to refresh
	Returns:	-
 ---------------------------------------------------------------------------------------------------------------*/
function reload_page(strPagePath)
 {
	window.location.href=strPagePath
}



/*----------------------------------------------------------------------------------------------------------------
	Function:	CheckNull(FieldValue,FieldName)
	Purpose:	function to Check Null Value
	Inputs:		FormName 	string 		Parameter containing name of the form
			LabelName	string 		Label of field on which validation is applied
			FieldName 	string 		Name of field on which this validatuon is applied.
	Returns:	true/false	boolean		Parameter returning true or false for output value
 ---------------------------------------------------------------------------------------------------------------*/
function CheckForNull(FormName,LabelName,FieldName){
	var FieldRef=eval("document." + FormName +"." + FieldName);
	var FieldValue=FieldRef.value
	FieldValue=LTrim(RTrim(FieldValue))
	var MsgRef = eval("document." + FormName +".txtMessage");
	var counter=0

	if(parseInt(FieldValue.length) < 1)	{ 
		alert(LabelName + " must be entered.");
		//MsgRef.value = LabelName + " Must Be Entered!"
		eval("document." + FormName +"." + FieldName + ".focus()")
		return false;
	}
	else{
		//Check Spaces in String 
		for (LintCount=0;LintCount<=parseInt(FieldValue.length);LintCount++)
		{
			//If Space Found
			if(FieldValue.charAt(LintCount)==' ')
			{
				counter=counter+1
			}
		}
		//If Total Number of Spaces Equal to Total Length of String Then Return False
		if(parseInt(counter)==parseInt(FieldValue.length))
		{
			alert(LabelName + " must be entered.");
			//MsgRef.value = LabelName + " Must Be Entered!"
			FieldRef.value=''
			eval("document." + FormName +"." + FieldName + ".focus()")
			return false;
		}
		else
		{
			
			FieldRef.value=FieldValue
			return true;
		}
	    }
}


/*----------------------------------------------------------------------------------------------------------------
	Function:	CheckIsNumber(FormName,LabelName,FieldName)
	Purpose:	For Checking Integer........for fields where only numerics are required
	Inputs:		FormName	string 		Parameter containing name of the form
				LabelName	string 		Parameter containing Label name to display in message
				FieldName	string 		Parameter containing Name of field for validatuon
	Returns:	true / false
-----------------------------------------------------------------------------------------------------------------*/
function CheckIsNumber(FormName,LabelName,FieldName) {
	var FieldRef=eval("document." + FormName +"." + FieldName);
	if(isNaN(FieldRef.value)) {
		alert (" Numeric values allowed in "+ LabelName +" Field");
		FieldRef.value="";
		FieldRef.focus();
		return false;
	}
	else {
		return true;
	}
}


/*----------------------------------------------------------------------------------------------------------------
	Function:	open_childwin(strVirtualPath,intWidth,intHeight,strTitle)
	Purpose:	Function to open a new child window
	Inputs:		strVirtualPath	string		Parameter holding the virtual path of file to load
			intWidth	Integer		Parameter for pop up window width
			intHeight	Integer		Parameter for pop up window height
			strTitle	string		Parameter holding the title for child window
	Returns:	hndWin		boolean		Parameter returning handle to child window opened
 ---------------------------------------------------------------------------------------------------------------*/
function open_childwin(strVirtualPath,intWidth,intHeight,strTitle){
//	var LstrPath=strVirtualPath

	var strFormtString= "'toolbar=no,scrollbars=yes,height=" + intHeight + ",width=" + intWidth + ",top=100,left=100'"
	window.child=window.open('',"winPreview",strFormtString)
	window.child.document.open("text/html");
	window.child.document.writeln("<DIV STYLE='position:absolute;left:100;top:200;font-Family:Sans-Serif;font-Size:18pt;visibility:show;'><CENTER><IMG SRC='images/POPUP.GIF' alt='POPUP' border='0' align=bottom ><br><FONT COLOR='green'><B>Loading....</B></FONT></CENTER></DIV>")
	window.child.document.close();
	window.child.location.href=strVirtualPath
//	hndWin=window.open(LstrPath,"winPreview",strFormtString)
//	hndWin.document.title=strTitle
//	return hndWin
}

/*----------------------------------------------------------------------------------------------------------------
	Function:	OpenCalender(FORMNAME,FIELDNAME)
	Purpose:	function to open a calender
	Inputs:		FORMNAME	string		Parameter containing name of the form
			FIELDNAME	string		Parameter containing field name to set  text
	Returns:	-
 ---------------------------------------------------------------------------------------------------------------*/
function OpenCalender(FORMNAME,FIELDNAME) {
	if (!window.child || window.child.close) {
		window.child = window.open("","child","menubar=no,toolbar=0,resizable=no,scrollbars=no,status=0, alwaysraised=yes,titlebar=YES, height=250, width=300, top=100, left=500");
		window.child.document.open("text/html");
		window.child.document.writeln('<DIV STYLE="position:absolute;left:200;top:200;font-Family:Sans-Serif;font-Size:18pt;visibility:show;"><CENTER><IMG SRC="../images/POPUP.GIF" alt="POPUP" border="0" align=bottom ><br><FONT COLOR="green"><B>Loading....</B></FONT></CENTER></DIV>');
		window.child.document.close();
		window.child.focus();	
		window.child.location.href = "ASPCalendar.asp?FORMNAME="+FORMNAME+"&NAME="+FIELDNAME
	}
}



/*----------------------------------------------------------------------------------------------------------------
	Function:	CheckDate(FormName,FieldName)
	Purpose:	Used For Date Validations
	Inputs:		FormName	string		Parameter containing form name
			FieldName	string		Parameter containing field name
	Returns:	true/false	boolean		Parameter returning true or false for output value
 ---------------------------------------------------------------------------------------------------------------*/
function CheckDate(FormName,FieldName)
{	
	var j=0;
	var intCheck=0;
	var intDay=""; intMonth=""; intYear="";
	var ArrDate=new Array();
	var arrMonthDays = new Array(31,29,31,30,31,30,31,31,30,31,30,31);
	var strDate=eval("document." + FormName +"." + FieldName + ".value");
	var strlen=strDate.length;
	var strTempString=""
	var strTempDate=""
	//Concatinating 0 in begning in case value of lenght 1
	if((strlen >= 8) && (strlen <= 9))	{
		strDate=strDate+"/"
		for (var i=0; i<=strlen; i++) {
	      	if(!(strDate.charAt(i) == "/")) {
		  		strTempString=strTempString + strDate.charAt(i)
	     	}
			else {
				if (strTempString.length < 2) {
					strTempString="0" + strTempString
					if (strTempDate.length < 1) {strTempDate=strTempString }
					else {strTempDate=strTempDate + "/" + strTempString	}	
					strTempString=""
				}	
				else {
					if (strTempDate.length < 1) {strTempDate=strTempString}
					else {strTempDate=strTempDate + "/" + strTempString	}	
					strTempString=""
				}	
			}	
		}
		strDate=strTempDate
	}

	strlen=strDate.length;
	if((strlen >= 8) && (strlen <= 10))	{
		for (var i=0; i<=strlen; i++) {
	      		if(!(strDate.charAt(i) == "/")) {
		  			ArrDate[j]=strDate.charAt(i)
		  			j=j+1
	     		}
				else {
					intCheck=intCheck+1;
				}
	  	}
	  	
	  	//****Check For two '//' in the date enterd
	  	
	 	if(intCheck !=2) {  
	 		alert("Invalid Date Format")
			eval("document." + FormName +"." + FieldName + ".focus()");
			return false;
		}
		intMon=ArrDate[0] + ArrDate[1];
		intDay=ArrDate[2] + ArrDate[3];
		intYear=ArrDate[4] + ArrDate[5] + ArrDate[6] + ArrDate[7];
		if(isNaN(intDay)==false){
			if(isNaN(intMon)==false){
				if(isNaN(intYear)==false){
					//*****************Check for Zero in Days
					if(intDay=='00'){
						alert("Invalid Number Of Days");
						eval("document." + FormName +"." + FieldName + ".focus()");
						return false;
					}
					//*****************Check for Zero in Month
					if(intMon=='00'){
						alert("Invalid Number Of Months");
						eval("document." + FormName +"." + FieldName + ".focus()");
						return false;
					}
					if(intYear == "0000"){
						alert("Invalid Year");
						eval("document." + FormName +"." + FieldName + ".focus()");
						return false;	
					}
					if(parseInt(intYear.length) != 4){
						alert("Invalid Year");
						eval("document." + FormName +"." + FieldName + ".focus()");
						return false;	
					}
					//*****************Coparing months with days
					if(parseInt(intDay) > arrMonthDays[parseInt(intMon-1)]) {
	    				alert("Invalid Number Of Days");
	    				eval("document." + FormName +"." + FieldName + ".focus()");
						return false;
					}
					else {
	 					if(intMon > 12) {
		  					alert("Invalid Month")
							eval("document." + FormName +"." + FieldName + ".focus()");
							return false;
 						}
						else {
							if(intMon==2) {
								if(intYear%4==0 || intYear%400==0) {
									if(intDay>29) {
				  						alert("Day can't be greater than 29 in February for a leap year");
										eval("document." + FormName +"." + FieldName + ".focus()");
										return false;	
									}	
								}
			 					else{
									if(intDay>28){
				    					alert("Day can't be greater than 28 in February");
	           		   					eval("document." + FormName +"." + FieldName + ".focus()");
				    					return false;
									}
                 				}
							}
						}		
					}
				}
				else {
					alert("Character/s Not Allowed.");
					eval("document." + FormName +"." + FieldName + ".focus()");
					return false;	
				}		
			}
			else {
				alert("Character/s Not Allowed.");
				eval("document." + FormName +"." + FieldName + ".focus()");
				return false;	
			}	
		}
		else {
			alert("Character/s Not Allowed.");
			eval("document." + FormName +"." + FieldName + ".focus()");
			return false;	
		}	
	}
	else {
		alert("Invalid Date Format.");
		eval("document." + FormName +"." + FieldName + ".focus()");
		return false;	
	}
}


function CheckMMDate2(FormName,FieldName)
{	
	var j=0;
	var intCheck=0;
	var intDay=""; intMonth=""; intYear="";
	var ArrDate=new Array();
	var arrMonthDays = new Array(31,29,31,30,31,30,31,31,30,31,30,31);
	var strDate=eval("document." + FormName +"." + FieldName + ".value");
	var strlen=strDate.length;
	var strTempString=""
	var strTempDate=""
	//Concatinating 0 in begning in case value of lenght 1
	if (strlen == 6) 	{
		strDate=strDate+"/"
		for (var i=0; i<=strlen; i++) {
	      	if(!(strDate.charAt(i) == "/")) {
		  		strTempString=strTempString + strDate.charAt(i)
	     	}
			else {
				if (strTempString.length < 2) {
					strTempString="0" + strTempString
					if (strTempDate.length < 1) {strTempDate=strTempString }
					else {strTempDate=strTempDate + "/" + strTempString	}	
					strTempString=""
				}	
				else {
					if (strTempDate.length < 1) {strTempDate=strTempString}
					else {strTempDate=strTempDate + "/" + strTempString	}	
					strTempString=""
				}	
			}	
		}
		strDate=strTempDate
	}

	strlen=strDate.length;
	if ((strlen >= 6) && (strlen <= 7))	{
		for (var i=0; i<=strlen; i++) {
	      		if(!(strDate.charAt(i) == "/")) {
		  			ArrDate[j]=strDate.charAt(i)
		  			j=j+1
	     		}
				else {
					intCheck=intCheck+1;
				}
	  	}
	  	
	  	//****Check For two '//' in the date enterd
	  	
	 	if(intCheck !=1) {  
	 		alert("Invalid Date Format")
			eval("document." + FormName +"." + FieldName + ".focus()");
			return false;
		}
		intMon=ArrDate[0] + ArrDate[1];
	     intYear=ArrDate[2] + ArrDate[3] + ArrDate[4] + ArrDate[5];
		
			if(isNaN(intMon)==false){
				if(isNaN(intYear)==false){
				
					//*****************Check for Zero in Month
					if(intMon=='00'){
						alert("Invalid Number Of Months");
						eval("document." + FormName +"." + FieldName + ".focus()");
						return false;
					}
					if(intYear == "0000"){
						alert("Invalid Year");
						eval("document." + FormName +"." + FieldName + ".focus()");
						return false;	
					}
					if(parseInt(intYear.length) != 4){
						alert("Invalid Year");
						eval("document." + FormName +"." + FieldName + ".focus()");
						return false;	
					}
					//*****************Coparing months with days
					
					else {
	 					if(intMon > 12) {
		  					alert("Invalid Month")
							eval("document." + FormName +"." + FieldName + ".focus()");
							return false;
 						}
						
					}
				}
				else {
					alert("Character/s Not Allowed.");
					eval("document." + FormName +"." + FieldName + ".focus()");
					return false;	
				}		
			}
			else {
				alert("Character/s Not Allowed.");
				eval("document." + FormName +"." + FieldName + ".focus()");
				return false;	
			}	
		}
		
	else {
		alert("Invalid Date Format.");
		eval("document." + FormName +"." + FieldName + ".focus()");
		return false;	
	}
}









/*---------------------------------------------------------------------------------------------------------------
	Function:	MinMax(FormName,LabelName,FieldName,MinVal,MaxVal)
	Purpose:	function to check for minimum and maximum length of a  feild
	Inputs:		FormName	string	 	parameter holding the name of the form
			LabelName	string	 	parameter holding message display text
			FieldName	string	 	parameter holding the name of the text field
			MinVal		integer	 	parameter holding the minimum allowed length
			MaxVal		integer	 	parameter holding the maximum allowed length
	Returns:	true/false	boolean		parameter returning true or false for output value
--------------------------------------------------------------------------------------------------------------*/
function MinMax(FormName,LabelName,FieldName,MinVal,MaxVal)
{
	var FieldRef=eval("document." + FormName +"." + FieldName);
	var FieldValue=FieldRef.value
	if(FieldValue.length > parseInt(MaxVal))
	{
		alert(LabelName +" 's Length Can't Be Greater Than " + MaxVal);	
		FieldRef.focus();
		return false;
	}
	else {
		if(FieldValue.length < parseInt(MinVal)) {	
			alert(LabelName +" Length Can't Be Less Than " + MinVal);
			FieldRef.focus();
			return false;
		}
		else {
			return true;
		}
	}
}



/*----------------------------------------------------------------------------------------------------------------
	Function:	FormatListView(FieldValue,intMaxDisplayLength)
	Purpose:	Function to format a display string with required truncation or number of spaces
	Inputs:		FieldValue	  	string	The Value enterd in the field
			intMaxDisplayLength  	string	The Display Length of the value in the field
	Returns:	Formatted o/p string
 ---------------------------------------------------------------------------------------------------------------*/
function FormatListView(FieldValue,intMaxDisplayLength)
{
	var LoopCounter=0
	var strSpaceString=""
	var Vallength=0
	Vallength=FieldValue.length;
	strTruncatedValue=""

	if(Vallength >= intMaxDisplayLength) {
		strTruncatedValue=FieldValue.substr(0,intMaxDisplayLength);
		return strTruncatedValue
	}
	else {
		LoopCounter=15
		for(intCount=0;intCount<=LoopCounter;intCount++) {
			strSpaceString=strSpaceString+ " "
		}
		FieldValue=FieldValue+strSpaceString;
		return FieldValue;
	}
}

/*---------------------------------------------------------------------------------------------------------------
	Function:	MinMaxValue(FormName,LabelName,FieldName,MinVal,MaxVal)
	Purpose:	function to check for minimum and maximum value of a  feild
	Inputs:		FormName	string	 	parameter holding the name of the form
			LabelName	string	 	parameter holding message display text
			FieldName	string	 	parameter holding the name of the text field
			MinVal		integer	 	parameter holding the minimum allowed value
			MaxVal		integer	 	parameter holding the maximum allowed value
	Returns:	true/false	boolean		parameter returning true or false for output value
--------------------------------------------------------------------------------------------------------------*/

function MinMaxValue(FormName,LabelName,FieldName,MinVal,MaxVal){
	var FieldRef=eval("document." + FormName +"." + FieldName);
	var FieldValue=parseFloat(FieldRef.value)
	if(FieldValue > parseFloat(MaxVal))
	{
		alert(LabelName + " Value Can't Be Greater Than " + MaxVal);	
		FieldRef.focus();
		return false;
	}
	else {
		if(FieldValue < parseFloat(MinVal)) {	
			alert(LabelName + " Value Can't Be Less Than " + MinVal);
			FieldRef.focus();
			return false;
		}
		else {
			return true;
		}
	}
}

/*---------------------------------------------------------------------------------------------------------------
	Function:	MinMaxVal(FormName,LabelName,FieldName,MaxVal)
	Purpose:	Function to check for maximum value enterd
	Inputs:		FormName	string	 	parameter holding the name of the form
			LabelName	string	 	parameter holding message display text
			FieldName	string	 	parameter holding the name of the text field
			MaxVal		integer	 	parameter holding the maximum allowed Value
	Returns:	true/false	boolean		parameter returning true or false for output value
--------------------------------------------------------------------------------------------------------------*/
function MinMaxVal(FormName,LabelName,FieldName,MaxVal){
	var FlieldRef=eval("document." + FormName +"." + FieldName);
	if((parseFloat(FlieldRef.value) > parseFloat(MaxVal)) || (parseFloat(FlieldRef.value) < 0 )) {
		alert(LabelName +" Value Should Be Between 0 To " + MaxVal);
		FlieldRef.focus();
		return false;
	}
	else {
		return true;
	}

}


function CompareDates(ADtLowerDate,AStrLowerDateLabel,ADtHigherDate,AStrHigherDateLabel,AChrMsgStatus){
   //var LDtLowerDate = ChangeFormatDD2MM(ADtLowerDate)	        //converting date format to mm/dd/yyyy
   //var LDtHigherDate = ChangeFormatDD2MM(ADtHigherDate)      //converting date format to mm/dd/yyyy
   var LStrAlertMessage

   if(AChrMsgStatus.toUpperCase() == 'L'){
	LStrAlertMessage = AStrLowerDateLabel + ' Must Not Exceed ' + AStrHigherDateLabel
   }
   else{
	LStrAlertMessage = AStrHigherDateLabel + ' Must Not Be Less Than ' + AStrLowerDateLabel
   	}
   if(Date.parse(ADtLowerDate) <= Date.parse(ADtHigherDate)) {
	return true;
   }
   else {
	alert(LStrAlertMessage)
	return false
	}
}

/*---------------------------------------------------------------------------------------------------------------
	Function:	ChkAll()
	Purpose:	Function to check and uncheck all the checkboxes
	Inputs:		AIntUbound      integer         parameter holding no. of checkboxes starting from 0
	Returns:	None
--------------------------------------------------------------------------------------------------------------*/
function ChkAll(AIntUbound){
	var iCtr
	var strVal
	var LIntUbound = parseInt(AIntUbound)+1

	if(document.forms(0).chkSelectAll.checked == false){
		for(iCtr=1;iCtr<=parseInt(LIntUbound);iCtr++){
			strVal = eval("document.forms(0).chkName" + iCtr)
			strVal.checked=false
		}
		return true;
	}
	else{
		if(document.forms(0).chkSelectAll.checked == true){
			for(iCtr=1;iCtr<=parseInt(LIntUbound);iCtr++){
				strVal = eval("document.forms(0).chkName" + iCtr)
				strVal.checked=true
			}
			return true;
		}				
	}
}


function ChkSelectAll(CheckBoxControl) {		
    if (CheckBoxControl.checked == true) {
       var i;

        for (i=0; i < document.forms[0].elements.length; i++) {
            if ((document.forms[0].elements[i].type == 'checkbox') && (document.forms[0].elements[i].name.indexOf('dgrdData') > -1)) {					
				if (document.forms[0].elements[i].disabled==false)
				{
	                document.forms[0].elements[i].checked = true;
				}
            }
        }
    } 
    
    else {
        
        var i;
        
        for (i=0; i < document.forms[0].elements.length; i++) {
            
            if ((document.forms[0].elements[i].type == 'checkbox') && (document.forms[0].elements[i].name.indexOf('dgrdData') > -1)) {
                
                document.forms[0].elements[i].checked = false;
            }
        }
    }
}

/*---------------------------------------------------------------------------------------------------------------
	Function:	RadioBtnOnClick()
	Purpose:	Function to close the LOV window and display the selected value in the textbox
	Inputs:		AStrFormName      	String         parameter holding form name
			AStrSelFieldName	String	       parameter holding field name
			AStrSelFieldValue	String	       parameter holding field value
	Returns:	None
--------------------------------------------------------------------------------------------------------------*/
function RadioBtnOnClick(AStrFormName,AStrSelFieldName,AStrSelFieldValue){
	var ParentFieldRef = eval("window.opener.document." + AStrFormName + "." + AStrSelFieldName)
	ParentFieldRef.value = AStrSelFieldValue
	
	window.close()
	ParentFieldRef.focus()
}

/*---------------------------------------------------------------------------------------------------------------
	Function:	RadioBtnOnClick_Local()
	Purpose:	Function to close the LOV window and display the selected value in the textbox
	Inputs:		AStrFormName      	String         parameter holding form name
			AStrSelFieldName	String	       parameter holding field name
			AStrSelFieldValue	String	       parameter holding field value
			AChrDelim		String	       parameter holding delimiter
	Returns:	None
--------------------------------------------------------------------------------------------------------------*/

function RadioBtnOnClick_LOV(AStrFileName,AStrSelFieldValue,AChrStatus){
	document.location.href = AStrFileName + "?pageloadstatus=reload&fieldvalue=" + AStrSelFieldValue + "&lov_status=" + AChrStatus
}

/*--------------------------------------------------------------------------------------------------------------------------------------------------------------
	Function:	openLOV()
	Purpose:	Function to open the LOV window and send the required inputs in the form of query string to be used by "ViewListOfValues()" function
	Inputs:		AIntSqlNo		Integer	       parameter holding SQL Key No
			AStrFormName      	String         parameter holding form name
			AStrSelFieldName	String	       parameter holding field name
			AStrSelFieldValue	String	       parameter holding field value
			AStrTitle		String	       parameter holding title of the Child window
	Returns:	None
-----------------------------------------------------------------------------------------------------------------------------------------------------------------*/
function openLOV(AIntSqlNo,AStrFormName,AStrSelFieldName,AStrSelFieldValue,AStrTitle){
	var LStrInput = "ASPLOV.asp?sqlno=" + AIntSqlNo + "&frmname=" + AStrFormName + "&fieldname=" + AStrSelFieldName + "&fieldvalue=" + FilterProcess(AStrSelFieldValue,'~')
	open_childwin(LStrInput,'600','525',AStrTitle)
}


function OnLOVSearchClick(AIntSqlNo,AStrFormName,AStrSelFieldName,AStrSelFieldValue,AStrSearchFieldName,AStrSearchFieldValue){
	var LStrFieldName
	var LStrFieldValue
	
	if(CheckForNull('frmLoanM','Search On','cmbSearch')==false) return false;
	
	if(CheckForNull('frmLoanM','Search Value','txtSearch')==true){
		if(AbortNonRequiredCharacters('frmLoanM','txtSearch','`~!@#$%^&*()+{};:,<>?|','Search Value Must Be Valid !')==false) return false;
	}
	else{
		return false;
	}
	
	if(parseInt(AStrSearchFieldName.length) < 1){
		LStrFieldName = document.frmLoanM.cmbSearch.value;
		LStrFieldValue = LTrim(RTrim(document.frmLoanM.txtSearch.value));
	}
	else{
		LStrFieldName = AStrSearchFieldName + "~" + document.frmLoanM.cmbSearch.value;
		LStrFieldValue = AStrSearchFieldValue + "~" + LTrim(RTrim(document.frmLoanM.txtSearch.value));
	}
	document.location.href = "ASPLOV.asp?search=ON&sqlno=" + AIntSqlNo + "&frmname=" + AStrFormName + "&fieldname=" + AStrSelFieldNam


