//var isNS4 = (navigator.appName=="Netscape")?true:false;
/* ************** INDEX ****************
1. CompareDates(strFromDate, strToDate)
2. fnCompareDate(strDate1,strDate2)
3. fnRoundDecimals(originalnumber, decimals) 
4. padwithzeros(roundedvalue, decimalplaces) 
5. funMakeUpperCase(obj,formname)
6. fnLTrim(str)
7. fnRTrim(str) 
8. fnTrim(str)
9. fnCodeValidation(val)
10.fnNameValidation(val)
11.fnDescriptionValidation(val)
12.fnAddressValidation(val)
13.fnPhFaxPgMobValidation(val)
14.fnEmailValidation(oBj)
15.fnAmountValidation(val)
16.fnIntegerValidation(val)
17.fnURLValidation(val)
18.intValidation(val)
19.intValidationPrecision(val)
20.fnChangeToUCase(obj, formname)
21.fnIPAddressValidation(val)
22.fnGetCurrentDateOnly()
23.fn_DMY_TO_MDY(strDate, Seperator)
24.fn_DMY_TO_YMD(strDate, Seperator)
25.fnIsEmpty(CntlName, LableName)
26.fnIsEmptyCombo(CntlName, LableName)
27.fnTextAreaLength(CntlName,LableName,Length,e)
28.Validate_TextArea(source,value) 
29.Debug(strValue)
30.MemberidValidation(val)
31.fnDateAdd(mDatePart , mNumber, mDate)
32.fnDateDiff(mDatePart, mStartDate, mEndDate)
33.isValidDate(mDate) 
34.fnPasswordValidation(val)
35.isValidDateCommon(mDate,Lable) 
36.isLombardSpecialChars(Val)
37.isValidDateCommonMonthYear(mDate,mLabel) 
38.fnDisplayDateFormat(DataString)
39.fnAlphaCharactersValidation(Val)
40.fnOnPaste()
41.fnSetEmiValue(mTotalPremium, mEMIPeriod)
42.fnValidateNRIDelyAddress()
43.fnAlphNumericValidation(Val)
44.fnSetDOBAttribute(mObject)
45.fnFillCombo(mObject, spName, param)
46.fnClearCombo(mObject,defaultValue,defaultString)
47.fnTxtMinLen(Ctrl,CharLength, ForCtrl)
48.fnNameValidate(val)
49.DeleteText(CntlName,CntlValue)	
50.isLombardPasswordChars(Val)
51.fnWindowPopUPOpen(URL)
52.fnSetSelectedText(mObject, val)
53.fnSetSelectedValue(mObject, val)
54.intOnlyValidation(val) for only integers without any alert message Same as function intValidation(val)
55.fnPhoneValidation(val) for Phone where it should remove the 0 in the start of the phone number
56.fnOtherDiseaseValidation(val) for Other disease where it should accept only Alphabets with space and comma only
57.fnDateDiffAll(mDatePart, mStartDate, mEndDate) for Ristey which returns not only days difference but even mth, year seperated by pipe
58.calcHeight() Calculate the Height of the Window & resizes the IFrame.
59.fnValidateDateInput(val) Validates Date onKePress Event
60.fnPolicyNoValidation() validates policy no
61.fnRedirectPage(mUrl, mFrom, mDealNo) to submit to A Particular Page from the Calculator Page
62.fnValidateDepositAmt(DealNo, PremiumAmt) validate MBT type for Balance 06/02/2007
****************************** */

	/* This function works with date.parse */
	//function to compare from date and to date
	function CompareDates(strFromDate, strToDate)
	{
		
		if (Date.parse(strFromDate) > Date.parse(strToDate))
			return false;
		else
			return true;
	}

	function fnCompareDate(strDate1,strDate2)// Function To comapair Two Dates of format dd/mm/yyyy
	{
		var strDay		= strDate1.substr(0,strDate1.indexOf("/"));
		var strAfterMon = strDate1.substr(strDate1.indexOf("/")+1);
		var strMon		= strAfterMon.substr(0,strAfterMon.indexOf("/"));
		var strYear		= strAfterMon.substr(strAfterMon.indexOf("/")+1);

		var startdate	= new Date(parseInt(strYear,10),parseInt(strMon,10)-1,parseInt(strDay,10));

		var strDay1		= strDate2.substr(0,strDate2.indexOf("/"));
		var strAfterMon1= strDate2.substr(strDate2.indexOf("/")+1);
		var strMon1		= strAfterMon1.substr(0,strAfterMon1.indexOf("/"));
		var strYear1	= strAfterMon1.substr(strAfterMon1.indexOf("/")+1);

		var enddate		= new Date(parseInt(strYear1,10),parseInt(strMon1,10)-1,parseInt(strDay1,10));
		
		datediff		= enddate - startdate
		
		if(datediff == 0)
		{
			return 0; // End Date = Start Date
		}   
		if(datediff<0)
		{
			return 1; // End Date > Start Date
		} 
		
		return 2; // End Date < Start Date
	}

	/* 
	This function that will take any value and round it to a specified number of decimal 
	places. If the value has fewer decimal places than what you want it rounded to, 
	the decimals are padded with zeroes.
		e.g RoundDecimals( The_No_You_Want_To_Format, NoOfDecimals);
	*/
	function fnRoundDecimals(originalnumber, decimals) 
	{
		var result1 = originalnumber * Math.pow(10, decimals)
		var result2 = Math.round(result1)
		var result3 = result2 / Math.pow(10, decimals)
		return padwithzeros(result3, decimals)
	}
	function padwithzeros(roundedvalue, decimalplaces) 
	{
		// Convert the number to a string
		var valuestring = roundedvalue.toString()
		
		// Locate the decimal point
		var decimallocation = valuestring.indexOf(".")

		// Is there a decimal point?
		if (decimallocation == -1) {
		    
		    // If no, then all decimal places will be padded with 0s
		    decimalpartlength = 0
		    
		    // If decimalplaces is greater than zero, tack on a decimal point
		    valuestring += decimalplaces > 0 ? "." : ""
		}
		else {

		    // If yes, then only the extra decimal places will be padded with 0s
		    decimalpartlength = valuestring.length - decimallocation - 1
		}
		
		// Calculate the number of decimal places that need to be padded with 0s
		var padtotal = decimalplaces - decimalpartlength
		
		if (padtotal > 0) 
		{
		    // Pad the string with 0s
		    for (var counter = 1; counter <= padtotal; counter++) 
		        valuestring += "0"
	    }
		return valuestring
	}
	
	function funMakeUpperCase(obj,formname)
	{
		var objControl, strValue
		objControl=eval('document.'+formname+'.'+obj.name)
		strValue=objControl.value;
		
		strValue=strValue.toUpperCase();
		objControl.value=strValue;
	}

	//Left trim method: strltrim
	function fnLTrim(str) 
	{
		//Match spaces at beginning of text and replace with a null string
		return str.replace(/^\s+/,'');
	}
	//Right trim method: strrtrim
	function fnRTrim(str) 
	{
		//Match spaces at end of text and replace with a null string
		return str.replace(/\s+$/,'');
	}
	//Trim method: strtrim
	function fnTrim(str) 
	{
		//Match spaces at beginning and end of text and replace with null strings
		return str.replace(/^\s+/,'').replace(/\s+$/,'');
	}
/* *************************************************************************************************************** */
	function fnCodeValidation(val, e)
	{
		var n = fnGetKeyCode(e);
		// First Character of Addresss Can not be a Blank Space
		if (val.length == 0 && n == 32)
			return false;

		if(fnValidateCommonKeys(n))
			return true;
		//Only the A-Z, a-z, and 0-9, -, /, \, these Characters are allowed in the Name
		//'' NOTE - This function will NOT allow to enter spaces (ascii=32) into the Name Fields
		if (!((n >= 65 && n <= 90) || (n >= 97 && n <= 122) || (n >= 48 && n <= 57) || (n == 45) || (n == 47) || (n == 92))) 
			return false;
		return true;
	}   

	// ---- This Function is used to Validate the Name Characters to be Entered in the Application
	function fnNameValidation(val, e)
	{ 
		var n = fnGetKeyCode(e);
		// First Character of Name Can not be a Blank Space
		if ((n == 8) || (n == 9) || (n==0))
			return true;
			
		if (val.length == 0 && n == 32)
			return false;
		
		if(fnValidateCommonKeys(n))
			return true;
		// E)  Only the A-Z, a-z,(, ), ., -,0-9,
		//      these Characters are allowed in the Name also comma is NOT allowed.
		// NOTE - This function will NOT allow to enter spaces (ascii=32) into the Name Fields

		if (!((n >= 65 && n <= 90) || (n >= 97 && n <= 122) || n == 40 || n == 41 || n == 45 || n == 46 || n == 3 || n == 22 || n == 32 || n == 24 ))	// || (n >= 48 && n <= 57)
			return false;
		else
		    if (n == 35 || n == 124 || n == 43 || n == 38 || n == 39 || n == 64 || n == 45)
			    return false;
				
		return true;
	}

	function fnDescriptionValidation(val, e)
	{
		var n = fnGetKeyCode(e);
		// First Character of Addresss Can not be a Blank Space
		if (val.length == 0 && n == 32)
			return false;

		if(fnValidateCommonKeys(n))
			return true;
		// Only the A-Z, a-z, 0-9, spaces, !,#, %, %, &, ',
		// (, ), ., -, /, :, ;, @, [, \, ], _,  {, },
		// these Characters are Allowed in the Description Fields
		if  (!((n >= 65 && n <= 90) || (n >= 97 && n <= 122) || (n >= 48 && n <= 57) || (n == 32) || (n == 33) || (n >= 35 && n <= 47) || (n == 58) || (n == 59) || (n == 64) || (n == 91) || (n == 92) || (n == 93) || (n == 95) || (n == 123) || (n == 125)))
			return false;
		return true;
	}

	function fnAddressValidation(val, e)
	{
		var n = fnGetKeyCode(e);
		// This Function is used to Validate the Address Characters to be Entered in the Application
		// First Character of Addresss Can not be a Blank Space
		if (val.length == 0 && n == 32)
			return false;

		if(fnValidateCommonKeys(n))
			return true;
			
		// Only the A-Z, a-z, 0-9, spaces, &, (, ), ,, ., -, /, :, ;, [, \, ], _, {, },
		// Ctrl+C, Ctrl+V, Ctrl+X, Added On 22-01-2002 For Master Creation EXE
		// these Characters are Allowed in the Address
		if  (!((n >= 65 && n <= 90) || (n >= 97 && n <= 122) || (n >= 48 && n <= 57) || (n == 32) || (n == 38) || (n == 40) || (n == 41) || (n >= 44 && n <= 47) || (n == 58) || (n == 59) || (n >= 91 &&  n <= 93) || (n == 93) || (n == 95) || (n == 123) || (n == 125) || (n == 3) || (n == 13) || (n == 22) || (n == 24)))
			return false;
		return true;
	}

	function fnPhFaxPgMobValidation( e)
	{
		var n = fnGetKeyCode(e);
		//if (val.length == 0 && n == 32)
			//return false;
			
		if(fnValidateCommonKeys(n))
			return true;
		// Only the 0-9, (40, )41, +43, -45, /47, <60, >62, (< > For Extention Number), \92
		// these Characters are Allowed in the Amount Field
			if (!((n >= 48 && n <= 57) || (n == 40) || (n == 41) || (n == 43) || (n == 45) || (n == 47) || (n == 60) || (n == 62) || (n == 92)))
				return false;
		return true;
	}

	function fnEmailValidation(oBj) // oBj will be (document.frmSample.txtEmail)
	{
		var emailID = oBj.value;
		if (emailID != "")
		{
			//var mailPat = new RegExp("^[a-zA-Z0-9]{1,}[.]{0,}[_]{0,}[a-zA-Z0-9]{1,}[@][a-zA-Z0-9]{1,}[.][a-zA-Z0-9]{2,}[.]{0,}[a-zA-Z0-9]{0,}$")
			var mailPat = new RegExp(/^[a-zA-Z0-9._-]+@([a-zA-Z0-9.-]+\.)+[a-zA-Z0-9.-]{2,4}$/);
			if(!mailPat.test(emailID))
			{
				alert("Incorrect Email Address");
				oBj.focus();
				return false;
			}
			return true;
		}
		return true;
	}

	function fnGetKeyCode(e)
	{
		return (navigator.appName=="Netscape") ? e.which : event.keyCode;
	}

	function fnAmountValidation(val,e,str)
	{
		var n = fnGetKeyCode(e);
		
		if(fnValidateCommonKeys(n))
			return true;
			
		if ((n < 48 || n > 57 ) && (n != 46 ))
			return false;
			

			
		//if (n == 46) {
		    //var strvalue = document.getElementById(str).value;
			//firstindex = strValue.indexOf(".");
			//if (firstindex >= 0)
				//return false;
		//}
		return true;
	}

	function fnIntegerValidation(e)	
	{
	
		var n = fnGetKeyCode(e);
		if ((n == 8) || (n == 9) || (n==0))
			return true;
			
		if(fnValidateCommonKeys(n))
			return true;
			
		if ((n > 47 && n < 58) || n == 8 || n == 9)
			return true; 
			
        return false;
	}
	
	function fnURLValidation(val)	
	{
		//no validations for the time being.. will implement later - on!
		return true;
	}       

	function intValidation(val, e)
	{
		var n = fnGetKeyCode(e);
		//Only the 0-9, these Characters are Allowed in the Integer Field
		if(fnValidateCommonKeys(n))
			return true;
			
		if (!(n >= 48 && n <= 57)) 
		{
			alert("Enter proper Numeric Characters.");
			return false;
		}
		return true;
	}
	function intOnlyValidation(val, e)
	{
		var n = fnGetKeyCode(e);
		if(fnValidateCommonKeys(n))
			return true;		
		
		if (!(n >= 48 && n <= 57)) 
			return false;
		return true;
	}
	function fnPhoneValidation(valcode, valphone)
	{
		if ((valcode != "" && valcode !="--STD--" && valcode !="--STD") && (valphone != "" && valphone!="--PHONE--" && valphone!="--PHONE-"))
		{
			if(valcode.indexOf('0') == 0)
				valcode = valcode.substring(1,valcode.length);
			if(valcode.length + valphone.length != 10) 
			{
				alert("Please enter valid phone number");
				return false
			}
			else
				return true;
		}
		else
			return false;
	}
	
	function intValidationPrecision(val, e)
	{
		var n = fnGetKeyCode(e);
		
		if(fnValidateCommonKeys(n))
			return true;		
		//Only the 0-9, these Characters are Allowed in the Integer Field
		if (!((n >= 48 && n <= 57 ) || (n == 46)))
		{
			alert("Enter proper Numeric Characters(0-9) and precision.");
			return false;
		}
		return true;
	}

	function fnChangeToUCase(obj, formname)
	{
		//function to convert control value to upper case
		var objControl, strValue
		objControl=eval('document.'+formname+'.'+obj.name)
		strValue=objControl.value;

		strValue=strValue.toUpperCase();
		objControl.value=strValue;
	}

	function fnIPAddressValidation(val, e)
	{
		var n = fnGetKeyCode(e);
		
		if(fnValidateCommonKeys(n))
			return true;
			
		var i, intNoOfDots;
		intNoOfDots = 0;
		if (n <= 45 || n > 57 )
			return false;
		if (n == 46)
		{	
			for (i=0; i<val.length; i++)
			{
				if (val.charAt(i) == ".")
					intNoOfDots = intNoOfDots + 1;
			}
			if (intNoOfDots >= 3)
				return false;
		}
		return true;
	}
    function fnGetCurrentDate_DMY() //('dd-mm-yyyy') Added by Rupam CR 92 14/05/2008 
	{
		var strCurrentDate = new Date();
		strCurrentDate =strCurrentDate.getDate()+"-"+(strCurrentDate.getMonth()+1)+"-"+strCurrentDate.getFullYear();
		return 	strCurrentDate;		
	}
	function fnGetCurrentDateOnly()
	{
		var strCurrentDate = new Date();
		strCurrentDate = new Date(strCurrentDate.getFullYear(),strCurrentDate.getMonth(),strCurrentDate.getDate());
		return 	strCurrentDate;		
	}

	function fn_DMY_TO_MDY(strDate, Seperator)
	{
		var arrstrDate = strDate.split(Seperator); 
		strDate	= arrstrDate[1]+Seperator+arrstrDate[0]+Seperator+arrstrDate[2];
		return strDate;	
	}
	function fn_DMY_TO_YMD(strDate, Seperator)
	{
		var arrstrDate = strDate.split(Seperator); 
		strDate	= arrstrDate[2]+Seperator+arrstrDate[1]+Seperator+arrstrDate[0];
		return strDate;	
	}
	function fn_SendingDate(strDate, Seperator)
	{
		var arrstrDate = strDate.split(Seperator); 
		strDate	= arrstrDate[2]+"-"+arrstrDate[1]+"-"+arrstrDate[0];
		return strDate;	
	}

   /*
	*********************************************************************
	Name		:	fnIs    
	Description:	Function to Check the Text Box is Empty
	Input		:	strInput (Value to be Checked)
	Output		:	None
	return		:	Boolean
	*********************************************************************
	*/
	function fnIsEmpty(CntlName, LableName)
	{
		if( (fnTrim(CntlName.value) == "") || (fnTrim(CntlName.value) == "dd/mm/yyyy") )
		{
			alert( "Enter " + LableName);
			CntlName.focus();
			return false;
		}
		return true;
	}
	
	function fnIsEmptyCombo(CntlName, LableName)
	{
		if(CntlName != null && CntlName.selectedIndex > -1)
		{
			if(CntlName.options[CntlName.selectedIndex].value.trim() == "-1")
			{
				alert("Please Select " + LableName);
				CntlName.focus();
				return false;
			}
		}
		else
		{
			alert("Please Select " + LableName);
			CntlName.focus();
			return false;
		}
		return true;
	} 

	 /*
	*********************************************************************
	Name		:	fnTextAreaLength
	Description:	Function to Check the maxlength of textarea.
	Event		:   onblur
	Input		:	strInput (Value to be Checked)
	Output		:	None
	return		:	true/false
	*********************************************************************
	*/	
	
	function fnTextAreaLength(CntlName,LableName,Length,e)
	{
		CntlName.value = CntlName.value.trim();
		var n = fnGetKeyCode(e);

		if(fnValidateCommonKeys(n))
			return true;
					
		if ((n == 8) || (n == 9) || (n==0))
			return true;
			
		if(fnTrim(CntlName.value).length > Length)
		{
			alert("Please Enter " + LableName  + " upto "+ Length +" Characters");
			CntlName.focus();
			return false;
		}
		else
			return true;
	} 	
	
	function Validate_TextArea(source,value) 
	{
		str = value.Value;
		str = strtrim(str);
		
		
		if ( str.length > 2500 || str.length< 5 )
			value.IsValid = false;
		else
			value.IsValid = true;
	}

	/*
	*********************************************************************
	Name		:	Debug
	Description :	Displays error in the new window where the error is TOO LARGE to be seen the alert window.
	Input		:	string message
	Output		:	undefined
	return		:	undefined
	*********************************************************************
	*/	
	function Debug(strValue)
	{
		var mWinOpen = window.open('','','width=500,height=300,status=no,toolbar=no,menubar=no,scrollbars=yes,resizable=yes,left=160,top=100');
		mWinOpen.document.write(strValue);
		mWinOpen.document.close();
	}

	function MemberidValidation(e)
	{
		var n = fnGetKeyCode(e);
		
		if(fnValidateCommonKeys(n))
			return true;		
		// Only the A-Z, a-z, 0-9, spaces, and -
		// these Characters are Allowed in the Description Fields
		if(!((n>=65 && n<=90)||(n>=97 && n<=122)||(n>=48 && n<=57)||(n==32)|| (n == 45)))
			return false;
		return true;
	}

	function fnDateAdd(mDatePart , mNumber, mDate)
	{
		//var xml = clienCallback("Date", "DateAdd|"+mDatePart+"|"+mNumber+"|"+mDate+"|");
		//return xml.responseText;
		
		var arrDate = mDate.split("/");	
		var dt = new Date(fnCInt(arrDate[2]), fnCInt(arrDate[1])-1, fnCInt(arrDate[0]));
		
		if (mDatePart.toLowerCase() == 'd')
			return dt.addDays(mNumber).toDateFormat('dd/MM/yyyy');
		else if (mDatePart.toLowerCase() == 'm')
			return dt.addMonths(mNumber).toDateFormat('dd/MM/yyyy');
		else if (mDatePart.toLowerCase() == 'y')
			return dt.addYears(mNumber).toDateFormat('dd/MM/yyyy');
		else
			return dt.toDateFormat('dd/MM/yyyy');
	}
	
	/*This function returns Date Difference by days, month and year which are separated by pipe*/
	function fnDateDiffAll(mNumber, mDate)
	{
		var xml = clienCallback("Date", "DateDiffAll|"+mNumber+"|"+mDate+"|");
		return xml.responseText;
	}
	/*End of function fnDateDiffAll*/
	
	function fnDateDiff(mDatePart, mStartDate, mEndDate)
	{
		//var xml = clienCallback("Date", "DateDiff|"+mDatePart+"|"+mStartDate+"|"+mEndDate+"|");
		//return xml.responseText;
		
		var arrDate = mStartDate.split("/");
		var stdt = new Date(fnCInt(arrDate[2]), fnCInt(arrDate[1])-1, fnCInt(arrDate[0]));
	
		var arrDate = mEndDate.split("/");
		var endt = new Date(fnCInt(arrDate[2]), fnCInt(arrDate[1])-1, fnCInt(arrDate[0]));

		return endt.subtract(stdt).dateDiff(mDatePart);
	}
	
	/* Accept Textfield Object */
	function isValidDate(mDate) 
	{
		//dateStr = mDate.value;
		dateStr = fnReplace(mDate.value, "-", "/");
		if (dateStr == "dd/mm/yyyy" || dateStr == "")
		{
			//To assign the value to the object as "dd/mm/yyyy"
			mDate.value = "dd/mm/yyyy";
			return true;
		}
		// Checks for the following valid date formats:
		// MM/DD/YY   MM/DD/YYYY   MM-DD-YY   MM-DD-YYYY
		// Also separates date into month, day, and year variables

		var datePat1 = /^(\d{1,2})(\/|-)(\d{1,2})\2(\d{2}|\d{4})$/;

		// To require a 4 digit year entry, use this line instead:
		//var datePat = new RegExp("^[0-9]{1,2}[/]{1,1}[0-9]{1,2}[/]{1,1}[0-9]{2,4}$"); // do  not delete
		
		//This expression is to be added rather than the one using
		//Added on 05th December 2006
		var datePat = new RegExp("^[0-9]{1,2}[/]{1,1}[0-9]{1,2}[/]{1,1}([0-9]{2}|[0-9]{4})$"); 
		if(!datePat.test(dateStr))
		{
			alert("Date is not in a valid format.");
			mDate.value = "";
			mDate.focus();
			return false;
		}

		var matchArray = dateStr.match(datePat1); // if the format is ok.

		month = matchArray[3]; // parse date into variables
		day = matchArray[1];
		year = matchArray[4];

		if (month < 1 || month > 12) 
		{ // check month range
			alert("Month must be between 1 and 12.");
			return false;
		}
		if (day < 1 || day > 31) 
		{
			alert("Day must be between 1 and 31.");
			return false;
		}
		if ((month==4 || month==6 || month==9 || month==11) && day==31) 
		{
			alert("Month "+month+" doesn't have 31 days!")
				return false
				}
		if (month == 2) 
		{ // check for february 29th
			var isleap = (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0));
			if (day>29 || (day==29 && !isleap)) 
			{
				alert("February " + year + " doesn't have " + day + " days!");
				return false;
			}
		}
		month = "0"+month;
		month = month.substring(month.length-2,month.length)
			day = "0"+day;
		day = day.substring(day.length-2,day.length)
			year = "20" + year;
		year = year.substring(year.length-4,year.length)
		mDate.value = day + "/" + month + "/" + year;
		
		return true;  // Added by Deepak on 12-08-2006
	}
	
	function fnPasswordValidation(mObject)
	{
		var valid = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ~!@#$%^&*";

		for (var i=0; i<=mObject.value.length; i++) 
		{
			if (valid.indexOf(mObject.value.charAt(i)) < 0) 
			{
				alert("Your password contains invalid characters");
				mObject.focus();
				return false;
			}
		}
		return true;
	}

	// Fucntion to validate Date with lable
	function isValidDateCommon(mDate,mLabel) 
	{
		dateStr = fnReplace(mDate.value, "-", "/");
		if (dateStr == "dd/mm/yyyy" || dateStr == "")
		{
			//To assign the value to the object as "dd/mm/yyyy"
			mDate.value = "dd/mm/yyyy";
			return true;
		}
		if (dateStr!='')
		{

			// Checks for the following valid date formats:
			// MM/DD/YY   MM/DD/YYYY   MM-DD-YY   MM-DD-YYYY
			// Also separates date into month, day, and year variables

			var datePat1 = /^(\d{1,2})(\/|-)(\d{1,2})\2(\d{2}|\d{4})$/;

			// To require a 4 digit year entry, use this line instead:
			
			//var datePat = new RegExp("^[0-9]{1,2}[/]{1,1}[0-9]{1,2}[/]{1,1}[0-9]{2,4}$"); // do  not delete\
			
			
			//This expression is to be added rather than the one using
			//Added on 05th December 2006
			var datePat = new RegExp("^[0-9]{1,2}[/]{1,1}[0-9]{1,2}[/]{1,1}([0-9]{2}|[0-9]{4})$"); 
			if(!datePat.test(dateStr))
			{
				alert("Please enter " + mLabel + " in dd/mm/yyyy format")
				mDate.value="";
				mDate.focus();
				return false;
			}
			
			var matchArray = dateStr.match(datePat1); // if the format is ok.

			month = matchArray[3]; // parse date into variables
			day = matchArray[1];
			year = matchArray[4];

			if (month < 1 || month > 12) 
			{ // check month range
				alert("Month must be between 1 and 12.");
				mDate.value="";
				mDate.focus();
				return false;
			}
			if (day < 1 || day > 31) 
			{
				alert("Day must be between 1 and 31.");
				mDate.value="";
				mDate.focus();
				return false;
			}
			if ((month==4 || month==6 || month==9 || month==11) && day==31) 
			{
				alert("Month "+month+" doesn't have 31 days!")
				mDate.value="";
				mDate.focus();
				return false
			}
			if (month == 2) 
			{ // check for february 29th
				var isleap = (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0));
				if (day>29 || (day==29 && !isleap)) 
				{
					alert("February " + year + " doesn't have " + day + " days!");
					mDate.value="";
					mDate.focus();
					return false;
				}
			}
			month = "0"+month;
			month = month.substring(month.length-2,month.length)
			day = "0"+day;
			day = day.substring(day.length-2,day.length)
			year = "20" + year;
			year = year.substring(year.length-4,year.length)
			mDate.value = day + "/" + month + "/" + year;
			return true;
		}
		return false;
	}
	
	// Fucntion for Lombard Specal chars  +,|,# and & 
	
	function isLombardSpecialChars(strValue, e)
	{
		var n = fnGetKeyCode(e);
		
		if(fnValidateCommonKeys(n))
			return true;		
		//   37 %, 34 ", 42 *, 59 ;, 45 --, 60 <, 62 >, 35 # , 124 |, 43 + , 38 & , 39 '
		// First Character of Can not be a Blank Space
		if ((strValue.length == 0) && (n == 32))
			return false;
			
		if(strValue.length >=1)
		{
			if(n == 45 && strValue.substring(strValue.length -1, strValue.length) == "-")
				return false;
		}
		if (n == 37 || n == 34 || n == 42 || n == 59 || n == 60 || n == 62 || n == 35 || n == 124 || n == 43 || n == 38 || n == 39)
			return false;
			
		return true;
	}
	
	function fnGenericValidation(strvalue)
	{
	
	}
	
	
	// Fucntion to validate MonthYear with lable (mm/yyyy)
	function isValidDateCommonMonthYear(mDate,mLabel) 
	{
		dateStr = fnReplace(mDate.value, "-", "/");
		
		if (dateStr == "dd/mm/yyyy" || dateStr == "")
		{
			alert(mLabel + " is Blank.")
			//mDate.focus();
			return false;
		}

		if (dateStr!='')
		{
			// Checks for the following valid date formats:
			// MM/DD/YY   MM/DD/YYYY   MM-DD-YY   MM-DD-YYYY
			// Also separates date into month, day, and year variables
			var datePat1 = /^(\d{1,2})(\/|-)(\d{1,2})\2(\d{2}|\d{4})$/;
			// To require a 4 digit year entry, use this line instead:

			var datePat = new RegExp("^[0-9]{1,2}[/]{1,1}[0-9]{1,2}[/]{1,1}[0-9]{2,4}$"); // do  not delete

			dateStr = '01/'+ dateStr;

			if(!datePat.test(dateStr))
			{
				alert(mLabel + " is not in a valid format.")
				mDate.value="";
				mDate.focus();
				return false;
			}
			var matchArray = dateStr.match(datePat1); // if the format is ok.
			// An IF Condition is given for checking the MatchArray (format is ok) is not null... --- ADDED BY GIRISHANKAR
			if(matchArray !=null)
			{
				month = matchArray[3]; // parse date into variables
				day = matchArray[1];
				year = matchArray[4];
			
				if (month < 1 || month > 12) 
				{ // check month range
					alert("Month must be between 1 and 12.");
					mDate.value="";
					mDate.focus();
					return false;
				}
				if (day < 1 || day > 31) 
				{
					alert("Day must be between 1 and 31.");
					mDate.value="";
					mDate.focus();
					return false;
				}
				if ((month==4 || month==6 || month==9 || month==11) && day==31) 
				{
					alert("Month "+month+" doesn't have 31 days!")
					mDate.value="";
					mDate.focus();
						return false
				}
				if (month == 2) 
				{ // check for february 29th
					var isleap = (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0));
					if (day>29 || (day==29 && !isleap)) 
					{
						alert("February " + year + " doesn't have " + day + " days!");
						mDate.value="";
					mDate.focus();
						return false;
					}
				}
				month = "0"+month;
				month = month.substring(month.length-2,month.length)
				day = "0"+day;
				day = day.substring(day.length-2,day.length)
				year = "20" + year;
				year = year.substring(year.length-4,year.length)
				mDate.value = month + "/" + year;
			}//if(matchArray !=null)
			else
			{
				return false;
			}//if(matchArray !=null)
			
			// An IF Condition is given for checking the MatchArray (format is ok) is not null... --- ADDED BY GIRISHANKAR
			return true;
		}
		
	}
	
	/* Will accept date format as "DD/MM/YYYY" */
	function fnDisplayDateFormat(DataString)
	{
		var	monthName =	new	Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec")
		var arrDataString = DataString.split("/");
		return arrDataString[0] +"-"+  monthName[parseFloat(arrDataString[1])-1] +"-"+ arrDataString[2];
	}
	
	
	
	/* *************************************************************************************************************** */
	function fnAlphaCharactersValidation(val, e)
	{
		var n = fnGetKeyCode(e);
		
		if(fnValidateCommonKeys(n))
			return true;		
		// First Character of Addresss Can not be a Blank Space
		if ((val.length == 0) && (n == 32))
			return false;
		//Only the A-Z, a-z, 
		//'' NOTE - This function will NOT allow to enter spaces (ascii=32) into the Name Fields
		if (!((n >= 65 && n <= 90) || (n >= 97 && n <= 122)) ) 
			return false;
		return true;
	}   

	/*
	To Restrict the user from Copy-Paste
	*/
	function fnOnPaste()
	{
		//for IE
		event.returnValue = false;
	}
	
	/* This is use for EMI */
	//function fnSetEmiValue(mObject, mEMIValue)
	function fnSetEmiValue(mTotalPremium, mEMIPeriod)
	{
	if((vDealNo=='False')||(vDealNo==null)||(vDealNo==""))   //cr-56 Added by sapna 24/04/2008
		{

			if (blnEMI)
			{
				var mEMIValue = parseInt(mTotalPremium)/mEMIPeriod;
				
				if (parseFloat(mTotalPremium) >= 1500)
					document.getElementById('lblEMIDetails').innerHTML = "Interest free EMI Rs."+ fnFormatCurrency(fnFormatNumber(mEMIValue,0)).trim().replace(".00","") +" for 12 months on ICICI Bank Credit Card";
				else
					document.getElementById('lblEMIDetails').innerHTML = "";
			}
		}
		else
		{
			document.getElementById('lblEMIDetails').innerHTML = "";
		}
	}
	// Added By Rupam For CR-134 Date 11/07/08
	function fnSetEmiValueForHealth(mTotalPremium, mEMIPeriod)
	{
		
	if((vDealNo=='False')||(vDealNo==null)||(vDealNo==""))   
		{
			if (blnEMI)
			{
				
				var mEMIValue = parseInt(mTotalPremium)/mEMIPeriod;
				
				if (parseFloat(mTotalPremium) >= 1500)
					document.getElementById('lblEMIDetails').innerHTML = "<span style='font-size :18pt'>Interest free EMI of Rs. "+ fnFormatCurrency(fnFormatNumber(mEMIValue,0)).trim().replace(".00","") +" for 12 months<FONT SIZE=6 STYLE='font-size: 11pt'><b>&nbsp;(on ICICI Bank Credit Cards)</font></span></b>";
					
					
				else
					document.getElementById('lblEMIDetails').innerHTML = "";
					
					
			}
		}
		else
		{
			document.getElementById('lblEMIDetails').innerHTML = "";
			
		}
	}
	
	/* This is use for Validate Dely Address  42 */
	function fnValidateNRIDelyAddress()
	{
		var retDely;
		retDely = fnIsEmpty(document.getElementById('txtDeliverAdd'), 'Delivery Address')
		if (retDely == true )
			retDely = fnIsEmpty(document.getElementById('txtDeliverCity'), 'Delivery City')
		if (retDely == true )
			retDely = fnIsEmpty(document.getElementById('txtDeliverState'), 'Delivery State')
		
		if (retDely == true )
			retDely = fnIsEmptyCombo(document.getElementById('ddlDeliverCountry'), 'Delivery Country')
		if (retDely == true )
			retDely = fnIsEmpty(document.getElementById('txtDeliverZipcode'), 'Zipcode')
			//CR-108
		if (retDely == true && document.getElementById('txtDeliverPhoneNo')!=null)
			retDely = fnIsEmpty(document.getElementById('txtDeliverPhoneNo'), 'Contact No.')
			//
		if (retDely == true )
				return true;					
			else
				return false;
	}
		
	function fnAlphNumericValidation(Val, e)
	{
		var n = fnGetKeyCode(e);
		
		if(fnValidateCommonKeys(n))
			return true;		
		//alert("N:"+n);
		// First Character of Addresss Can not be a Blank Space
		if ((n == 8) || (n == 9) || (n==0))
			return true;
			
		if ((Val.length == 0) && (n == 32))
			return false;
		//Only the A-Z, a-z, 
		if (!((n >= 65 && n <= 90) || (n >= 97 && n <= 122) || (n >= 48 && n <= 57)) ) 
			return false;
		return true;
	}
		
	function fnSetDOBAttribute(mObject, mLoginID, mRelationFor)
	{
		var xml = clienCallback("Combo", mLoginID+"|"+mRelationFor+"|");
		var Models = xml.responseText;
		var modelArray = Models.split("#@!");
		
		var i = 0;
		mObject.length = modelArray.length;
		mObject.options[0].value = "-1";
		mObject.options[0].text  = "--Select--";
		mObject.options[0].dob = "";
		
		for(var i=1; i < modelArray.length; i++)
		{
			arr = modelArray[i-1].split("|");
			mObject.options[i].value = arr[0];
			mObject.options[i].text  = arr[1];
			mObject.options[i].dob = arr[2];
			mObject.options[i].name = arr[3];
		}
	}
	
	function fnFillCombo(mObject, spName, param)
	{

		var xml = clienCallback("FillDropDown", spName+"|"+param+"|");
		var Models = xml.responseText;
		if(Models != "")
		{
			var modelArray = Models.split("#@!");
			
			var i = 0;
			mObject.length = modelArray.length;
			mObject.options[0].value = "-1";
			mObject.options[0].text  = "--Select--";
			mObject.options[0].dob = "";
			for(var i=1; i < modelArray.length; i++)
			{
				arr = modelArray[i-1].split("|");
				mObject.options[i].value = arr[0];
				mObject.options[i].text  = arr[1];
			}
			return true;
		}
		else
		{
			return false;
		}
	}
	
	function fnClearCombo(mObject,strVal,strDesc)
	{
		var noitems=0;
		noitems = mObject.length;
		
		//for(var i=0;i<=noitems;i++)
		var i = 0;
		while(mObject.length != 0)
			mObject.remove(i);

		//Cross Browser - 09-May-2007  - Manoj
		
		/*
		var oOption = document.createElement("OPTION");
		oOption.value = strVal;
		oOption.text  = strDesc;
		mObject.add(oOption);
		*/
			
		mObject.length = 1;	
		mObject.options[0].value = strVal;
		mObject.options[0].text  = strDesc;
		//
		return "";
	}

	function fnTxtMinLen(Ctrl,CharLength, ForCtrl)
	{

		var Ctrlval=Ctrl.value;	
		if(Ctrlval.length<CharLength)
		{
			alert("Please Enter Min " + CharLength + " Characters "+ForCtrl);
			Ctrl.focus();
			return false;
		}	
		return true;	
	}

	function fnNameValidate(val, e)
	{
		var n = fnGetKeyCode(e);
		
		if(fnValidateCommonKeys(n))
			return true;		
		//this fun will allow to enter only a-z,A-Z,',.,/ and space values into the name	
		if((n>=65 && n<=90) || (n>=97 && n<=122) ||(n==32) ||(n==39)||(n==47)||(n==39) ||(n==46))// || (n>=97 && n<=122))
			return true;
		return false;
	}

	function DeleteText(CntlName,CntlValue)	
	{
		var docElemt = eval("document.forms[0]."+CntlName);
		CntlValue = CntlValue.substring(0,2);
		if(CntlValue =="--")
			docElemt.value = "";
	}
	
	function fnYesNo(mPar)
	{
		if ((mPar == "N") || (parseInt(mPar) == 0))
			return "No";
		else
			return "Yes";
	}
	
	
	function isLombardPasswordChars(strValue, e)
	{
		var n = fnGetKeyCode(e);
		
		if(fnValidateCommonKeys(n))
			return true;		
		//64@ , 35# , 36$ , 38 & , 37%
		// First Character of Can not be a Blank Space
		if ((strValue.length == 0) && (n == 32))
			return false;
		if (n == 38 || n == 36 || n == 37)
			return false;
		return true;
	}
	
	function fnWindowPopUPOpen(URL)
	{
		window.open(URL,'Project10','width=800,height=600,status=yes,toolbar=no,menubar=no,scrollbars=yes,left=160,top=100');
	}
	
	//CR Health Renewals Sumit Begins Here
	function fnWindowPopUPOpenHealthOffline(URL)
	{
		window.open(URL,'CustomerCare','width=700, height=350, menubar=no, resizable=no');
	}
	//CR Health Renewals Sumit Ends Here

	function fnWindowPopUPOpenResizable(URL)
	{
		window.open(URL,'Project10','width=800,height=600,status=yes,toolbar=no,menubar=no,scrollbars=yes,resizable=yes,left=160,top=100');
	}
		
	function fnSetSelectedText(mObject, val)
	{
		for (var i=0;i<mObject.length;i++)
		{
			if (mObject.options[i].text.toLowerCase() == val.toLowerCase())
				mObject.selectedIndex = i;
		}
	}
	
	function fnSetSelectedValue(mObject, val)
	{
		for (var i=0;i<mObject.length;i++)
		{
			if (mObject.options[i].value.toLowerCase() == val.toLowerCase())
				mObject.selectedIndex = i;
		}
	}
	
// Function that allow only letters, number and space

	function fnAlphNumericSpaceValidation(Val, e)
	{
		var n = fnGetKeyCode(e);
		
		if(fnValidateCommonKeys(n))
			return true;		
		// First Character of Addresss Can not be a Blank Space
		if ((Val.length == 0) && (n == 32))
			return false;

		//Only the A-Z, a-z, 
		if (!((n >= 65 && n <= 90) || (n >= 97 && n <= 122) || (n >= 48 && n <= 57) || (n == 32)) ) 
			return false;

		return true;
	}
	
// ---- This Function is used to Validate the Name Characters to be Entered in the Application
	function fnNameValidationWithOutHypehen(val, e)
	{ 
		var n = fnGetKeyCode(e);
		
		if(fnValidateCommonKeys(n))
			return true;		
		// First Character of Name Can not be a Blank Space
		if ((n == 8) || (n == 9) || (n==0))
			return true;
			
		if ((val.length == 0) && (n == 32))
			return false;

		// Only the A-Z, a-z,(, ), .,0-9,
		// These Characters are allowed in the Name also comma is NOT allowed.
		// NOTE - This function will NOT allow to enter spaces (ascii=32) into the Name Fields
		if (!( (n >= 65 && n <= 90) || (n >= 97 && n <= 122) || (n == 40) || (n == 41)|| (n == 46) || (n == 3) || (n == 22) || (n == 24) || (n == 32) ))	
			return false;
		else
		{
			if (n == 35 || n == 124 || n == 43 || n == 38 || n == 39 || n == 64 )
				return false;
		}
	}


	function fnFinancerAddressValidation(val, e)
	{
		var n = fnGetKeyCode(e);
		
		if(fnValidateCommonKeys(n))
			return true;	
				
		if ((n == 8) || (n == 9) || (n==0))
			return true;
			
		// This Function is used to Validate the Address Characters to be Entered 
		// First Character of Addresss Can not be a Blank Space
		if ((val.length == 0) && (n == 32))
			return false;
		// Only the A-Z, a-z, 0-9, spaces, hypen
		if  (!( (n >= 65 && n <= 90)   || (n >= 97 && n <= 122) ||(n == 32) || (n == 45) || (n == 44) || (n == 47) ||(n == 13)))
			return false;
		return true;
	}
	
	function fnOtherDiseaseValidation(val, e)
	{
		var n = fnGetKeyCode(e);
		
		if(fnValidateCommonKeys(n))
			return true;		
			
		if ((n == 8) || (n == 9) || (n==0))
			return true;
			
		if ((val.length == 0) && (n == 32))
			return false;

		if(!((n == 32) || (n >= 65 && n <= 90) || (n >= 97 && n <= 122) || (n == 44)))
			return false;
		return true;
	}
	
						
	function fnSetSelectedvalue(mObject, val)
	{
		for (var i=0;i<mObject.length;i++)
		{
			if (mObject.options[i].text == val)
				mObject.selectedIndex = i;
		}
	}		
	
	/* Added By Albert 14-12-2006 */
	function calcHeight()
	{
		var mWidth = document.body.scrollWidth + 4;
		var mHeight = document.body.scrollHeight + 5;
		//alert(mWidth + " X " + mHeight);
		self.resizeTo(mWidth, mHeight);
	}
	
	function fnValidateDateInput(strValue, e)
	{
		var n = fnGetKeyCode(e);
		
		if(fnValidateCommonKeys(n))
			return true;		
		//alert("n:"+n);
		//   37 %, 34 ", 42 *, 59 ;, 45 --, 60 <, 62 >, 35 # , 124 |, 43 + , 38 & , 39 ' , 64 @
		// First Character of Can not be a Blank Space
		//if ((n > 47 && n < 58) || n == 35 || n == 36 || n == 46 || n == 8 || n == 9)
		if ((n == 8) || (n == 9) || (n==0))
			return true;
			
		if ((strValue.length == 0) && (n == 32))
			return false;

		if(strValue.length >1)
		{		
			if(n == 45 && strValue.substring(strValue.length -1, strValue.length) == "-")
				return false;
		}
		if (!(n >=47 && n <= 57))
			return false;

		return true;
	}
	
	function fnPolicyNoValidation(e)
	{
		var n = fnGetKeyCode(e);
		
		if(fnValidateCommonKeys(n))
			return true;		
			
		if((n>=65 && n<=90)||(n>=97 && n<=122))
			return true;
		else if((n>=48 && n<=57)  || (n == 47) || (n == 45))
			return true;		
		else
			return false;
	}
	function fnRedirectPage(mUrl, mFrom, mDealNo)
	{
		if (mFrom == "Y")
		{
			lomwin = window.open(mUrl,'lomwin','top=5,left=5,width=' + (parseInt(screen.width) - 6) + ',height=' + (parseInt(screen.height) - 6) + ',toolbar=yes,location=yes,menubar=yes,scrollbars=yes,status=yes,resizable=yes');
			location.href = "../../../../Common/Empty.aspx?DealNo=" + mDealNo;
		}
		else
		{
			document.forms[0].action = mUrl;
			document.forms[0].submit();
		}
	}
	
	function fnGenderCheck(objGender,CustTitle)
	{
		if(CustTitle == "Mr")
			objGender.value = "Male";
		else
			objGender.value = "Female";
	}
	
	function fnValidateDepositAmt(DealNo, PremiumAmt)
	{
		/* Get data from the server(Ajax) */
		//params  = ""
		//<%=Session["DepositType"]%>
		//var DepositType ='<%=Session["DepositType"]%>';
		var xml = clienCallback("CHECKMBTBAL",DealNo + "|" + PremiumAmt + "|");
		var Models = xml.responseText;
		
		if(xml.status == '200' || xml.status == '0')
		{
			if (Models == '-2')
			{
				alert("Insufficent Balance");
				return false;
			}
			else if(Models == '-1' || Models == '1')
				return true;
		}

		return true;
	}
		

	/*function fnValidateDepositAmt(DealNo, PremiumAmt)
	{
		/* Get data from the server(Ajax) */
		//params  = ""
		//<%=Session["DepositType"]%>
	/*	if (DepositType == 'MBT')
		{
			//var DepositType ='<%=Session["DepositType"]%>';
			var xml = clienCallback("CHECKMBTBAL",DealNo + "|" + DepositType + "|" + PremiumAmt + "|");			
			var Models = xml.responseText;

			if(xml.readyState == 4 && (xml.status == 0 || xml.status == 200))
			{
				if (Models != '1')
				{
					alert("Transaction cannot be compeleted. Balance in account is Rs." + Models);
					return false;
				}
			}
			/*
			else
			{
				alert("Sufficient Balance");
				return false;
			}*/
	/*	}
	}*/
	
//<!-- Changed by Albert for Browser Compatibility -->
/* *** Taken from common-function.vbs ************** */
function fnFormatNumber(mValue, mDecimal)
{
	return mValue.formatNumber(mDecimal);
}
function fnFormatCurrency(mValue)
{
	return mValue.formatCurrency();
}
function fnReplace(mValue, findStr, replaceStr)
{
	//return mValue.replaceAll(findStr, replaceStr, false);
	return mValue.toString().replaceAll(findStr, replaceStr, false);
}
function fnValidateObject(mObject)
{
	return true;
}
function fnCInt(mValue)
{
	return new Number(mValue);
}
/* *** Ends ************** */

function fnValidateCommonKeys(keyCode)	
{
	if ((keyCode == 8) || (keyCode == 9) || (keyCode == 0))
		return true;
	else
	    return false;

	return true;
}
function fnIsCheckRadio(CntlName, LableName)
	{
		var retval = false;
		for(var i=0;i<CntlName.length;i++)
		{
			if(CntlName[i].checked)
			{
				retval = true;

				break;
			}
		}
		
		if(!retval)
		{
			alert("Please Select " + LableName);
		}
		
		return retval;
	} 
function fnLoginIdValidate(val, e)
{
	var n = fnGetKeyCode(e);
	
	if(fnValidateCommonKeys(n))
			return true;
	
	if(val.length<1)
	{
		if((n>=65 && n<=90) || (n>=97 && n<=122) )
		{
			return true;	
		}
		else
		{
			alert("First Character should be alphabatic for Login ID");
			return false;
		}	
	}
/*		if(val.indexOf('_') > 0 && n == 95)
	{
		return false;
	}
*/			
	if (!((n >= 48 && n <= 57) || (n >= 65 && n <= 90) ||
	(n >= 97 && n <= 122) ||(n==45) ||(n==95)) )
	{			
		return false;
	}		
}