/* NUMERIC CHECK */
/* Eg. numchk('Zip Code',document.form.text1,document.form.text1.value) */

function numchk(name,col,val)
{
	if (isNaN(val) == true)
	{
		alert("Enter the Numeric Value for " + name);
		col.focus();
		return false;
	}
	return true;
}

/*  NULL CHECK  */

/* Numeric check with allowing to enter '+','-','() */
function numspechk(name,col,val)
{
	if (isNaN(val) == true)
	{
		alert("Enter the Numeric Value for " + name);
		col.focus();
		return false;
	}
	return true;
}
/*  NULL CHECK  */
/* Eg. nullchk('Name',document.form.text1,document.form.text1.value) */

function nullchk(name,col,val)
{
	var j=0;
	len = val.length;
	for(i=0;i<len;i++)
	{
		if (val.substr(i,1) != " ")
		 j++;
	}
	if (j == 0)
	{
		alert("Please enter the " + name);
		col.focus();
		return false;
	}
	if (val == 0)
	{
		alert("Please enter the Value for " + name);
		col.focus();
		return false;
	}
	return true;
}

/*  NULL CHECK FOR LIST BOX  */
/* Eg. listchk('Name',document.form.text1,document.form.text1.value) */

function listchk(name,col,val)
{
	var j=0;
	len = val.length;
	for(i=0;i<len;i++)
	{
		if (val.substr(i,1) != " ")
		 j++;
	}
	if (j == 0)
	{
		alert("Please select the valid " + name);
		col.focus();
		return false;
	}
	if (val == 0)
	{
		alert("Please select the valid " + name);
		col.focus();
		return false;
	}
	return true;
}


/* Delete confirmation pass the parameter of document.formname */
/* Eg.  con(document.form) */
function con(frm)
{
	if (confirm("Are you sure you want to delete ?"))
	{
		return true; //frm.submit();
	}
	else
	{
			return false;
			//location.Replace("deluserprofile.asp")
	}
}


function con1(frm)
{
	if (confirm("Are you sure you want to Modify ?"))
	{
		return true; //frm.submit();
	}
	else
	{
		return false;
	}
}


/* Clear the Null value in Text Box */
/* Eg. nullclrchk(document.form.text1,document.form.text1.value) */

function nullclrchk(col,val)
{
	if((val == "NULL") || (val == 0) || (val =="null") || (val == " "))
	{
		col.value = ""
		return true;
	}
	return false;
}

/* Time validateion pass the parameter as name, column name, value */
/* Eg. timechk('Start Time',document.frmTest.txt1,document.frmTest.txt1.value)*/

function timechk(name,col,val)
{
	hr = val.substr(0,2)
	cen = val.substr(2,1)
	minu = val.substr(3,2)
	if(cen != ":")
	{
		alert("Enter the Time in HH:MM Format for " + name);
		col.focus();
		return false;
	}
	if( isNaN(hr) || (hr > 24) || (hr < 0))
	{
		alert("Enter the valid Hour for " + name);
		col.focus();
		return false;
	}
	if( isNaN(minu) || (minu > 60) || (minu < 0))
	{
		alert("Enter the valid Minute for " + name);
		col.focus();
		return false;
	}
	return true;
}


/* Date Validation pass the parameter of coloumn name and value for DOB */
/* Eg. datedob(document.form.text1,document.form.text1.value) */

 function opendialog1(strMsg)
    {
    var strLocation = document.location.href;
    var MemberUpdate = new RegExp('FrmUpdateMember');
    var PROUpdate = new RegExp('UpdatePRO');
    var Prospects = new RegExp('Prospects');
    
    if (MemberUpdate.test(strLocation)||PROUpdate.test(strLocation)||Prospects.test(strLocation))
    {
    ShowMessage(strMsg);
    }
    else
        {    
        var strPageurl;
        strPageurl = "Displaymsg.htm?Errmsg=" + strMsg;
        if (document.all)
        window.showModalDialog(strPageurl,'MsgWindow','dialogWidth:450px; dialogHeight:375px; status:0; toolbars:0; help:0; scroll:0;');
        else
        window.open(strPageurl,'MsgWindow','width=450,height=375,left=200,top=100,location=no,scrollbars=no,resizable=no,status=no,toolbars=no,menu=no');
        }
    }

function datechk(col,val)
{

	var dd=Number(new String(val.substr(0,2)));
	var slash1 = val.substr(2,1);
	var mm=Number( new String(val.substr(3,2)));
	var slash2 = val.substr(5,1);
	var yyyy = Number(new String(val.substr(6,4)));
	var present_dt=new Date();
	var StrMsg;
	var present_dt1=present_dt.getDate();
	var present_dt2=present_dt.getMonth();
	var present_dt3=present_dt.getFullYear();
		
	var present_mth=new Date();
	var present_yr = parseInt(present_dt.getFullYear()); 
	
		
	var variable_dt = new Date(yyyy, mm, dd) //, present_dt.getHours(), present_dt.getMinutes(),present_dt.getSeconds(),present_dt.getMilliseconds())
	for(var i=0;i<val.length;i++)
	{	
		if (val.substr(i,1) == " ")
		{
		StrMsg='Enter the Date in DD/MM/YYYY format';
       //opendialog1(StrMsg);

			alert("Enter the Date in DD/MM/YYYY format");
			col.focus();
			return false;
		}
	}
	if (isNaN(dd) || isNaN(mm) || isNaN(yyyy) || (slash1 != '/' || slash2 != '/') || (val.length != 10))
	{	
	StrMsg='Enter the Date in DD/MM/YYYY format';
        //opendialog1(StrMsg);
        
		alert("Enter the Date in DD/MM/YYYY format");
		col.focus();
		return false;
	}
	else if (dd <= 0 || dd > 31)
	{
	StrMsg='Enter the valid Day';
        //opendialog1(StrMsg);
        
		alert("Enter the valid Day");
		col.focus();
		return false;
	}
	
	else if (mm <= 0 || mm > 12)
	{	
	StrMsg='Enter a valid month';
       // opendialog1(StrMsg);
        
		alert("Enter a valid month ");
		col.focus();
		return false;
	}
	else if (yyyy < 0)
	{
	StrMsg='Enter the valid year';
        //opendialog1(StrMsg);
        
		alert("Enter the valid year");
		col.focus();
		return false;
	}
	else if(dd < check_Monthdays(mm, yyyy, 'dbegin') || dd > check_Monthdays(mm, yyyy,'dend'))
	{	
	StrMsg='Enter a proper day value';
        //opendialog1(StrMsg);
        
		alert("Enter a proper day value");
		col.focus();
		return false;
	}
	else if(yyyy < 1900)	
	{
	StrMsg='Enter a year greater than or equal to 1900';
        //opendialog1(StrMsg);
        
	   alert("Enter a year greater than or equal to 1900");
		col.focus();
		return false;
	}
//	else if (yyyy > present_yr)
//	{
//	StrMsg='Enter a year less than or equal to current year';
//        //opendialog1(StrMsg);
//        
//		alert("Enter a year less than or equal to current year");
//		col.focus();
//		return false;
//	}
	//else if (dd >= present_dt1 && mm >= present_dt2+1 && yyyy >= present_dt3)
	
//	if (yyyy >= present_dt3)
//	{
//	if (mm > present_dt2+1) 
//	{
//		StrMsg='Date should be less than or equal to current date';
//        //opendialog1(StrMsg);
//		alert("Date should be less than current date");
//		col.focus();
//		return false;
//	}
//	else if (mm == present_dt2+1 && dd > present_dt1)
//	    {
//		StrMsg='Date should be less than or equal to current date';
//        //opendialog1(StrMsg);
//		alert("Date should be less than current date");
//		col.focus();
//		return false;
//		}
//	}
	return true;
}																	

function datechk_FutureDateOnly(col,val)
{
	dd=Number(new String(val.substr(0,2)))
	slash1 = val.substr(2,1)
	mm=Number( new String(val.substr(3,2)))
	slash2 = val.substr(5,1)
	yyyy = Number(new String(val.substr(6,4)))
	present_dt=new Date()
	var StrMsg
	present_dt1=present_dt.getDate()
	present_dt2=present_dt.getMonth()
	present_dt3=present_dt.getFullYear()
		
	present_mth=new Date()
	present_yr = parseInt(present_dt.getFullYear()) 
	
			
	variable_dt = new Date(yyyy, mm, dd) //, present_dt.getHours(), present_dt.getMinutes(),present_dt.getSeconds(),present_dt.getMilliseconds())
	for(var i=0;i<val.length;i++)
	{	
		if (val.substr(i,1) == " ")
		{
		StrMsg='Enter the Date in DD/MM/YYYY format'
        opendialog1(StrMsg)

//			alert("Enter the Date in DD/MM/YYYY format");
			col.focus();
			return false;
		}
	}
	if (isNaN(dd) || isNaN(mm) || isNaN(yyyy) || (slash1 != '/' || slash2 != '/') || (val.length != 10))
	{	
	StrMsg='Enter the Date in DD/MM/YYYY format'
        opendialog1(StrMsg)
        
		//alert("Enter the Date in DD/MM/YYYY format");
		col.focus();
		return false;
	}
	else if (dd < 0 || dd > 31)
	{
	StrMsg='Enter the valid Day'
        opendialog1(StrMsg)
        
		//alert("Enter the valid Day");
		col.focus();
		return false;
	}
	
	else if (mm < 0 || mm > 12)
	{	
	StrMsg='Enter a valid month'
        opendialog1(StrMsg)
        
		//alert("Enter a valid month ");
		col.focus();
		return false;
	}
	else if (yyyy < 0 || yyyy < present_dt3)
	{
	StrMsg='Year should not be less than current year'
        opendialog1(StrMsg)
        
		//alert("Enter the valid year");
		col.focus();
		return false;
	}
	else if(dd < check_Monthdays(mm, yyyy, 'dbegin') || dd > check_Monthdays(mm, yyyy,'dend'))
	{	
	StrMsg='Enter a proper day value'
        opendialog1(StrMsg)
        
		//alert("Enter a proper day value");
		col.focus();
		return false;
	}
	
	return true;
}																	


 
function check_Monthdays(param1, param2, param3)					
{																	
	var mm = Number(new String(param1));
	var yyyy = Number(new String(param2));
	var mendday;
	if (mm == 4 || mm == 6 || mm == 9 || mm == 11)
	{																
		mendday = Number(new String('30'));
	}																
	else if (mm == 2)
	{																
		mendday = (eval(yyyy%4)==0) ? Number(new String('29')) : Number(new String('28'));
	}																
	else if (mm == 1 || mm == 3 || mm == 5 || mm == 7 || mm == 8 || mm == 10 || mm == 12)
	{																
		mendday = Number(new String('31'));							
	}																

	if (param3 == 'dbegin')											
		return Number(1);
	else															
		return Number(mendday);
}																	


function datedob(col,val)								
{
	check_col = new String(col)
	check_val = new String(val)
			
	present_dt=new Date()
	
	present_dt1=present_dt.getDate()
	present_dt2=present_dt.getMonth()
	present_dt3=present_dt.getFullYear()
		
	present_mth=new Date()
	present_yr = parseInt(present_dt.getFullYear()) 
	
	//dd=Number(new String(val.substr(0,2))-1)
	dd=Number(new String(val.substr(0,2)))
	slash1 = val.substr(2,1)
	mm=Number( new String(val.substr(3,2)))
	slash2 = val.substr(5,1)
	yyyy = Number(new String(val.substr(6,4)))
	
	variable_dt = new Date(yyyy, mm, dd) //, present_dt.getHours(), present_dt.getMinutes(),present_dt.getSeconds(),present_dt.getMilliseconds())	
	
	if (isNaN(dd) || isNaN(mm) || isNaN(yyyy) || (slash1 != '/' || slash2 != '/') || (check_val.length != 10))
	{	
		alert("Enter the Date in DD/MM/YYYY format");
		col.focus();
		return false;
	}
	else if (mm < 0 || mm > 12)
	{	
		alert("Enter a valid month ");
		col.focus();
		return false;
	}																
	else if(dd < check_Monthdays(mm, yyyy, 'dbegin') || dd > check_Monthdays(mm, yyyy,'dend'))
	{	
		alert("Enter a proper day value");
		col.focus();
		return false;
	}	
	else if (yyyy > present_yr)
	{
		alert("Enter a year less than or equal to current year");
		col.focus();
		return false;
	}
//      changed Aug 01'2002
//	    else if(mm > (present_dt2+1)){
//		alert("Enter a month less than or equal to current month");
//		col.focus();
//		return false;
//      }
	else if (dd >= present_dt1 && mm >= present_dt2+1 && yyyy >= present_dt3)
	{
		alert("Date should be less than current date");
		col.focus();
		return false;
	}	
	return true;
}																	


function datebtn(dd1,dd2,dd1nam,dd2col)
{ 
	if (!datechk(dd2col,dd1))
		return false;
	ddtoday = new Date()
	
	dd = dd1.substr(0,2)
	mm = dd1.substr(3,2)-1
	yyyy = dd1.substr(6,4)
	variable_dt1 = new Date(yyyy,mm,dd)
	
	if (dd2 == 'DOB')
	{
		var d
		d = new Date();
		dd = d.getDate();
		mm = d.getMonth();
		yyyy = d.getFullYear();
	}
	else
	{
		dd = dd2.substr(0,2)
		mm = dd2.substr(3,2)-1
		yyyy = dd2.substr(6,4)
		variable_dt2 = new Date(yyyy,mm,dd)	
		if (ddtoday > variable_dt2)
		{
			alert("The date should be the greater than today's Date");
			dd2col.focus();
			return false;
		}
	}	
	variable_dt2 = new Date(yyyy,mm,dd)

	
	if(variable_dt1 > variable_dt2)
	{
		if (dd2 == 'DOB')
			alert("Date of Birth should be less than Today's Date");
		else
			alert("The date should be the greater than " + dd1nam );
			
		dd2col.focus();
		return false;
	}
	
	return true;
}

/* E-Mail Check pass the parameter of coloumn name and value*/
/* Eg. emailchk(document.form.text1,document.form.text1.value) */

function emailchk(col,val)
{
	var emailPat=/^(.+)@(.+)$/
	var specialChars="\\(\\)<>@,;:\\\\\\\"\\.\\[\\]"
	var validChars="\[^\\s" + specialChars + "\]"
	var quotedUser="(\"[^\"]*\")"
	var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/
	var atom=validChars + '+'
	var word="(" + atom + "|" + quotedUser + ")"
	var userPat=new RegExp("^" + word + "(\\." + word + ")*$")
	var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$")
	var matchArray=val.match(emailPat)
	if (matchArray==null) 
	{
	StrMsg="Enter valid EmailID"
	
        opendialog1(StrMsg)
        
		//alert("E-mail address seems incorrect (check @ )");
		col.focus();
		return false;
	}
	var user=matchArray[1]
	var domain=matchArray[2]
	if (user.match(userPat)==null)
	{
	
	StrMsg="Enter valid EmailID"
        opendialog1(StrMsg)
        
	   //alert("The E-mail username doesn't seem to be valid.");
		return false;
	}
	var IPArray=domain.match(ipDomainPat)
	if (IPArray!=null) 
	{
		for (var i=1;i<=4;i++) 
		{
			if (IPArray[i]>255) 
			{
			
			StrMsg="Enter valid EmailID"
        opendialog1(StrMsg)
        
				//alert("Destination IP address is invalid!")
				col.focus();
				return false
			}
        }
		return true
	}
	var domainArray=domain.match(domainPat)
	if (domainArray==null) 
	{
	
	StrMsg="Enter valid EmailID"
        opendialog1(StrMsg)
        
		//alert("The domain name doesn't seem to be valid.")
		col.focus();
	    return false
	}
	var atomPat=new RegExp(atom,"g")
	var domArr=domain.match(atomPat)
	var len=domArr.length
	if (domArr[domArr.length-1].length<2 || domArr[domArr.length-1].length>3) 
	{
	
	StrMsg="Enter valid EmailID"
        opendialog1(StrMsg)
        
	  // alert("The address must end in a three-letter domain, or two letter country.")
	   col.focus();
	   return false
	}
	if (len<2) 
	{
	
	StrMsg="Enter valid EmailID"
        opendialog1(StrMsg)
        
	  // var errStr="This address is missing a hostname!"
	   //alert(errStr);
	   col.focus();
	   return false
	}
	return true;
}
//*******************************Included by vasanthi on 18/09/2007 for checking the date based on regional culture info
function checkdate(objName,Lang1) {
var datefield = objName;
if (chkdate(objName,Lang1) == false) {
datefield.select();
StrMsg='Date entered is invalid. Please try again.';
        opendialog1(StrMsg);
//alert("That date is invalid. Please try again.");
datefield.Value='';
//datefield.ClearSelection();
datefield.focus();
return false;
}
else {
return true;
}
}
function chkdate(objName,Lang1) {
var Lang= "BE" ; //document.getElementById(Lang1);
//alert(Lang.value);
//if(Lang.value=="en-us")
//{
//var strDatestyle = "US";//United States date style
//}
//else
//{
//var strDatestyle = "BE"; //FOR TESTING PURPOSE ONLY I HAVE HARD CODED(BCZ,CURRENT SCENARIO ONLY SUPPORT ENGLISH AND BELGIUM)
//}
var strDatestyle = "BE";
var strDate;
var strDateArray="";
var strDay;
var strMonth;
var strYear;
var intday;
var intMonth;
var intYear;
var booFound = false;
var datefield = objName;
//Commented by vasanthi on 22/09/2007 
//var strSeparatorArray = new Array("-"," ","/",".");
var strSeparatorArray = new Array("-","/",".");
var intElementNr;
var err = 0;
var strMonthArray = new Array(12);
strMonthArray[0] = "Jan";
strMonthArray[1] = "Feb";
strMonthArray[2] = "Mar";
strMonthArray[3] = "Apr";
strMonthArray[4] = "May";
strMonthArray[5] = "Jun";
strMonthArray[6] = "Jul";
strMonthArray[7] = "Aug";
strMonthArray[8] = "Sep";
strMonthArray[9] = "Oct";
strMonthArray[10] = "Nov";
strMonthArray[11] = "Dec";
strDate = datefield.value;
if (strDate.length < 1) {
return true;
}
for (intElementNr = 0; intElementNr < strSeparatorArray.length; intElementNr++) {
//alert(strSeparatorArray[intElementNr]);
//alert(strDate.indexOf(strSeparatorArray[intElementNr]));
if (strDate.indexOf(strSeparatorArray[intElementNr]) != -1)
 {
strDateArray = strDate.split(strSeparatorArray[intElementNr]);
}
}
if (strDateArray.length != 3) 
{
err = 1;
return false;
}
else
 {
strDay = strDateArray[0];
strMonth = strDateArray[1];
strYear = strDateArray[2];
}
booFound = true;
if (booFound == false) {
if (strDate.length>5) {
strDay = strDate.substr(0, 2);
strMonth = strDate.substr(2, 2);
strYear = strDate.substr(4);
}
}
if (strYear.length == 2) {
strYear = '20' + strYear;
}
// US style
if (strDatestyle == "US") {
strTemp = strDay;
strDay = strMonth;
strMonth = strTemp;
}
intday = parseInt(strDay, 10);
if (isNaN(intday)) {
err = 2;
return false;
}
intMonth = parseInt(strMonth, 10);
if (isNaN(intMonth))
 {
//for (i = 0;i<12;i++) 
//{
//if (strMonth.toUpperCase() == strMonthArray[i].toUpperCase())
// {
//intMonth = i+1;
//strMonth = strMonthArray[i];
//i = 12;
//}
//}
if (isNaN(intMonth)) {
err = 3;
return false;
}
}
intYear = parseInt(strYear, 10);
if (isNaN(intYear)) {
err = 4;
return false;
}
if (intMonth>12 || intMonth<1) {
err = 5;
return false;
}
if ((intMonth == 1 || intMonth == 3 || intMonth == 5 || intMonth == 7 || intMonth == 8 || intMonth == 10 || intMonth == 12) && (intday > 31 || intday < 1)) {
err = 6;
return false;
}
if ((intMonth == 4 || intMonth == 6 || intMonth == 9 || intMonth == 11) && (intday > 30 || intday < 1)) {
err = 7;
return false;
}
if (intMonth == 2) {
if (intday < 1) {
err = 8;
return false;
}
if (LeapYear(intYear) == true) {
if (intday > 29) {
err = 9;
return false;
}
}
else {
if (intday > 28) {
err = 10;
return false;
}
}
}
//if (strDatestyle == "US") {
//datefield.value = strMonthArray[intMonth-1] + " " + intday+" " + strYear;
//}
//else {
//datefield.value = intday + " " + strMonthArray[intMonth-1] + " " + strYear;
//}
return true;
}
function LeapYear(intYear) {
if (intYear % 100 == 0) {
if (intYear % 400 == 0) { return true; }
}
else {
if ((intYear % 4) == 0) { return true; }
}
return false;
}
//function doDateCheck(from, to) {
//if (Date.parse(from.value) <= Date.parse(to.value)) {
//StrMsg='That date is invalid. Please try again.'
//        opendialog1(StrMsg)
////alert("The dates are valid.");
//}
//else {
//if (from.value == "" || to.value == "")
//StrMsg='Both dates must be entered.'
//        opendialog1(StrMsg)
////alert("Both dates must be entered.");
//else
//StrMsg='To date must occur after the from date.'
//        opendialog1(StrMsg)
//alert("To date must occur after the from date.");
//}
//}
//*************Included by vasanthi on 18/09/2007 for restrict to enter characters and allowed only numeric and special characters(, and .)
function Decimal_amount_length_check(myField,Lang1)
{
var Lang=document.getElementById(Lang1);
var val=myField.value;
var l=myField.value.length;
if(Lang.value=="en-us")
    var dotind=val.indexOf('.');
else
    var dotind=val.indexOf(',');

if(dotind== -1)
    {
    if(l>16)
    {
    StrMsg='Amount Length Should Not Exceed 16.'
    opendialog1(StrMsg)
    return false;
    }
    }
else
    {
    var num=val.substring(dotind+1,l);
    if(num.length>16)
    {
    StrMsg='Amount Of The Whole Number Length Should Not Exceed 16.'
    opendialog1(StrMsg)
    return false;
    }
    }
    return true;
}

function currencyFormat(fld,Lang1,e)
 {
var Lang=document.getElementById(Lang1);
//alert(Lang.value);
if(Lang.value=="en-us")
{
milSep=",";
decSep=".";
}
else
{
milSep=".";
decSep=",";
}

var sep = 0;
var key = '';
var i = j = 0;
var len = len2 = 0;
//included - for negative payment  - 22-Sep-2007
var strCheck = '0123456789';
var aux = aux2 = '';
var neg ='-';
var whichCode = (window.Event) ? e.which : e.keyCode;
if (whichCode == 13) return true;  // Enter
key = String.fromCharCode(whichCode);  // Get key value from key code
if (strCheck.indexOf(key) == -1) return false;  // || ((neg.indexOf(key) == -1) && (fldvalue.indexOf('-')>0)) return false;  // Not a valid key
//negation 
len = fld.value.length;
for(i = 0; i < len; i++)
if ((fld.value.charAt(i) != '0') && (fld.value.charAt(i) != decSep)) break;
aux = '';
for(; i < len; i++)
if (strCheck.indexOf(fld.value.charAt(i))!=-1) aux += fld.value.charAt(i);
aux += key;
len = aux.length;
if (len == 0) fld.value = '';
if (len == 1) fld.value = '0'+ decSep + '0' + aux;
if (len == 2) fld.value = '0'+ decSep + aux;
if (len > 2) {
aux2 = '';
for (j = 0, i = len - 3; i >= 0; i--) {
if (j == 3) {
aux2 += milSep;
j = 0;
}
aux2 += aux.charAt(i);
j++;
}
fld.value = '';
len2 = aux2.length;
for (i = len2 - 1; i >= 0; i--)
fld.value += aux2.charAt(i);
fld.value += decSep + aux.substr(len - 2, len);
}
return false;
}
function currencyFormat2(fld,Lang1,e,c)
 {
//var Lang=document.getElementById(Lang1);
//alert(Lang.value);
//if(Lang.value=="en-us")
//{
//milSep=",";
//decSep=".";
//}
//else
//{
milSep=".";
decSep=",";
//}

var sep = 0;
var key = '';
var i = j = 0;
var len = len2 = 0;
//included - for negative payment  - 22-Sep-2007
if(c=='-')
var strCheck = '0123456789-,';
else
var strCheck = '0123456789,';


var whichCode = (window.Event) ? e.which : e.keyCode;
if (whichCode == 13) return true;  // Enter


key = String.fromCharCode(whichCode);  // Get key value from key code
len = fld.value.length;
var special ='-'
if (strCheck.indexOf(key) == -1) return false; 
if ((key == '-') && (len != 0)) 
return false;
if (len != 0)
{
if ((key == ',') && (fld.value.indexOf(',') != -1) ) return false; }
return true;
}


function currencyFormat3(fld,Lang1,e)
 {
var Lang=document.getElementById(Lang1);
//alert(Lang.value);
if(Lang.value=="en-us")
{
milSep=",";
decSep=".";
}
else
{
milSep=".";
decSep=",";
}

var sep = 0;
var key = '';
var i = j = 0;
var len = len2 = 0;
//included - for negative payment  - 22-Sep-2007
var strCheck = '0123456789';
var aux = aux2 = '';
var neg ='-';
var whichCode = (window.Event) ? e.which : e.keyCode;
if (whichCode == 13) return true;  // Enter

key = String.fromCharCode(whichCode);  // Get key value from key code
//negation 
len = fld.value.length;
if ((key == '-')  )
{
if (len != 0)
{
var negat = fld.value;
if (negat.indexOf('-') != -1) 
    return false;
else 
  {
  fld.value =  fld.value +'-';
  return false;
}
}
else
fld.value='-';
}
//negation
if (strCheck.indexOf(key) == -1) return false;  // || ((neg.indexOf(key) == -1) && (fldvalue.indexOf('-')>0)) return false;  // Not a valid key

for(i = 0; i < len; i++)
if ((fld.value.charAt(i) != '0') && (fld.value.charAt(i) != decSep)) break;
aux = '';
for(; i < len; i++)
if (strCheck.indexOf(fld.value.charAt(i))!=-1) aux += fld.value.charAt(i);
aux += key;
len = aux.length;
if (len == 0) fld.value = '';
if (len == 1) fld.value = '0'+ decSep + '0' + aux;
if (len == 2) fld.value = '0'+ decSep + aux;
if (len > 2) {
aux2 = '';
for (j = 0, i = len - 3; i >= 0; i--) {
if (j == 3) {
aux2 += milSep;
j = 0;
}
aux2 += aux.charAt(i);
j++;
}
fld.value = '';
len2 = aux2.length;
for (i = len2 - 1; i >= 0; i--)
fld.value += aux2.charAt(i);
fld.value += decSep + aux.substr(len - 2, len);
}
return false;
}

//*************
//*******************************

//****************Included by vasanthi on 28/09/2007 for trim the "_" from account number
function TrimUsingRecursion(strText) 
{
 var strReplaceAll = strText;
var intIndexOfMatch = strReplaceAll.indexOf( "_" );
while (intIndexOfMatch != -1)
{
strReplaceAll = strReplaceAll.replace( "_", "" )
intIndexOfMatch = strReplaceAll.indexOf( "_" );
}
 return strReplaceAll;
}

//****************

 function RegClose()
    {
 
       //window.opener.document.form1.submit();
       window.dialogArguments.document.form1.submit();
       self.close();
       return false;
 
    }
    