﻿
var vsHelpFileInfo = "1" //For Help
var vsHelpFileMode = "NEW" //For Help
var vsHelpScheduler="N"
var status ="Health Plan Systems"
//var msgDateFormat = "Please enter date in format: MM/DD/YYYY"
var msgDateFormat = "Format : MM/DD/YYYY"
var msgDateExceeds = "Date exceeds current date."
var msgPhoneFormat= "Format : 000-000-0000"
var msgFaxFormat= "Format : 000-000-0000"
var msgCellPhoneFormat= "Format: 000-000-0000"
var msgBeeperFormat= "Format: 000-000-0000"
var msgTaxFormat= "Format: 00-0000000"
var msgTaxSSNEINFormat= "Format: 000000000"
var msgSsnFormat = "Format: 000-00-0000"
var msgZipFormat = "Format: 00000-0000"
//var msgValidName = "Enter valid characters [Valid character set [A-Z],[a-z],space,comma,.,-,&]"
      /*
      Date			:	07/19/2004
      Name			:	siddiq
      Document Name	:	Insurance-Dental.doc
      BugID			:	Bug012
      Description	:	Full stop added and prompt (&) place altered
      */
var msgValidName = "Valid characters : [A-Z],[a-z],space,comma,full stop,&,hyphen."
var msgPersonName = "Valid characters : [A-Z],[a-z],space,',-"
var msgContactName = "Valid characters : [A-Z],[a-z],space,hyphen."
var msgValidAlphaNumeric="Valid characters : [A-Z],[a-z],[0-9]";
var msgEmailFormat="Invalid Email address."
var sMsgXMLErr = "The page has encountered an error. Please try again!!"
var sEmptyMessage = " is empty."
var sMsgNoEncounterPending = "No Encounters pending to be billed."
var sMsgDemoUser = "Demonstration only. Please contact support@hpsprof.2hps.com for details"
var msgNotValid="Not a valid"
var msgZero="Invalid number "
var msgSave="Saved successfully"
var msgDelete="Deleted successfully"
var msgUpdate="Updated successfully"
var msgErrorMessage="Do you want to cancel changes made (if any)?" 
var msgNotActivated= "Not Activated."
var msgNoPatients="No patient information available."
var msgPatientSelect="Select a patient."
var msgDiscountRateFormat="Format: 00.00"
var sMsgNoMatchPassword = "Password characters doesn't Match!!!"; //michael-08/04/2004

var sMsgInValidCCTrans = "Not a Valid Credit Card Payment! \nClick the button 'Credit Card Payment' to enter Credit Card Details and Process."; //michael-08/07/2004  

var sMsgNPIInvalid = "NPI Number Must be 10 digit with a vaild check digit"
var sMsgNPIInvalidFormat = "NPI Number should be 10 digits"

var sShowHideFields
sShowHideFields=""


/*---------------------------------------------------------------------------------------------------------------------
UDF:
FUNCTION NAME	-	vfnXMLCodeCheck
PURPOSE			-   To load Description when Code is chosen 
ARGUMENTS		-	Object of the Code, Object of description, string
RETURN VALUE	-   Nil
---------------------------------------------------------------------------------------------------------------------*/

// FUNCTION NOT USED 

function vfnXMLCodeCheck(objCode,objDesc,sMsg)
{
	if(objCode.value!="")
	{
		/*if(sMsg=="ICD" && objCode.value.length<=3)		
		{
			//alert("Invalid diagonis code.")
			//jayaraj 			
			alert("Invalid ICD Diagnosis Code. Enter full diagnosis Code.")			
			
			objDesc.value=""
			
			return false;
			
			fnSelectDescription(objCode,objDesc,'ICD','')
			
			//objCode.focus()
			return false;
		}*/
		
		var parser=new ActiveXObject("microsoft.xmldom")
		parser.async="false"
			
		parser.load("XMLCodeCheck.asp?Code=" + escape(objCode.value) + "&msg=" + sMsg)
		
		nodes = parser.documentElement.childNodes
		
		var Description = nodes.item(0).text
		
		if (nodes.item(0).text=="NA")
		{
			alert(sMsg+" Code not available in the list.")
			objDesc.value=""
			objCode.focus()
			objCode.select();
		}
		else
		{
			if(sMsg=="ICD") 
			{
				if(Description.indexOf("*")<0)
					objDesc.value=Description
				else
				{				
					//alert("Invalid ICD Diagnosis Code. Enter full diagnosis Code.")			
					alert("Invalid code. Enter/Select valid code.")			
					objDesc.value=""								
					fnSelectDescription(objCode,objDesc,'ICD','')
				}
			}
			else
			{
				objDesc.value=nodes.item(0).text
			}
			
		}
	}
}



/*---------------------------------------------------------------------------------------------------------------------
UDF:
FUNCTION NAME	-	vfnXMLCodeCheckNew
PURPOSE			-   To load Description when Code is chosen 
ARGUMENTS		-	
RETURN VALUE	-   Nil
---------------------------------------------------------------------------------------------------------------------*/

function vfnXMLCodeCheckNew(sCodeType, objQulaifier, objCode, objDesc, objFocus, sCheckFieldVal, sCodeName, sAddPractice,objSerDate) 
{

	if(objDesc.value!="Modifier not applicable")
	{
		 objDesc.value=""
	}
	if(sCodeName==null) sCodeName = sCodeType

	var sQulaifier
	vfnToUpper(objCode)

	if(sAddPractice==null) sAddPractice="" //JAN-3-2003 'Michael J Optioanl, used only in the function.
	
	if(objQulaifier==null || objQulaifier=="")
		sQulaifier = "";
	else if(objQulaifier=="ND" || objQulaifier=="HC" || objQulaifier=="ID")
		sQulaifier = objQulaifier
	else
		sQulaifier = objQulaifier.options[objQulaifier.selectedIndex].value;		

	if(objSerDate!=null)
	var sSerDate=objSerDate.value
			
	if(objCode.value!="")
	{
	
		if((sSerDate==null) || (sSerDate ==""))
			var sQueryString = "Code=" + escape(objCode.value) + "&msg=" + sCodeType + "&Qualifier=" + sQulaifier + "&qAddPractice=" + sAddPractice
		else
			var sQueryString = "Code=" + escape(objCode.value) + "&msg=" + sCodeType + "&Qualifier=" + sQulaifier + "&qAddPractice=" + sAddPractice + "&SerDate=" + sSerDate

		var parser=new ActiveXObject("microsoft.xmldom")
		parser.async="false"		
		//alert("XMLCodeCheck.asp?" + sQueryString)	
		//location.href="XMLCodeCheck.asp?" + sQueryString
		//return
		//alert("XMLCodeCheck.asp?" + sQueryString)
		parser.load("XMLCodeCheck.asp?" + sQueryString)
		nodes = parser.documentElement.childNodes

		var Description = nodes.item(0).text
		if (Description=="NA")
		{
			if(sCodeName!=null) 
				alert(sCodeName + " not available in the list.")
			else
				alert(sCodeType + " not available in the list.")
				
			objCode.focus()
			objCode.select()
		}
		else
		{
		
			if(sCodeType=="ICD" || sCodeType=="PROC") 
			{
				if(Description.indexOf("*")>=0)
				{
					alert("Invalid code. Enter/Select valid code.")			//alert("Invalid ICD Diagnosis Code. Enter full diagnosis Code.")								
					vfnShowSearch(sCodeType, objQulaifier, objCode, objDesc, null, "SHOW",sSerDate)//JAN-02-2003 'Michael J //Old fnSelectDescription(objCode,objDesc,'ICD','')
				}	
				//------------------------------------Confirm from User to add code to practice tables --------------
				else if(Description=="$ADD_PRACTICE?$")
				{
					if(confirm(sCodeName + " Code not available in Practice setup list!!. Do you want to add it to the list?")==true) //Call the function again
					{
						vfnXMLCodeCheckNew(sCodeType, objQulaifier, objCode, objDesc, objFocus, sCheckFieldVal, sCodeName, "Y",sSerDate) 
					}
					else
					{
						objCode.focus()
						objCode.select()
					}				
				}
				//------------------------------------Confirm from User to add code to practice tables --------------
				else
				{				
					objDesc.value=Description
				}
				
			}
			else
			{
				objDesc.value=nodes.item(0).text
			}
			
		}
	}
}

var agt = navigator.userAgent.toLowerCase()
var IsIE = (agt.indexOf('msie')!=-1)
var IsOpera = (agt.indexOf('opera')!=-1)
if(IsOpera==true) IsIE=false

//09-Mar-2006 Browser Compatible
var IsIEGrid = IsIE
if(IsOpera==true) IsIEGrid=true

document.onhelp = F1Help;	

	function F1Help()
	{	
        	
		vfnShowHelp()		
	    //vfnShowHelpFund()
		return false;
	}
	
function vfnHtmlEncode(s) {
        var str = new String(s);
        str = str.replace(/&/g, "&amp;");
        str = str.replace(/</g, "&lt;");
        str = str.replace(/>/g, "&gt;");
        str = str.replace(/"/g, "&quot;");
        return str;
} 

function vfnHtmlDecode(s) {
        var str = new String(s);
        str = str.replace("&amp;",/&/g);
			str = str.replace("&lt;",/</g);        
			str = str.replace("&gt;",/>/g);
        str = str.replace("&quot;",'"');
        return str;
} 


function vfnShowSearch(sCodeType, objQulaifier, objCode, objDesc, objFocus, sCheckFieldVal,objSerDate)
{
	 var ctlCode=objCode.name
	var ctlDesc=objDesc.name
	var ctlFocus, sQulaifier
	var Code=objCode.value
	var Desc=objDesc.value
	var SerDate=objSerDate.value
	
	if(objQulaifier==null || objQulaifier=="")
		sQulaifier = "";
	else if(objQulaifier=="ND" || objQulaifier=="HC" || objQulaifier=="ID")
		sQulaifier = objQulaifier
	else
		sQulaifier = objQulaifier.options[objQulaifier.selectedIndex].value;		
		
	if(objFocus==null) 
		ctlFocus="";
	else
		ctlFocus=objFocus.name;
	
	if(sCheckFieldVal=="DONTSHOW" || sCheckFieldVal.value=="") 	{}		 //Don't Open
	else if(sCheckFieldVal==null || sCheckFieldVal!="")//Do Open
	{
		if(SerDate==null)
			var qrystr="CodeType=" + sCodeType + "&Qualifier=" + sQulaifier + "&Code=" + Code + "&ctlCode=" + ctlCode + "&Desc=" + escape(Desc) + "&ctlDesc=" + ctlDesc + "&ctlFocus=" + ctlFocus		
		else
			var qrystr="CodeType=" + sCodeType + "&Qualifier=" + sQulaifier + "&Code=" + Code + "&ctlCode=" + ctlCode + "&Desc=" + escape(Desc) + "&ctlDesc=" + ctlDesc + "&ctlFocus=" + ctlFocus + "&SerDate=" + SerDate

//	  Gowrishankar - 06/30/2004
//	  window.open("SearchCodesWin.asp?"+qrystr,"SearchCodesWin","resize=1,toolbar=no,scrollbars=yes,menubar=no,height=500,width=730,top=20,left=30")
		window.open("SearchCodesWin.asp?"+qrystr+"&AnesSetup=YES","SearchCodesWin","resize=1,toolbar=no,scrollbars=yes,menubar=no,height=500,width=730,top=20,left=30")
	}	
}


function vfnNewSearch(sCodeType, objQulaifier, objCode, objDesc, objFocus, sCheckFieldVal,objSerDate)
{

	 var ctlCode=objCode.name
	var ctlDesc=objDesc.name
	var ctlFocus, sQulaifier
	var Code=objCode.value
	var Desc=objDesc.value
	var SerDate=objSerDate.value
	
	if(objQulaifier==null || objQulaifier=="")
		sQulaifier = "";
	else if(objQulaifier=="ND" || objQulaifier=="HC" || objQulaifier=="ID")
		sQulaifier = objQulaifier
	else
		sQulaifier = objQulaifier.options[objQulaifier.selectedIndex].value;		
		
	if(objFocus==null) 
		ctlFocus="";
	else
		ctlFocus=objFocus.name;
	
	if(sCheckFieldVal=="DONTSHOW" || sCheckFieldVal.value=="") 	{}		 //Don't Open
	else if(sCheckFieldVal==null || sCheckFieldVal!="")//Do Open
	{
		if(SerDate==null)
			var qrystr="CodeType=" + sCodeType + "&Qualifier=" + sQulaifier + "&Code=" + Code + "&ctlCode=" + ctlCode + "&Desc=" + escape(Desc) + "&ctlDesc=" + ctlDesc + "&ctlFocus=" + ctlFocus		
		else
			var qrystr="CodeType=" + sCodeType + "&Qualifier=" + sQulaifier + "&Code=" + Code + "&ctlCode=" + ctlCode + "&Desc=" + escape(Desc) + "&ctlDesc=" + ctlDesc + "&ctlFocus=" + ctlFocus + "&SerDate=" + SerDate

//	  Gowrishankar - 06/30/2004
//	  window.open("SearchCodesWin.asp?"+qrystr,"SearchCodesWin","resize=1,toolbar=no,scrollbars=yes,menubar=no,height=500,width=730,top=20,left=30")
		window.open("SearchCodesWin.aspx?"+qrystr+"&AnesSetup=YES","SearchCodesWin","resize=1,toolbar=no,scrollbars=yes,menubar=no,height=500,width=730,top=20,left=30")
		//alert("SearchCodesWin.aspx?"+qrystr+"&AnesSetup=YES","SearchCodesWin","resize=1,toolbar=no,scrollbars=yes,menubar=no,height=500,width=730,top=20,left=30");
	}	
}


function vfnShowSearchDaig(sCodeType, objQulaifier, objCode, objDesc, objFocus, sCheckFieldVal,objSerDate,sPatientID)
{
	 var ctlCode=objCode.name
	var ctlDesc=objDesc.name
	var ctlFocus, sQulaifier
	var Code=objCode.value
	var Desc=objDesc.value
	var SerDate=objSerDate.value
	var sPrvDaig
	Code=""
	Desc=""
	/*if (objChkPDC.checked==true)
	{
	    sPrvDaig="Y"
	}
	else
	{
	    sPrvDaig="N"
	}
	*/
	 sPrvDaig="Y"
	//alert(sPrvDaig)
	
	if(objQulaifier==null || objQulaifier=="")
		sQulaifier = "";
	else if(objQulaifier=="ND" || objQulaifier=="HC" || objQulaifier=="ID")
		sQulaifier = objQulaifier
	else
		sQulaifier = objQulaifier.options[objQulaifier.selectedIndex].value;		
		
	if(objFocus==null) 
		ctlFocus="";
	else
		ctlFocus=objFocus.name;
	
	if(sCheckFieldVal=="DONTSHOW" || sCheckFieldVal.value=="") 	{}		 //Don't Open
	else if(sCheckFieldVal==null || sCheckFieldVal!="")//Do Open
	{
		if(SerDate==null)
			var qrystr="CodeType=" + sCodeType + "&Qualifier=" + sQulaifier + "&Code=" + Code + "&ctlCode=" + ctlCode + "&Desc=" + escape(Desc) + "&ctlDesc=" + ctlDesc + "&ctlFocus=" + ctlFocus + "&PATID=" + sPatientID+ "&PDC=" + sPrvDaig		
		else
			var qrystr="CodeType=" + sCodeType + "&Qualifier=" + sQulaifier + "&Code=" + Code + "&ctlCode=" + ctlCode + "&Desc=" + escape(Desc) + "&ctlDesc=" + ctlDesc + "&ctlFocus=" + ctlFocus + "&SerDate=" + SerDate + "&PATID=" + sPatientID+ "&PDC=" + sPrvDaig

//	  Gowrishankar - 06/30/2004
//	  window.open("SearchCodesWin.asp?"+qrystr,"SearchCodesWin","resize=1,toolbar=no,scrollbars=yes,menubar=no,height=500,width=730,top=20,left=30")
		window.open("SearchCodesWin_previous.asp?"+qrystr+"&AnesSetup=YES","SearchCodesWin","resize=1,toolbar=no,scrollbars=yes,menubar=no,height=500,width=730,top=20,left=30")
	}	
}




/*---------------------------------------------------------------------------------------------------------------------
UDF:
FUNCTION NAME	-	vfnXMLProCodeCheck
PURPOSE			-   To load Description when Code is chosen 
ARGUMENTS		-	Object of the Code, Object of description, string
RETURN VALUE	-   Nil
---------------------------------------------------------------------------------------------------------------------*/

function vfnXMLProCodeCheck(objCode,objDesc,sMsg)
{
	if(objCode.value!="")
	{
				
		var parser=new ActiveXObject("microsoft.xmldom")
		parser.async="false"
			
		parser.load("XMLCodeCheck.asp?Code=" + escape(objCode.value) + "&msg=" + sMsg)
		
		nodes = parser.documentElement.childNodes
		
		var Description = nodes.item(0).text
		
		if (nodes.item(0).text=="NA")
		{
			alert(sMsg+" Code not available in the list.")
			objDesc.value=""
			objCode.focus()
			objCode.select();
		}
		else
		{
			if(sMsg=="ICD") 
			{
				if(Description.indexOf("*")<0)
					objDesc.value=Description
				else
				{				
					//alert("Invalid ICD Diagnosis Code.Enter full diagnosis Code.")			
					alert("Invalid code.Enter/Select valid code.")			
					objDesc.value=""								
					fnSelectProDescription(objCode,objDesc,'ICD','')
				}
			}
			else
			{
				objDesc.value=nodes.item(0).text
			}
			
		}
	}
}

/*---------------------------------------------------------------------------------------------------------------------
UDF:
FUNCTION NAME	-	vfnPopuluate
PURPOSE			-   To load City and State when zip is entered
ARGUMENTS		-	Code object, City object, State object, string
RETURN VALUE	-   Nil
---------------------------------------------------------------------------------------------------------------------*/
function vfnPopuluate(objCode,obj1,obj2,sMsg)
{

	if(objCode.value!="")
	{
		var parser=new ActiveXObject("microsoft.xmldom")
		parser.async="false"
			
		//alert('jayaraj')
		
		//location.href="XMLCodeCheck.asp?Code=" + escape(objCode.value) + "&msg=" + sMsg
		//return	

		parser.load("XMLCodeCheck.asp?Code=" + escape(objCode.value) + "&msg=" + sMsg)

		
		nodes = parser.documentElement.childNodes
				//answer_text.innerHTML=nodes.item(0).text
		//alert(nodes.item(0).text)
		//alert(nodes.item(1).text)

		if (nodes.item(0).text=="NA")
		{
			alert(sMsg+" Code not available in the list.")
			obj1.value=""
			obj2.value=""
			objCode.focus()
			objCode.select();
		}
		else
		{
			obj1.value=nodes.item(0).text
			obj2.value=nodes.item(1).text
		}
	}
}

function vfnPopuluateZip(objCode,obj1,obj2,obj3,sMsg)
{
if(objCode.value!="")
{

	var parser=new ActiveXObject("microsoft.xmldom")
	parser.async="false"
		
	//location.href="XMLCodeCheck.asp?Code=" + escape(objCode.value) + "&msg=" + sMsg
	//return		
	parser.load("XMLCodeCheck.asp?Code=" + escape(objCode.value) + "&msg=" + sMsg)
	
	
	nodes = parser.documentElement.childNodes
	
			//answer_text.innerHTML=nodes.item(0).text

	if (nodes.item(0).text=="NA")
	{
		alert(sMsg+" Code not available in the list.")
		obj1.value=""
		obj2.value=""
		obj3.value=""
		objCode.focus()
		objCode.select();
	}
	else
	{
		obj1.value=nodes.item(0).text
		obj2.value=nodes.item(1).text
		obj3.value=nodes.item(2).text
		
	}
}
}


function vfnXMLTaxCheck(objCode,sMsg)
{

	if(objCode.value!="")
	{
		var parser=new ActiveXObject("microsoft.xmldom")
		parser.async="false"
		
		parser.load("XMLCodeCheck.asp?Code=" + escape(objCode.value) + "&msg=" + sMsg)
		nodes = parser.documentElement.childNodes
		if (nodes.item(0).text=="NA")
		{
			alert("Tax ID already exists.")
			objCode.focus()
			objCode.select();
		}
	}
}


/*---------------------------------------------------------------------------------------------------------------------
UDF:
FUNCTION NAME	-	vfnXMLCheckAvailability
PURPOSE			-   To find the code existis in db 
ARGUMENTS		-	Object of the Code, Object of description, string
RETURN VALUE	-   Nil
---------------------------------------------------------------------------------------------------------------------*/

function vfnXMLCheckAvailability(objCode,sMsg,alertMsg,sOldCode)
{
	//sOldCode - for custom code, in edit mode to avoid the checking
	if(objCode.value!="")
	{
	if (sOldCode==null) sOldCode=""
	
	//location.href="XMLCodeCheck.asp?Code=" + escape(objCode.value) + "&msg=" + sMsg + "&qOldCode=" + sOldCode
	//return;
		var parser=new ActiveXObject("microsoft.xmldom")
		parser.async="false"
			
		parser.load("XMLCodeCheck.asp?Code=" + escape(objCode.value) + "&msg=" + sMsg + "&qOldCode=" + sOldCode)		
		nodes = parser.documentElement.childNodes		
		if (nodes.item(0).text=="NA")
		{
			if(alertMsg==null)
				alert("Code not available in the list")						
			else
				alert(alertMsg)
				
			objCode.focus();
			objCode.select();
		}
	}
}

//Purpose: To get the values from diff type of objects
//Author: Michael J
//Date: 07/28/2004
function vfnGetValue(obj)
{
	if (obj.type=="text" || obj.type=="password" || obj.type=="textarea" ||obj.type=="file" || obj.type=="hidden")
	{
		obj.value = vfnTrim(obj)
		return obj.value;
	}	
	else if(obj.type=="select-one")	
	{
		return obj.options[obj.selectedIndex].value
	}
	else
	{
		alert("")
	}
	
}

/*---------------------------------------------------------------------------------------------------------------------
UDF:
FUNCTION NAME	-	vfnXMLLoadList
PURPOSE			-   To Load the the list box iteem from db 
ARGUMENTS		-	XML File Name (optional, default=XML_LoadList.asp, pass empty), 
				-   List Type(This list type should be present in the xml file)
				-   selLoadName - List box to be loaded with Name or  Description
				-   selLoadID - List box to be loaded with ID (optional: Pass empty)
				-	N List boxes objects for the query string values qID1,qID2....				
RETURN VALUE	-   Nil, if error occurs, Message Box would be shown
---------------------------------------------------------------------------------------------------------------------*/
function vfnXMLLoadList()
{
	var sXMLFile = arguments[0]
	var sListType = arguments[1]
	var selLoadName = arguments[2]
	var selLoadID = arguments[3]
	
	var sID = ""
	for (i=4; i<(arguments.length); i++)  // Forming n number of values in query string
	{
		if(i==4)
		{
			//	sID = "qID" + (i-3) + "=" + escape(arguments[i].options[arguments[i].selectedIndex].value)
			 sID = "qID" + (i-3) + "=" + escape( vfnGetValue(arguments[i]) ) //Michael: 07/28/2004
		}
		else
		{
			 
			//sID = sID + "&qID" + (i-3) + "=" + escape(arguments[i].options[arguments[i].selectedIndex].value)
			sID = sID + "&qID" + (i-3) + "=" + escape( vfnGetValue(arguments[i]) ) //Michael: 07/28/2004
		}
	}
	
	//var sValue1 = selValue1.options[selValue1.selectedIndex].value;	
	if(sXMLFile==null || sXMLFile=="")
	sXMLFile="XML_LoadList.asp"
	try{
	var parser=new ActiveXObject("microsoft.xmldom")
	parser.async="false"		
	parser.load(sXMLFile +"?qListType=" + sListType + "&" + sID)
	nodes = parser.documentElement.childNodes
	}
	catch(e)
	{
		alert(sMsgXMLErr);	
		selLoadName.selectedIndex=0;
		
		if(selLoadID!=null && selLoadID!="")
		selLoadID.selectedIndex=0;

		return false;
	}
	
	var sItem, arListItem
	
	selLoadName.length=1;
	
	if(selLoadID!=null && selLoadID!="")
	selLoadID.length=1;
 	
 	if(nodes.item(0).text=="NA") return; 	
 	
	for(var i=0;i<nodes.length;i++)
	{
		sItem = nodes.item(i).text
		
		arListItem = sItem.split(String.fromCharCode(30))	//0 - ID; 1 - Description
		selLoadName.options[selLoadName.length] = new Option(arListItem[1],arListItem[0])
		
		if(selLoadID!=null && selLoadID!="")
		selLoadID.options[selLoadID.length] = new Option(arListItem[0],arListItem[0])
	}
}





/*---------------------------------------------------------------------------------------------------------------------
UDF:
FUNCTION NAME	-	vfnShowTab()
PURPOSE			-   To show tab 
ARGUMENTS		-	Nil
RETURN VALUE	-   Nil
---------------------------------------------------------------------------------------------------------------------*/

function vfnShowTab() 
{
	 
	var i;
	for (i=0; i<(arguments.length); i++)  
	{
		if (i==0)
		{
			document.all[arguments[0]+'lt'].className = 'bgofftabbottom' ;
			document.all[arguments[0]+'lnk'].className ='bgofftabbottommid';
			document.all[arguments[0]+'rt'].className = 'bgofftabbottom';			
			document.all[arguments[0]+'font'].className = 'bgofffont';
			document.images[arguments[0]+'lti'].src="Images/tab_subtask_stroked_l.gif";
			document.images[arguments[0]+'rti'].src="Images/tab_subtask_stroked_r.gif";
		}
		else
		{
			document.all[arguments[i]+'lt'].className =  'bgontabbottom';
			document.all[arguments[i]+'lnk'].className = 'bgontabbottommid';
			document.all[arguments[i]+'rt'].className = 'bgontabbottom';
			document.all[arguments[i]+'font'].className = 'bgonfont';
			document.images[arguments[0]+'lti'].src="Images/tab_subtask_plain_l.gif";
			document.images[arguments[0]+'rti'].src="Images/tab_subtask_plain_r.gif";
		}
	}
}
function fnAgeEmpty(objAge)
{
	if(objAge.value=="")
	{
		objAge.value=""
	}
}
/*----------------------------------------------------------------------------------------------------------------------
UDF:
FUNCTION NAME	-	vfnAgeCount
PURPOSE			-	To calculate the age
ARGUMENTS		-	Date Object and Age Object
RETURN VALUE	-	Age
------------------------------------------------------------------------------------------------------------------------*/

function vfnAgeCount(objDOB,objAge)
{
if(objDOB.value!="")
{
	birthday = new Date(objDOB.value);
	today = new Date();
	
	//Find the date diff. Diff in milli seconds will return. add Milli Sec for 1 day then divide by the milli seconds for a year
	var iDateDiff = (today - birthday+(24*60*60*1000))/(1000*60*60*24*365.25)
	
			
	var iAge = Math.floor(iDateDiff)
	var iAgeDisplay  = iAge;
	
	if(iAge==0)	//If 0 find the months
	{
		iAge = Math.floor( (iDateDiff*365.25)/(30.4375) )
		iAgeDisplay = (iAge==1) ?  iAge + " Month" : iAge + " Months";
	}
	
	if(iAge==0)	//If 0 find the days
	{	
		iAge = Math.floor( (iDateDiff*365.25))
		iAgeDisplay = (iAge==1) ?  iAge + " Day" : iAge + " Days";
	}
	
	objAge.value=iAgeDisplay;
}
else
{
	objAge.value=""
}
}

//Prem Modified on May 2nd, 2007.
function vfnAgeCountDisplay(objDOB,objAge)
{
if(objDOB.value!="")
{
	birthday = new Date(objDOB.value);
	today = new Date();
	
	//Find the date diff. Diff in milli seconds will return. add Milli Sec for 1 day then divide by the milli seconds for a year
	var iDateDiff = (today - birthday+(24*60*60*1000))/(1000*60*60*24*365.25)
	
			
	var iAge = Math.floor(iDateDiff)
	var iAgeDisplay  = iAge;
	
	if(iAge==0)	//If 0 find the months
	{
		iAge = Math.floor( (iDateDiff*365.25)/(30.4375) )
		iAgeDisplay = 0;
	}
	
	if(iAge==0)	//If 0 find the days
	{	
		iAge = Math.floor( (iDateDiff*365.25))
		iAgeDisplay = 0;
	}
	
	objAge.value=iAgeDisplay;
}
else
{
	objAge.value=""
}
}

function vfnAgeCountold(objDOB,objAge)
{

	birthday = new Date(objDOB.value);
	today = new Date();
	years = today.getFullYear() - birthday.getFullYear();
	birthday.setYear( today.getFullYear() );
	   
	// If your birthday hasn't occurred yet this year, subtract 1.
	if(today < birthday)
	{
		years-- ;
	}
	      
	if(years>0)
	{ 
		objAge.value=years ;
	}
	else if(years<=0)
	{
		months=today.getMonth() - birthday.getMonth(); 
		if(months<2 )
			objAge.value=months + " month" ;
		else if(months>1)
			objAge.value=months + " month(s)" ;
		else if(months<=0)
		{
			days=today.getDate() - birthday.getDate();
			if(days>=0)
				objAge.value=days + " day(s)" ;
			else
			objAge.value=""	;			
		}
	}
}


/*----------------------------------------------------------------------------------------------------------------------
FUNCTION NAME	-	vfnTrim
PURPOSE			-	To trim spaces
ARGUMENTS		-	Field object
RETURN VALUE	-	Trimmed value
-------------------------------------------------------------------------------------------------------------------------*/

function vfnTrim(obj)
{
  	var Field
    Field = obj
    if (!Field) // Validate the Form element
      {
        alert("Function : Element is not Defined !");
        return(-1);
      }
			
	var y=Field.value.length;
    var retval=Field.value;
    var m=0;
		
    while(m < y) //Start removing white spaces from left side
	{  
      	if ((retval.substring(0,1)==" ")||(retval.substring(0,1)=="     "))
		{ 
          	retval=Field.value.substring(m+1,y); //remove left most white char
        } 
        else 
        { 
          	break;
        }
        m++;
    }
				
    y=retval.length;
    m=y;
	
      while (m >= 0) //Start removing white spaces from right side
		{  
        	if ((retval.substring(m-1,m)==" ")||(retval.substring(m-1,m)==" "))
          	{  
            	retval=retval.substring(0,m-1); //remove right most white char
            } 
          else 
            { 
              break;  //first non - white character encountered while 
                      //traversing from right to left. so break the loop
            }
          m--;
        }
        
      return retval;
}

/*----------------------------------------------------------------------------------------------------------------------
FUNCTION NAME	-	vfnTrimString
PURPOSE			-	To trim spaces
ARGUMENTS		-	Vlaue
RETURN VALUE	-	Trimmed value
-------------------------------------------------------------------------------------------------------------------------*/
function vfnTrimString(s) 
{
  // Remove leading spaces and carriage returns
  
  while ((s.substring(0,1) == ' ') || (s.substring(0,1) == '\n') || (s.substring(0,1) == '\r'))
  {
    s = s.substring(1,s.length);
  }

  // Remove trailing spaces and carriage returns

  while ((s.substring(s.length-1,s.length) == ' ') || (s.substring(s.length-1,s.length) == '\n') || (s.substring(s.length-1,s.length) == '\r'))
  {
    s = s.substring(0,s.length-1);
  }
  return s;
}





/*----------------------------------------------------------------------------------------------------------------------
UDF:
FUNCTION NAME	- vfnReplace
PURPOSE			- To remove the character (eg - or /)
ARGUMENTS		- Field value, character to be removed
RETURN VALUE	- Field value with the character removed
-------------------------------------------------------------------------------------------------------------------------*/

function vfnReplace(sData,replaceChar)
{
	var newData=""
	for(var i=0; i<sData.length; i++)
	{
		if(sData.charAt(i)==replaceChar)
		{
		}
		else
		{
			newData = newData + sData.charAt(i)
		}
	}
	return newData
}



/*----------------------------------------------------------------------------------------------------------------------
UDF:
FUNCTION NAME	- MM_findObj
PURPOSE			- used for layers
-------------------------------------------------------------------------------------------------------------------------*/

function MM_findObj(n, d) { //v3.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document); return x;
}


/*----------------------------------------------------------------------------------------------------------------------
UDF:
FUNCTION NAME	- MM_showHideLayers
PURPOSE			- used to show and hide layers
-------------------------------------------------------------------------------------------------------------------------*/

function MM_showHideLayers() { //v3.0
 
   
  var i,p,v,obj,args=MM_showHideLayers.arguments;
 
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v='hide')?'hidden':v; }
    obj.visibility=v; }
}


/*---------------------------------------------------------------------------------------------------------------------
UDF:
FUNCTION NAME	-	vfnCheckFforEmpty
PURPOSE			-   To check for empty.
ARGUMENTS		-	Field object, Message, Layer name, X position , Y position , ScrollBy/ScrollTo
RETURN VALUE	-   alert() (if empty) and return boolean (return false if empty)
---------------------------------------------------------------------------------------------------------------------*/
function vfnCheckForEmpty(obj,sMsg,sLayerName, scrollX, scrollY,scrollMode)
{
	if (scrollX==null) scrollX=-800 //for netscape
	if (scrollY==null) scrollY=-100
	if (scrollMode==null) scrollMode="By"	
	
	if (obj.type=="text" || obj.type=="password" || obj.type=="textarea" ||obj.type=="file")
	{
		obj.value=vfnTrim(obj)
		if (obj.value=="")
		{	
			if(sLayerName!=null  && sLayerName!="")
			vfnLayerFocus(sLayerName)
			
			if (scrollMode=="To") window.scrollTo (scrollX, scrollY)
			
			obj.focus()
			obj.select();
			
			if (scrollMode=="By") window.scrollBy(scrollX,scrollY)
			
			alert(sMsg + sEmptyMessage)
			
			return false;
		}
		else
			return true;
	}
	
	else if(obj.type=="select-one")	
	{
		
		
	
		if (obj.options[obj.selectedIndex].value=="")
		{
			if(sLayerName!=null && sLayerName!="")
			{
				vfnLayerFocus(sLayerName)
			}
			
			if (scrollMode=="To") window.scrollTo (scrollX, scrollY)
		// Removed the alert - 08/19/2005 - Jayaraj	
			//alert(obj.value)
			obj.focus() 
			//obj.select();		
			
			if (scrollMode=="By") window.scrollBy(scrollX,scrollY)
			
			alert(sMsg + " " + sEmptyMessage)
			
			return false;
		}
		else
			return true;
	}
}


/*---------------------------------------------------------------------------------------------------------------------
	UDF:
	FUNCTION NAME	-	vfnLayerFocus
	PURPOSE			-	To bring focus to a particular layer.
	ARGUMENTS		-	Layer name
	RETURN VALUE	-   Nil
---------------------------------------------------------------------------------------------------------------------*/

function vfnLayerFocus(sLayerName)
{
	switch (sLayerName)
	{	
		
		case "Guarantor":
			MM_showHideLayers('divTab','','show','divGuarantor','','show','divEmployer','','hide','divComm','','hide')
			vfnShowTab('Guarantor','Communication','Employer')
			break;
		case "Communication":
			MM_showHideLayers('divTab','','show','divGuarantor','','hide','divEmployer','','hide','divComm','','show')
			vfnShowTab('Communication','Guarantor','Employer')
			break;
		case "Employer":
			MM_showHideLayers('divTab','','show','divGuarantor','','hide','divEmployer','','show','divComm','','hide')
			vfnShowTab('Guarantor','Communication','Employer')
			break;
		case "Patient":
			MM_showHideLayers('Billing','','hide','divTab','','show','divPatient','','show')
			vfnShowTab('Patient','Billing')
			break;
		case "Insurance1":
			MM_showHideLayers('Insurance2','','hide','Billing','','hide','Insurance1','','show','divTab','','show','divPatient','','hide')
			vfnShowTab('Insurance','Patient','Billing');
			break;
		case "Insurance2":
			MM_showHideLayers('Insurance2','','show','Billing','','hide','Insurance1','','hide','divTab','','show','divPatient','','hide')
			vfnShowTab('Insurance','Patient','Billing');
			break;
		case "Billing":
			MM_showHideLayers('Billing','','show','divTab','','show','divPatient','','hide')
			vfnShowTab('Billing','Patient')
			break;
		case "Comm":
			MM_showHideLayers('divRelativeTab','','show','divContact','','hide','divContactList','','show','divComm','','show');
			vfnShowTab('Comm','Contact')
			break;
		case "Contact":
			MM_showHideLayers('divEmergencyTab','','show','divContact','','show','divContactList','','show','divComm','','hide');
			vfnShowTab('Contact','Comm')
			break;
		case "Diagnosis":
			//alert("into")
			MM_showHideLayers('divPrescription','','hide','divInsurance','','hide','divPhysician','','hide','divOthers','','hide','divProcedure','','hide','divDiagnosis','','show','divPatientNotes','','hide')
			vfnShowTab('Diagnosis','Procedure','Physician','Insurance','Others','PatientNotes','Prescription')	
			break;
		case "Procedure":
			MM_showHideLayers('divPrescription','','hide','divInsurance','','hide','divPhysician','','hide','divOthers','','hide','divProcedure','','show','divDiagnosis','','hide','divPatientNotes','','hide')
			vfnShowTab('Procedure','Diagnosis','Physician','Insurance','Others','PatientNotes','Prescription')
			break;
		case "Physician":
			MM_showHideLayers('divPrescription','','hide','divInsurance','','hide','divPhysician','','show','divOthers','','hide','divProcedure','','hide','divDiagnosis','','hide','divPatientNotes','','hide')
			vfnShowTab('Physician','Diagnosis','Procedure','Insurance','Others','PatientNotes','Prescription')
			break;
		case "Insurance":
			MM_showHideLayers('divPrescription','','hide','divInsurance','','show','divPhysician','','hide','divOthers','','hide','divProcedure','','hide','divDiagnosis','','hide','divPatientNotes','','hide')
			vfnShowTab('Insurance','Diagnosis','Procedure','Physician','Others','PatientNotes','Prescription')
			break;
		case "Others":
			MM_showHideLayers('divPrescription','','hide','divInsurance','','hide','divPhysician','','hide','divOthers','','show','divProcedure','','hide','divDiagnosis','','hide','divPatientNotes','','hide')
			vfnShowTab('Others','Diagnosis','Procedure','Physician','Insurance','PatientNotes','Prescription')
			break;
		case "PatientNotes":
			MM_showHideLayers('divPrescription','','hide','divInsurance','','hide','divPhysician','','hide','divOthers','','hide','divProcedure','','hide','divDiagnosis','','hide','divPatientNotes','','show')
			vfnShowTab('PatientNotes','Diagnosis','Procedure','Physician','Insurance','Others','Prescription')
			break;
		case "Prescription":
			MM_showHideLayers('divPrescription','','show','divInsurance','','hide','divPhysician','','hide','divOthers','','hide','divProcedure','','hide','divDiagnosis','','hide','divPatientNotes','','hide')
			vfnShowTab('Prescription','Physician','Diagnosis','Procedure','Insurance','Others','PatientNotes')
			break;
		case "PractProvider":
			MM_showHideLayers('divTab','','show','divPractSpecialty','','hide','divPractHospital','','hide','divPractAddress','','hide','divPractInsurance','','hide','divPractProvider','','show')
			vfnShowTab('PractProvider','PractAddress','PractSpecialty','PractInsurance','PractHospital') 	
			break;
		case "PractAddress": 
			MM_showHideLayers('divTab','','show','divPractSpecialty','','hide','divPractHospital','','hide','divPractAddress','','show','divPractInsurance','','hide','divPractProvider','','hide')
			vfnShowTab('PractAddress','PractProvider','PractSpecialty','PractInsurance','PractHospital')	
			break;
		case "PractSpecialty":
			MM_showHideLayers('divTab','','show','divPractSpecialty','','show','divPractHospital','','hide','divPractAddress','','hide','divPractInsurance','','hide','divPractProvider','','hide')
			vfnShowTab('PractSpecialty','PractProvider','PractAddress','PractInsurance','PractHospital')	
			break;
		case "PractInsurance":
			MM_showHideLayers('divTab','','show','divPractSpecialty','','hide','divPractHospital','','hide','divPractAddress','','hide','divPractInsurance','','show','divPractProvider','','hide')
			vfnShowTab('PractInsurance','PractProvider','PractAddress','PractSpecialty','PractHospital')	
			break;
		case "PractHospital":
			MM_showHideLayers('divTab','','show','divPractSpecialty','','hide','divPractHospital','','show','divPractAddress','','hide','divPractInsurance','','hide','divPractProvider','','hide')
			vfnShowTab('PractHospital','PractProvider','PractAddress','PractSpecialty','PractInsurance')	
			break;
		case "InsInsuranceRelation":
			MM_showHideLayers('Insurance2','','hide','Insurance1','','show','divTab','','show')
			vfnShowTab('Insurance1','Insurance2')	
			break;
		case "InsInsurance":
			MM_showHideLayers('Insurance2','','show','Insurance1','','hide','divTab','','show')
			vfnShowTab('Insurance2','Insurance1')
			break;
		case "RefPhysician":
			MM_showHideLayers('divReason','','hide','divAuthorisation','','hide','divEmergencyTab','','show','divPhysician','','show','divComm','','hide')
			vfnShowTab('RefPhysician','RefComm','RefAuth','RefReason')
			break;
		case "RefComm":
			MM_showHideLayers('divReason','','hide','divAuthorisation','','hide','divEmergencyTab','','show','divPhysician','','hide','divComm','','show')
			vfnShowTab('RefComm','RefPhysician','RefAuth','RefReason')
			break;
		case "RefAuth": 	
			MM_showHideLayers('divReason','','hide','divAuthorisation','','show','divEmergencyTab','','show','divPhysician','','hide','divComm','','hide')
			vfnShowTab('RefAuth','RefPhysician','RefComm','RefReason')
			break;
		case "RefReason":
			MM_showHideLayers('divReason','','show','divAuthorisation','','hide','divEmergencyTab','','show','divPhysician','','hide','divComm','','hide')
			vfnShowTab('RefReason','RefPhysician','RefComm','RefAuth')
			break;
		case "InsuranceCompany":
			MM_showHideLayers('EliClaims','','hide','Insurance','','show','divTab','','show','Claims','','hide','EDIClaims','','hide','divHCFA1500','','hide')
			vfnShowTab('Insurance','Claims','EDIClaims','EDIEligibility','HCFA1500')
			break;
		case "Claims":
			MM_showHideLayers('EliClaims','','hide','Insurance','','hide','divTab','','show','Claims','','show','EDIClaims','','hide','divHCFA1500','','hide')
			vfnShowTab('Claims','Insurance','EDIClaims','EDIEligibility','HCFA1500')
			break;
		case "EDIClaims":
			MM_showHideLayers('EliClaims','','hide','Insurance','','hide','divTab','','show','Claims','','hide','EDIClaims','','show','divHCFA1500','','hide')
			vfnShowTab('EDIClaims','Claims','Insurance','EDIEligibility','HCFA1500')
			break;
			//vijay 
		case "PractProv":
			MM_showHideLayers('divPractAddress','','hide','divPractInsurance','','hide','divPractProvider','','show')
			vfnShowTab('PractProvider','PractAddress','PractInsurance') 	
			break;
		case "PractAdd": 
			MM_showHideLayers('divPractAddress','','show','divPractInsurance','','hide','divPractProvider','','hide')
			vfnShowTab('PractAddress','PractProvider','PractInsurance')	
			break;	
			//over vijay	
			
			//priya  lastupdated by:Jayaraj : MAR-19-2004
		case "SetupPractice":
			MM_showHideLayers('divEncounter','','hide','divPatient','','hide','divPractice','','show','divClearinghouse','','hide','divPatientBilling','','hide')
			vfnShowTab('Practice','Patient','Encounter','Clearinghouse','PatientBilling')
			break;
		case "SetupPatient":
			MM_showHideLayers('divEncounter','','hide','divPatient','','show','divPractice','','hide','divClearinghouse','','hide','divPatientBilling','','hide')
			vfnShowTab('Patient','Encounter','Clearinghouse','PatientBilling','Practice')
			break;
		case "SetupEncounter":
			MM_showHideLayers('divEncounter','','show','divPatient','','hide','divPractice','','hide','divClearinghouse','','hide','divPatientBilling','','hide')
			vfnShowTab('Encounter','Clearinghouse','PatientBilling','Practice','Patient')		
			break;
		//over priya lastupdated by:Jayaraj : MAR-19-2004
		//Update Block by Rajesh : Jan - 17 - 2005
		case "SetupPatientBill":
			MM_showHideLayers('divEncounter','','hide','divPatient','','hide','divPractice','','hide','divClearinghouse','','hide','divPatientBilling','','show')
			vfnShowTab('PatientBilling','Practice','Patient','Encounter','Clearinghouse')		
			break;
		case "SetupClearinghouse":
			MM_showHideLayers('divEncounter','','hide','divPatient','','hide','divPractice','','hide','divClearinghouse','','show','divPatientBilling','','hide')
			vfnShowTab('Clearinghouse','PatientBilling','Practice','Patient','Encounter')
			break;		
		//End of Block by Rajesh : Jan - 17 - 2005	
	}
}


/*---------------------------------------------------------------------------------------------------------------------
	UDF:
	FUNCTION NAME	-	vfnIsNumber	
	PURPOSE			-	To check if the entered value is Integer.
	ARGUMENTS		-	Field object, bAlert=true
	RETURN VALUE	-	If Integer returns true.
---------------------------------------------------------------------------------------------------------------------*/

function vfnIsNumber(e, obj, bAlert, sLabel, sLayerName)
{

	var sLabelNew=""
	if(!bAlert && bAlert!=0) bAlert=1
		
	if(sLabel) sLabelNew = sLabel + ":\n\n" //Default Value	

	if(obj.value!="")
	{
		var s1=obj.value;
		var s2;
		var tem=0;
		for (var i=0;i<s1.length;i++)
		{
			s2=s1.charAt(i);
			if( (s2>='0') && (s2<='9') )
			{
				tem=1;
			}
			else
			{
				tem=0
				break;
			}
		}

		if (tem==0)
		{
			if(bAlert==1)
			{
				vfnAlertFocus(e, obj, sLabelNew + "Valid characters  : [0-9]", sLayerName)
			}
			 
			/*obj.focus();				
			obj.select();	 //coment by MIchael
			
			if(bAlert==1)
				alert();*/
			
			return false;
		}
		else
			return true;
	}
	else
		return true;
}
function vfnIsValidCharT(e,obj,sLabel,sLayerName)          
{

	var Field
	var sLabelNew=""
	if(sLabel) sLabelNew = sLabel + ":\n\n"  //Default Value	
	obj.value=vfnTrim(obj)
	Field = obj
    var length = Field.value.length;
    var value=new String(Field.value);
    var re = /[^a-z A-Z0-9!\&'()+,-_;?=%@\[\]{}|<>#]+/g;
    var error=false;
    var errChar="";
    for(var i=0;i<length;i++)
	{
	    var sChar;
	    if(new RegExp(re).test(value.substring(i,i+1)))
	    {
	        error=true;
	        if(errChar.indexOf(value.substring(i,i+1))==-1)
	        {
	            if(value.substring(i,i+1)=='\n')
	            {
	                if(errChar.indexOf('CR-LF')==-1)
	                {
	                    errChar=errChar+'CR-LF'+', ';
	                    i=i+1;
	                }
	            }
                else
                {
                    if(vfnTrimString(value.substring(i,i+1))!="")
                    {
	                    errChar=errChar+value.substring(i,i+1)+', ';
	                }
	            }
	        }
	    }
    }
    errChar=vfnTrimString(errChar);
    if(errChar.length>0)
    {
        errChar=errChar.substring(0,errChar.length-1)
    }
    if( new RegExp(re).test(value))
    {
		var tmpMsg="System does not permit entry of the following characters " +
		           "in this field as these\nare not valid " + 
		           "as per HPS PROFESSIONAL / they are used as " +
                    "delimiters.\n\n"  + 
                    "" + errChar+ "\n\n";
					 
					 
        var option=confirm(sLabelNew + tmpMsg);
        if(option==true)
        {
            value=value.replace(re,"");
            obj.value=value;
            if(obj.length==0)
            {
            alert('Enter');
            }
            obj.focus();
            return true;
        }
        else
        {
            obj.focus();
            return false;
        }
    }
    else
    {
        return true;
    }
	return true; //If valid character
}

function vfnEnableFormFields()
{
    
	for(var i=0; i<document.forms[0].elements.length; i++)
	{
		document.forms[0].elements[i].disabled=false;
	}
}
/*----------------------------------------------------------------------------------------------------------------------
UDF:
FUNCTION NAME	-	vfnIsValidAlphaChar
PURPOSE			-	To allow [a-z], [A-Z] and restricting other characters
ARGUMENTS		-	Form object
RETURN VALUE	-	If valid returns true else displays alert
-------------------------------------------------------------------------------------------------------------------------*/
function vfnIsValidAlphaChar(obj)          
{

	var Field
	obj.value=vfnTrim(obj)
	Field = obj
    var length = Field.value.length;
   
    for (var ct = 0; ct <= (Field.value.length - 1); ct++)
    {
		var Validchar = Field.value.substring(ct,ct+1);  // Check one Character at a time
		var character = 0;  // Set character as invalid alphanumeric value
		if(!(((Validchar >= "A") && (Validchar <= "Z")) || ((Validchar >= "a") && (Validchar <= "z"))))
		{
			alert("Valid characters : [A-Z],[a-z]");
			obj.focus();
			obj.select();
			return false;		
		}
	 }
	return true; //If valid character
}


/*----------------------------------------------------------------------------------------------------------------------
UDF:
FUNCTION NAME	-	vfnIsValidAlphaSplChar
PURPOSE			-	To allow [a-z], [A-Z], space, comma, hyphen, numbers and restricting other characters
ARGUMENTS		-	Field object
RETURN VALUE	-	If valid returns true else displays alert
-------------------------------------------------------------------------------------------------------------------------*/

function vfnIsValidAlphaSplChar(obj)          
{
	var Field
	obj.value=vfnTrim(obj)

	Field = obj
	
    var length = Field.value.length;
    
    for (var ct = 0; ct <= (Field.value.length - 1); ct++)
    {
		var Validchar = Field.value.substring(ct,ct+1);  // Check one Character at a time
		var character = 0;  // Set character as invalid alphanumeric value
		if (((Validchar >= "A") && (Validchar <= "Z")) || ((Validchar >= "a") && (Validchar <= "z")) || (Validchar == " ") || (Validchar == ",") || (Validchar == "-")||((Validchar >="0") && (Validchar <= "9")))
		{
       		character = 1; //valid character
	  	}
		else
		{
			character = 0; //Invalid character			
			obj.focus();
			obj.select();
			alert("Valid characters : [A-Z],[a-z],[0-9],space,comma,hyphen");
			return false;
		}
	}
	return true; //If valid character
}


/*----------------------------------------------------------------------------------------------------------------------
UDF:
FUNCTION NAME	- vfnIsValidAlphaNum
PURPOSE			- To allow [A-Z], [a-z], numbers and restrict all other characters
ARGUMENTS		- Field object
RETURN VALUE	- If valid returns true else displays alert
-------------------------------------------------------------------------------------------------------------------------*/

function vfnIsValidAlphaNum(obj)          
{

	var Field
	obj.value=vfnTrim(obj)
	Field = obj
    var length = Field.value.length;
   
    for (var ct = 0; ct <= (Field.value.length - 1); ct++)
    {
		var Validchar = Field.value.substring(ct,ct+1);  // Check one Character at a time
		var character = 0;  // Set character as invalid alphanumeric value
		if(!(((Validchar >= "A") && (Validchar <= "Z")) || ((Validchar >= "a") && (Validchar <= "z")) || ((Validchar >= "0") && (Validchar <= "9") ||(Validchar == " "))))
		//if(!(((Validchar >= "A") && (Validchar <= "Z")) || ((Validchar >= "a") && (Validchar <= "z")) || ((Validchar >= "0") && (Validchar <= "9"))))
		{
			alert("Valid characters : [A-Z],[a-z],[0-9]");
			obj.focus();
			obj.select();  // jayaraj 12-Dec-2003
			return false;
		}
	}
	return true; //If valid character
}

/*----------------------------------------------------------------------------------------------------------------------
UDF:
FUNCTION NAME	- vfnIsValidMemberID
PURPOSE			- To allow [A-Z], [a-z], numbers and restrict all other characters and spaces, Used for MemberID
ARGUMENTS		- Field object
RETURN VALUE	- If valid returns true else displays alert
-------------------------------------------------------------------------------------------------------------------------*/

function vfnIsValidMemberID(obj)          
{

	var Field
	obj.value=vfnTrim(obj)
	Field = obj
    var length = Field.value.length;
   
    for (var ct = 0; ct <= (Field.value.length - 1); ct++)
    {
		var Validchar = Field.value.substring(ct,ct+1);  // Check one Character at a time
		var character = 0;  // Set character as invalid alphanumeric value
		if(!(((Validchar >= "A") && (Validchar <= "Z")) || ((Validchar >= "a") && (Validchar <= "z")) || ((Validchar >= "0") && (Validchar <= "9"))))
		{
			alert("Valid characters : [A-Z],[a-z],[0-9]");
			obj.focus();
			obj.select();  // jayaraj 12-Dec-2003
			return false;
		}
	}
	return true; //If valid character
}
/*----------------------------------------------------------------------------------------------------------------------
UDF:
FUNCTION NAME	- vfnIsValidName
PURPOSE			- To allow [A-Z],[a-z],space,comma,.,-,&,'
ARGUMENTS		- Field object
RETURN VALUE	- If valid returns true else displays alert
-------------------------------------------------------------------------------------------------------------------------*/
function vfnIsValidNameOld(e, obj, sLabel,sLayerName) 
{	
	var sLabelNew=""
	if(sLabel) sLabelNew = sLabel + ":\n\n"  //Default Value	
	obj.value=vfnTrim(obj)	
	var iLength = obj.value.length;
		
	for (var ct = 0; ct <= (iLength - 1); ct++)
	{	
		var Validchar = obj.value.substring(ct,ct+1);  // Check one Character at a time
		var character = 0;  // Set character as invalid alphanumeric value
		if (((Validchar >= "A") && (Validchar <= "Z")) || ((Validchar >= "a") && (Validchar <= "z")) || (Validchar == ".") || (Validchar == " ") || (Validchar == ",") || (Validchar == "-") || (Validchar == "'") || (Validchar == "(") || (Validchar == ")"))
		{
			character = 1; //valid character
		}
		else
		{
			character = 0; //Invalid character

			vfnAlertFocus(e, obj, sLabelNew + msgValidName,sLayerName)
			//obj.focus();
			//obj.select();  // jayaraj 12-Dec-2003
			return false;
		}
	}
	obj.value=((obj.value).charAt(0)).toUpperCase()+obj.value.substring(1,(obj.value).length)
	return true; //If valid character

	
}
//.....New function added by Jaladi
function vfnIsValidCName(e, obj, sLabel,sLayerName) 
{	
	var sLabelNew=""
	if(sLabel) sLabelNew = sLabel + ":\n\n"  //Default Value	
	obj.value=vfnTrim(obj)	
	var iLength = obj.value.length;
		
	for (var ct = 0; ct <= (iLength - 1); ct++)
	{	
		var Validchar = obj.value.substring(ct,ct+1);  // Check one Character at a time
		var character = 0;  // Set character as invalid alphanumeric value
		if (((Validchar >= "A") && (Validchar <= "Z")) || ((Validchar >= "a") && (Validchar <= "z")) || (Validchar == " ")|| (Validchar == "-"))
		{
			character = 1; //valid character
		}
		else
		{
			character = 0; //Invalid character

			vfnAlertFocus(e, obj, sLabelNew + msgContactName,sLayerName)
			//obj.focus();
			//obj.select();  // jayaraj 12-Dec-2003
			return false;
		}
	}
	obj.value=((obj.value).charAt(0)).toUpperCase()+obj.value.substring(1,(obj.value).length)
	return true; //If valid character

	
}

//.....New function added by Prem
function vfnIsValidName(e, obj, sLabel,sLayerName) 
{	
	var sLabelNew=""
	if(sLabel) sLabelNew = sLabel + ":\n\n"  //Default Value	
	obj.value=vfnTrim(obj)	
	var iLength = obj.value.length;
		
	for (var ct = 0; ct <= (iLength - 1); ct++)
	{	
		var Validchar = obj.value.substring(ct,ct+1);  // Check one Character at a time
		var character = 0;  // Set character as invalid alphanumeric value
		if (((Validchar >= "A") && (Validchar <= "Z")) || ((Validchar >= "a") && (Validchar <= "z")) || (Validchar == " ") || (Validchar == "'") || (Validchar == "-"))
		{
			character = 1; //valid character
		}
		else
		{
			character = 0; //Invalid character

			vfnAlertFocus(e, obj, sLabelNew + msgPersonName,sLayerName)
			//obj.focus();
			//obj.select();  // jayaraj 12-Dec-2003
			return false;
		}
	}
	obj.value=((obj.value).charAt(0)).toUpperCase()+obj.value.substring(1,(obj.value).length)
	return true; //If valid character

	
}

/*----------------------------------------------------------------------------------------------------------------------
FUNCTION NAME	- vfnQuotes
PURPOSE			- To allow all characters except single quotes and double quotes
ARGUMENTS		- field object
RETURN VALUE	- If valid returns true else displays alert 
-------------------------------------------------------------------------------------------------------------------------*/
function vfnQuotes(obj)
{
	var Field
	obj.value=vfnTrim(obj)
	Field = obj
	var length = Field.value.length;
     
    for (var ct = 0; ct <= (Field.value.length - 1); ct++)
    {
		var Validchar = Field.value.substring(ct,ct+1);  // Check one Character at a
							    // time
		var character = 0;  // Set character as invalid alphanumeric value
		if ((Validchar == "'") || (Validchar == '"'))
		{
			character = 0; //Invalid character			
			obj.focus();
			obj.select();
			alert("Type valid characters [Invalid characters are single quotes and double quotes]");
			return false;
	  	}
		else
		{
			character = 1; //valid character
		}
	}
	return true; //If valid character
}


/*----------------------------------------------------------------------------------------------------------------------
UDF:
FUNCTION NAME	-	vfnPhoneFaxFormat
PURPOSE			-	To format Phone and Fax values to the format 000-000-0000
ARGUMENTS		-	Form object, character to distinguish phone or fax
RETURN VALUE	-	If valid returns true else displays alert  
-------------------------------------------------------------------------------------------------------------------------*/
function vfnPhoneFaxFormat(e,obj,nType,sLabel,sLayerName)
{
    obj.value=vfnTrim(obj);	
	phonefaxno=obj.value;			
	var sLabelNew =""
	if(sLabel) sLabelNew = sLabel + ":\n\n"  //Default Value	
	if(phonefaxno=="")return true;
	phonefaxno = vfnReplace(phonefaxno,"-")
	obj.value = phonefaxno
	
		if(vfnIsValidAlphaNumeric(e,obj,sLabel,sLayerName)) //vfnIsNumber
		{	if(phonefaxno.length==10)
			{
				if(phonefaxno.substring(0,3)=="000" && phonefaxno.substring(3,6)=="000" && phonefaxno.substring(6,10)=="0000")	
					{
						if(nType=="F"){
							sMsgInvalid=" Fax #."
						}
						else if(nType=="P"){		
							sMsgInvalid=" Phone #."			
						}
						else if(nType=="C"){					
							sMsgInvalid=" Cell phone #."
						}
						else if(nType=="B"){
							sMsgInvalid=" Beeper."
						}
						vfnAlertFocus(e, obj, sLabelNew + msgNotValid + sMsgInvalid,sLayerName)
						return false
					}
				
				obj.value = phonefaxno.substring(0,3) + "-" + phonefaxno.substring(3,6) + "-" + phonefaxno.substring(6,10)	
				vfnToUpper(obj)
			}
			else
			{
				if(nType=="F"){					
					vfnAlertFocus(e, obj, sLabelNew + msgFaxFormat,sLayerName)
				}			
				else if(nType=="P"){					
					vfnAlertFocus(e, obj, sLabelNew + msgPhoneFormat,sLayerName)
				}
				else if(nType=="C"){					
					vfnAlertFocus(e, obj, sLabelNew + msgCellPhoneFormat,sLayerName)
				}
				else if(nType=="B"){
					vfnAlertFocus(e, obj, sLabelNew + msgBeeperFormat,sLayerName)
				}	
				return false;
			}
			
		}
		else
			return false;
		
		/*else{
			obj.select();obj.focus();
			alert("Enter valid characters [Valid character set [0-9]]");
			return false;}*/
		
		return true
}


/*----------------------------------------------------------------------------------------------------------------------
UDF:
FUNCTION NAME	-	vfnTaxIDFormat
PURPOSE			-	To format tax value to format 00-0000000
ARGUMENTS		-	Field object
RETURN VALUE	-	If valid returns true else displays alert   
-------------------------------------------------------------------------------------------------------------------------*/
function vfnTaxIDFormat_new(e, obj, sLabel, sLayerName)
{
	var sLabelNew = ""
    obj.value=vfnTrim(obj);
	taxID=obj.value;			
	if(sLabel) sLabelNew = sLabel + ":\n\n"  //Default Value	
	if(taxID=="")return true;
	 			
		taxID = vfnReplace(taxID,"-")
		obj.value = taxID
		
		if(vfnIsNumber(e,obj,1,sLabel,sLayerName))
		{		
			if( taxID.substring(0,2)=="00" && taxID.substring(2,9)=="0000000")
			{
				vfnAlertFocus(e,obj,sLabelNew + msgNotValid + " Tax ID.",sLayerName)
				return false;
			
			}
			if(taxID.length==9)
			{	
				obj.value = taxID.substring(0,2) + "-" + taxID.substring(2,9)	
			}
			else
			{
				vfnAlertFocus(e,obj,sLabelNew + msgTaxFormat,sLayerName)
				obj.select();
				//alert(msgTaxFormat);
				return false;
			}
		}
		else{
			/*obj.select();
			obj.focus();
			alert("Enter valid characters [Valid character set [0-9]]");*/
			return false;
			}
		
		return true
}

function vfnTaxIDFormat(obj)
{
    obj.value=vfnTrim(obj);
	taxID=obj.value;			
	
	if(taxID=="")return true;
	 			
		taxID = vfnReplace(taxID,"-")
		obj.value = taxID
		
		if(vfnIsNumber(obj))
		{		
			if( taxID.substring(0,2)=="00" && taxID.substring(2,9)=="0000000")
			{
				
				obj.focus();
				obj.select();
				alert(msgNotValid + " Tax ID.");
				return false;
			
			}
			if(taxID.length==9)
			{	
				obj.value = taxID.substring(0,2) + "-" + taxID.substring(2,9)	
			}
			else
			{
				obj.focus();
				obj.select();
				alert(msgTaxFormat);
				return false;
			}
		}
		else{
			/*obj.select();
			obj.focus();
			alert("Enter valid characters [Valid character set [0-9]]");*/
			return false;
			}
		
		return true
}


/*----------------------------------------------------------------------------------------------------------------------
UDF:
FUNCTION NAME	-	vfnTaxIDSSNEINFormat
PURPOSE			-	To validate tax id format 000000000
ARGUMENTS		-	Field object
RETURN VALUE	-	If valid returns true else displays alert   
AUTHOR			-   Michael J
Function for	-	Change ID: 5 (HPSProf_Impact Analysis of Changes.xls)
-------------------------------------------------------------------------------------------------------------------------*/

function vfnTaxIDSSNEINFormat(obj)
{
    obj.value=vfnTrim(obj);
	taxID=obj.value;			
	
	if(taxID=="")return true;
	 			
		taxID = vfnReplace(taxID,"-")
		obj.value = taxID
		
		if(vfnIsNumber(obj))
		{		
			
			if(taxID.length==9)
			{	
				//obj.value = taxID.substring(0,2) + "-" + taxID.substring(2,9)	
			}
			else
			{
				obj.focus();
				obj.select();
				alert(msgTaxSSNEINFormat);
				return false;
			}
		}
		else
		{	
			return false;
		}		
		return true
}


/*----------------------------------------------------------------------------------------------------------------------
UDF:
FUNCTION NAME	-	vfnSSNFormat
PURPOSE			-	To format SSN value to format 000-00-0000
ARGUMENTS		-	Field object
RETURN VALUE	-	If valid returns true else displays alert   
-------------------------------------------------------------------------------------------------------------------------*/

function vfnSSNFormat(e, obj, sLabel,sLayerName)
{
	var sLabelNew =""
	obj.value=vfnTrim(obj);	
	ssn=obj.value;
	if(sLabel) sLabelNew = sLabel + ":\n\n"  //Default Value	

	if(ssn=="")return true;	
					
		ssn = vfnReplace(ssn,"-")

		obj.value = ssn	
		if(vfnIsNumber(e, obj, 1, sLabel, sLayerName))
		{		
			if(ssn.substring(0,3)=="000" && ssn.substring(3,5)=="00" && ssn.substring(5,9)=="0000")	
			{
				vfnAlertFocus(e, obj, sLabelNew + msgNotValid + " SSN.", sLayerName )				 
				return false
			}
			
			if(ssn.length==9)
			{	
				obj.value = ssn.substring(0,3) + "-" + ssn.substring(3,5)	+ "-" + ssn.substring(5,9)	
			}
			else
			{	
				vfnAlertFocus(e, obj, sLabelNew + msgSsnFormat,sLayerName)
				return false;
			}
		}
		else
		{
			/*obj.select();
			obj.focus();
			alert("Valid characters : [0-9]");*/	
			//alert("false")
			return false;
			
		}		

return true
}



/*------------------------------------------------------------------------------------------
UDF:
FUNCTION NAME	-	vfnZipFormat
PURPOSE			-	To format zip value to format 00000-0000
ARGUMENTS		-	Field object
RETURN VALUE	-	If valid returns true else displays alert   
-------------------------------------------------------------------------------------------*/


function vfnZipFormat(e,obj,sLabel,sLayerName)
{	
	var sLabelNew=""
	obj.value=vfnTrim(obj);	
	zip=obj.value;
	if(sLabel) sLabelNew = sLabel + ":\n\n"  //Default Value	
	if(zip=="") return true;
		
		zip = vfnReplace(zip,"-")		
		obj.value = zip;
	    sLabel="Zip Code"
		if(vfnIsNumber(e,obj,1,sLabel,sLayerName))
		{		
			if(zip.length==9 || zip.length==5)
			{				
			if( zip.substring(0,5)=="00000" || zip.substring(5,9)=="0000")
				{
					vfnAlertFocus(e, obj, "Zip Code:\n\n" + msgNotValid ,sLayerName)
					return false;
					
				}
			if(zip.length==9) obj.value = zip.substring(0,5) + "-" + zip.substring(5,9);
	
			}
			else
			{
				vfnAlertFocus(e, obj, "Zip Code:\n\n"  + msgZipFormat ,sLayerName)
				return false;
			}
		}
		else{
			/*alert("Enter valid characters [Valid character set [0-9]]");
			obj.select();
			obj.focus();*/
			return false;
			}
	return true;
		//obj.value=left(zip
}



/*----------------------------------------------------------------------------------------------------------------------
UDF:
FUNCTION NAME	-	vfnEmailCheck
PURPOSE			-	To validate the field for a valid email address
ARGUMENTS		-	Field object
RETURN VALUE	-	If valid returns true else displays alert   
-------------------------------------------------------------------------------------------------------------------------*/

function oldvfnEmailCheck(obj)
{
	emailStr=obj.value

	if(emailStr=="")return true;	

	/* The following variable tells the rest of the function whether or not
	to verify that the address ends in a two-letter country or well-known
	TLD.  1 means check it, 0 means don't. */

	var checkTLD=1;

	/* The following is the list of known TLDs that an e-mail address must end with. */

	var knownDomsPat=/^(com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum)$/;

	/* The following pattern is used to check if the entered e-mail address
	fits the user@domain format.  It also is used to separate the username
	from the domain. */

	var emailPat=/^(.+)@(.+)$/;

	/* The following string represents the pattern for matching all special
	characters.  We don't want to allow special characters in the address. 
	These characters include ( ) < > @ , ; : \ " . [ ] */

	var specialChars="\\(\\)><@,;:\\\\\\\"\\.\\[\\]";

	/* The following string represents the range of characters allowed in a 
	username or domainname.  It really states which chars aren't allowed.*/

	var validChars="\[^\\s" + specialChars + "\]";

	/* The following pattern applies if the "user" is a quoted string (in
	which case, there are no rules about which characters are allowed
	and which aren't; anything goes).  E.g. "jiminy cricket"@disney.com
	is a legal e-mail address. */

	var quotedUser="(\"[^\"]*\")";

	/* The following pattern applies for domains that are IP addresses,
	rather than symbolic names.  E.g. joe@[123.124.233.4] is a legal
	e-mail address. NOTE: The square brackets are required. */

	var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/;

	/* The following string represents an atom (basically a series of non-special characters.) */

	var atom=validChars + '+';

	/* The following string represents one word in the typical username.
	For example, in john.doe@somewhere.com, john and doe are words.
	Basically, a word is either an atom or quoted string. */

	var word="(" + atom + "|" + quotedUser + ")";

	// The following pattern describes the structure of the user

	var userPat=new RegExp("^" + word + "(\\." + word + ")*$");

	/* The following pattern describes the structure of a normal symbolic
	domain, as opposed to ipDomainPat, shown above. */

	var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$");

	/* Finally, let's start trying to figure out if the supplied address is valid. */

	/* Begin with the coarse pattern to simply break up user@domain into different pieces that are easy to analyze. */

	var matchArray=emailStr.match(emailPat);

	if (matchArray==null) {

	/* Too many/few @'s or something; basically, this address doesn't even fit the general mould of a valid e-mail address. */

	//alert("Email address seems incorrect (check @ and .'s)");	priya
	alert(msgEmailFormat)
	
	obj.focus();
	obj.select();
	return false;
	}
	var user=matchArray[1];
	var domain=matchArray[2];

	// Start by checking that only basic ASCII characters are in the strings (0-127).

	for (i=0; i<user.length; i++) {
	if (user.charCodeAt(i)>127) {
	//alert("Ths username contains invalid characters."); priya
	alert(msgEmailFormat)
	
	obj.focus()
	obj.select();
	return false;
	   }
	}
	for (i=0; i<domain.length; i++) {
	if (domain.charCodeAt(i)>127) {
	//alert("Ths domain name contains invalid characters."); priya
	alert(msgEmailFormat)
	obj.focus()
	obj.select();
	return false;
	   }
	}

	// See if "user" is valid 

	if (user.match(userPat)==null) {

	// user is not valid

	//alert("The username doesn't seem to be valid."); priya
	alert(msgEmailFormat)
	obj.focus()
	obj.select();
	return false;
	}

	/* if the e-mail address is at an IP address (as opposed to a symbolic
	host name) make sure the IP address is valid. */

	var IPArray=domain.match(ipDomainPat);

	if (IPArray!=null)
	{

		// this is an IP address

		for (var i=1;i<=4;i++)
		{
			if (IPArray[i]>255) 
			{
				// alert("Destination IP address is invalid!"); priya
				alert(msgEmailFormat)
				obj.focus();
				obj.select();
				return false;
			}
		}
		return true;
	}

	// Domain is symbolic name.  Check if it's valid.
	 
	var atomPat=new RegExp("^" + atom + "$");
	var domArr=domain.split(".");
	var len=domArr.length;
	for (i=0;i<len;i++) {
	if (domArr[i].search(atomPat)==-1) {
	// alert("The domain name does not seem to be valid."); priya
	alert(msgEmailFormat)	
	obj.focus();
	obj.select();
	return false;
	   }
	}

	/* domain name seems valid, but now make sure that it ends in a known top-level domain (like com, edu, gov) or a two-letter word,
	representing country (uk, nl), and that there's a hostname preceding the domain or country. */

	if (checkTLD && domArr[domArr.length-1].length!=2 && 
	domArr[domArr.length-1].search(knownDomsPat)==-1) {

	// alert("The address must end in a well-known domain or two letter " + "country."); priya
	alert(msgEmailFormat)	
	obj.focus();
	obj.select();
	return false;
	}

	// Make sure there's a host name preceding the domain.

	if (len<2) {
	// alert("This address is missing a hostname!"); priya
	alert(msgEmailFormat)
	obj.focus();
	obj.select();
	return false;
	}

	// If we've gotten this far, everything's valid!
	return true;
}

/*----------------------------------------------------------------------------------------------------------------------
UDF:
FUNCTION NAME	-	vfnSelectListItem
PURPOSE			-	To select the value (in the list box) given in the parameter 'selValue'. 
ARGUMENTS		-	Field object, Selected Value
RETURN VALUE	-	If the supplied value(selValue) is present in the list box, the particular item will be selected.
------------------------------------------------------------------------------------------------------------------------*/

function vfnSelectListItem(selObj,selValue)
{
	var iSIndex=0
	for(var i=0; i<selObj.length; i++)
	{
	
		if(selObj.options[i].value==selValue)
		{
			iSIndex=i
			break;
		}
	}
	selObj.selectedIndex=iSIndex;
}

/*----------------------------------------------------------------------------------------------------------------------
UDF: Date:		-	4:32 AM 07/22/2003(MIchael)
FUNCTION NAME	-	vfnSelectListBox
PURPOSE			-	On choosing a value from one select box, to load the corresponding value in the other select box
ARGUMENTS		-	selObj1,selObj2 (List box objects)
RETURN VALUE	-	If the selected value in the first list box is present in the second list box, the particular item will 
				-   be selected in the second list box
------------------------------------------------------------------------------------------------------------------------*/

function vfnSelectList(selObj1,selObj2)
{
	var iSIndex=0
	var selValue = selObj1.options[selObj1.selectedIndex].value;
	
	for(var i=0; i<selObj2.length; i++)
	{
		if(selObj2.options[i].value==selValue)
		{
			iSIndex=i
			break;
		}
	}
	selObj2.selectedIndex=iSIndex;
}
function vfnDateCheck1(e,obj,GTToday,sLabel,sTitle,sLayerName)
{
// Purpose: To format the value to the format MM/DD/YYYY if the values is a valid date.
	var iMonth,iDay,iYear
	var sAlertTitle=""
	
	sAlertTitle = vfnGetAlertTitle (sLabel, sTitle) //Get Alert Title
	
	if(vfnDateFormat(obj,GTToday)==false)
	{
		vfnAlertFocus(e,obj,sAlertTitle + msgDateFormat,sLayerName);

		return false;
	}
	obj.value=vfnTrim(obj);
	if(obj.value=="") return true;
	var sOriginalValue = obj.value
	var sDate = vfnReplace(obj.value,"/")	
	obj.value = sDate;
	if(vfnIsNumber(e,obj,0) && sDate.length==8)
	{
		iMonth=sDate.substring(0,2);
		iDay=sDate.substring(2,4);
		iYear=sDate.substring(4,8);
	
		if((iMonth>=1 && iMonth<=12) && (iDay>=1 && iDay<=vfnGetDays(iMonth-1,iYear)) )
		{	
			obj.value = sDate.substring(0,2) + "/" + sDate.substring(2,4) + "/" + sDate.substring(4,8);
			
		
			
			if (parseInt(iYear)<(new Date().getFullYear()-150))
			{
				vfnAlertFocus(e,obj,sAlertTitle + "is not a valid year",sLayerName);
				return false;			
			}
						
			return true;
		}
		else
		{
			vfnAlertFocus(e,obj,sAlertTitle + msgDateFormat,sLayerName)
			obj.value=sOriginalValue
			obj.select();
			return false;
		}
	}
	else
	{
		vfnAlertFocus(e,obj,sAlertTitle + msgDateFormat,sLayerName)
		obj.value=sOriginalValue
		obj.select();
		return false;
	}
}


/*--------TO FORMAT DATE-------------------------------------------------------------------------------------------------
	FUNCTIONS USED IN FORMATTING THE DATE ARE 
	
	1)vfnDateCheck
	3)getDays
	4)vfnLeapYear
*/

function vfnDateCheck(e,obj,GTToday,sLabel,sTitle,sLayerName)
{
// Purpose: To format the value to the format MM/DD/YYYY if the values is a valid date.
	var iMonth,iDay,iYear
	var sAlertTitle=""
	sAlertTitle = vfnGetAlertTitle (sLabel, sTitle) //Get Alert Title
	
	if(vfnDateFormat(obj,GTToday)==false)
	{
		vfnAlertFocus(e,obj,sAlertTitle + msgDateFormat,sLayerName);

		return false;
	}
	obj.value=vfnTrim(obj);
	if(obj.value=="") return true;
	var sOriginalValue = obj.value
	var sDate = vfnReplace(obj.value,"/")	
	obj.value = sDate;
	
	if(vfnIsNumber(e,obj,0) && sDate.length==8)
	{
	
		iMonth=sDate.substring(0,2);
		iDay=sDate.substring(2,4);
		iYear=sDate.substring(4,8);
	
		if((iMonth>=1 && iMonth<=12) && (iDay>=1 && iDay<=vfnGetDays(iMonth-1,iYear)) )
		{	
			obj.value = sDate.substring(0,2) + "/" + sDate.substring(2,4) + "/" + sDate.substring(4,8);
			
			if(GTToday==1 && new Date(obj.value)>new Date())
			{
				vfnAlertFocus(e,obj,sAlertTitle + msgDateExceeds,sLayerName);
				return false;
			}
			
			if (parseInt(iYear)<1900)
			{
				vfnAlertFocus(e,obj,sAlertTitle + "is not a valid year",sLayerName);
				return false;			
			}
			//Prem Added: 12/18/2006.
			if (parseInt(iYear)>(new Date().getFullYear()+100))
			{
				vfnAlertFocus(e,obj,sAlertTitle + "is not a valid year",sLayerName);
				return false;			
			}
						
			return true;
		}
		else
		{
			vfnAlertFocus(e,obj,sAlertTitle + msgDateFormat,sLayerName)
			obj.value=sOriginalValue
			obj.select();
			return false;
		}
	}
	else
	{
		vfnAlertFocus(e,obj,sAlertTitle + msgDateFormat,sLayerName)
		obj.value=sOriginalValue
		obj.select();
		return false;
	}
}




function vfnEncDateCheck(obj,GTToday1,sMsg1,sTitle)
{
//  Purpose: To format the value to the format MM/DD/YYYY if the values is a valid date.

	var iMonth,iDay,iYear
	
	obj.value=vfnTrim(obj);
	if(obj.value=="") return true;
	var sOriginalValue = obj.value
	var sDate = vfnReplace(obj.value,"/")	
	obj.value = sDate;

	if(vfnIsNumber(obj,0) && sDate.length==8)
	{
		iMonth=sDate.substring(0,2);
		iDay=sDate.substring(2,4);
		iYear=sDate.substring(4,8);
	
		if((iMonth>=1 && iMonth<=12) && (iDay>=1 && iDay<=vfnGetDays(iMonth-1,iYear)) )
		{
			obj.value = sDate.substring(0,2) + "/" + sDate.substring(2,4) + "/" + sDate.substring(4,8);
			if(GTToday1==1 && new Date(obj.value)>new Date())
			{
				alert(msgDateExceeds)
				obj.focus();
				obj.select();  // jayaraj 12-Dec-2003
				return false;
			}
		}
		else
		{
			alert(msgDateFormat)
			obj.value=sOriginalValue
			obj.focus();
			obj.select();  // jayaraj 12-Dec-2003
			return false;		
		}
	}
	else if(vfnIsNumber(obj,0) && sDate.length==6)
	{
		iMonth=sDate.substring(0,2);
		iDay=sDate.substring(2,4);
		iYear=sDate.substring(4,6);
	
		if((iMonth>=1 && iMonth<=12) && (iDay>=1 && iDay<=vfnGetDays(iMonth-1,iYear)) )
		{
			obj.value = sDate.substring(0,2) + "/" + sDate.substring(2,4) + "/20" + sDate.substring(4,6);
			if(GTToday1==1 && new Date(obj.value)>new Date())
			{
				alert(msgDateExceeds)
				obj.focus();
				obj.select();  // jayaraj 12-Dec-2003
				return false;
			}
			return true;
		}
		else
		{
			alert(msgDateFormat)
			obj.value=sOriginalValue
			obj.focus();
			obj.select();  // jayaraj 12-Dec-2003
			return false;		
		}
	}
	else
	{
		alert(msgDateFormat)
		obj.value=sOriginalValue
		obj.focus();
		obj.select();  // jayaraj 12-Dec-2003
		return false;
	}
}


/*-----------------------------------------------------------------------------------------------------------------------

FUNCTION NAME	 - fnGetDays
PURPOSE			 - TO GET THE DAYS FOR THE CORRESPONDING MONTHS

-------------------------------------------------------------------------------------------------------------------------*/



function vfnGetDays(month,year){

	var ar=new Array(12)

	ar[0]=31
	ar[1]=(vfnLeapYear(year))?29:28
	ar[2]=31
	ar[3]=30
	ar[4]=31
	ar[5]=30
	ar[6]=31
	ar[7]=31
	ar[8]=30
	ar[9]=31
	ar[10]=30
	ar[11]=31
	return ar[month]
}

/*-------------------------------------------------------------------------------------------------------------------------

FUNCTION NAME	 - vfnLeapYear
PURPOSE			 - TO CHECK IF THE YEAR VALUE PASSED IS A LEAP YEAR OR NOT

----------------------------------------------------------------------------------------------------------------------------*/
function vfnLeapYear(year){
	if(year%4==0)
		return true;
	else
	return false;
}


//-----------------------------------------------DATE FORMAT END----------------------------------------------------------------------

function fnDateCompare(date1,GTToday1,date2,GTToday2,sMsg1,sMsg2, sTite,dd1Comdd2)
{
//1 or undefine - dd1<dd2
//10 - dd1<=dd2
//-1 - dd1>dd2
//-10 - dd1>=dd2



if(sTite=="")
{}
else
sTite=sTite+" : "

var ck=false

	ck=vfnDateCheck(date1,GTToday1) && vfnDateCheck(date2,GTToday2)
if(ck)
{
if(date1.value=="" && date2.value=="")
	return true;
else if(date1.value=="")
	{
	alert("Type " + sMsg1);
	date1.focus();
	date1.select();
	return false;
	}
else if(date2.value=="")
	{
	alert("Type " + sMsg2);
	date2.focus();
	date2.select()
	return false; 
	}
else if(dd1Comdd2==10 && (new Date(date1.value) > new Date(date2.value)))
	{
	alert(sTite+sMsg2 +" should be greater than or equal to "+ sMsg1+".")
	date2.focus();
	date2.select()
	return false
	}
else if(dd1Comdd2!=10 &&(new Date(date1.value) >= new Date(date2.value)) )
	{	
	alert(sTite+sMsg2 +" should be greater than "+ sMsg1+".")
	date2.focus();
	date2.select();
	return false
	}
else
	return true;
		}
		else
			return false;
		
}
function vfnDateDiff(e,obj1,obj2,sLabel)
{

    if(obj1.value!="")
    {
      if ((((Date.parse(obj2.value))-(Date.parse(obj1.value)))/(24*60*60*1000)).toFixed(0) < 0)
      {
          alert(sLabel);
          obj2.focus();
          obj2.select();
          return false;
      }
      else
        return true;
    }
    else
        return true;
}

function vfnDateDiffFn(e,obj1,obj2,sLabel)
{

    if(obj1.value!="")
    {
      if ((((Date.parse(obj2.value))-(Date.parse(obj1.value)))/(24*60*60*1000)).toFixed(0) <= 0)
      {
          alert(sLabel);
          obj2.focus();
          obj2.select();
          return false;
      }
      else
        return true;
    }
    else
        return true;
}

/*----------------------------------------------------------------------------------------------------------------------
UDF: Date:		-	
FUNCTION NAME	-	vfnCurrencyCheck
PURPOSE			-	To Check the currency
ARGUMENTS		-	object
RETURN VALUE	-	If valid currency, return true else alert() and false
------------------------------------------------------------------------------------------------------------------------*/
function vfnCurrencyCheck(obj)
{

obj.value = vfnTrim(obj)
var ctrlValue = obj.value;
var RegCurrency=/^\d{1,10}$|^\d{1,7}\.\d{1,2}$/

 if(ctrlValue!="")
 {
 		DeciPointLen=ctrlValue.indexOf(".")
		
		if(RegCurrency.test(ctrlValue)==false)
		{
		 alert("Type valid currency - 0000000.00");   		 
		 obj.focus();
		 obj.select();
		 return false;
		}
		else
		{
			obj.value=vfnCurrFormat(obj.value)
			return true;
		}
 }
 else
 {
	obj.value=vfnCurrFormat(obj.value)
	return true;
 }

}


function vfnHoursWorked(obj)
{

obj.value = vfnTrim(obj)
var ctrlValue = obj.value;
var RegCurrency=/^\d{1,10}$|^\d{1,7}\.\d{1,2}$/

 if(ctrlValue!="")
 {
 		DeciPointLen=ctrlValue.indexOf(".")
		
		if(RegCurrency.test(ctrlValue)==false)
		{
		 alert("Type valid hours - 0000000.00");   		 
		 obj.focus();
		 obj.select();
		 return false;
		}
		else
		{
			obj.value=vfnCurrFormat(obj.value)
			return true;
		}
 }
 else
 {
	obj.value=vfnCurrFormat(obj.value)
	return true;
 }

}

//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<  Crystal Report >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
function fnShowPatientReport(sReportName,sPatientID,sOtherID)
{ 	
	
	
	var sViewer
	if (navigator.appName=="Microsoft Internet Explorer")
		{
			sViewer="ActiveX" // document.forms[0].Viewer.value ="ActiveX(IE Only)"
		}	
	else if (navigator.appName=="Netscape")
		{
			sViewer="Java" //document.forms[0].Viewer.value ="Java" 
		}
	
	
	var sQString = "?qViewer=" + sViewer + "&qReportName=" + sReportName + "&qPatientID=" + sPatientID + "&qOtherID=" + sOtherID
	//alert(sQString)	
	
	var iTop =(window.screen.availHeight-600)/2
	var iLeft =(window.screen.availWidth-800)/2 
	var iwidth=808
	var iheight=600
    WinObj=window.open("CrystalReport/CrystalReport.asp"+sQString,"PatientReport",'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,width='+ iwidth +',height=' + iheight +',top=' + iTop + ',left=' + iLeft);
}

//
function fnShowReport(sReportFileName, sReportName, sID1,sID2)
{ 	
 
    
	if (sReportFileName==null || sReportFileName=="")
		sReportFileName="CrystalReport.asp"
	
	/*if(sReportName.indexOf(".asp")==-1)
	{
	
	}
	else
	{
		sCrystalReportName=sReportName
	}*/	

	var sViewer
	if (navigator.appName=="Microsoft Internet Explorer")
		{
			sViewer="ActiveX" //document.forms[0].Viewer.value ="ActiveX(IE Only)"
		}	
	else if (navigator.appName=="Netscape")
		{
			sViewer="Java" //document.forms[0].Viewer.value ="Java" 
		}
	
	var sQString = "?qViewer=" + sViewer + "&qReportName=" + sReportName + "&qID1=" + sID1 + "&qID2=" + sID2

//	alert(sQString)	 
	var iTop =(window.screen.availHeight-600)/2
	var iLeft =(window.screen.availWidth-800)/2 
	var iwidth=808
	var iheight=600
	
	WinObj=window.open("CrystalReport/" + sReportFileName + sQString,"PatientReport",'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,width='+ iwidth +',height=' + iheight +',top=' + iTop + ',left=' + iLeft);
var h=window.screen.availHeight
var w=window.screen.availWidth
WinObj.moveTo(0,0)
WinObj.resizeTo(w,h)



	
}




//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<  Crystal Report >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>



/*----------------------------------------------------------------------------------------------------------------------
UDF: Date:		-	08/26/2003
FUNCTION NAME	-	vfnShowMe
PURPOSE			-	This function will act as dummy anchor
ARGUMENTS		-	Nill
------------------------------------------------------------------------------------------------------------------------*/
function vfnShowMe()
{

	
}

function vfnMenuAlert(sMsg)
{

if(sMsg==""){}
else{
	alert(sMsg)
}
}
function pad(number,length) 
{
   //return number;
    var str = '' + number;
    while (str.length < length)
        str = '0' + str;
    return str;
}


function vfnLoadReferral(sFieldName1, sFieldValue1, sFieldName2, sFieldValue2, sFieldName3, sFieldValue3)
{
	var tabopen="", row="", tabclose=""

	tabopen ='<table width="90%" border="1" cellspacing="3" cellpadding="2" id="grid_Referral" className = "gridrowselect">'
	
	row=row + '<tr  class="gridrow">'
	row=row + '<td   class="textbold width="40%">&nbsp;' + sFieldName1 + '</td>'
    row=row + '<td  class="text" width="60%">&nbsp;'+ sFieldValue1 + '</td>'
    row=row + '</tr>'
    
    row=row + '<tr class="gridrow">'
	row=row + '<td  class="textbold width="40%">&nbsp;' + sFieldName2 + '</td>'
    row=row + '<td  class="text" width="60%">&nbsp;'+ sFieldValue2 + '</td>'
    row=row + '</tr>'
    
    row=row + '<tr class="gridrow">' 
	row=row + '<td  class="textbold width="40%">&nbsp;' + sFieldName3 + '</td>'
    row=row + '<td  class="text" width="60%">&nbsp;'+ sFieldValue3 + '</td>'
    row=row + '</tr>'
    
    tabclose='</table>'
    tableHTML = tabopen +  row + tabclose
	window.opener.grid_Referral.outerHTML=tableHTML
	
}


function vfnToUpper(obj)
{

	obj.value=obj.value.toUpperCase()
	
}



function vfnCurrFormat(svalue)
{

if(svalue!=null) svalue = svalue.toString();

var iIndex, sFormatVal

iIndex=svalue.indexOf(".")
	if(iIndex==-1)
	{	
		if(svalue=="")
			sFormatVal= "0.00"
		else
			sFormatVal= svalue + ".00"
		 
	}
	else
	{
		sDec = svalue.substr(iIndex+1,svalue.length-1)
		if(sDec.length==1)
		{
			sFormatVal=svalue+"0"
		}
		else
		{
			sFormatVal=svalue
		}
	}
	
	
	if(sFormatVal.length-sFormatVal.indexOf(".")-1>2)
	{	
		return vbsRound(sFormatVal,2); //Calling From VB Script
	}
	else
	{
		return sFormatVal;
	}
}



/*function vfnCurrencyCheck(obj)
{
 var ctrlValue=obj.value;
 var RegCurrency=/^\d{1,10}$|^\d{1,7}\.\d{1,2}$/

 if(ctrlValue!="")
 {
 		DeciPointLen=ctrlValue.indexOf(".")
		
		if(RegCurrency.test(ctrlValue)==false)
		{
		 alert("Please enter valid currency.[Valid Currency-0000000.00]");   		 
		 obj.focus();
		 obj.select();
		 return false;
		}
		else
		{
			if(DeciPointLen==-1)
			{
				obj.value=ctrlValue+"."+"00"
			}
			return true;
		}
 }
 else
 {
	return true;
 }
}*/


//If the value is valid number, convert the value to number
function vfnToNumber(sValue)
{
	if(sValue!=null) sValue = sValue.toString();
	if(isNaN(sValue)==true)
		return 0;
	else
	{
		//return new Number(sValue) + 0		
		return vbsRound(sValue,2)
	}
}


//To obtain, time for URL 
function vfnGetTime()
{
	return new Date().getTime();
}

//Use this function instead of using location.href directly
function vfnLocationHref(arg)
{
	location.href=arg + "&t=" + vfnGetTime();
}




function vfnCancel()
{
//	if(confirm("Do you want to cancel changes made (if any)?")==true)
	if(confirm(msgErrorMessage)==true)
	{
		window.location.reload();
	}
}
 
/*----------------------------------------------------------------------------------------------------------------------
UDF: Date:		-	11/26/2003
FUNCTION NAME	-	vfnSelectAllCheck
PURPOSE			-	On selecting a check box all other check box below it gets selected
ARGUMENTS		-	objChkAll,sChkName,iCount
------------------------------------------------------------------------------------------------------------------------*/

function vfnSelectAllCheck(objChkAll,sChkName,iCount)
{
	if(objChkAll.checked==true)
	{
		for(i=1;i<iCount.value;i++)
		{
			document.myform.elements[sChkName+i].checked=true
		}
	}
	else
	{
		for(i=1;i<iCount.value;i++)
		{
			document.myform.elements[sChkName+i].checked=false
		}
	}
}


/*----------------------------------------------------------------------------------------------------------------------
UDF:
FUNCTION NAME	-	vfnEmailCheck
PURPOSE			-	To validate the field for a valid email address
ARGUMENTS		-	Field object
RETURN VALUE	-	If valid returns true else displays alert    
-------------------------------------------------------------------------------------------------------------------------*/

function vfnEmailCheck(e,obj,sLabel,sLayerName)
{
	//emailStr=obj.value
	var sLabelNew =""
	if(sLabel) sLabelNew = sLabel + ":\n\n"  //Default Value	
	emailStr=vfnTrim(obj)

	if(emailStr=="")return true;	

	/* The following variable tells the rest of the function whether or not
	to verify that the address ends in a two-letter country or well-known
	TLD.  1 means check it, 0 means don't. */

	var checkTLD=1;

	/* The following is the list of known TLDs that an e-mail address must end with. */

	var knownDomsPat=/^(com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum)$/;

	/* The following pattern is used to check if the entered e-mail address
	fits the user@domain format.  It also is used to separate the username
	from the domain. */

	var emailPat=/^(.+)@(.+)$/;

	/* The following string represents the pattern for matching all special
	characters.  We don't want to allow special characters in the address. 
	These characters include ( ) < > @ , ; : \ " . [ ] */

	var specialChars="\\(\\)><@,;:\\\\\\\"\\.\\[\\]";

	/* The following string represents the range of characters allowed in a 
	username or domainname.  It really states which chars aren't allowed.*/

	var validChars="\[^\\s" + specialChars + "\]";

	/* The following pattern applies if the "user" is a quoted string (in
	which case, there are no rules about which characters are allowed
	and which aren't; anything goes).  E.g. "jiminy cricket"@disney.com
	is a legal e-mail address. */

	var quotedUser="(\"[^\"]*\")";

	/* The following pattern applies for domains that are IP addresses,
	rather than symbolic names.  E.g. joe@[123.124.233.4] is a legal
	e-mail address. NOTE: The square brackets are required. */

	var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/;

	/* The following string represents an atom (basically a series of non-special characters.) */

	var atom=validChars + '+';

	/* The following string represents one word in the typical username.
	For example, in john.doe@somewhere.com, john and doe are words.
	Basically, a word is either an atom or quoted string. */

	var word="(" + atom + "|" + quotedUser + ")";

	// The following pattern describes the structure of the user

	var userPat=new RegExp("^" + word + "(\\." + word + ")*$");

	/* The following pattern describes the structure of a normal symbolic
	domain, as opposed to ipDomainPat, shown above. */

	var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$");

	/* Finally, let's start trying to figure out if the supplied address is valid. */

	/* Begin with the coarse pattern to simply break up user@domain into different pieces that are easy to analyze. */

	var matchArray=emailStr.match(emailPat);

	if (matchArray==null) {

	/* Too many/few @'s or something; basically, this address doesn't even fit the general mould of a valid e-mail address. */

	//alert("Email address seems incorrect (check @ and .'s)");	 priya
	vfnAlertFocus(e, obj,sLabelNew + msgEmailFormat,sLayerName)
	return false;
	}
	var user=matchArray[1];
	var domain=matchArray[2];

	// Start by checking that only basic ASCII characters are in the strings (0-127).

	// Checking Username part of an email
	for (i=0; i<user.length; i++) {
  	 if ((user.charCodeAt(i)>=64 && user.charCodeAt(i)<=90) || (user.charCodeAt(i)>=97 && user.charCodeAt(i)<=122) || (user.charCodeAt(i)==46) || (user.charCodeAt(i)==95) || (user.charCodeAt(i)>=48 && user.charCodeAt(i)<=57) || (user.charCodeAt(i)==45))
	 {}
	 else
	 {
//		alert("Ths Username contains invalid characters."); priya
		vfnAlertFocus(e, obj, sLabelNew + msgEmailFormat,sLayerName)
		return false;
     }
	}

	// Checking Domain part of an email
	
	for (i=0; i<domain.length; i++) {
  	 if ((domain.charCodeAt(i)>=64 && domain.charCodeAt(i)<=90) || (domain.charCodeAt(i)>=97 && domain.charCodeAt(i)<=122) || (domain.charCodeAt(i)==46) || (domain.charCodeAt(i)==95) || (domain.charCodeAt(i)>=48 && domain.charCodeAt(i)<=57) || (domain.charCodeAt(i)==45))
	 {}
	 else
	 {
		// alert("Ths Domain contains invalid characters."); priya
		vfnAlertFocus(e, obj, sLabelNew + msgEmailFormat,sLayerName)
		return false;
     }
	}

	// See if "user" is valid 

	if (user.match(userPat)==null) {

	// user is not valid

	//alert("The username doesn't seem to be valid."); priya
	vfnAlertFocus(e, obj, sLabelNew + msgEmailFormat,sLayerName)
	return false;
	}

	/* if the e-mail address is at an IP address (as opposed to a symbolic
	host name) make sure the IP address is valid. */

	var IPArray=domain.match(ipDomainPat);

	if (IPArray!=null)
	{

		// this is an IP address

		for (var i=1;i<=4;i++)
		{
			if (IPArray[i]>255) 
			{
				// alert("Destination IP address is invalid!"); priya
				vfnAlertFocus(e, obj, sLabelNew + msgEmailFormat,sLayerName)
				return false;
			}
		}
		return true;
	}

	// Domain is symbolic name.  Check if it's valid.
	 
	var atomPat=new RegExp("^" + atom + "$");
	var domArr=domain.split(".");
	var len=domArr.length;
	for (i=0;i<len;i++) {
	if (domArr[i].search(atomPat)==-1) {
	// alert("The domain name does not seem to be valid."); priya
	vfnAlertFocus(e, obj, sLabelNew + msgEmailFormat,sLayerName)
	return false;
	   }
	}

	/* domain name seems valid, but now make sure that it ends in a known top-level domain (like com, edu, gov) or a two-letter word,
	representing country (uk, nl), and that there's a hostname preceding the domain or country. */

	if (checkTLD && domArr[domArr.length-1].length!=2 && 
	(domArr[domArr.length-1].toLowerCase()).search(knownDomsPat)==-1) {//toLowserCase() for Accept Captial Letter

	// alert("The address must end in a well-known domain or two letter " + "country."); priya
	vfnAlertFocus(e, obj, sLabelNew + msgEmailFormat,sLayerName)
	return false;
	}
	// Make sure there's a host name preceding the domain.
	if (len<2) {
	// alert("This address is missing a hostname!"); priya
	vfnAlertFocus(e, obj, sLabelNew + msgEmailFormat,sLayerName)
	return false;
	}
	// If we've gotten this far, everything's valid!
	return true;
}


/*---------------------------------------------------------------------------------------------------------------------*/
//FUNCTION PURPOSE - To enable and disable fields based on mode of payment
/*---------------------------------------------------------------------------------------------------------------------*/
//-----------------------PAYMENTS SCREENS; INSURANCE, PATIENT, CAPITATION------------------------------------------
//var vsCheckNo="",vsCheckDate="", vsBankName=""
//var vsCardNo="",vsCardDate="", vsProviderName=""

var sCheckNo="",sCheckDate="", sBankName=""
function vfnCheckPaymentMode()
{
var butCCPayment

with(document.myform)
{
	var sPayMode = selModeOfPay.options[selModeOfPay.selectedIndex].value;
	if(sPayMode=="CA")
	{
		//Store the values in string before clear;
		sCheckNo = txtCheckNo.value; txtCheckNo.value=""; txtCheckNo.disabled=true;
		sCheckDate = txtCheckDate.value; txtCheckDate.value="";	txtCheckDate.disabled=true;
		sBankName = txtBankName.value; txtBankName.value=""; txtBankName.disabled=true;
		
		document.all['idCheckNo'].disabled=true;
		document.all['idCheckDate'].disabled=true;
		document.all['idBankName'].disabled=true;
	}
	else
	{
		txtCheckNo.value = (txtCheckNo.value=="" ? sCheckNo : txtCheckNo.value)
		txtCheckNo.disabled=false;
		txtCheckDate.value = (txtCheckDate.value=="" ? sCheckDate : txtCheckDate.value)
		txtCheckDate.disabled=false;
		txtBankName.value = (txtBankName.value=="" ? sBankName : txtBankName.value)
		txtBankName.disabled=false;
		
		document.all['idCheckNo'].disabled=false;
		document.all['idCheckDate'].disabled=false;
		document.all['idBankName'].disabled=false;
		
		
	}
	
	if(sPayMode=="CH")
	{
		document.all['idCheckNo'].innerHTML="Check No"
		document.all['idCheckDate'].innerHTML="Check Date"
		document.all['idBankName'].innerHTML="Bank"
		if(butCCPayment!=null) butCCPayment.disabled=true;
	}
	else if(sPayMode=="CC")
	{
		//document.all['idCheckNo'].innerHTML="Card No"
		//document.all['idCheckDate'].innerHTML="Expire Date"
		//document.all['idBankName'].innerHTML="Card Provider"	
		
		
		//michael: 07-06-2004 sCheckNo = txtCheckNo.value; txtCheckNo.value=""; txtCheckNo.disabled=true; 
		//michael: 07-06-2004 sCheckDate = txtCheckDate.value; txtCheckDate.value="";	txtCheckDate.disabled=true;
		
		sCheckNo = txtCheckNo.value; //txtCheckNo.value=""; 
		txtCheckNo.disabled=true;
		sCheckDate = txtCheckDate.value; //txtCheckDate.value="";	
		txtCheckDate.disabled=true;
		
		sBankName = txtBankName.value; txtBankName.value=""; txtBankName.disabled=true;
		if(butCCPayment!=null) butCCPayment.disabled=false;
			
		document.all['idCheckNo'].innerHTML="Transaction No"
		document.all['idCheckDate'].innerHTML="Transaction Date"		
			
		document.all['idCheckNo'].disabled=false;
		document.all['idCheckDate'].disabled=false;
		document.all['idBankName'].disabled=true;
			
	}
	else if(sPayMode=="AC" || sPayMode=="WT")
	{
		document.all['idCheckNo'].innerHTML="Transaction No."
		document.all['idCheckDate'].innerHTML="Transaction Date"
		document.all['idBankName'].innerHTML="Bank"	
		if(butCCPayment!=null) butCCPayment.disabled=true;
	}
	else
	{
		document.all['idCheckNo'].innerHTML="Check/Transaction No." //Caption changed from Check/Card No.
		document.all['idCheckDate'].innerHTML="Check Date/Transaction Date" //Caption changed from Check Date/Expire Date 
		document.all['idBankName'].innerHTML="Bank"	 ///Card Provider - Removed

		document.all['idCheckNo'].disabled=true;
		document.all['idCheckDate'].disabled=true;
		document.all['idBankName'].disabled=true;

		txtCheckNo.value = ""
		txtCheckDate.value = ""
		txtBankName.value = ""

		txtCheckNo.disabled = true
		txtCheckDate.disabled = true
		txtBankName.disabled = true
		if(butCCPayment!=null) butCCPayment.disabled=true;
	}
}//End If
}
 


//Used in : Payment_Insurance.asp, Payment_Patient.asp,CapitationPayment.asp,
function vfnValidateCheckInfo()
{

return true;  //Done as in doc: Corrections for DRJ office --02272004.doc
			  // All these fields are optional.(As Suresh told)
			  //Date: MAR-02-2004
			

with(document.myform)
{	
	if(selModeOfPay.options[selModeOfPay.selectedIndex].value=="CH")
	{
		if(!vfnCheckForEmpty(txtCheckNo,"Check No")){}
		else if(!vfnCheckForEmpty(txtCheckDate,"Check Date")){}		
		else if(!vfnCheckForEmpty(txtBankName,"Bank Name")){}
		else
		{
			return true;
		}
	}
	else if(selModeOfPay.options[selModeOfPay.selectedIndex].value=="CC")
	{
		if(!vfnCheckForEmpty(txtCheckNo,"Card No")){}
		else if(!vfnCheckForEmpty(txtCheckDate,"Expire Date")){}		
		else if(!vfnCheckForEmpty(txtBankName,"Card Provider")){}
		else
		{
			return true;
		}
	}
	else
	{
		return true;
	}


}//End With
}


/*----------------------------------------------------------------------------------------------------------------------
UDF:
FUNCTION NAME	-	vfnChkExt
PURPOSE			-	If the phone field is null then clear and lock the extensiobn field
ARGUMENTS		-	PhoneField,ExtField
RETURN VALUE	-	Nil
-------------------------------------------------------------------------------------------------------------------------*/
function vfnChkExt(objPhone,objExt)
{
	if(objPhone.value!="")
		{
			objExt.disabled=false;
		}
	else
		{
			objExt.value="";
			objExt.disabled=true;
		}
}


/*----------------------------------------------------------------------------------------------------------------------
UDF:
FUNCTION NAME	-	vfnClearRadio
PURPOSE			-	To clear the checked values in radio buttons
ARGUMENTS		-	Radio button object and number of buttons(optional)
RETURN VALUE	-	Nil
AUTHOR			-	Michael J MAR-23-2004
-------------------------------------------------------------------------------------------------------------------------*/
function vfnClearRadio(objRadio,iRadioLength)
{
	if(iRadioLength==null && objRadio.length==null)
		iRadioLength=1;	
	else if(iRadioLength==null)
		iRadioLength = objRadio.length;
		
	if (iRadioLength=="" || iRadioLength==0)
	{
	}
	else if (iRadioLength==1)
	{ 
		objRadio.checked=false;
	}
	else if (iRadioLength>1)
	{
	 	for (i=0;i<objRadio.length;i++)
		{
			objRadio[i].checked=false;
		}
	}
	
}


/*----------------------------------------------------------------------------------------------------------------------
UDF:
FUNCTION NAME	-	vfnClearFormFields
PURPOSE			-	To clear all form fields txtbox, textarea, select()1 item), checkbox, password,
ARGUMENTS		-	(FormObject(myform-default), objects not to clear...n obkects -- to be done in future)
RETURN VALUE	-	Nil
-------------------------------------------------------------------------------------------------------------------------*/
function vfnClearFormFields()
{
	var FieldObject
	//var form
	for(var i=0; i<document.forms[0].elements.length; i++)
	{
		FieldObject = document.forms[0].elements[i]
		
		if (FieldObject.type=="text" || FieldObject.type=="password" || FieldObject.type=="textarea")
		{
			FieldObject.value="";
		}
		else if (FieldObject.type=="select-one")
		{
			FieldObject.selectedIndex=0;
		}

	}
	
}

/*----------------------------------------------------------------------------------------------------------------------
UDF:
FUNCTION NAME	-	vfnTrimFormFields()
PURPOSE			-	To Trim all form fields txtbox, textarea, Listbox, password, Radio button, checkbox
ARGUMENTS		-	FormObject(myform-default)
RETURN VALUE	-	Nil
Author			-   Johnson (14-Feb-2005)
-------------------------------------------------------------------------------------------------------------------------*/

function vfnTrimFormFields()
{
	var FieldObject
	for(var i=0; i<document.forms[0].elements.length; i++)
	{
  	 FieldObject = document.forms[0].elements[i]
		if (FieldObject.type=="text" || FieldObject.type=="password" || FieldObject.type=="textarea"  || FieldObject.type=="radio" || FieldObject.type=="checkbox" || FieldObject.type=="select-one" || FieldObject.type=="hidden")
		{
			FieldObject.value= vfnTrim(FieldObject);
		}
	}
}



/*----------------------------------------------------------------------------------------------------------------------
Auth : vijay Amirthraj
FUNCTION NAME	-	vfnClearFormFields
PURPOSE			-	automatical split the mm/dd/yyyy format 
ARGUMENTS		-	(FormObject(myform-default
RETURN VALUE	-	Nil
-------------------------------------------------------------------------------------------------------------------------*/

function vfnDateFormat(obj,GTToday)
{

if(vfnTrim(obj)=="") 
return
str=vfnTrim(obj)
str1=""
str2=""
var iDateRange=29

//FEB-21-2004 'Michael
if(GTToday==1) 
{
	iDateRange = new Date().getYear()
	iDateRange = iDateRange.toString()
	iDateRange = parseInt(iDateRange.substring(2,4),10)
}
//Over FEB-21-2004 'Michael

for(i=0;i<str.length;i++)
	if(str.charAt(i)!="/")
	{
		if(parseInt(str.charAt(i),10)<=9)
			str1=str1+str.charAt(i)
	}
	else
	{//vijay 30 dec 2k3
	if (i==1)
	str1="0"+str1
	if(i==3 || i==4 && str1.length!=4)			 
	
	str1=str1.substring(0,2)+"0"+str1.substring(2,str1.length)
	//over 30 dec 2k3
	}
if(str1!="")
str=str1
if (str1.length<6)
return false
/*if (parseInt(str.substring(0,2),10)>12 && parseInt(str.substring(2,4),10)<=12)
			str1=str.substring(2,4)+"/"+str.substring(0,2)+"/"
else*/
	str1=str.substring(0,2)+"/"+str.substring(2,4)+"/"
if((str.substring(4,str.length)).length<=2)
	{
	if(parseInt(str.substring(4,str.length), 10)<=iDateRange)
		str2="20"+str.substring(4,str.length)
	else 
		str2="19"+str.substring(4,str.length)
	}
if (str2=="")
str2=str.substring(4,str.length)
str=str1+str2
obj.value=str
str=""
}

// New Email function FROM HPS SITE
// ******************* E-Mail *****************
function fnEmailFormat(objEMail)
{
	var EMailValue = objEMail.value;
	var a = "@";
	var b = ".";
	var a2 = 0;

    //----------------------------------------------------------------------------------------
    //   The '@' symbol should not be repeated more than once.
    //----------------------------------------------------------------------------------------
	var a1 = EMailValue.indexOf('@');
	var s2 = EMailValue.substring(a1+1, EMailValue.length);
	
	var a2 = s2.indexOf('@');

	if(a2!=-1)
	{
		window.alert(sEMailMessage + "'@' should not occur more than once.")
		objEMail.focus();
		return;
	}
    //----------------------------------------------------------------------------------------
    //   The '.' symbol should not be repeated more than once simultaneously.
    //----------------------------------------------------------------------------------------
	//var b1 = EMailValue.indexOf('.');
	//var s3 = EMailValue.substring(b1+1, EMailValue.length);

	//b2 = s3.indexOf('.');
  
	//if(b2!=-1)
	//{
	//	window.alert(sEMailMessage + "'.' should not occur more than once.")
	//	objEMail.focus();
	//	return;
	//}

	if(EMailValue!="")
	{
		var s2 = EMailValue.charAt(0);
		var dx = EMailValue.indexOf('@');
		var dx2 = EMailValue.indexOf('.');
		var t = EMailValue.substring(dx2+1,EMailValue.length)
        
	var s3="";   //FOR SPACE CHECKING
	var t1=0;
	var tem="";
	for(var i=0;i<EMailValue.length;i++)
	{
	s3=EMailValue.charAt(i);
	if(s3==" ")
	t1++;
	}
	
	if(!(((s2>='a')&&(s2<='z'))||((s2>='A')&&(s2<='Z'))))
	{
	alert("Invalid E-mail address.");
	objEMail.focus();
	return false
	}
	else if((dx<3)||(dx2<7))
	{
	alert("Invalid E-mail address.");
	objEMail.focus();
	return false
	}
	else if(t.length<2)
	{
	alert("Invalid E-mail address.");
	objEMail.focus();
	return false
	}
	else if(t1>0)
	{
	alert("Invalid E-mail address.");
	objEMail.focus();
	return false
	}
        
	else if(!((objEMail.value.indexOf("'")==-1) && (objEMail.value.indexOf('"')==-1 )))
	{
	alert("Cannot accept single or double quotes")
	objEMail.focus()
	return false
	}
   }
	else
	
	return true


 }




//Function Used for Text Area
function fnCheckMaxChars(taObject,sMaxChar)
{
	//to check for 255 characters as default
	
   if (sMaxChar==null)
    sMaxChar=225
    
   if (taObject.value.length>=sMaxChar)
    {         
      alert("Further entry is not allowed")
      taObject.focus()
      return false;
     }
}

//Function Used for Text Area
function fnRemoveExcessChars(taObject,sMaxChar) //Use Replace at ASP for single quote
{
	if (sMaxChar==null)
    sMaxChar=225
    
    taObj=vfnTrim(taObject)
    taObject.value=taObj.substring(0,sMaxChar)
}


//function used for Exten Area
function fnExtenCheck(obj)
{
obj.value=vfnTrim(obj)
if (obj.value=="")
return true
value=parseInt(obj.value,10)
if(value==0)
{
alert(msgZero)
obj.focus()
obj.select()
return false
}
}



//date compare
function vfnDateCompareNew(obj,obj1,Msg1,Msg2)
{
Date1=new Date(obj.value)
Date2=new Date(obj1.value)
if (Date1>Date2)
{
alert(Msg1+" should be greater than or equal to "+Msg2)
obj1.focus();
return false
}
}

function vfnCheckPageSize(obj)
{
var sPageSize = obj.value
	if(vfnIsNumber(obj)==true)
	{
		if(parseInt(sPageSize,10) >1000 || parseInt(sPageSize,10) < 1)
		{
			alert("Enter a number between 1 and 1000")
			obj.focus()
			obj.select()
		} 
	
	}

}



//****** To Check the USer Name ***


function fnIsValidUserName(r_varCtrl,sMsg)
{

	var Field
	r_varCtrl.value=vfnTrim(r_varCtrl)
	Field = r_varCtrl
	//Field.value = vfnTrim(Field);
    var length = Field.value.length;
   
   		
    for (var ct = 0; ct <= (Field.value.length - 1); ct++)
    {
		var Validchar = Field.value.substring(ct,ct+1);  // Check one Character at a
							    // time
		var character = 0;  // Set character as invalid alphanumeric value
		
		if (((Validchar >= "A") && (Validchar <= "Z")) || ((Validchar >= "a") && (Validchar <= "z")) || ((Validchar >= "0") && (Validchar <= "9")) || (Validchar == "-") || (Validchar == "_"))
		{
		
       		character = 1; //valid character
	  	}
		else
		{
		
			character = 0; //Invalid character
			alert("Valid characters : [A-Z],[a-z],[0-9],underscore,hyphen");
			r_varCtrl.focus();
			r_varCtrl.select();
			return false;
		}
	     
	}
	
	if(Field.value!="" && Field.value.length<5)
	{
		alert(sMsg + " must have a minimum of 5 characters.")
		r_varCtrl.focus();
		r_varCtrl.select();
		return false
	}
		
	return true; //If valid character
}


//Function to validate whether the given ID is not Zero. - Gowrishankar - 02/26/2004
function fnChkID(obj, sMsg)
{
	if (parseInt(obj.value, 10) == 0)
	{
		alert(sMsg)
		obj.focus()
		obj.select()
	}
}


//MAR-02-2004
//UPDATED: JULY-14-2004
function vfnFocusSelect(obj)
{
	
	if (obj.type=="text" || obj.type=="password" || obj.type=="textarea" ||obj.type=="file")
	{
		obj.focus()
		obj.select()
		
	}
	else //JULY-14-2004  'Michael J
	{
		obj.focus()		
	}
}


function fnDateFormat(sDate)
{
if(vfnTrim(sDate)=="") 
return
str=vfnTrim(sDate)
str1=""
str2=""
var iDateRange=29

for(i=0;i<str.length;i++)
	if(str.charAt(i)!="/")
	{
		if(parseInt(str.charAt(i),10)<=9)
			str1=str1+str.charAt(i)
	}
	else
	{//vijay 30 dec 2k3
	if (i==1)
	str1="0"+str1
	if(i==3 || i==4 && str1.length!=4)			 
	
	str1=str1.substring(0,2)+"0"+str1.substring(2,str1.length)
	//over 30 dec 2k3
	}
if(str1!="")
str=str1
if (str1.length<6)
return false

/*if (parseInt(str.substring(0,2),10)>12 && parseInt(str.substring(2,4),10)<=12)
	str1=str.substring(2,4)+"/"+str.substring(0,2)+"/"
else*/
	str1=str.substring(0,2)+"/"+str.substring(2,4)+"/"

if((str.substring(4,str.length)).length<=2)
	{
	if(parseInt(str.substring(4,str.length), 10)<=iDateRange)
		str2="20"+str.substring(4,str.length)
	else 
		str2="19"+str.substring(4,str.length)
	}
if (str2=="")
str2=str.substring(4,str.length)
str=str1+str2
sDate=str
str=""
return sDate
}


/*---------------------------------------------------------------------------------------------------------------------
UDF: 04/May/2004 - Gowrishankar
FUNCTION NAME	-	vfnPopulatePatient
PURPOSE			-   To load Patient LastName, FirstName when PatientID is entered
ARGUMENTS		-	PatientID object, LastName Object, FirstName object, Message
RETURN VALUE	-   Nil
Changed			-   LastName, FirstName are merged to one Textbox
---------------------------------------------------------------------------------------------------------------------*/
function vfnPopulatePatient(objCode,obj1,obj2,sMsg)
{
	if(objCode.value!="")
	{
		var parser=new ActiveXObject("microsoft.xmldom")
		parser.async="false"
			
		//alert('jayaraj')
		
		//location.href="XMLCodeCheck.asp?Code=" + escape(objCode.value) + "&msg=" + sMsg
		//return	
		
        if(sMsg=="PATIENT_ASPX")
        {
            sMsg="PATIENT"
		    parser.load("../XMLCodeCheck.asp?Code=" + escape(objCode.value) + "&msg=" + sMsg)
		}
		else
		{
		    parser.load("XMLCodeCheck.asp?Code=" + escape(objCode.value) + "&msg=" + sMsg)
		}
		nodes = parser.documentElement.childNodes
				//answer_text.innerHTML=nodes.item(0).text
		//alert(nodes.item(0).text)
		//alert(nodes.item(1).text)
 
  
		if (nodes.item(0).text=="NA")
		{
			alert("Patient ID not available.")
			obj1.value=""
			obj2.value=""
			objCode.focus()
			objCode.select();
		}
		else
		{
			obj1.value=nodes.item(1).text +", " + nodes.item(2).text + " " + nodes.item(3).text
//johnson			obj2.value=nodes.item(2).text
		}
	}
	else
		{
			obj1.value=""
		//	obj2.value=""
		}	
}


//Johnson 10-June-2005 to check Valid file name
function vfnCheckTildeString(str)
{
	var Field;
	str.value=vfnTrim(str);
	Field = str;
    var length = Field.value.length;
  if(length>0) 
  {
    for (var ct = 0; ct<=(Field.value.length - 1); ct++)
    {
		var Validchar = Field.value.substring(ct,ct+1);  // Check one Character at a time
//		if ((Validchar=="~")||(Validchar=="/")||(Validchar=="\")||(Validchar=="<")||(Validchar==">")||(Validchar==":")||(Validchar=="|")||(Validchar=="?"))
		if (Validchar=="~")
		{
			alert("Not a Valid file name");
			str.focus();
			str.select();
			return false;
		}
	 }
	vfnFileExtension(str);
//	return true; //If valid fileName
	}
}

//Johnson 11-June-2005 to check Valid file Extension NOT IN(COM ZIP XLS DOC JPG JPEG GIF PDF PSD TIF BMP DLL)
function vfnFileExtension(sFile)
{
	var sLast = sFile.value.substring(sFile.value.length-3, sFile.value.length).toUpperCase()
	var iFlag

	if ((sLast=="EXE")||(sLast=="ZIP")||(sLast=="XLS")||(sLast=="DOC")||(sLast=="JPG")||(sLast=="JPEG")||(sLast=="GIF")||(sLast=="PDF")||(sLast=="PSD")||(sLast=="TIF")||(sLast=="BMP")||(sLast=="DLL"))
	{
	 alert("Not a Valid file name");
	 iFlag="F"
	}
		if (iFlag=="F")
		{
			sFile.focus();
			return false
		}	
		else 
			return true	
}

/*---------------------------------------------------------------------------------------------------------------------
UDF: 04/May/2004	-	S.Dinesh
FUNCTION NAME		-	openCenterWindow
PURPOSE				-   Open the new Window & place it on the center of the window
RETURN VALUE		-   Nil
---------------------------------------------------------------------------------------------------------------------*/

function openCenterWindow(filenameurl,widowname,widowwidth,windowheight)
{
	var wwidth=window.screen.availWidth
	var wheight=window.screen.availHeight
	wwidth=(wwidth-widowwidth)/2 //left
	wheight=(wheight-windowheight)/2 //height
	var url = filenameurl
	var newwindowname=widowname
	var feau=arguments[4]
	var features
    if(feau==null)
    {
		features="toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=0"+",width="+widowwidth+",height="+windowheight+",left="+wwidth+",top="+wheight
	}
	else
	{	
		features= feau + ",width="+widowwidth+",height="+windowheight+",left="+wwidth+",top="+wheight
	}
	var sealWin = window.open(url,newwindowname,features)
	sealWin.focus()
}


function openContirbutionWindow(filenameurl,widowname,widowwidth,windowheight)
{
	var wwidth=window.screen.availWidth
	var wheight=window.screen.availHeight
	wwidth=(wwidth-widowwidth)/2 //left
	wheight=(wheight-windowheight)/2 //height
	var url = filenameurl
	var newwindowname=widowname
	var feau=arguments[4]
	var features
    if(feau==null)
    {
		features="toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=0"+",width="+widowwidth+",height="+windowheight+",left="+wwidth+",top="+wheight
	}
	else
	{	
		features= feau + ",width="+widowwidth+",height="+windowheight+",left="+wwidth+",top="+wheight
	}
	var sealWin = window.open(url,newwindowname,features)
	sealWin.focus();
	return sealWin;
}


//Michael 
function  vfnIsValidCard(obj)
{
	var cardNo=new String(obj.value)
	var len= cardNo.length
	// AMEX -- 34 or 37 -- 15 length
	if  ( new RegExp(/^34|^37/).test(cardNo) && len==15 ){return true}
	// MasterCard -- 51 through 55 -- 16 length
	else if( new RegExp(/^51|^52|^53|^54|^55/).test(cardNo) && len==16)    {return true}
	// VISA -- 4 -- 13 and 16 length
	else if( new RegExp(/^4/).test(cardNo) && (len==13 || len==16) ){return true}
	// Diners Club -- 300-305, 36 or 38 -- 14 length
	else if( new RegExp(/^300|^301|^302|^303|^304|^305|^36|^38/).test(cardNo) && len==14 ){return true}
	// Discover -- 6011 -- 16 length
	else if( new RegExp(/^6011/).test(cardNo) && len==16 ){return true}
	// JCB -- 3 -- 16 length
	else if( new RegExp(/^3/).test(cardNo) && len==16 ){return true}
	// JCB -- 2131, 1800 -- 15 length
	else if( new RegExp(/^2131|^1800/).test(cardNo)   && len==15 ){return true}
	else
	{
		alert("Invalid Card Number.")
		vfnFocusSelect(obj)
		return false
	}
}

//Michael
function vfnDisableFormFields()
{
	for(var i=0; i<document.forms[0].elements.length; i++)
	{
		document.forms[0].elements[i].disabled=true;

	}
	
	//Enable disired fields
	for(var i=0; i<arguments.length; i++)
	{
		arguments[i].disabled=false;
	}
}

/*----------------------------------------------------------------------------------------------------------------------
UDF:
FUNCTION NAME	- vfnCheckID
PURPOSE			- To allow [A-Z], [a-z], numbers, space, check if its a number and not allow zeros
ARGUMENTS		- Field object, message
RETURN VALUE	- If valid returns true else displays alert
Changes			- Done by Johnson (Make changes To allow Numbers only) on 28-Sept-2004
-------------------------------------------------------------------------------------------------------------------------*/

function vfnCheckIDOLD(obj,sMsg)
{
	if(vfnIsValidAlphaNum(obj))
	{
		if(vfnIsNumber(obj,1))
		{
			if (parseInt(obj.value, 10) == 0)
			{
				alert(sMsg)
				obj.focus()
				obj.select()
				return true
			}	
			else
			{
				return false
			}
			return true
		}
		else
			return false
	}
	else
		return false;
}


//Added by Johnson on 29-Sept-2004

function vfnCheckID(obj,sMsg)
{
	if(vfnIsValidAlphaNum(obj))
	{
			if (parseInt(obj.value, 10) == 0)
			{
				alert(sMsg)
				obj.focus()
				obj.select()
				return false
			}
			else
				 return true
	}
	else
		return false
}


function vfnSecWarn()
{	
	alert("Warning!\n\nYou are not authorized to do this operation!!!")
}

function fnCallbtnSearch(e,obj)
{

        if(IsIE==true){
        if(event.keyCode==13)
        {
        
           document.getElementById(obj).click();
           return false;
        } }
        else {
        if(e.which==13)
        {  document.getElementById(obj).click(); return false;}
        }
    
} 


function vfnHelp() //Old
{
	var objHelpWin
	//sFileName = sFileName + "?t=" + new Date().getTime();		
	objHelpWin = window.open("Help/HPS_Professional_on_Web_Help.htm#","Help","resize=1,toolbar=no,scrollbars=yes,menubar=no,height=500,width=730,top=20,left=30")	
	objHelpWin.location.href="Help/HPS_Professional_on_Web_Help.htm#"
	objHelpWin.focus()
}


/*----------------------------------------------------------------------------------------------------------------------
UDF:
FUNCTION NAME	-	vfnIsPercent
PURPOSE			-	To format the Percentage
ARGUMENTS		-	Field object
RETURN VALUE	-	Formated value
-------------------------------------------------------------------------------------------------------------------------*/
function vfnIsPercent(e,obj,sLabel)
{
	var sLabelNew="";
	var Field;
	var iDot;
	var num;
	//if(sLabel) sLabelNew = sLabel + ":\n\n";  //Default Value	
	if(sLabel) sLabelNew = sLabel + ":\n\n ";  //Default Value	
	obj.value=vfnTrim(obj);
	Field = obj;
	var length = Field.value.length;
    iDot=0;	
	for (var ct = 0; ct <= (Field.value.length - 1); ct++)
	{
		var Validchar = Field.value.substring(ct,ct+1);  
		var character = 0;  
		
		//To check for number of dots
		if (((Validchar >= "0") && (Validchar <= "9") && (iDot<=1)) || Validchar==".")
		{
			character = 1; //valid character
			if(Validchar==".")
			{
			    iDot=iDot+1;
			}
			if(iDot>1)
			{
			    character = 0; //Invalid character			
			    vfnAlertFocus(e, obj, sLabelNew + "Valid characters  [0-9],(.)")
			    return false;
			}
		}
		else
		{
			character = 0; //Invalid character			
			vfnAlertFocus(e, obj, sLabelNew + "Valid characters  [0-9],(.)")
			return false;
		}
	}
	if(obj.value=="." || obj.value=="")
    {
        //obj.value="0.00"
    }	    
	else
	{
	    num=parseFloat(obj.value);
	    obj.value=obj.value;
    }
    if(obj.value < 0 || obj.value >100)
    {
            character = 0; //Invalid character			
			vfnAlertFocus(e, obj, sLabelNew + "Valid between 0 and 100")
			return false;
    }
	return true; //If valid character
} 
//Edit the file whcsh_home.htm to get disired window with, it is in the folder Validation/
function vfnShowHelp()
{
	var arTemp = vsHelpFileInfo.split("~~")
	var iHelpFileID
	var LayerElement
	
	for(i=0; i<arTemp.length; i=i+3) //0, 3
	{
		
		 
		LayerElement = document.getElementById(arTemp[i])		
		 
		if(LayerElement!=null && LayerElement.style.visibility == "visible")
		{	
			if(parseInt(arTemp[i+2],10)!=0 && vsHelpFileMode=="EDIT")
				iHelpFileID = arTemp[i+2]
			else			
				iHelpFileID = arTemp[i+1]				
				
			break;
		}
		else //if none of the layer is visible
		{
			if(parseInt(arTemp[i+2],10)!=0 && vsHelpFileMode=="EDIT")
				iHelpFileID = arTemp[i+2]
			else			
				iHelpFileID = arTemp[i+1]				
		}
	}
	if(vsHelpFileMode=="INDEX")
	    RH_ShowHelp(0, 'Help/Local_4_Web_Remittance.htm>myhelpwindow', HH_HELP_CONTEXT, iHelpFileID)
	else
		RH_ShowHelp(0, '../Help/Local_4_Web_Remittance.htm>myhelpwindow', HH_HELP_CONTEXT, iHelpFileID)
}



function vfnShowReportHelp()
{
	
	var arTemp = vsHelpFileInfo.split("~~")
	var iHelpFileID
	var LayerElement
	
	for(i=0; i<arTemp.length; i=i+3) //0, 3
	{
		
		
		LayerElement = document.getElementById(arTemp[i])
		
		if(LayerElement!=null && LayerElement.style.visibility == "visible")
		{	
			if(parseInt(arTemp[i+2],10)!=0 && vsHelpFileMode=="EDIT")
				iHelpFileID = arTemp[i+2]
			else			
				iHelpFileID = arTemp[i+1]				
				
			break;
		}
		else //if none of the layer is visible
		{
			if(parseInt(arTemp[i+2],10)!=0 && vsHelpFileMode=="EDIT")
				iHelpFileID = arTemp[i+2]
			else			
				iHelpFileID = arTemp[i+1]				
		}
	}
	
	RH_ShowHelp(0, 'Help/Local_4_Web_Remittance.htm>myhelpwindow', HH_HELP_CONTEXT, iHelpFileID)
}








/*--------------------------------------------------------------------------
//The Helper function for WebHelp Context Sensitive Help - Start
--------------------------------------------------------------------------*/

var gbNav6=false;
var gbNav61=false;
var gbNav4=false;
var gbIE4=false;
var gbIE=false;
var gbIE5=false;
var gbIE55=false;

var gAgent=navigator.userAgent.toLowerCase();
var gbMac=(gAgent.indexOf("mac")!=-1);
var gbSunOS=(gAgent.indexOf("sunos")!=-1);
var gbOpera=(gAgent.indexOf("opera")!=-1);

var HH_DISPLAY_TOPIC = 0;
var HH_DISPLAY_TOC = 1;
var HH_DISPLAY_INDEX = 2;
var HH_DISPLAY_SEARCH = 3;
var HH_HELP_CONTEXT = 15;

var gVersion=navigator.appVersion.toLowerCase();

var gnVerMajor=parseInt(gVersion);
var gnVerMinor=parseFloat(gVersion);

gbIE=(navigator.appName.indexOf("Microsoft")!=-1);
if(gnVerMajor>=4)
{
	if(navigator.appName=="Netscape")
	{
		gbNav4=true;
		if(gnVerMajor>=5)
			gbNav6=true;
	}
	gbIE4=(navigator.appName.indexOf("Microsoft")!=-1);
}
if(gbNav6)
{
	document.gnPageWidth=innerWidth;
	document.gnPageHeight=innerHeight;
	var nPos=gAgent.indexOf("netscape");
	if(nPos!=-1)
	{
		var nVersion=parseFloat(gAgent.substring(nPos+10));
		if(nVersion>=6.1)
			gbNav61=true;
	}
}else if(gbIE4)
{
	var nPos=gAgent.indexOf("msie");
	if(nPos!=-1)
	{
		var nVersion=parseFloat(gAgent.substring(nPos+5));
		if(nVersion>=5)
			gbIE5=true;
		if(nVersion>=5.5)
			gbIE55=true;
	}
}

function RH_ShowHelp(hParent, a_pszHelpFile, uCommand, dwData)
{
	 
	
	// this function only support WebHelp
	var strHelpPath = a_pszHelpFile;
	var strWnd = "";
	var nPos = a_pszHelpFile.indexOf(">");
	if (nPos != -1)
	{
		strHelpPath = a_pszHelpFile.substring(0, nPos);
		strWnd = a_pszHelpFile.substring(nPos+1); 
	}
	
	
	
	if (isServerBased(strHelpPath))
		RH_ShowWebHelp_Server(hParent, strHelpPath, strWnd, uCommand, dwData);
	else
		RH_ShowWebHelp(hParent, strHelpPath, strWnd, uCommand, dwData);
}

function RH_ShowWebHelp_Server(hParent, strHelpPath, strWnd, uCommand, dwData)
{
	// hParent never used.
	ShowWebHelp_Server(strHelpPath, strWnd, uCommand, dwData);
}

function RH_ShowWebHelp(hParent, strHelpPath, strWnd, uCommand, dwData)
{
	// hParent never used.
	ShowWebHelp(strHelpPath, strWnd, uCommand, dwData);
}


function ShowWebHelp_Server(strHelpPath, strWnd, uCommand, nMapId)
{
	
	 
	
	
	var a_pszHelpFile = "";
	if (uCommand == HH_HELP_CONTEXT)
	{
		if (strHelpPath.indexOf("?") == -1)
			a_pszHelpFile = strHelpPath + "?ctxid=" + nMapId;
		else
			a_pszHelpFile = strHelpPath + "&ctxid=" + nMapId;
	}
	else
	{
		if (strHelpPath.indexOf("?") == -1)
			a_pszHelpFile = strHelpPath + "?ctxid=0";
		else
			a_pszHelpFile = strHelpPath + "&ctxid=0";
	}

	if (strWnd)
		a_pszHelpFile += ">" + strWnd;

	if (gbIE4)
	{
		a_pszHelpFile += "&cmd=newwnd&rtype=iefrm";
		loadData(a_pszHelpFile);
	}
	else if (gbNav4)
	{
		a_pszHelpFile += "&cmd=newwnd&rtype=nswnd";
		var sParam = "left="+screen.width+",top="+screen.height+",width=100,height=100";
		window.open(a_pszHelpFile, "__webCshStub", sParam);
	}
	else
	{
		var sParam = "left="+screen.width+",top="+screen.height+",width=100,height=100";
		if (gbIE5)
			window.open("about:blank", "__webCshStub", sParam);
		window.open(a_pszHelpFile, "__webCshStub");
	}
}


function ShowWebHelp(strHelpPath, strWnd, uCommand, nMapId)
{
	 
	
	var a_pszHelpFile = "";
	if (uCommand == HH_DISPLAY_TOPIC)
	{
		a_pszHelpFile = strHelpPath + "#<id=0";
	}
	if (uCommand == HH_HELP_CONTEXT)
	{
		a_pszHelpFile = strHelpPath + "#<id=" + nMapId;
	}
	else if (uCommand == HH_DISPLAY_INDEX)
	{
		a_pszHelpFile = strHelpPath + "#<cmd=idx";
	}
	else if (uCommand == HH_DISPLAY_SEARCH)
	{
		a_pszHelpFile = strHelpPath + "#<cmd=fts";
	}
	else if (uCommand == HH_DISPLAY_TOC)
	{
		a_pszHelpFile = strHelpPath + "#<cmd=toc";
	}
	
	if (strWnd)
		a_pszHelpFile += ">>wnd=" + strWnd;
	
	if (a_pszHelpFile)
	{
		if (gbIE4)
			loadData(a_pszHelpFile);
		else if (gbNav4)
		{
			var sParam = "left="+screen.width+",top="+screen.height+",width=100,height=100";
			window.open(a_pszHelpFile, "__webCshStub", sParam);
		}
		else
		{
			var sParam = "left="+screen.width+",top="+screen.height+",width=100,height=100";
			if (gbIE5)
				window.open("about:blank", "__webCshStub", sParam);
			window.open(a_pszHelpFile, "__webCshStub");
		}
	}
}

function isServerBased(a_pszHelpFile)
{
	if (a_pszHelpFile.length > 0)
	{
		var nPos = a_pszHelpFile.lastIndexOf('.');
		if (nPos != -1 && a_pszHelpFile.length >= nPos + 4)
		{
			var sExt = a_pszHelpFile.substring(nPos, nPos + 4);
			if (sExt.toLowerCase() == ".htm")
			{
				return false;
			}
		}
	}
	return true;
}

function getElement(sID)
{

	if(document.getElementById)
		{
		return document.getElementById(sID);
		}
	else if(document.all)
		return document.all(sID);
	return null;
}

function loadData(sFileName)
{
	if(!getElement("dataDiv"))
	{
		if(!insertDataDiv())
		{
			gsFileName=sFileName;
			return;
		}
	}
	var sHTML="";
	if(gbMac)
		sHTML+="<iframe name=\"__WebHelpCshStub\" src=\""+sFileName+"\"></iframe>";
	else
		sHTML+="<iframe name=\"__WebHelpCshStub\" style=\"visibility:hidden;width:0;height:0\" src=\""+sFileName+"\"></iframe>";
	
	var oDivCon=getElement("dataDiv");
	if(oDivCon)
	{
		if(gbNav6)
		{
			if(oDivCon.getElementsByTagName&&oDivCon.getElementsByTagName("iFrame").length>0)
			{
				oDivCon.getElementsByTagName("iFrame")[0].src=sFileName;
			}
			else
				oDivCon.innerHTML=sHTML;
		}
		else
		{
			//alert(sHTML)
			oDivCon.innerHTML=sHTML;			
		}
	}
}

function insertDataDiv()
{
	var sHTML="";
	if(gbMac)
		sHTML+="<div id=dataDiv style=\"display:none;\"></div>";
	else
		sHTML+="<div id=dataDiv style=\"visibility:hidden\"></div>";

	document.body.insertAdjacentHTML("beforeEnd",sHTML);
	return true;
}

/*--------------------------------------------------------------------------
//The Helper function for WebHelp Context Sensitive Help - End
--------------------------------------------------------------------------*/

/*----------------------------------------------------------------------------------------------------------------------
UDF:
FUNCTION NAME	-	vfnCheckEDIOrgName
PURPOSE			-	To allow [a-z], [A-Z], [0-9], comma, fullstop, forward slash, hyphen, underscore, hash, percentage, at, space and restricting other characters
ARGUMENTS		-	Field object
RETURN VALUE	-	If valid returns true else displays alert
-------------------------------------------------------------------------------------------------------------------------*/

function vfnCheckEDIOrgName(obj)          
{
	var Field
	obj.value=vfnTrim(obj)

	Field = obj
	
    var length = Field.value.length;
    
    for (var ct = 0; ct <= (Field.value.length - 1); ct++)
    {
		var Validchar = Field.value.substring(ct,ct+1);  // Check one Character at a time
		var character = 0;  // Set character as invalid alphanumeric value
		if (((Validchar >= "A") && (Validchar <= "Z")) || ((Validchar >= "a") && (Validchar <= "z")) || (Validchar == " ") || (Validchar == ",") || (Validchar == "-")|| (Validchar == ".")|| (Validchar == "/")|| (Validchar == "_")|| (Validchar == "#")|| (Validchar == "%")|| (Validchar == "@")||((Validchar >="0") && (Validchar <= "9")))
		{
       		character = 1; //valid character
	  	}
		else
		{
			character = 0; //Invalid character			
			obj.focus();
			obj.select();
			alert("Valid characters : [A-Z], [a-z], [0-9], comma, space, . , / , - , _ , # , % , @");
			return false;
		}
	}
	return true; //If valid character
}



function vfnReplaceAll(s, t, u) {
  /*
  **  Replace a token in a string
  **    s  string to be processed
  **    t  token to be found and removed
  **    u  token to be inserted
  **  returns new String
  */
 // alert(s)
  i = s.indexOf(t);
  r = "";
  if (i == -1) return s;
  r += s.substring(0,i) + u;
  if ( i + t.length < s.length)
    r += vfnReplaceAll(s.substring(i + t.length, s.length), t, u);
    return r;
  
  }

function vfnCheckNo(obj, optionNo)
{
 if(obj.value!="")
 {
	var soptionNo = optionNo;	
	var s1=obj.value;
	var s2,s3;
	var tem=0;
	var sTemp="";	
			s3=s1.charAt(0).toUpperCase();
	//alert(s3)
			sTemp = obj.value;
		if (sTemp=='00'||sTemp=='000'||sTemp=='0000'||sTemp=='00000'||sTemp=='000000'||sTemp=='0000000'||sTemp=='00000000'||sTemp=='000000000'||sTemp=='0000000000')
		{
			obj.focus();
			obj.select();
			alert("Valid characters : [0-9]");
			return false;
		}
	
	 if (s3==soptionNo)
	 {
		for (var i=1;i<s1.length;i++)
		{
			s2=s1.charAt(i);
			if( (s2>='0') && (s2<='9') )
			{
				tem=1;
			}
			else
			{
				tem=0;
				break;
			}
		}

		if (tem==0)
		{
			obj.focus();
			obj.select();
			alert("Valid characters : [0-9]");
			return false;
		}
		else if (tem==1)
		{
			obj.value=s1.toUpperCase();
			return true;
		}
	 }
	 else
	 {
	 
	 if(vfnIsNumber(obj)==true)
		{
		obj.value=soptionNo+s1
		}
		return true;
	 }
	}
}
function vfnCheckNo_New(e,obj, optionNo)
{
    
 if(obj.value!="")
 {
	var soptionNo = optionNo;	
	var s1=obj.value;
	var s2,s3;
	var tem=0;
	var sTemp="";	
			s3=s1.charAt(0).toUpperCase();
	//alert(s3)
			sTemp = obj.value;
		if (sTemp=='00'||sTemp=='000'||sTemp=='0000'||sTemp=='00000'||sTemp=='000000'||sTemp=='0000000'||sTemp=='00000000'||sTemp=='000000000'||sTemp=='0000000000')
		{
			obj.focus();
			obj.select();
			alert("Valid characters : [0-9]");
			return false;
		}
	
	 if (s3==soptionNo)
	 {
		for (var i=1;i<s1.length;i++)
		{
			s2=s1.charAt(i);
			if( (s2>='0') && (s2<='9') )
			{
				tem=1;
			}
			else
			{
				tem=0;
				break;
			}
		}

		if (tem==0)
		{
			obj.focus();
			obj.select();
			alert("Valid characters : [0-9]");
			return false;
		}
		else if (tem==1)
		{
			obj.value=s1.toUpperCase();
			return true;
		}
	 }
	 else
	 {
	     if(vfnIsNumber(e,obj,'1','')==true)
	     {
		    obj.value=soptionNo+s1
		    return true;
	     }
	     else {return false;}
	 }
	 
	}
}

function vfnCompareNo(obj1,obj2,Type)
{
 var Fieldfr,FieldTo;
 //Fieldfr = document.myform.txtEncNoFrom;
 //FieldTo = document.myform.txtEncNoTo;
 Fieldfr = obj1
 FieldTo = obj2
 
	if ((Fieldfr.value!='') && (FieldTo.value!=''))
	{
		var e1,l1,e2,l2;
	 l1 = Fieldfr.value.length;
	 l2 = FieldTo.value.length;
	 e1 = Fieldfr.value.substring(1,l1);
	 e2= FieldTo.value.substring(1,l2);

		if(parseInt(e1) > parseInt(e2))
		 {		
		 alert(Type +" To should be greater than or equal to "+Type+" From");		 
		 FieldTo.focus();
		 FieldTo.select();
		 return false;
		 }
		else
		 return true;	 
	}
} 


//Added by Johnson 08/25/2005 for checking the AmountCompare
/*----------------------------------------------------------------------------------------------------------------------
UDF:
FUNCTION NAME	-	vfnAmountCompare
PURPOSE			-	To compare the amount range between from amount and to amount(From should not be greater than To)
ARGUMENTS		-	obj1,obj2,Type
RETURN VALUE	-	If valid returns true else displays alert
-------------------------------------------------------------------------------------------------------------------------*/
function vfnAmountCompare(obj1,obj2,Type)
{
 var Fieldfr,FieldTo;
 Fieldfr = obj1
 FieldTo = obj2

	if ((Fieldfr.value!='') && (FieldTo.value!=''))
	{
		var e1,l1,e2,l2;
	 l1 = Fieldfr.value.length;
	 l2 = FieldTo.value.length;
	 e1 = Fieldfr.value.substring(0,l1);
	 e2= FieldTo.value.substring(0,l2);

		if(parseInt(e1) > parseInt(e2))
		 {
		 alert( Type +" From should not be greater than "+Type+"To");
		 Fieldfr.focus();
		 Fieldfr.select();
		 return false;
		 }
		else
		 return true;	 
	}
} 

/*----------------------------------------------------------------------------------------------------------------------
UDF:
FUNCTION NAME	-	vfnSelectRow
PURPOSE			-	To highlight the selected row in the records display grid
ARGUMENTS		-	tableId, rowNo, staticRow
RETURN VALUE	-	No
-------------------------------------------------------------------------------------------------------------------------*/
function vfnSelectRow(tableId, rowNo, staticRow)
{
	var obj=  document.getElementById(tableId);

	for(var i=1; i<obj.rows.length; i++)
		obj.rows[i].className="gridrow";
	
	if(staticRow>1)		
		obj.rows[rowNo+1].className="gridrowselect";
	else
		obj.rows[rowNo].className="gridrowselect";
}

/*------------------------------------------------------------------------------
UDF:
FUNCTION NAME	-	vfnCheckViewRecords
PURPOSE			-	Non-Paidclaims checkbox is selected then selectViewrecords listbox automaticaly 
						selected 'All Records' value.
ARGUMENTS		-	argCheck, argSel, arg
RETURN VALUE	-	Nil 
-------------------------------------------------------------------------------*/
function vfnCheckViewRecords(argCheck, argSel, arg)
{
	with(document.myform)
	{
	if(argCheck.checked==true)
		vfnSelectListItem(argSel, 'ALL')
	else if(argCheck.checked==false && arg!='Select')
		argSel.selectedIndex=0;
	}
}
//sType='P' - Parser, 'N' - Node 
function vfnXMLHttpRequest(sURL,sType)
{

	var parser
	var nodes=null
	var xmlhttp
	
	if (window.XMLHttpRequest) //Netcape
	{
		xmlhttp=new XMLHttpRequest()
		xmlhttp.open("GET",sURL,false)
		xmlhttp.send(null)
	}
	else if(window.ActiveXObject) //IE only
	{
	    if (window.XMLHttpRequest) //Netcape and IE 7
        {
            xmlhttp=new XMLHttpRequest()
        }
        else if(window.ActiveXObject) //IE5.x and IE 6 only
        {
	        xmlhttp=new ActiveXObject("Microsoft.XMLHTTP")
        }
		
		if (xmlhttp)
		{
			xmlhttp.open("GET",sURL,false)
			xmlhttp.send()
		}
	}
	if (xmlhttp.readyState==4)
	{		
			var xmlstring=xmlhttp.responseText			
			if (xmlhttp.status!=200)
			{
				alert(sMsgXMLErr)
				xmlstring="<answer>NA</answer>"
			}
			
			if (window.XMLHttpRequest && IsIE==false) //For IE7 - It should use ActiveX
			{			
				var domparser = new DOMParser();
				parser = domparser.parseFromString(xmlstring, "text/xml");
				nodes=parser.documentElement.childNodes;
			}
			else
			{
			    var parser=new ActiveXObject("microsoft.xmldom")
				parser.async="false"				
				parser.loadXML(xmlstring)			
				nodes = parser.documentElement.childNodes
				
			}			

		//if(nodes.length>
		//alert(nodes.item(0).nodeValue)
		
		if(sType=="P")
			return parser
		else
			return nodes
		
		
	}
}


//sType='RT' - Response Text
function vfnXMLHttpRequestPost(sURL, sPostData, sType, sServer)
{
    var sResponseText;
    var xmlhttp

 try{
 	    if (window.XMLHttpRequest) //Netcape
	    {
		    xmlhttp=new XMLHttpRequest()
		    xmlhttp.open("POST",sURL,false);
		    xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		    xmlhttp.send(sPostData);
	    }
	    else if(window.ActiveXObject) //IE only
	    {
		    xmlhttp=new ActiveXObject("Microsoft.XMLHTTP")
		    if (xmlhttp)
		    {
			    xmlhttp.open("POST",sURL,false);
			    xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
			    xmlhttp.send(sPostData)
		    }
	    }

    }
    catch(e)
    {
       
        
    }

	
	if (xmlhttp.readyState==4)
	{
	    
			sResponseText=xmlhttp.responseText
			
			if (xmlhttp.status!=200)
			{
				alert(sMsgXMLErr)
				sResponseText="NA"
			}
			
        return sResponseText;
	}
	
}
function vfnIsValidPassword(e, objPwd, sAccMode, sLabel)
{
	var sPass = objPwd.value;
	var Validchar;
	var bValid=true;
	var sAlertTitle = vfnGetAlertTitle(sLabel, ''); //vfnGetAlertTitle(sLabel, '') Not Used
	
	//if(sAccMode=="CHECK") //As done in CH, validation done
	//	return vfnIsValidAlphaNum(e, objPwd, sLabel)
	
	for(var i=0;i<sPass.length; i++)
	{
		Validchar=sPass.charAt(i)
		
		//if (((Validchar >= "A") && (Validchar <= "Z")) || ((Validchar >= "a") && (Validchar <= "z")) || ((Validchar >= "0") && (Validchar <= "9")))
		if (((Validchar >= "A") && (Validchar <= "Z")) || ((Validchar >= "a") && (Validchar <= "z")) || ((Validchar >= "0") && (Validchar <= "9")) || (Validchar == "-") || (Validchar == "_"))
		{
			
		}
		else
		{	
			bValid=false			
		}
	}
	if (sPass=="") return true;
	
	if (bValid==true)
	    {	   
	        if (sPass.length>=6)
	        {
	            return true
	        }
	        else
	        {
	         vfnAlertFocus(e,objPwd,sAlertTitle + "should be 6 to 15 characters in length, and consist of letters and numbers.",'')
		    return false;
	        }
	    }    
	else
	{
	    vfnAlertFocus(e,objPwd,sAlertTitle + "Valid characters: [A-Z], [a-z], [0-9], Underscore, Hyphen",'')
		return false;
	}
//	if (bValid==true && sPass.length>=6)
//	{
//		return true
//	}
//	else
//	{
//		//vfnAlertFocus(e,objPwd,sAlertTitle + "Password should have minimum of 6 characters." +'\n\n'+ "You can have alphabets and numbers.",'');		
//		vfnAlertFocus(e,objPwd,sAlertTitle + "Valid characters : [A-Z],[a-z],[0-9],underscore,hyphen",'')
//		return false;
//	}
}
var sMsgNoMatchPassword = "Password characters do not match";

function vfnIsValidUserName(e, r_varCtrl, sAccMode, sLabel)
{

	var Field
	r_varCtrl.value=vfnTrim(r_varCtrl)
	Field = r_varCtrl
    var length = Field.value.length;
    var sAlertTitle = vfnGetAlertTitle(sLabel, '')
   		
    for (var ct = 0; ct <= (Field.value.length - 1); ct++)
    {
		var Validchar = Field.value.substring(ct,ct+1);  // Check one Character at a
							    // time
		var character = 0;  // Set character as invalid alphanumeric value
		
		if (((Validchar >= "A") && (Validchar <= "Z")) || ((Validchar >= "a") && (Validchar <= "z")) || ((Validchar >= "0") && (Validchar <= "9")) || (Validchar == "-") || (Validchar == "_"))
		{
			character = 1; //valid character
	  	}
		else
		{
			character = 0; //Invalid character			
			vfnAlertFocus(e,r_varCtrl,sAlertTitle + "Valid characters: [A-Z], [a-z], [0-9], Underscore, Hyphen",'')
			return false;
		}
	}
	
	if(Field.value!="" && Field.value.length<6)
	{
		vfnAlertFocus(e,r_varCtrl,sLabel + " should be 6 to 15 characters in length, and consist of letters and numbers.",'')
		return false
	}
	return true; //If valid character
}

function vfnAlertFocus(e, obj, msg, sLayerName)
{
	if (!e) var e = window.event
		
	if(IsIE || e.type=="click" || e.type=="submit" || e.type=="keydown")
	{

		if(sLayerName) 
		{
			vfnLayerFocus(sLayerName);
		}
		alert(msg);
		obj.focus();
		obj.select();				
	}	
}
function vfnGetAlertTitle(sLabel, sTitle)
{
var sLabelNew="", sTitleNew="", sAlertTitle=""
	
	if(sLabel) sLabelNew = sLabel
	if(sTitle) sTitleNew = sTitle
	
	//Forming Alert Title
	if(sLabelNew!="" && sTitleNew!="")
		sAlertTitle = sTitleNew + " - " + sLabelNew + ":\n\n"
	else if(sLabelNew!="")
		sAlertTitle = sLabelNew + ":\n\n"  
	else if(sTitleNew!="")
		sAlertTitle = sTitleNew + ":\n\n" 	
	
	return sAlertTitle;
}
function vfnAlertFocusStr(sEventType, obj, msg, sLayerName)
{
	if(IsIE || sEventType=="click" || sEventType=="submit")
	{
		if(sLayerName) 
		{
			vfnLayerFocus(sLayerName);
		}		
		alert(msg);
		obj.focus();
		obj.select();
	}	
}

function vfnTrim(obj)
{
  	var Field
    Field = obj
    if (!Field) // Validate the Form element
      {
        alert("Function : Element is not Defined !");
        return(-1);
      }
			
	var y=Field.value.length;
    var retval=Field.value;
    var m=0;
		
    while(m < y) //Start removing white spaces from left side
	{  
      	if ((retval.substring(0,1)==" ")||(retval.substring(0,1)=="     "))
		{ 
          	retval=Field.value.substring(m+1,y); //remove left most white char
        } 
        else 
        { 
          	break;
        }
        m++;
    }
				
    y=retval.length;
    m=y;
	
      while (m >= 0) //Start removing white spaces from right side
		{  
        	if ((retval.substring(m-1,m)==" ")||(retval.substring(m-1,m)==" "))
          	{  
            	retval=retval.substring(0,m-1); //remove right most white char
            } 
          else 
            { 
              break;  //first non - white character encountered while 
                      //traversing from right to left. so break the loop
            }
          m--;
        }
        
        return retval;
}
//////////////////venkat jaladi
/////////////////19-03-2007
/////////////////perform reset function

function vfnCheckLength(e,obj1,size,sLabel)
{
    if(obj1.value!="")
    {
        var s1=obj1.value;        
        if(s1.length>=size)
        {            
            alert(sLabel)
            obj1.focus();         
            return false;     
           
        }
        else 
        {  
              return true;     
        }
    }
    else
    {
        return true;
    }
}
function vfnClear()
{
document.aspnetForm.reset();
window.scroll(0,0);
return  false;

}
/*----------------------------------------------------------------------------------------------------------------------
UDF:
FUNCTION NAME	-	vfnIsValidAlphaNumeric
PURPOSE			-	To validate alphanumeric values
ARGUMENTS		-	Field object
RETURN VALUE	-	True or False
-------------------------------------------------------------------------------------------------------------------------*/
function vfnIsValidAlphaNumeric(e, obj, sLabel,sLayerName) 
{	
	var sLabelNew=""
	if(sLabel) sLabelNew = sLabel + ":\n\n"  //Default Value	
	obj.value=vfnTrim(obj)	
	var iLength = obj.value.length;
		
	for (var ct = 0; ct <= (iLength - 1); ct++)
	{	
		var Validchar = obj.value.substring(ct,ct+1);  // Check one Character at a time
		var character = 0;  // Set character as invalid alphanumeric value
		if (((Validchar >= "A") && (Validchar <= "Z")) || ((Validchar >= "a") && (Validchar <= "z")) || ((Validchar >= "0") && (Validchar <= "9")))
		{
			character = 1; //valid character
		}
		else
		{
			character = 0; //Invalid character

			vfnAlertFocus(e, obj, sLabelNew + msgValidAlphaNumeric,sLayerName)
			//obj.focus();
			//obj.select();  // jayaraj 12-Dec-2003
			return false;
		}
	}
	obj.value=((obj.value).charAt(0)).toUpperCase()+obj.value.substring(1,(obj.value).length)
	return true; //If valid character
}
/*------------------------------------------------------------------------------
UDF:
FUNCTION NAME	-	vfnIsValidNPI
PURPOSE			-	To Validate the NPI
ARGUMENTS		-	event,object
RETURN VALUE	-	Nil 
-------------------------------------------------------------------------------*/
function vfnIsValidNPI_new(e,obj,sLabel,sLayerName)
{
    var sLabelNew=""
	if(sLabel) sLabelNew = sLabel + ":\n\n"  //Default Value	
	var tmp, sum, i, j;
	var value="";
	var npi = obj.value;
		
	i = npi.length;
if(i>0)
{
	if(!vfnIsNumber(e,obj,1,sLabel,sLayerName))return false;
	
	if(i!=10 && i!=15)
	{
	vfnAlertFocus(e, obj, sLabelNew + sMsgNPIInvalidFormat,sLayerName)
	
	obj.focus();
	return false;
	}
	if ((i == 15) && (npi.substring(0,5)=="80840")) 
	    sum = 0; 
	else if (i == 10)
		sum = 24;	
	else 
	{
	
	vfnAlertFocus(e, obj, sLabelNew + sMsgNPIInvalid,sLayerName)
	obj.focus();
	return false;	
	}
	j = 0;
	
	while (i--)
	{	
		   
		tmp = npi.charAt(i) - '0';		
		if (j++ & 1)
		{		   
			if ((tmp <<= 1) > 9)
			{
			
				tmp -= 10;	
				tmp++;
					
			}
		}
		
		sum += tmp;
		
	}
	
	if ((sum % 10) == 0)
	{
	    
	  return true;
	  
	}
	else
	{	
	vfnAlertFocus(e, obj, sLabelNew + sMsgNPIInvalid,sLayerName)
	obj.focus();
	return false;
   }
 }
 return true;
}

/*------------------------------------------------------------------------------
UDF:
FUNCTION NAME	-	vfnIsValidNPI
PURPOSE			-	To Validate the NPI
ARGUMENTS		-	event,object
RETURN VALUE	-	Nil 
-------------------------------------------------------------------------------*/
function vfnIsValidNPI(obj)
{
	var tmp, sum, i, j;
	var value="";
	var npi = obj.value;
		
	i = npi.length;
if(i>0)
{
	if(!vfnIsNumber(obj,1))return false;
	
	 var sfirstDig=obj.value.substring(0,1);
    if((parseInt(sfirstDig)>=1 && parseInt(sfirstDig)<=4)==false )
    {
            alert("The NPI number you have entered is invalid.\nThe first digit should range between 1 to 4.");
            obj.focus();
		    return false;
    }	
    
	if(i!=10 && i!=15)
	{
	alert(sMsgNPIInvalidFormat);
	obj.focus();
	return false;
	}
	if ((i == 15) && (npi.substring(0,5)=="80840")) 
	    sum = 0; 
	else if (i == 10)
		sum = 24;	
	else 
	{
	alert(sMsgNPIInvalid);
	obj.focus();
	return false;	
	}
	j = 0;
	
	while (i--)
	{	
		   
		tmp = npi.charAt(i) - '0';		
		if (j++ & 1)
		{		   
			if ((tmp <<= 1) > 9)
			{
			
				tmp -= 10;	
				tmp++;
					
			}
		}
		
		sum += tmp;
		
	}
	
	if ((sum % 10) == 0)
	{
	    
	  return true;
	  
	}
	else
	{
	alert(sMsgNPIInvalid); 
	obj.focus();
	return false;
   }
 }
 return true;
}

function vfnCheckMaxDate(e,obj1,obj2,sLabel)
{

    if(obj1.value!="")
    {
        if ((((Date.parse(obj2.value))-(Date.parse(obj1.value)))/(24*60*60*1000)).toFixed(0) <= 0)
        {
          alert(sLabel);
          obj2.focus();
          obj2.select();
          return false;
        }
        else
            return true;
    }
    else
        return true;
}

function vfnRetypePassword(e,pw1,pw2)
{
	var Password = pw1.value;
	var RPassword = pw2.value;
	if(Password!="" && RPassword!="")
	{
	    if(Password != RPassword) //To Check both passwords are same.
		{
		    vfnAlertFocus(e,pw1,sMsgNoMatchPassword,'');		      
			return false;
		}
		else
		{
		    return true;
		}
	}
	else
		return true;
}

//Global variables for XMLHttp
var xmlhttp, xmlparser, xmlnodes
var gsXMLDelim ="$A#" //Delimiter used to split the data received via XML Http
function vfnPopuluateUserZip(sEventType,objZip,objCity,objState,objCounty,objZipStatus,sLabel,sLayerName)
{
    if(sLabel!=null && sLabel!='')
        var sURL =  "XmlHttpValidate.aspx?Code=" + escape(objZip.value) + "&msg=ZIP"
    else
	    var sURL =  "XmlHttpValidate.aspx?Code=" + escape(objZip.value) + "&msg=ZIP"
		
	if(objZip.value!="")
	{
		//Assign objects to Global Variables
		gObjField1 = objZip; gObjField2 = objCity; gObjField3 = objState; gObjField4 = objCounty; gObjZipStatus=objZipStatus;
		gsEventType = sEventType;
		gsLabel = sLabel; gsLayerName = sLayerName		
		var nodes = vfnXMLHttpRequest(sURL,"N")
				
		if (vfnGetNodeValue(nodes, 0)=="NA")
		{
			objZipStatus.value="NOT_AVAILABLE"
			objCity.value=""
			objState.value=""			
			objCounty.value=""		
			vfnAlertFocusStr(sEventType, objZip, "Zip Code not available in the list.")
			return false					
		}
		else
		{		
			gObjZipStatus.value="AVAILABLE"				
			objCity.value   = vfnGetNodeValue(nodes, 0)
			objState.value  = vfnGetNodeValue(nodes, 1)				
			
			if(objCounty) 
			objCounty.value = vfnGetNodeValue(nodes, 2)
			return true
		}		 
	}
	else
		return true
}

function vfnPopuluateNPI(sEventType,objNPI,objOrgName,objSuffix,objLname,objFname,objmname,objAdd1,objAdd2,objcity,objstate,objcounty,objzip,objfax,objphone,objNPIStatus,sLabel,sLayerName)
{
    if(sLabel!=null && sLabel!='')
        var sURL =  "../XmlHttpValidate.aspx?Code=" + escape(objNPI.value) + "&msg=NPI"
    else
	    var sURL =  "XmlHttpValidate.aspx?Code=" + escape(objNPI.value) + "&msg=NPI"
		
	if(objNPI.value!="")
	{
		//Assign objects to Global Variables
		gObjField1 = objNPI; gObjField2 = objOrgName; gObjField3 = objSuffix; gObjField4 = objLname;gObjField5 = objFname;
		gObjField6 = objmname; gObjField7 = objAdd1; gObjField8 = objAdd2; gObjField9 = objcity;gObjField10 = objstate;
		gObjField11 = objcounty; gObjField12 = objzip; gObjField13 = objfax; gObjField14 = objphone;
		gObjNPIStatus=objNPIStatus;
		gsEventType = sEventType;
		gsLabel = sLabel; gsLayerName = sLayerName		
		var nodes = vfnXMLHttpRequest(sURL,"N")
				
		if (vfnGetNodeValue(nodes, 0)=="NA")
		{
			gObjNPIStatus.value="NOT_AVAILABLE"
			objOrgName.value=""
			objSuffix.value=""			
			objLname.value=""		
			objFname.value=""		
			objmname.value=""		
			objAdd1.value=""		
			objAdd2.value=""		
			objcity.value=""		
			objstate.value=""		
			objcounty.value=""		
			objzip.value=""		
			objfax.value=""		
			objphone.value=""					
			vfnAlertFocusStr(sEventType, objNPI, "NPI not available in the list.")
			return false
					
		}
		else if (vfnGetNodeValue(nodes, 0)=="AN")
		{
			gObjNPIStatus.value="AVAILABLE"
			objOrgName.value=""
			objSuffix.value=""			
			objLname.value=""		
			objFname.value=""		
			objmname.value=""		
			objAdd1.value=""		
			objAdd2.value=""		
			objcity.value=""		
			objstate.value=""		
			objcounty.value=""		
			objzip.value=""		
			objfax.value=""		
			objphone.value=""					
			vfnAlertFocusStr(sEventType, objNPI, "NPI already exists.")
			return false					
		}
		else if (vfnGetNodeValue(nodes, 0)=="AA")
		{
			gObjNPIStatus.value="AVAILABLE"
//			objOrgName.value=""
//			objSuffix.value=""			
//			objLname.value=""		
//			objFname.value=""		
//			objmname.value=""		
//			objAdd1.value=""		
//			objAdd2.value=""		
//			objcity.value=""		
//			objstate.value=""		
//			objcounty.value=""		
//			objzip.value=""		
//			objfax.value=""		
//			objphone.value=""								
			return false					
		}
		else
		{		
			gObjNPIStatus.value="AVAILABLE"					
			objOrgName.value= vfnGetNodeValue(nodes, 0)
			objSuffix.value= vfnGetNodeValue(nodes, 1)		
			objLname.value= vfnGetNodeValue(nodes, 2)	
			objFname.value= vfnGetNodeValue(nodes, 3)	
			objmname.value= vfnGetNodeValue(nodes, 4)	
			objAdd1.value= vfnGetNodeValue(nodes, 5)	
			objAdd2.value= vfnGetNodeValue(nodes, 6)		
			objcity.value= vfnGetNodeValue(nodes, 7)		
			objstate.value= vfnGetNodeValue(nodes, 8)	
			objcounty.value= vfnGetNodeValue(nodes,9)
			objzip.value= vfnGetNodeValue(nodes, 10)	
			objfax.value= vfnGetNodeValue(nodes, 11)	
			objphone.value= vfnGetNodeValue(nodes, 12)			
			
			return true
		}		 
	}
	else
		return true
}


function vfnPopuluateZip(sEventType,objZip,objCity,objState,objCounty,objZipStatus,sLabel,sLayerName)
{
    if(sLabel!=null && sLabel!='')
        var sURL =  "../XmlHttpValidate.aspx?Code=" + escape(objZip.value) + "&msg=ZIP"
    else
	    var sURL =  "../XmlHttpValidate.aspx?Code=" + escape(objZip.value) + "&msg=ZIP"
	
	if(objZip.value!="")
	{
		//Assign objects to Global Variables
		gObjField1 = objZip; gObjField2 = objCity; gObjField3 = objState; gObjField4 = objCounty; gObjZipStatus=objZipStatus;
		gsEventType = sEventType;
		gsLabel = sLabel; gsLayerName = sLayerName
		
		var nodes = vfnXMLHttpRequest(sURL,"N")		
		if (vfnGetNodeValue(nodes, 0)=="NA")
		{
			objZipStatus.value="NOT_AVAILABLE"
			objCity.value=""
			objState.value=""			
			objCounty.value=""		
			vfnAlertFocusStr(sEventType, objZip, "Zip Code not available in the list.")
			return false
					
		}
		else
		{
			gObjZipStatus.value="AVAILABLE"				
			objCity.value   = vfnGetNodeValue(nodes, 0)
			objState.value  = vfnGetNodeValue(nodes, 1)				
			
			if(objCounty) 
			objCounty.value = vfnGetNodeValue(nodes, 2)
			return true
		}		 
	}
	else
		return true
}

function vfnGetNodeValue(nodes, iPos)
{
	if(nodes.item(iPos).firstChild)
		return nodes.item(iPos).firstChild.nodeValue;
	else
		return "";
}

function fnCheckDropDown(obj,Message)
{
    if(obj.selectedIndex==0)
    {
        alert("Select " + Message);
        obj.focus();
        return true;
    }   
}


 function winOpen(val)
 {   
	    openCenterWindow("../Provider/SearchcollegeInfo.aspx?selCty="+val,"Search",750,600,"scrollbars=1")
	    return false;
 }
 
function fnCheckExistingMember(e,sID,IP,uid,stype)
{
    try
    {
       
        var sURL
        sURL="XmlHttpValidate.aspx?MN=Fetchvalue"+"&SessionID="+sID+"&IPAddress="+IP+"&quid="+uid+"&Type="+stype
        nodes=vfnXMLHttpRequest(sURL,"N")
    }
    catch(e)
    {
        alert("The page has encountered an error. Please try again!!");	
        return false;
    }
       
    var sItem, arListItem
    if(nodes.item(0).nodeValue=="NA") return
    
   
        
        for(var iLoop=0;iLoop<nodes.length;iLoop++)
        {
            
            sItem = vfnGetNodeValue(nodes,iLoop)
            arListItem = sItem.split("#~@")
            
            var ddlprod;var ddlCategry;
            
            if(arListItem[1]!="")
            {
                if(arListItem[1]!="" && arListItem[0]!="")
                {
                        arListItem[0].replace(" XMLand ", " & ");
                        arListItem[1].replace(" XMLand ", " & ");
                }
                return true;
                
            }
            
        }
        
        return false;
    
}
function fnCheckExistingUser(e,sID,IP)
{
    try
    {
       
        var sURL
        sURL="XmlHttpValidate.aspx?MN=Fetchvalue"+"&SessionID="+sID+"&IPAddress="+IP+"&Type=USER"
        nodes=vfnXMLHttpRequest(sURL,"N")
    }
    catch(e)
    {
        alert("The page has encountered an error. Please try again!!");	
        return false;
    }
       
    var sItem, arListItem
    if(nodes.item(0).nodeValue=="NA") return
    
   
        
        for(var iLoop=0;iLoop<nodes.length;iLoop++)
        {
            
            sItem = vfnGetNodeValue(nodes,iLoop)
            arListItem = sItem.split("#~@")
            
            var ddlprod;var ddlCategry;
            
            if(arListItem[1]!="")
            {
                if(arListItem[1]!="" && arListItem[0]!="")
                {
                        arListItem[0].replace(" XMLand ", " & ");
                        arListItem[1].replace(" XMLand ", " & ");
                }
                return true;
                
            }
            
        }
        
        return false;
    
}
function fnCheckExistingMember(e,uid)
{
    try
    {
       
        var sURL
        sURL="XmlHttpValidate.aspx?MN=Fetchvalue"+"&Uid="+uid+"&Type=MEMBER"
        nodes=vfnXMLHttpRequest(sURL,"N")
    }
    catch(e)
    {
        alert("The page has encountered an error. Please try again!!");	
        return false;
    }
       
    var sItem, arListItem
    if(nodes.item(0).nodeValue=="NA") return
    
   
        
        for(var iLoop=0;iLoop<nodes.length;iLoop++)
        {
            
            sItem = vfnGetNodeValue(nodes,iLoop)
            arListItem = sItem.split("#~@")
            
            var ddlprod;var ddlCategry;
            
            if(arListItem[1]!="")
            {
                if(arListItem[1]!="" && arListItem[0]!="")
                {
                        arListItem[0].replace(" XMLand ", " & ");
                        arListItem[1].replace(" XMLand ", " & ");
                }
                return true;
                
            }
            
        }
        
        return false;
    
}


function checkchars(e,obj,sLabel,sMin)
{
    if(obj.value!="" && sMin!=null && sMin!="")
    {
            if(obj.value.length > sMin)
	        {
	            if(sLabel) sLabelNew = sLabel + ":\n\n"
	            //alert(msg + " : The Length of Entered text is " + nValue.length + ". It must be " + maxlength + " characters or less!")
		        //vfnAlertFocus(e, obj, sLabelNew + sLabel +" must be Maximum " + sMin + " characters.");		        
		        //vfnAlertFocus(e,obj,sLabelNew + sLabel +" The Length of Entered text is " + obj.value.length + ".It must be " + sMin + " characters or less!"); 
		        vfnAlertFocus(e,obj,sLabelNew + " The field length is " + obj.value.length + " and the maximum length allowed is only " + sMin + " characters."); 
		        obj.focus();
		        obj.select();
		        return false;
		    } 
		    else
		    {
		        return true;
		    }
    }
    else
    {
        return true;
    }
}