var isMozilla;
var objDiv = null;
var DivID = "";
var over = false;
function MouseDown(e) 
{ 
    if (over)
    {
        if (isMozilla) {
            objDiv = DivID //document.getElementById(DivID);
            X = e.layerX;
            Y = e.layerY;
            return false;
        }
        else {
            objDiv = DivID //document.getElementById(DivID);
            objDiv = objDiv.style;
            X = event.offsetX;
            Y = event.offsetY;
        }
    }
}

function MouseMove(e) 
{
    if (objDiv) {
        if (isMozilla) {
            objDiv.style.top = (e.pageY-Y) + 'px';
            objDiv.style.left = (e.pageX-X) + 'px';
            return false;
        }
        else 
        {
            objDiv.pixelLeft = event.clientX-X + document.body.scrollLeft;
            objDiv.pixelTop = event.clientY-Y + document.body.scrollTop;
            return false;
        }
    }
}

function MouseUp() 
{
    objDiv = null;
    if(typeof stopKey1 == 'function') 
    {
        document.onmousedown = stopKey1;
    } 
}

function initializefunction(Modalpopup)
{
    DivID = document.getElementById(Modalpopup);
    objDiv=DivID;
    isMozilla = (document.all) ? 0 : 1;


    if (isMozilla) 
    {
        document.captureEvents(Event.MOUSEDOWN | Event.MOUSEMOVE | Event.MOUSEUP);
    }

    document.onmousedown = MouseDown;
    document.onmousemove = MouseMove;
    document.onmouseup = MouseUp;
}
function ClientPopulated(source, eventArgs)
{
    if (source._currentPrefix != null)
    {
        var list = source.get_completionList();
        var search = source._currentPrefix.toLowerCase();
        for (var i = 0; i < list.childNodes.length; i++)
        {
             var obj=list.childNodes[i]._value.split("^").length
             if(list.childNodes[i]._value.split("^").length==2)
              {
                var _value=list.childNodes[i]._value.split("^");       
                var text=_value[0];
                var moreText=_value[1];
                list.childNodes[i]._value=moreText;
                list.childNodes[i].innerHTML=text;
               }
            var text = list.childNodes[i].innerHTML;
            var index = text.toLowerCase().indexOf(search);
            if (index != -1)
            {
                var value1 = text.substring(0, index);
                value1 += '<span class="AutoComplete_ListItemHiliteText">';
                value1 += text.substr(index, search.length);
                value1 += '</span>';
                value1 += text.substring(index + search.length);
                list.childNodes[i].innerHTML = value1;
            }
        }
    }
}
// Function to remove highlight span once selected
function ClientItemSelected(source, e)
{
    var node;
    var value = e.get_value();
   
    if (value) node = e.get_item();
    else
    {
        value = e.get_item().parentNode._value;
        node = e.get_item().parentNode;
       
    }
   
    var text = (node.innerText) ? node.innerText : (node.textContent) ? node.textContent : node.innerHtml;
	//source.get_element().value = text;
	source.get_element().value = value;
	

}
function aceListOver(source, eventArgs) 
{
   source.get_element().value = eventArgs.get_value(); 
} 
//	PURPOSE: This function is not taking the decimal point (.) from the Numeric KeyPad
function ClearFileuploadControl (obj) 
{ 
   var fil=document.getElementById(obj); 
   fil.select(); 
   n=fil.createTextRange(); 
   n.execCommand('delete'); 
   fil.focus(); 
} 

function revString(str) { 
           var retStr = ""; 
           for (i=str.length - 1 ; i > - 1 ; i--){ 
              retStr += str.substr(i,1); 
           } 
           return retStr; 
        } 
        
  //Purpose of this function is Trim the string Added By Rakesh.      
    function trim(s)
    {
          s= s.replace(/^\s*/, "").replace(/\s*$/, "");
          return s;
    } 

////////function checkValidNumeric(ctrlname,mxlen,decpoint,event.keyCode)
////////{
////////			var strNumeric = '1234567890'
////////			//alert(String.fromCharCode(event.keyCode));
////////			var str = ctrlname.value;	
////////			ctrLen=ctrlname.value.length + 1 ;
////////			ctrlname.maxLength = mxlen;
////////			
////////			if (decpoint == 0 || decpoint =='')
////////			{
////////				if (strNumeric.indexOf(String.fromCharCode(event.keyCode)) == -1 && event.keyCode != 8) 
////////				{
////////					return false;
////////				}		
////////			}
////////			
////////			if(decpoint > 0 && event.keyCode != 8 )
////////			{	
////////				
////////				if (ctrlname.value.indexOf('.')!=-1)
////////				{
////////					
////////					if (event.keyCode ==46)
////////					{
////////						return false;
////////					}
////////					if ((ctrlname.value.slice(ctrlname.value.indexOf('.')).length)> decpoint)
////////					{
////////						return false;
////////					}
////////				}
////////				if (strNumeric.indexOf(String.fromCharCode(event.keyCode)) == -1 && event.keyCode != 8 && event.keyCode !=46) 
////////				{
////////					
////////					return false;
////////				}	
////////			}
////////}
 function formatCurrency(ctrlname,decPoint)
{
	var exponentialLen = ctrlname.value.slice(ctrlname.value.indexOf('.')).length-1;
	var str = ctrlname.value;
	if(str.indexOf('.',0)!=-1)
	{
		if (exponentialLen > decPoint)
		{
			str = Math.round(parseFloat(str)*Math.pow(10,decPoint))/Math.pow(10,decPoint) ;
			str = str.toString()
			if(str.indexOf('.')==-1)
			{
				str = str +'.'
				for(i=0;i<decPoint;i++)
				{
					str = str+'0';
				}	
			} 
		}
		
		if (exponentialLen < decPoint)
		{
			var intDiff = parseInt(decPoint) - parseInt(exponentialLen);
			for(i=0;i<intDiff;i++)
			{
				str = str+'0';
			}	
		}
				
	}	
	else
	{
		if (str.length > 0)
		{
			str = str+".";	
		}
		else
		{
			str = "0.";	
		}	
		
		for(i=0;i<decPoint;i++)
		{
			str = str+'0';
		}	
	}
	ctrlname.value =  str;	
	
}

// function checkValidNumeric(ctrlname,mxlen,decpoint,e)
//		{
//			if(document.all)
//	        { //it's IE 
//                var e = window.event.keyCode; 
//            }
//            else
//            { 
//                e = e.which; 
//            }
//          
//			var strNumeric = '1234567890'
//			//alert(String.fromCharCode(event.keyCode));
//			var str = ctrlname.value;	
//			ctrLen=ctrlname.value.length + 1 ;
//			ctrlname.maxLength = mxlen;
//			
//			if (decpoint == 0 || decpoint =='')
//			{alert(strNumeric.indexOf(String.fromCharCode(e)));
//				if (strNumeric.indexOf(String.fromCharCode(e)) == -1 && e != 8) 
//				{
//				    
//					return false;
//				}		
//			}
//			
//			if(decpoint > 0 && e != 8 )
//			{	
//				
//				if (ctrlname.value.indexOf('.')!=-1)
//				{
//					
//					if (e ==46)
//					{
//						return false;
//					}
//					if ((ctrlname.value.slice(ctrlname.value.indexOf('.')).length)> decpoint)
//					{
//						return false;
//					}
//				}
//				if (strNumeric.indexOf(String.fromCharCode(e)) == -1 && e != 8 && e !=46) 
//				{
//					
//					return false;
//				}	
//			}
//			
//		}



// Check for Special Characters in a Name, Address fields
function fnCheckSpecialChars(ctl)
{
	if ( ctl.value.length > 0)
	{
		var str=ctl.value;
		var len=ctl.value.length;
		for(i=0; i<len; i++)
		{
			var k=str.charAt(i);
			var st="ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz0123456789.',/-:;_()";
			if((st.indexOf(k,0))== -1)
			{
				//alert(st.indexOf(k,0));
				return false;
			}	
			
		}
	}
	return true;
}

// this function is used for first name and last name  plz don't modify this one
function fnCheckNames(ctl)
{

	if ( ctl.value.length > 0)
	{
		var str=ctl.value;
		var len=ctl.value.length;
		for(i=0; i<len; i++)
		{
			var k=str.charAt(i);
			var st="0123456789";
			if((st.indexOf(k,0))!= -1)
			{
				//alert(st.indexOf(k,0));
				return false;
			}	
			
		}
	}
	return true;
}

function Mid(str, start, len)
/***
		Author : Vinod
        IN: str - the string we are LEFTing
            start - our string's starting position (0 based!!)
            len - how many characters from start we want to get

        RETVAL: The substring from start to start+len
***/
{
        // Make sure start and len are within proper bounds
        if (start < 0 || len < 0) return "";
		var iEnd, iLen = String(str).length;
        if (start + len > iLen)
                iEnd = iLen;
        else
                iEnd = start + len;

        return String(str).substring(start,iEnd);
}

function fnSpaceError(ctl)
{

if(ctl.value.length>0)
{

 var str=ctl.value;
		var len=ctl.value.length;
		for(i=0; i<len; i++)
		{
		var k=str.charAt(i);
			
			if(k==" ")
			{
			return "false";
			}
		}
}		
return true;
}


// Purpose: To open a new window
// This function is opening the CPTCodes.asp page in to new window to search for the CPTCodes
//
function CPTList(strFieldName,ProvID)
{
	var Wndfeatures ;
	
	Wndfeatures ='dialogHeight: 500px; dialogWidth: 800px; dialogTop: 30px; dialogLeft: 100px;';
	//Wndfeatures = Wndfeatures + PopUpWindowFeatures;
	Wndfeatures = Wndfeatures + PopUpWindowFeatures;
    var str=window.showModalDialog("../Common/CPTCodes.asp?ProvID="+ProvID,0,Wndfeatures);
    if (str!=undefined)
	{
	var Myobj=document.getElementById(strFieldName);
	Myobj.value=str;
	}
}



// Purpose: To open a new window
// This function is opening the ServicePlaces.asp page in to new window to search for the Service Places
// 

function ServicesList(strFieldName,FrmName)
{
	var Wndfeatures ;
	
	Wndfeatures ='dialogHeight: 500px; dialogWidth: 800px; dialogTop: 30px; dialogLeft: 100px;';
	Wndfeatures = Wndfeatures + PopUpWindowFeatures;
    var str=window.showModalDialog("../Common/Services.asp",0,Wndfeatures);
    if (str!=undefined)
	{
	var Myobj=document.getElementById(strFieldName);
	Myobj.value=str;
	}
	if(Myobj!=undefined)  {
		eval(FrmName+".submit()");
	}
}


// Purpose: To open a new window
// This function is opening the ServicePlaces.asp page in to new window to search for the Service Places
// 

function ServicePlaceList(strFieldName1,strFieldName2)
{
	var Wndfeatures ;
	
	Wndfeatures ='dialogHeight: 500px; dialogWidth: 800px; dialogTop: 30px; dialogLeft: 100px;';
	Wndfeatures = Wndfeatures + PopUpWindowFeatures;
    var str=window.showModalDialog("../Common/ServicePlaces.asp",0,Wndfeatures);
    if (str!=undefined)
	{
	str[0]=str[0].replace(">","'");
	var Myobj=document.getElementById(strFieldName1);
	Myobj.value=str[0];
	var Myobj=document.getElementById(strFieldName2);
	Myobj.value=str[1];
	}
}


// Same as above But it displays Check Boxes to select multiple CPTS
var CPTWin=null;
function MCPTList(formName)
{

	var Wndfeatures ;
	var Wndfeatures ;

	Wndfeatures ='dialogHeight: 700px; dialogWidth: 800px; dialogTop: 30px; dialogLeft: 100px;';
	//Wndfeatures = Wndfeatures + PopUpWindowFeatures;
	Wndfeatures = Wndfeatures + PopUpWindowFeatures;
	var str=window.showModalDialog("CPTCodeFrame.asp",0,Wndfeatures);
	if(str!=undefined) {
		document.EditProvCPTInfoForm.submit();
	}
	
//  eval("document.EditProvCPTInfoForm.txtPRate"+Code+".disabled=true");
//	CPTWin=window.open("../Common/MCPTCodes.asp", "CPTList",
//		"menubar=no,toolbar=no,directories=no,width=840,height=560,left=20,top=30");
//	CPTWin.tn=txtName;
//	CPTWin.fn=formName;
//	CPTWin.focus();
	
}
function CptCodeSearch(txtFromName,formName,txtcount,txtNotAllowed)
{
	var SelectedCptCodes;
	var	OtherCptCodes;
	OtherCptCodes='';
	var ObjSelectedCptCodes;
	
	ObjSelectedCptCodes=document.getElementById(txtFromName);
	SelectedCptCodes=ObjSelectedCptCodes.value;
	
	var LstCount=txtcount-1;
	for (var LstId=1;LstId<=LstCount;LstId++)
	{
		var ObjString=txtFromName;
		ObjString=ObjString.slice(0,-1);
		
		var OtherCptCodesList= ObjString + LstId
		var objOtherCptCodesList=document.getElementById(OtherCptCodesList)
		
		if(ObjSelectedCptCodes.name!=objOtherCptCodesList.name)
		{
			if (OtherCptCodes=='')
			{
				OtherCptCodes=objOtherCptCodesList.value;
			}
			else
			{
				if(objOtherCptCodesList.value!='')
				{
					
						OtherCptCodes=OtherCptCodes + ',' + objOtherCptCodesList.value;
					
				}	
			}	
				
		}
		
	
	}
	
	var objNotAllowed=document.getElementById(txtNotAllowed)
	var NotAllowedCPTCodes=objNotAllowed.value;
	if (NotAllowedCPTCodes!='')
	{
		if(OtherCptCodes!='')
		{
			OtherCptCodes=OtherCptCodes + ','+ NotAllowedCPTCodes
		}
		else
		{
			OtherCptCodes= NotAllowedCPTCodes
		}	
	}	
	
	var ParamArray =  new Array('../Common/CptCodesSearch.aspx?OtherCpts='+ OtherCptCodes + '&SameCpts='+ SelectedCptCodes,'CPT Codes Search' )
	var Wndfeatures 
	Wndfeatures ='dialogHeight:660px; dialogWidth:840px;';
	Wndfeatures = Wndfeatures + 'scroll:yes;edge: Raised;center: Yes; help: No; resizable: No; status: No;';
	var CptCodeArray = window.showModalDialog('../Includes/PopupFrame.htm',ParamArray,Wndfeatures);
	var ObjCptElement =document.getElementById(txtFromName);
	if(CptCodeArray!=undefined)
	{
		ObjCptElement.value=CptCodeArray[0];
		//ObjCptElement.focus();	
		
	}
	else
	{
		return false;
	}	
	
	
	
}

function NotAllowedCptCodeSearch(txtFromName,formName,txtcount,txtNotAllowed)
{
	var SelectedCptCodes;
	var	OtherCptCodes;
	OtherCptCodes='';
	var ObjSelectedCptCodes;
	
	ObjSelectedCptCodes=document.getElementById(txtNotAllowed);
	SelectedCptCodes=ObjSelectedCptCodes.value;
	
	var LstCount=txtcount-1;
	
	for (var LstId=1;LstId<=LstCount;LstId++)
	{
		var ObjString=txtFromName;
		var OtherCptCodesList= ObjString + LstId
		var objOtherCptCodesList=document.getElementById(OtherCptCodesList)
		
			if (OtherCptCodes=='')
			{
				OtherCptCodes=objOtherCptCodesList.value;
			}
			else
			{
				if(objOtherCptCodesList.value!='')
				{
					
						OtherCptCodes=OtherCptCodes + ',' + objOtherCptCodesList.value;
					
				}	
			}	
				
		
		
	
	}
	

	
	var ParamArray =  new Array('../Common/CptCodesSearch.aspx?OtherCpts='+ OtherCptCodes + '&SameCpts='+ SelectedCptCodes,'CPT Codes Search' )
	var Wndfeatures 
	Wndfeatures ='dialogHeight:660px; dialogWidth:840px;';
	Wndfeatures = Wndfeatures + 'scroll:yes;edge: Raised;center: Yes; help: No; resizable: No; status: No;';
	var CptCodeArray = window.showModalDialog('../Includes/PopupFrame.htm',ParamArray,Wndfeatures);
	if(CptCodeArray!=undefined)
	{
		var ObjCptElement =document.getElementById(txtNotAllowed);
		ObjCptElement.value=CptCodeArray[0];
	}	
		
	
	
}


function MCPTList1(txtName,formName)
{
	
	CPTWin=window.open("../Common/MCPTCodes1.asp", "CPTList",
		"menubar=no,toolbar=no,directories=no,width=840,height=560,left=20,top=30");
	CPTWin.tn=txtName;
	CPTWin.fn=formName;
	CPTWin.focus();
}



function showdx(txtName , PageInd)
{

	var Wndfeatures ;
	var Wndfeatures ;
	var ParamArray = new Array('../Common/DxSearch.aspx?PageInd='+PageInd+'','Dsm List');
	Wndfeatures ='dialogHeight: 660px; dialogWidth: 900px;'
	Wndfeatures = Wndfeatures + PopUpWindowFeatures;
//	var str=window.frames.frameNameHere.showModalDialog('../Includes/PopupFrame.htm',ParamArray,Wndfeatures)
	var str=window.showModalDialog('../Includes/PopupFrame.htm',ParamArray,Wndfeatures)
	if(str!=undefined)
	{
	document.all(txtName).value=str[0];
	}
	
}

function INSList(txtName,formName)
{
	CPTWin=window.open("../patients/insurancesearch.asp", "Insurance",
		"menubar=no,toolbar=no,directories=no,width=600,height=360,left=20,top=30");
	CPTWin.tn=txtName;
	CPTWin.fn=formName;
	CPTWin.focus();
}
function ProvList(txtName,formName)
{
	CPTWin=window.open("../patients/providersearch.asp", "Providers",
		"menubar=no,toolbar=no,directories=no,width=600,height=360,left=100,top=100");
	CPTWin.tn=txtName;
	CPTWin.fn=formName;
	CPTWin.focus();
}

// Purpose: To close the new window & Passing the value to parent Window
// this function references the passed text input field in the parent window by id and
//		sets its value to the selected code.
// strcode : the passing value to parent window
// strFieldName : the field name of the elemnt in parent window
// strFormName  : the form name of the parent window 
function Select(strCode) 
{
		window.returnValue=strCode;
		//window.alert(strcode);
		window.close();
//	eval("window.opener.document." + strFormName + "." + strFieldName + ".value = '" + strCode + "';");
//	self.close();
	
}

function Select1(strCode1,strCode2) 
{
//	window.alert (strCode1 + ' ' + strCode2);
   var vals=new Array();
   vals[0]=strCode1;
   vals[1]=strCode2;
   window.returnValue=vals;
   window.close();
//	eval("window.opener.document." + strFormName + "." + strFieldName1 + ".value = '" + strCode1 + "';");
//	eval("window.opener.document." + strFormName + "." + strFieldName2 + ".value = '" + strCode2 + "';");
//	self.close();
	
	
}

// this functions closes the window
//
function CloseWindow() {
	self.close();
}

function Select2(strCode1,strCode2,strCode3,strCode4) 
{
   var vals=new Array();
  
   vals[0]=strCode1;
   vals[1]=strCode2;
   vals[2]=strCode3;
   vals[3]=strCode4;
   window.returnValue=vals;
  
   window.close();
//	eval("window.opener.document." + strFormName + "." + strFieldName1 + ".value = '" + strCode1 + "';");
//	eval("window.opener.document." + strFormName + "." + strFieldName2 + ".value = '" + strCode2 + "';");
//	self.close();
}

function Select3(strCode1) 
{
   var vals=new Array();
  
   vals[0]=strCode1;
   window.returnValue=vals;
  
   window.close();
//	eval("window.opener.document." + strFormName + "." + strFieldName1 + ".value = '" + strCode1 + "';");
//	eval("window.opener.document." + strFormName + "." + strFieldName2 + ".value = '" + strCode2 + "';");
//	self.close();

}

//Checking Space
//This Function takes control.value as a parameter
//If you want to check whether first character space or not, use MyChars
//function by checking return string as "SpaceError"
function CheckSpace(ctl)		
{
	var k=ctl.charAt(0);
	
	if (k==" ")
	{
		return(false);
	}
	return(true);
}


//Url

function validateUrl(objUrl)
{
    var re;
/* Modified by Aravind on 08-04-2004*/
    re = /(http|ftp|https):\/\/[\w]+(.[\w]+)([\w\-\.,@?^=%&:/~\+#]*[\w\-\@?^=%&/~\+#])?/;
  //re = /[\w]+(.[\w]+)([\w\-\.,@?^=%&:/~\+#]*[\w\-\@?^=%&/~\+#])?/;
    objUrl='http://'+objUrl
  //  alert(objUrl);
    if (re.test(objUrl) == true)
		return true;
    else
    {
        return false;
    }
}
			
//Characters
function MyChars(ctl)
{
	//For Blank Field
	if (ctl.value.length==0)
	{
		return "BlankError";
	}
	//For First Char is Space or not
	else if ( ctl.value.length > 0 )
	{
		if (CheckSpace(ctl.value)==false)
		{
			return "SpaceError";	
		}
	}	
	else if ( ctl.value.length > 0 )
	{
		var k=str.charAt(0);
		var st="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
		if((st.indexOf(k,0))==-1)
		{
			return "InvalidCharAtFirstError";
		}
	} 
	//For only Characters
	if ( ctl.value.length > 0)
	{
		var str=ctl.value;
		var len=ctl.value.length;
		for(i=0; i<len; i++)
		{
			var k=str.charAt(i);
			var st="ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz";
			if((st.indexOf(k,0))==-1)
			{
				return "NumError";
			}
		}
	 }
	 
	 if (ctl.value.length > 0)
	{
		var str=ctl.value;
		var len=ctl.value.length;
		for(i=0; i<len; i++)
		{
			var k=str.charAt(i);
			var st=" ";
			if(k==st)
			{
				return "SpaceInBwnError";
			}
		}
	}
	
return(true);
}


function fnDtDisableCtrl()
{
	if ((event.keyCode !=9) && (event.keyCode !=46))   //&& (event.keyCode !=8))
	{
		event.keyCode= 0;
		return false;
	}
}

//Numbers
function MyNumbers(ctl)
{
	if (ctl.value.length==0)
    {
        return false;
    }   
    else if(ctl.value.length>0)
    {
	var str=ctl.value;
	var len=ctl.value.length;
	for(i=0; i<len; i++)
	{
		var k=str.charAt(i);
		var st="0123456789()-.%";
		if((st.indexOf(k,0))==-1)
		{
			return false;
		}
	}
    }
return(true);
}

//Email validation
var testresults
function ValidateEmail(ctrl){
if (document.layers||document.getElementById||document.all)
{
	var str=ctrl.value
	var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
	if (filter.test(str))
		testresults=true
	else
		testresults=false
	
	return (testresults)
}
else
	return true;
}


//Credit Card Number
function MyCreditCard(ctl)
{
	if (ctl.value.length==0)
    {
		return(false);
    }   
    else if(ctl.value.length>0 && ctl.value.length<=16)
    {
		var str=ctl.value;
		var len=ctl.value.length;
		for(i=0; i<len; i++)
		{
			var k=str.charAt(i);
			var st="0123456789";
			if((st.indexOf(k,0))==-1)
			{
				return(false);
			}
		}
    }

    else if(ctl.value.length>16)  
    {
		return(false);
    }
return(true);
}

//to Display dates in select box

function DisplayDates(ctl)
{
	var cnt=ctl.length 
	for(var i=0; i<cnt; i++)
	{
			ctl.remove(0);
	}
	var oOption = document.createElement("OPTION");
		oOption.text="-- Date --";
		oOption.value="";
		ctl.add(oOption);
	for( var i=1; i<=31; i++)
	{
		var oOption = document.createElement("OPTION");
			oOption.text=i;
			oOption.value=i;
			ctl.add(oOption);
	}
}
//to Display dates in select box
function DisplayYears(ctl)
{
	var cnt=ctl.length 
	for(var i=0; i<cnt; i++)
	{
			ctl.remove(0);
	}
	var CurrDate = new Date();
	var StartYear=CurrDate.getYear()-25;
	var oOption = document.createElement("OPTION");
		oOption.text="-- Year --";
		oOption.value="";
		ctl.add(oOption);
	for( StartYear; StartYear<=CurrDate.getYear()+47; StartYear++)
	{
		var oOption = document.createElement("OPTION");
			oOption.text=StartYear;
			oOption.value=StartYear;
			ctl.add(oOption);
	}
}

//reformat a string

function reformat (s)

{   var arg;
    var sPos = 0;
    var resultString = "";

    for (var i = 1; i < reformat.arguments.length; i++) {
       arg = reformat.arguments[i];
       if (i % 2 == 1) resultString += arg;
       else {
           resultString += s.substring(sPos, sPos + arg);
           sPos += arg;
       }
    }
    return resultString;
}

var SSNDelimiters = "- ";
var defaultEmptyOK = false;
var digitsInSocialSecurityNumber = 9;
//var iSSN = "This field must be a 9 digit U.S. social security number (like 123 45 6789). Please reenter it now."
function reformatSSN (SSN)
{  	return (reformat (SSN, "", 3, "-", 2, "-", 4))
}

function checkSSN (theField, emptyOK)
{   if (checkSSN.arguments.length == 1) emptyOK = defaultEmptyOK;
    if ((emptyOK == true) && (isEmpty(theField.value))) return true;
    else
    {  var normalizedSSN = stripCharsInBag(theField.value, SSNDelimiters)
       if (!isSSN(normalizedSSN, false)) 
          //return warnInvalid (theField, iSSN);
          return false;
       else 
       {  // if you don't want to reformats as 123-45-6789, comment next line out
 //         theField.value = reformatSSN(normalizedSSN)
          return true;
       }
    }
}

function isSSN (s)
{   if (isEmpty(s)) 
       if (isSSN.arguments.length == 1) return defaultEmptyOK;
       else return (isSSN.arguments[1] == true);
    return (isInteger(s) && s.length == digitsInSocialSecurityNumber)
}

function isEmpty(s)
{   return ((s == null) || (s.length == 0))
}

function isInteger (s)

{   var i;

    if (isEmpty(s)) 
       if (isInteger.arguments.length == 1) return defaultEmptyOK;
       else return (isInteger.arguments[1] == true);

    // Search through string's characters one by one
    // until we find a non-numeric character.
    // When we do, return false; if we don't, return true.

    for (i = 0; i < s.length; i++)
    {   
        // Check that current character is number.
        var c = s.charAt(i);

        if (!isDigit(c)) return false;
    }

    // All characters are numbers.
    return true;
}

function isDigit (c)
{   return ((c >= "0") && (c <= "9"))
}

// Removes all characters which appear in string bag from string s.

function stripCharsInBag (s, bag)

{   var i;
    var returnString = "";

    // Search through string's characters one by one.
    // If character is not in bag, append to returnString.

    for (i = 0; i < s.length; i++)
    {   
        // Check that current character isn't whitespace.
        var c = s.charAt(i);
        if (bag.indexOf(c) == -1) returnString += c;
    }

    return returnString;
}

// U.S. phone numbers have 10 digits.
// They are formatted as 123 456 7890 or (123) 456-7890.
var digitsInUSPhoneNumber = 10;
// non-digit characters which are allowed in phone numbers
var phoneNumberDelimiters = "()- ";


// isUSPhoneNumber (STRING s [, BOOLEAN emptyOK])
// 
// isUSPhoneNumber returns true if string s is a valid U.S. Phone
// Number.  Must be 10 digits.
//
// NOTE: Strip out any delimiters (spaces, hyphens, parentheses, etc.)
// from string s before calling this function.
//
// For explanation of optional argument emptyOK,
// see comments of function isInteger.

function isUSPhoneNumber (s)
{   if (isEmpty(s)) 
       if (isUSPhoneNumber.arguments.length == 1) return defaultEmptyOK;
       else return (isUSPhoneNumber.arguments[1] == true);
    return (isInteger(s) && s.length == digitsInUSPhoneNumber)
}

// takes USPhone, a string of 10 digits
// and reformats as (123) 456-789

function reformatUSPhone (USPhone)
{   return (reformat (USPhone, "(", 3, ") ", 3, "-", 4))
}

// checkUSPhone (TEXTFIELD theField [, BOOLEAN emptyOK==false])
//
// Check that string theField.value is a valid US Phone.
//
// For explanation of optional argument emptyOK,
// see comments of function isInteger.

function checkUSPhone (theField, emptyOK)
{   if (checkUSPhone.arguments.length == 1) emptyOK = defaultEmptyOK;
    if ((emptyOK == true) && (isEmpty(theField.value))) return true;
    else
    {  var normalizedPhone = stripCharsInBag(theField.value, phoneNumberDelimiters)
       if (!isUSPhoneNumber(normalizedPhone, false)) 
          return false;
       else 
       {  // if you don't want to reformat as (123) 456-789, comment next line out
       //   theField.value = reformatUSPhone(normalizedPhone)
          return true;
       }
    }
}

// our preferred delimiter for reformatting ZIP Codes
var ZIPCodeDelimeter = "-"
// non-digit characters which are allowed in ZIP Codes
var ZIPCodeDelimiters = "-";

// U.S. ZIP codes have 5 or 9 digits.
// They are formatted as 12345 or 12345-6789.
var digitsInZIPCode1 = 5
var digitsInZIPCode2 = 9


// checkZIPCode (TEXTFIELD theField [, BOOLEAN emptyOK==false])
//
// Check that string theField.value is a valid ZIP code.
//
// For explanation of optional argument emptyOK,
// see comments of function isInteger.

function checkZIPCode (theField, emptyOK)
{   if (checkZIPCode.arguments.length == 1) emptyOK = defaultEmptyOK;
    if ((emptyOK == true) && (isEmpty(theField.value))) return true;
    else
    { var normalizedZIP = stripCharsInBag(theField.value, ZIPCodeDelimiters)
      if (!isZIPCode(normalizedZIP, false)) 
         return false;
      else 
      {  // if you don't want to insert a hyphen, comment next line out
         theField.value = reformatZIPCode(normalizedZIP)
         return true;
      }
    }
}

// isZIPCode (STRING s [, BOOLEAN emptyOK])
// 
// isZIPCode returns true if string s is a valid 
// U.S. ZIP code.  Must be 5 or 9 digits only.
//
// NOTE: Strip out any delimiters (spaces, hyphens, etc.)
// from string s before calling this function.  
//
// For explanation of optional argument emptyOK,
// see comments of function isInteger.

function isZIPCode (s)
{  if (isEmpty(s)) 
       if (isZIPCode.arguments.length == 1) return defaultEmptyOK;
       else return (isZIPCode.arguments[1] == true);
   return (isInteger(s) && 
            ((s.length == digitsInZIPCode1) ||
             (s.length == digitsInZIPCode2)))
}

// takes ZIPString, a string of 5 or 9 digits;
// if 9 digits, inserts separator hyphen

function reformatZIPCode (ZIPString)
{   if (ZIPString.length == 5) return ZIPString;
    else return (reformat (ZIPString, "", 5, "-", 4));
}

// non-digit characters which are allowed in credit card numbers
var creditCardDelimiters = " "
var iCreditCardPrefix = "This is not a valid "
var iCreditCardSuffix = " credit card number. Please reenter it now."

// Validate credit card info.

function checkCreditCard (olbl, theField)
{   var cardType = getSelectValue (olbl)
    var normalizedCCN = stripCharsInBag(theField.value, creditCardDelimiters)
    if (!isCardMatch(cardType, normalizedCCN)) 
       return false;
    else 
    {  theField.value = normalizedCCN
       return true
    }
}

function getSelectValue (olbl)
{
    if (olbl.innerText != "") 
		  return olbl.innerText;
}


/*  ================================================================
    FUNCTION:  isCardMatch()
 
    INPUT:    cardType - a string representing the credit card type
	      cardNumber - a string representing a credit card number

    RETURNS:  true, if the credit card number is valid for the particular
	      credit card type given in "cardType".
		    
	      false, otherwise
    ================================================================ */

function isCardMatch (cardType, cardNumber)
{

	cardType = cardType.toUpperCase();
	var doesMatch = true;

	if ((cardType == "VISA") && (!isVisa(cardNumber)))
		doesMatch = false;
	if ((cardType == "MASTERCARD") && (!isMasterCard(cardNumber)))
		doesMatch = false;
	if ( ( (cardType == "AMERICANEXPRESS") || (cardType == "AMEX") )
                && (!isAmericanExpress(cardNumber))) doesMatch = false;
	if ((cardType == "DISCOVER") && (!isDiscover(cardNumber)))
		doesMatch = false;
	
	return doesMatch;

}  // END FUNCTION CardMatch()


/*  ================================================================
    FUNCTION:  isVisa()
 
    INPUT:     cc - a string representing a credit card number

    RETURNS:  true, if the credit card number is a valid VISA number.
		    
	      false, otherwise

    Sample number: 4111 1111 1111 1111 (16 digits)
    ================================================================ */

function isVisa(cc)
{
  if (((cc.length == 16) || (cc.length == 13)) &&
      (cc.substring(0,1) == 4))
    return isCreditCard(cc);
  return false;
}  // END FUNCTION isVisa()


/*  ================================================================
    FUNCTION:  isMasterCard()
 
    INPUT:     cc - a string representing a credit card number

    RETURNS:  true, if the credit card number is a valid MasterCard
		    number.
		    
	      false, otherwise

    Sample number: 5500 0000 0000 0004 (16 digits)
    ================================================================ */

function isMasterCard(cc)
{
  firstdig = cc.substring(0,1);
  seconddig = cc.substring(1,2);
  if ((cc.length == 16) && (firstdig == 5) &&
      ((seconddig >= 1) && (seconddig <= 5)))
    return isCreditCard(cc);
  return false;

} // END FUNCTION isMasterCard()

/*  ================================================================
    FUNCTION:  isAmericanExpress()
 
    INPUT:     cc - a string representing a credit card number

    RETURNS:  true, if the credit card number is a valid American
		    Express number.
		    
	      false, otherwise

    Sample number: 340000000000009 (15 digits)
    ================================================================ */

function isAmericanExpress(cc)
{
  firstdig = cc.substring(0,1);
  seconddig = cc.substring(1,2);
  if ((cc.length == 15) && (firstdig == 3) &&
      ((seconddig == 4) || (seconddig == 7)))
    return isCreditCard(cc);
  return false;

} // END FUNCTION isAmericanExpress()


/*  ================================================================
    FUNCTION:  isDiscover()
 
    INPUT:     cc - a string representing a credit card number

    RETURNS:  true, if the credit card number is a valid Discover
		    card number.
		    
	      false, otherwise

    Sample number: 6011000000000004 (16 digits)
    ================================================================ */

function isDiscover(cc)
{
  first4digs = cc.substring(0,4);
  if ((cc.length == 16) && (first4digs == "6011"))
    return isCreditCard(cc);
  return false;

} // END FUNCTION isDiscover()


/*  ================================================================
    FUNCTION:  isCreditCard(st)
 
    INPUT:     st - a string representing a credit card number

    RETURNS:  true, if the credit card number passes the Luhn Mod-10
		    test.
	      false, otherwise
    ================================================================ */

function isCreditCard(st) {
  // Encoding only works on cards with less than 19 digits
  if (st.length > 19)
    return (false);

  sum = 0; mul = 1; l = st.length;
  for (i = 0; i < l; i++) {
    digit = st.substring(l-i-1,l-i);
    tproduct = parseInt(digit ,10)*mul;
    if (tproduct >= 10)
      sum += (tproduct % 10) + 1;
    else
      sum += tproduct;
    if (mul == 1)
      mul++;
    else
      mul--;
  }
// Uncomment the following line to help create credit card numbers
// 1. Create a dummy number with a 0 as the last digit
// 2. Examine the sum written out
// 3. Replace the last digit with the difference between the sum and
//    the next multiple of 10.

//  document.writeln("<BR>Sum      = ",sum,"<BR>");
//  alert("Sum      = " + sum);

  if ((sum % 10) == 0)
    return (true);
  else
    return (false);

} // END FUNCTION isCreditCard()



//			TO display modal dailog	

function ErrorWindow(url)
{
	window.status = "";
	//strFeatures = "dialogWidth=" + intwidth + "px;dialogHeight=" + intheight + "px;scroll=no;resizable=no;center=yes;border=thin;help=no;status=no";
	strFeatures = "dialogWidth=310px;dialogHeight=120px;scroll=no;resizable=no;center=yes;border=thin;help=no;status=no";
	strTitle = window.showModalDialog(url, "MyDialog", strFeatures);
}

// Check For Characters in a Date Field
function fnCheckChars(ctl)
{
	if ( ctl.value.length > 0)
	{
		var str=ctl.value;
		var len=ctl.value.length;
		for(i=0; i<len; i++)
		{
			var k=str.charAt(i);
			var st="ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz";
			if((st.indexOf(k,0))!= -1)
			{
				return false;
			}	
			
		}
	}
	return true;
}

// Function Check Start and End Times

function fnCheckTime(StartHour,EndHour,StartAMPM,EndAMPM,StartMinute,EndMinute)
{

var StartTimeHour = StartHour.value;
var EndTimeHour = EndHour.value;


if (StartAMPM.value == 'AM' && StartTimeHour == '12')
		StartTimeHour = '00';
		
if (EndAMPM.value == 'AM' &&  EndTimeHour == '12')
			return false;
			
if ((StartTimeHour == EndTimeHour) && (StartAMPM.value == EndAMPM.value) && (EndMinute.value <= StartMinute.value))
			return false;
				
if (StartAMPM.value != EndAMPM.value)
{
	if ((StartAMPM.value == 'PM')&& (EndAMPM.value == 'AM'))
		return false;
	else
		return true;	
		
} 

else if ((parseInt(EndTimeHour,10) < parseInt(StartTimeHour,10))&& parseInt(StartTimeHour,10) != 12)
	return false;
else
	return true;

}


function IsValidDate(DOB){
sysDate= new Date();
txtDate=new Date(DOB);
if(txtDate<sysDate)
return true;
else
return false;
}

//Function To validate ZIP
//Author : Aravind
function IsZip(ZIPString) {
if (ZIPString.length !=5)
{ 
	return false;
}

if (ZIPString.length==0)
    {
        return false;
    }   
    else if(ZIPString.length=5)
    {
	var str=ZIPString;
	var len=ZIPString.length;
	for(i=0; i<len; i++)
	{
		var k=str.charAt(i);
		var st="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
		if((st.indexOf(k.toUpperCase(),0))==-1)
		{
		   return false;
		}
	}
    }
return(true);

}
//**********************************************************************

function Glb_ShowAlert1(txtMsg,OperationType,txtCANCEL,txtOK,Title,Dlgwidth,DlgHieght,txtHead,BlnScroll)
{
	
	
	//Here we check the window features if Height,width,scroll is not set the default values are Assigned.
	
	
	if (!Dlgwidth)
	{
		Dlgwidth=350;
	}
	if (!DlgHieght)
	{
		DlgHieght=150+15*(parseInt(txtMsg.length/37)); //37 is the max characters length we can show with dialog width 350
	}
	if(!txtHead)
	{
		txtHead=''
	}
	if(!OperationType)
	{
	OperationType='Alert'
	}
	if(!Title)
	{
		Title='Find-a-Therapist -- Powered by Cognode';
	}
	else
	{
		Title='Find-a-Therapist -- Powered by Cognode';
	}
		
	if (!BlnScroll)
	{
		BlnScroll= 'No';
	}
	
	if(!txtCANCEL)
	{
		if (OperationType=='Delete')
		{
			txtCANCEL = 'No'
			
		}	
		if(OperationType=='Help')
		{
			txtCANCEL = ''
			
		}
		if(OperationType=='Alert')
		{
			//txtCANCEL = 'Ok'
			txtCANCEL = 'No'
			
		}
		if(OperationType=='Save')
		{
			txtCANCEL = 'No'
			
		}
		if(OperationType=='Edit')
		{
			txtCANCEL = 'No'
		}
		if(OperationType=='Task')
		{
			txtCANCEL = 'Others'
		}
		
		if(OperationType=='Later')
		{
			txtCANCEL = 'Later'
		}
		
	}


	if(!txtOK)
	{
		if (OperationType=='Delete')
			{
				txtOK = 'Yes'
			}	
			if(OperationType=='Help')
			{
				txtOK = 'Close'
			}
			if(OperationType=='Alert')
			{
				txtOK = 'Yes'
			}
			if(OperationType=='Save')
			{
				txtOK = 'Yes'
			}
			if(OperationType=='Edit')
			{
				txtOK = 'Yes'
			}
			if(OperationType=='Task')
			{
				txtOK = 'Self'
			}
			if(OperationType=='Later')
		{
			txtOK = 'Now'
		}
	}
	
	//Here u set the windows features i.e height ,width,left and top etc.
	
	var Wndfeatures 
	Wndfeatures ='dialogHeight:'+ DlgHieght  + 'px; dialogWidth:' + Dlgwidth + 'px;';
	Wndfeatures = Wndfeatures + 'scroll:'+ BlnScroll + ';edge: Raised;center: Yes; help: No; resizable: No; status: No;';

	var AlertArray=  new Array(txtHead,txtMsg,txtOK,txtCANCEL,Title)
	if (OperationType=='Delete')
	{
		var str = window.showModalDialog("../common/modal/DeleteTemplate.htm",AlertArray,Wndfeatures);
		return str;
	}	
	if(OperationType=='Help')
	{
		var str = window.showModalDialog("../common/modal/HelpTemplate.htm",AlertArray,Wndfeatures);
		return str;
	}
	if(OperationType=='Alert')
	{
	
		var str = window.showModalDialog("../common/modal/AlertTemplate1.htm",AlertArray,Wndfeatures);
		//var str = window.showModalDialog("\cognode\common\modal\AlertTemplate.htm",AlertArray,Wndfeatures);
		return str;
	}
	if(OperationType=='Save')
	{
		var str = window.showModalDialog("../common/modal/SaveTemplate.htm",AlertArray,Wndfeatures);
		return str;
	}
	if(OperationType=='Edit')
	{
		var str = window.showModalDialog("../common/modal/EditTemplate.htm",AlertArray,Wndfeatures);
		return str;
	}
	
	if(OperationType=='Later')
	{
		var str = window.showModalDialog("../common/modal/Later.htm",AlertArray,Wndfeatures);
		return str;
	}
	
}




//***************************************************************************
/*  ================================================================ */

// *** Calling The Global Function Which Shows Alert and Returns either True or False 

// -----------------------------------------------------------------------------	

//	PURPOSE:This Function is used to call the ShowAlert Page Which can be used as Message Window,Alert Window or Confirmation Window
		
//	INPUTS:
//	1)txtHead(HeadLine):Optional
//	2)txtMsg(Message):Mandatory
//	3)txtOK(OK Button Text):Optional
//	4)txtCANCEL(CANCEL Button Text):Mandatory
//	5)Dlgwidth(Dialog Width):Optional
//  6)DlgHieght(Dialog Height):Optional
//  7)BlnScroll(Displaying Scroll):Optional

//	Author:Mirza Baig


function Glb_ShowAlert(txtMsg,OperationType,txtCANCEL,txtOK,Title,Dlgwidth,DlgHieght,txtHead,BlnScroll)
{


	
if(navigator.appName=='Microsoft Internet Explorer')
{
	//Here we check the window features if Height,width,scroll is not set the default values are Assigned.
	
	
	if (!Dlgwidth)
	{
		Dlgwidth=350;
	}
	if (!DlgHieght)
	{
		DlgHieght=170+15*(parseInt(txtMsg.length/37)); //37 is the max characters length we can show with dialog width 350
	}
	if(!txtHead)
	{
		txtHead=''
	}
	if(!OperationType)
	{
	    OperationType='Alert'
	}
	if(!Title)
	{
		Title= document.title;
	}
	else
	{
		Title= Title ;
	}
		
	if (!BlnScroll)
	{
		BlnScroll= 'No';
	}
	
	if(!txtCANCEL)
	{
		if (OperationType=='Delete')
		{
			txtCANCEL = 'No'
			
		}	
		if(OperationType=='Help')
		{
			txtCANCEL = ''
			
		}
		if(OperationType=='Alert')
		{
			txtCANCEL = 'Ok'
			
		}
		if(OperationType=='Info')
		{
			txtCANCEL = 'Ok'
			
		}
		if(OperationType=='Save')
		{
			txtCANCEL = 'No'
			
		}
		if(OperationType=='Edit')
		{
			txtCANCEL = 'No'
		}
		if(OperationType=='Task')
		{
			txtCANCEL = 'Others'
		}
		 if(OperationType=='CreditCardAlert')
		 {
			txtCANCEL = 'Ok'
		 }
		
		 if(OperationType=='Later')
		 {
			txtCANCEL = 'Now'
		 }
		
	}


	if(!txtOK)
	{
		if (OperationType=='Delete')
			{
				txtOK = 'Yes'
			}	
			if(OperationType=='Help')
			{
				txtOK = 'Close'
			}
			if(OperationType=='Alert')
			{
				txtOK = ''
			}
			if(OperationType=='Info')
			{
				txtOK = ''
			}
			if(OperationType=='Save')
			{
				txtOK = 'Yes'
			}
			if(OperationType=='Edit')
			{
				txtOK = 'Yes'
			}
			if(OperationType=='Task')
		    {
			    txtOK = 'Self'
		    }
		    if(OperationType=='CreditCardAlert')
		    {
			    txtOK = ''
		    }
		     if(OperationType=='Later')
		 {
			txtCANCEL = 'Later'
		 }
		   
	}
	
	//Here u set the windows features i.e height ,width,left and top etc.
	
	var Wndfeatures 
	Wndfeatures ='dialogHeight:'+ DlgHieght  + 'px; dialogWidth:' + Dlgwidth + 'px;';
	Wndfeatures = Wndfeatures + 'scroll:'+ BlnScroll + ';edge: Raised;center: Yes; help: No; resizable: No; status: No;';

	var AlertArray=  new Array(txtHead,txtMsg,txtOK,txtCANCEL,Title)
	
	if (OperationType=='Delete')
	{
		var str = window.showModalDialog("../Common/modal/DeleteTemplate.htm",AlertArray,Wndfeatures);
		return str;
	}	
	if(OperationType=='Help')
	{
		var str = window.showModalDialog("../Common/modal/HelpTemplate.htm",AlertArray,Wndfeatures);
		
		return str;
	}
	if(OperationType=='Alert')
	{
		var str = window.showModalDialog("../Common/modal/AlertTemplate.htm",AlertArray,Wndfeatures);
		//var str = window.showModalDialog("\cognode\common\modal\AlertTemplate.htm",AlertArray,Wndfeatures);
		return str;
	}
	if(OperationType=='Info')
	{
		var str = window.showModalDialog("../Common/modal/InfoTemplate.htm",AlertArray,Wndfeatures);
		//var str = window.showModalDialog("\cognode\common\modal\AlertTemplate.htm",AlertArray,Wndfeatures);
		return str;
	}
	if(OperationType=='Save')
	{
		    var str = window.showModalDialog("../Common/modal/SaveTemplate.htm",AlertArray,Wndfeatures);
		    return str;
	}
	if(OperationType=='Task')
	{
		    var str = window.showModalDialog("../Common/modal/SaveTemplate.htm",AlertArray,Wndfeatures);
		    return str;
	}
	if(OperationType=='Edit')
	{
		var str = window.showModalDialog("../Common/modal/EditTemplate.htm",AlertArray,Wndfeatures);
		return str;
	}
	 if(OperationType=='CreditCardAlert')
	 {
	 var str = window.showModalDialog("../Common/Modal/Creditcard Success.htm",AlertArray,Wndfeatures);
	 return str;
	 }
	 
	  if(OperationType=='Later')
	 {
	 var str = window.showModalDialog("../Common/Modal/Later.htm",AlertArray,Wndfeatures);
	 return str;
	 }
	
	
}

else
{
	
	if(OperationType==undefined)
		{
		 alert(txtMsg);
		}
	else
		{
			if (OperationType=='Delete' || OperationType=='Save')
			{
				var truthBeTold = window.confirm(txtMsg);
				
				if (truthBeTold==true)
				{
					return 'True';
				}
					else
				{	
					return 'False';	
				}

			}
			if (OperationType=='')
			{
				window.alert(txtMsg);
			}
			else
			{
				var objVar
				objVar=confirm(txtMsg);
				if (objVar==true)
				{
					return true;
				}
				else
				{
					return false;
				}
			}	
		}
}
}
/*  ================================================================ */



/*  ================================================================ */

// *** The Function is used to show and hide the links in leftlink.asp

// -----------------------------------------------------------------------------	

//	PURPOSE:This Function is used to set show and hide of links of left links

		
//	INPUTS:
//	1)DivId(LinkId):Mandatory
//	2)DivCount(LinksCount):Mandatory

//	Author:Mirza Baig


function ShowChildNodes(DivId,DivCount)
	{
		
		var objImg= document.getElementById('imgHeader'+ DivId )
		if(objImg.src.indexOf('MINNODE')==-1)
		{
			
			objImg.src='../images/MINNODE.gif';
		
		}
		else
		{
			objImg.src='../images/PLUSNODE.gif';
		}
		
		for (var i=1; i <= DivCount; i++)
		{
			
			if (i!=DivId)
			{
					var objOtherImg= document.getElementById('imgHeader'+ i );
					objOtherImg.src='../images/PLUSNODE.gif';
					var ObjOtherDiv= document.getElementById('DivHeader'+ i );
					ObjOtherDiv.style.display ='None';
					
			}
			else
			{
					
					
					if(objImg.src.indexOf('MINNODE')!=-1)
					{
						var ObjOtherDiv= document.getElementById('DivHeader'+ i );
						ObjOtherDiv.style.display ='';
						
					}
					else
					{
						var ObjOtherDiv= document.getElementById('DivHeader'+ i );
						ObjOtherDiv.style.display ='None';
					}
				
			}
		
		}
	}
//  The following 3 Functions To Fill Country,State,City in to comboboxes
// Author : Aravind


function Show(Country,State,City,cboCountry,cboState,cboCity)
{
	changeCountry(cboCountry,cboState,cboCity);
	cboState.value=State;
	changeState(cboState,cboCity);
	cboCity.value=City;
}

function changeCountry(cboCountry,cboState,cboCity) 
{
	var i, o;
n=cboCountry.value;

	while (cboState.options.length > 0){
		cboState.options[0] = null;
	    }
		for (i = 0; i < states.length; i++)
			if (states[i].CountryID == n) {
				o = new Option(states[i].StateName, states[i].StateID);
					cboState.add(o);
	     }
	   changeState(cboState,cboCity);
}

function changeState(cboState,cboCity) 
{
	var i, o;
	n=cboState.value;
//	Glb_ShowAlert(cities[0] = {StateID:1, StateID:1, StateName:'AP'});
	// Clears the selectbox options array!
	while (cboCity.options.length > 0)
	    cboCity.options[0] = null;

	
//		cities[0] = {StateID:10, StateID:1, StateName:'AP'};
		for (i = 0; i < cities.length; i++)
			if (cities[i].StateID == n) {
				o = new Option(cities[i].CityName, cities[i].CityID);
				cboCity.add(o);
	     }
}

/*  ================================================================ */



/*  ================================================================ */

// *** The Function is used to make the Window width same as available Screen Width

// -----------------------------------------------------------------------------	

//	PURPOSE:This Function is used to make Window width same as available Screen Width

		
//	Author:Mirza Baig

function maxWindow()
{
window.moveTo(0,0);
if (document.all)
{
  top.window.resizeTo(screen.availWidth,screen.availHeight);
}

else if (document.layers||document.getElementById)
{
  if (top.window.outerHeight<screen.availHeight||top.window.outerWidth<screen.availWidth)
  {
    top.window.outerHeight = screen.availHeight;
    top.window.outerWidth = screen.availWidth;
  }
	     }
}


//---------------------------------------------------------------
// function to validate the phone number in the format of 123-456-7890
// Author Aravind
function isPhone(stringToSplit) { 
		var Noflag=0
		var Yesflag=1
		var separator="-";
		 arrayOfStrings = stringToSplit.split(separator); 
		 if ( arrayOfStrings.length!=3 )
		 return Noflag;
		 if((arrayOfStrings[0]).length!=3 || (arrayOfStrings[1]).length!=3 || (arrayOfStrings[2]).length!=4)
			return Noflag;
		 
		 if(arrayOfStrings.length==3)
		 {	
			if ( (isNaN(arrayOfStrings[0])) || (isNaN(arrayOfStrings[1])) || (isNaN(arrayOfStrings[2])) )
				return Noflag;
		 }
		else
		return Noflag;
		
		return Yesflag;
		}
//-------------------------------------------------------------------		
		
//--------------------------------------------------------------------		
// function to validate the SSN number in to the format of 123-45-6789
// Author Aravind
function isValidSSN(strSSN)
{
	
	if(strSSN.length=='9')
	{
		return 'true';
	}
	else
	{
		return 'false';
	   	
	}
}
	
//---------------------------------------------------------------------------		



/*  ================================================================ */



/*  ================================================================ */

// *** The Function is used to check the Number Control
// -----------------------------------------------------------------------------	

//	PURPOSE:This Function is used to check the Number Control

		
//	Author:Mirza Baig
//	Modified By: Ravi Kumar N
//	Date: 26 FEB 2005
//	PURPOSE: This function is not taking the decimal point (.) from the Numeric KeyPad

function isValidNumeric(ctrlname,mxlen,decpoint,e)
{
   // Modified By Rambabu on 18 March 2008
    if(navigator.appName=='Microsoft Internet Explorer')
    {
        e = window.event.keyCode    
    }
    else
    {
        e = e.which
    }
   
		if(decpoint==0)
		{
			if (e==190 || e==110)
			{
				return false;
			}
		}
		ctrLen=ctrlname.value.length + 1 ;
		
		if ((ctrLen > mxlen)&&(e !=8)&& (e !=9)&&(e !=46))
		{
			return false;
		}
		if (e==190 || e ==110)
		{
			if (ctrlname.value.indexOf('.')==-1)
			{
				var strval = ctrlname.value;
			}	
			else
			{
				
				return false;
			}
		}
		
		if(navigator.appName=='Microsoft Internet Explorer')
		{
		    if (window.event.shiftKey)
    		{
    			return false;
    		}
		}
				

		if ((e!=8)&&(e!=9)&&(e!=35)&&(e!=36)&&(e!=37)&&(e!=39)&& (e!=46)&&(e!=48)&&(e!=49)&&(e!=50)&&(e!=51)&&(e!=52)&&(e!=53)&&(e!=54)&&(e!=55)&&(e!=56)&&(e!=57)&&(e!=58)&&(e!=96)&&(e!=97)&&(e!=98)&&(e!=99)&&(e!=100)&&(e!=101)&&(e!=102)&&(e!=103)&&(e!=104)&&(e!=105)&&(e!=110)&&(e!=190))
		{
			return false;
		}
	
		//Added By Bhavani for checking allowed decimals validation
		//Start Here
	/*	the following code is commented by Ravi Kumar N
	if (((event.keyCode >= 48) && (event.keyCode <=57) ) ) && (decpoint>0))
	{*/
		if(decpoint > 0 && e != 8 && e != 35 && e != 36 && e !=37 && e != 39 && e != 39){	//added by Ravi Kumar N
		if (ctrlname.value.indexOf('.')!=-1)
			{
				//alert(ctrlname.value.slice(ctrlname.value.indexOf('.')).length);
			  arrayOfStrings=ctrlname.value.slice(ctrlname.value.indexOf('.'));
			   if ((ctrlname.value.slice(ctrlname.value.indexOf('.')).length)> decpoint)
			   {
			   return false;
			   }
				}
	}
		//End Here
}



function IsNumaricNumber(ctrlname,mxlen)
{
		
		ctrLen=ctrlname.value.length + 1 ;
		if ((ctrLen > mxlen)&&(event.keyCode !=8))
		{
			return false;
		}
		if ((event.keyCode !=9)&&(event.keyCode !=46)&&(event.keyCode !=8)&&(event.keyCode !=48)&&(event.keyCode !=189)&&(event.keyCode !=190)&&(event.keyCode !=49)&&(event.keyCode !=50)&&(event.keyCode !=51)&&(event.keyCode !=52)&&(event.keyCode !=53)&&(event.keyCode !=54)&&(event.keyCode !=55)&&(event.keyCode !=56)&&(event.keyCode !=57)&&(event.keyCode !=58))
		{
			event.keyCode= 0;
			return false;
		}
		
		
}



/*  ================================================================ */

// *** The Function is used to check the cpt codes control
// -----------------------------------------------------------------------------	

//	PURPOSE:This Function is used to check the cpt codes control

		
//	Author:Mirza Baig


function IsvalidCPT(ctrlname)
{
 if ((event.keyCode !=46)&&(event.keyCode !=8)&&(event.keyCode !=37)&&(event.keyCode !=39))
		{
			event.keyCode= 0;
			return false;
		}
}

//	Author:Bhavani Akundi
function ProvList(strFieldName1,strFieldName2,strVal,strFieldName3,strFieldName4)
{
	var Wndfeatures ;
	
	Wndfeatures ='dialogHeight: 660px; dialogWidth: 925px; dialogTop: 30px; dialogLeft: 80px;';
	Wndfeatures = Wndfeatures + PopUpWindowFeatures;
	var str=window.showModalDialog("../Schedule/ProviderFrame.asp?ServiceId="+strVal,0,Wndfeatures);

    if (str!=undefined)
	{
	str[0]=str[0].replace(">","'");
	var Myobj=document.getElementById(strFieldName1);
	Myobj.value=str[0];
	var Myobj=document.getElementById(strFieldName2);
	Myobj.value=str[1];
	var Myobj=document.getElementById(strFieldName3);
	Myobj.value=str[2];
	var Myobj=document.getElementById(strFieldName4);
	Myobj.value=str[3];
	return 1;
	}
	else
	{
	return 0;
	}
}
//	Author:Bhavani Akundi
function FacilityList(strFieldName1,strFieldName2,strVal,strFieldName3,strFieldName4)
{
	var Wndfeatures ;
	
	Wndfeatures ='dialogHeight: 660px; dialogWidth: 925px; dialogTop: 30px; dialogLeft: 80px;';
	Wndfeatures = Wndfeatures + PopUpWindowFeatures;
  var str=window.showModalDialog("../Schedule/FacilityFrame.asp?ProviderId="+strVal,0,Wndfeatures);
  if (str!=undefined)
	{
	str[0]=str[0].replace(">","'");
	var Myobj=document.getElementById(strFieldName1);
	Myobj.value=str[0];
	var Myobj=document.getElementById(strFieldName2);
	Myobj.value=str[1];
	var Myobj=document.getElementById(strFieldName3);
	Myobj.value=str[2];
	var Myobj=document.getElementById(strFieldName4);
	Myobj.value=str[3];
	return 1;
	}
else
	{
	return 0;
	}
}

//	Author:Bhavani Akundi
function CPTListForAppt(strFieldName1,strFieldName2,ProvID)
{
	var Wndfeatures ;
	
	Wndfeatures ='dialogHeight: 660px; dialogWidth: 800px; dialogTop: 30px; dialogLeft: 100px;';
	Wndfeatures = Wndfeatures + PopUpWindowFeatures;
    var str=window.showModalDialog("../Common/CPTCodes.asp?ProvID="+ProvID,0,Wndfeatures);
    if (str!=undefined)
	{
	str[0]=str[0].replace(">","'");
	var Myobj=document.getElementById(strFieldName1);
	Myobj.value=str[0];
	var Myobj=document.getElementById(strFieldName2);
	Myobj.value=str[1];
	}
}

//	Author:Bhavani Akundi
function PatientList(strFieldName1,strFieldName2,strVal)
{
	var Wndfeatures ;
	Wndfeatures ='dialogHeight: 660px; dialogWidth: 800px; dialogTop: 30px; dialogLeft: 100px;';
	Wndfeatures = Wndfeatures + PopUpWindowFeatures;
    var str=window.showModalDialog("../Schedule/PatientFrame.asp?ProviderId="+strVal,0,Wndfeatures);
    if (str!=undefined)
	{
	str[0]=str[0].replace(">","'");
	var Myobj=document.getElementById(strFieldName1);
	Myobj.value=str[0];
	var Myobj=document.getElementById(strFieldName2);
	Myobj.value=str[1];
	}
}

function IsValidPhone(strPhone)
{
	
	if(strPhone.length=='10')
	{
		return 'true';
	}
	else
	{
	   	return 'false';
	}
}

/*
Author	:	Aravind
Date	:	09-06-2004
Purpose :	To Select Payer, Payer Type, Plan Details
*/

function SearchInsurance(strFieldName1,strFieldName2,strFieldName3,strFieldName4,strFieldName5,strFieldName6)
{

	var ParamArray =  new Array('../Common/PayerSearch.asp')
	var Wndfeatures 
	Wndfeatures ='dialogHeight:600px; dialogWidth:800px;';
	Wndfeatures = Wndfeatures + 'scroll:yes;edge: Raised;center: Yes; help: No; resizable: No; status: No;';
	var AddressArray = window.showModalDialog('../Common/PayerSearchFrame.htm',ParamArray,Wndfeatures);
	if (AddressArray!=undefined)
	{	
		var Myobj=document.getElementById(strFieldName1.name);
		Myobj.value=AddressArray[4];
		var Myobj=document.getElementById(strFieldName2.name);
		Myobj.value=AddressArray[5];
		var Myobj=document.getElementById(strFieldName3.name);
		Myobj.value=AddressArray[0];
		var Myobj=document.getElementById(strFieldName4.name);
		Myobj.value=AddressArray[1];
		var Myobj=document.getElementById(strFieldName5.name);
		Myobj.value=AddressArray[2];
		var Myobj=document.getElementById(strFieldName6.name);
		Myobj.value=AddressArray[3];
	
	}	
	
}
/*
Author	:	Aravind
Date	:	09-06-2004
Purpose :	To Select Payer, Payer Type, Plan Details
*/

function SearchPayers(strFieldName1,strFieldName2)
{
	var ParamArray =  new Array('../Common/SearchPayers.asp')
	var Wndfeatures 
	
	Wndfeatures ='dialogHeight:600px; dialogWidth:750px;';
	Wndfeatures = Wndfeatures + 'scroll:yes;edge: Raised;center: Yes; help: No; resizable: No; status: No;';
	var AddressArray = window.showModalDialog('../Common/PayerSearchFrame.htm',ParamArray,Wndfeatures);
	if (AddressArray!=undefined)
	{	
		str=AddressArray.split("~")	
		var Myobj=document.getElementById(strFieldName1.name);
		Myobj.value=str[0];
		var Myobj=document.getElementById(strFieldName2.name);
		Myobj.value=str[1];
	}	
}

/*
Author	:	Aravind
Date	:	09-06-2004
Purpose :	To move the focus to the Next control while inserting phone numbers
*/

function gotoNext(ctrlname,mxlen,decpoint)
{		
		frmName=document.forms[document.forms.length-1];
		ctrLen=ctrlname.value.length + 1
		if(ctrLen>mxlen)
		{
			for(i=0;i+1<eval("document."+frmName.name+".elements.length");i++)
			{
				
				if(eval("document."+frmName.name+".elements[i].name")==ctrlname.name)
				{
				//	if(i+1<eval("document."+frmName.name+".elements.length"))
					//eval(frmName.name).elements[i+1].focus();
					
					//Changed By Samarendra B. on 28.05.2008
					eval("document."+frmName.name+".elements[i+1].focus()");
				}
			}
		}
	
}

/*
Author	:	Aravind
Date	:	09-06-2004
Purpose :	To Generate Global Alert
*/

function Global_Alert(strName)
{
 
	count = 0;
	pos = strName.indexOf("<br>");
	while ( pos != -1 )
	{
	count=count+20;
	pos = strName.indexOf("<br>",pos+1);	
	}	
	if(navigator.appName=='Microsoft Internet Explorer')
   {strName="<br>"+strName 
   var StrMsg=Glb_ShowAlert('The following fields are required '+ strName +'  Do you want to enter now?','Edit','No','Yes','Find-a-Therapist -- Powered by Cognode --',400,120+count);	
	return StrMsg;
   }
	else
	{strName="<br>"+strName;
     var str=strName;    
	str=str.replace(/<br>/gi,"\n");	
	var StrMsg=confirm('The following fields are required '+ str +'  Do you want to enter now?','Edit','No','Yes','Find-a-Therapist -- Powered by Cognode --',400,120+count);	
	return StrMsg;
	}
	
	
	
}

/*
Author	:	Ravi Kumar
Date	:	20050524
Purpose :	To Generate Global Alert for the missing item
*/

function Global_MissingItemsAlert(strName)
{
	count = 0;
	pos = strName.indexOf("<br>");
	while ( pos != -1 )
	{
	count=count+20;
	pos = strName.indexOf("<br>",pos+1);
	}	
	strName="<br>"+strName
	var StrMsg=Glb_ShowAlert('<b>The Following Fields are missing </b>'+ strName +' <b> Do you want to Enter Now?</b>','Edit','No','Yes','Find-a-Therapist -- Powered by Cognode --',400,120+count);	
	return StrMsg;
}
function Global_ViewMissingItemsAlert(strName)
{
	count = 0;
	pos = strName.indexOf("<br>");
	while ( pos != -1 )
	{
	count=count+20;
	pos = strName.indexOf("<br>",pos+1);
	}	
	strName="<br>"+strName
	
	var StrMsg=Glb_ShowAlert('<b>The following fields are missing </b>' + strName + '','','','','Find-a-Therapist -- Powered by Cognode --',400,120+count);
	return StrMsg;
}
//	Author:Bhavani Akundi
function GlobalProvList(strFieldName1,strFieldName2,strVal)
{
	var Wndfeatures ;
	
	Wndfeatures ='dialogHeight: 500px; dialogWidth: 900px; dialogTop: 30px; dialogLeft: 100px;';
	Wndfeatures = Wndfeatures + PopUpWindowFeatures;
    var str=window.showModalDialog("../../Schedule/Common/ProviderFrame.asp?ServiceId="+strVal,0,Wndfeatures);
    if (str!=undefined)
	{
	str[0]=str[0].replace(">","'");
	var Myobj=document.getElementById(strFieldName1);
	Myobj.value=str[0];
	var Myobj=document.getElementById(strFieldName2);
	Myobj.value=str[1];

	}
}
//	Author:Bhavani Akundi
function GlobalFacilityList(strFieldName1,strFieldName2,strVal)
{
	var Wndfeatures ;
	
	Wndfeatures ='dialogHeight: 500px; dialogWidth: 900px; dialogTop: 30px; dialogLeft: 100px;';
	Wndfeatures = Wndfeatures + PopUpWindowFeatures;
  var str=window.showModalDialog("../../Schedule/Common/FacilityFrame.asp?ProviderId="+strVal,0,Wndfeatures);
  if (str!=undefined)
	{
	str[0]=str[0].replace(">","'");
	var Myobj=document.getElementById(strFieldName1);
	Myobj.value=str[0];
	var Myobj=document.getElementById(strFieldName2);
	Myobj.value=str[1];
	}
}

function ShowCertsView(PatientID)
{
	var ParamArray =  new Array('../ActivePatients/ProfileCertsFullView.asp?PatientID='+ PatientID+ '&Mode=V','Certification Details')
	var Wndfeatures 
	Wndfeatures ='dialogHeight:660px; dialogWidth:860px;';
	Wndfeatures = Wndfeatures + 'scroll:yes;edge: Raised;center: Yes; help: No; resizable: No; status: No;';
	var Certs = window.showModalDialog('../ActivePatients/ProfileRespPartyFrame.htm',ParamArray,Wndfeatures);
	
}
function Select7(strCode1,strCode2,strCode3,strCode4,strCode5,strCode6,strCode7) 
{
   var vals=new Array();
	
   vals[0]=strCode1;
   vals[1]=strCode2;
   vals[2]=strCode3;
   vals[3]=strCode4;
   vals[4]=strCode5;
   vals[5]=strCode6;
   vals[6]=strCode7;
   window.returnValue=vals;
  
   window.close();
//	eval("window.opener.document." + strFormName + "." + strFieldName1 + ".value = '" + strCode1 + "';");
//	eval("window.opener.document." + strFormName + "." + strFieldName2 + ".value = '" + strCode2 + "';");
//	self.close();

}




//------------------------------------------------------------------------------------------
/*
	Source	: Copied from the Library of VBV Solutions (P) Ltd
	Author	: -----------------
	Date	: 20050711
	Purpose	: This Function is used to validate the given Email address
	Inputs	: ctrl	- Name of the control
	Return	:	
*/
	var testresults;
	function isValidEmail(ctrl){	
	if (document.layers||document.getElementById||document.all)
	{
		
		var str=ctrl.value
		var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
		if (filter.test(str))
			testresults=true
		else
			testresults=false
			
		return (testresults)
	}
	else
		return true;
	}
//------------------------------------------------------------------------------------------





/*  ================================================================ */

// *** The Function is used to check the Money
// -----------------------------------------------------------------------------	

//	PURPOSE:This Function is used to check the Money 

		
//	Author:Aravind

function isValidMoney(ctrlname,mxlen,decpoint)
{
	
	
		if(decpoint==0)
		{
			if (event.keyCode ==190)
			{
				return false;
			}
		}
		ctrLen=ctrlname.value.length + 1 ;
		
		if ((ctrLen > mxlen)&&(event.keyCode !=8)&& (event.keyCode !=9)&&(event.keyCode !=46))
		{
			return false;
		}
		if (event.keyCode ==190)
		{
			if (ctrlname.value.indexOf('.')==-1)
			{
				var strval = ctrlname.value;
			}	
			else
			{
				
				return false;
			}
		}
				
		if (window.event.shiftKey)
		{
			event.keyCode= 0;
			return false;
		}
		if ((event.keyCode !=9)&&(event.keyCode !=46)&&(event.keyCode !=8)&&(event.keyCode !=48)&&(event.keyCode !=190)&&(event.keyCode !=49)&&(event.keyCode !=50)&&(event.keyCode !=51)&&(event.keyCode !=52)&&(event.keyCode !=53)&&(event.keyCode !=54)&&(event.keyCode !=55)&&(event.keyCode !=56)&&(event.keyCode !=57)&&(event.keyCode !=58)&&(event.keyCode !=96)&&(event.keyCode !=97)&&(event.keyCode !=98)&&(event.keyCode !=99)&&(event.keyCode !=100)&&(event.keyCode !=101)&&(event.keyCode !=102)&&(event.keyCode !=103)&&(event.keyCode !=104)&&(event.keyCode !=105))
		{
			event.keyCode= 0;
			return false;
		}
}

/*  ================================================================ */

// *** The Function is used to Select The ListBox Items (Multy select)
// -----------------------------------------------------------------------------	

//	PURPOSE:The Function is used to Select The ListBox Items (Multy select) 

		
//	Author:Phani Varma

function selectListBoxItems(frmName,ControlName,ID)
{
	a=ID.split(",")
	b=eval("document."+frmName+"."+ControlName+".length")
	for(i=0;i<a.length;i++)
	{
		for(j=0;j<b;j++) 	
		{
			if(a[i]==eval("document."+frmName+"."+ControlName+".options[j].value"))
				{
					
					eval("document."+frmName+"."+ControlName+".options[j].selected=true");
				} 
		}
	}	
}

//	Author:Bhavani Akundi
function CatalogList(strVal)
{
	var Wndfeatures ;
	
	Wndfeatures ='dialogHeight: 500px; dialogWidth: 900px; dialogTop: 30px; dialogLeft: 100px;';
	Wndfeatures = Wndfeatures + PopUpWindowFeatures;
    var str=window.showModalDialog("../../CE/CatalogDetails.asp?CourseID="+strVal,0,Wndfeatures);
    if (str!=undefined)
	{
	str[0]=str[0].replace(">","'");
	var Myobj=document.getElementById(strVal);
	Myobj.value=str[0];
	}
}


//Author: Aravind
//For textarea maxlenght property
function isValidMaxlength(obj,ctrlMaxLength){
	if(event.keyCode!=8 && event.keyCode!=46){
		if(obj.value.length>=ctrlMaxLength){
			var strText=obj.value
			obj.value=strText.substr(0,ctrlMaxLength)
			return false
		}
	}
}

/*
Author	:	RaviKumar N
Date	:	24-SEP-2004
Purpose :	To Select Payer, Payer Type, Plan Details without Quick Add Facility
*/

function SearchIns(strFieldName1,strFieldName2,strFieldName3,strFieldName4,strFieldName5,strFieldName6,flgQuickAdd)
{

	var ParamArray =  new Array('../Common/PayerSearch.asp?flgQuickAdd='+flgQuickAdd);
	var Wndfeatures ;
	Wndfeatures ='dialogHeight:600px; dialogWidth:750px;';
	Wndfeatures = Wndfeatures + 'scroll:yes;edge: Raised;center: Yes; help: No; resizable: No; status: No;';
	var AddressArray = window.showModalDialog('../Common/PayerSearchFrame.htm',ParamArray,Wndfeatures);
	if (AddressArray!=undefined)
	{	

		var Myobj=document.getElementById(strFieldName1.name);
		Myobj.value=AddressArray[4];
		var Myobj=document.getElementById(strFieldName2.name);
		Myobj.value=AddressArray[5];
		var Myobj=document.getElementById(strFieldName3.name);
		Myobj.value=AddressArray[0];
		var Myobj=document.getElementById(strFieldName4.name);
		Myobj.value=AddressArray[1];
		var Myobj=document.getElementById(strFieldName5.name);
		Myobj.value=AddressArray[2];
		var Myobj=document.getElementById(strFieldName6.name);
		Myobj.value=AddressArray[3];
	
	}	
	
}
/*
Author	:	Phani Varma N
Date	:	15-Dec-2004
Purpose :	For Appling Security
*/

function checkSecurity(str,FormName)
{
	if(str!='')
	{
		var VarTempArray=str.split(",");
		var VarCount=VarTempArray.length;
			for(i=1;i<=VarCount;i++)
			{
				//	var ObjtxtName=document.getElementById(VarTempArray[i-1]);
				//	if (ObjtxtName!=undefined)
				//	{
				//		ObjtxtName.style.display='none';
				//	}
			
				for(var j=0; j < document.images.length;j++)
				{      
					if(document.images[j].id==VarTempArray[i-1])
					{
						document.images[j].style.display='none';
					}
				}
				checkTagName(VarTempArray[i-1],FormName);
			}	
	}	
}
/*
Author	:	Phani Varma N
Date	:	15-Dec-2004
Purpose :	For Applying Security
*/

function CbocheckSecurity(str,FrmName,CntrlName)
{
	if(str!='')
	{
		var VarTempArray=str.split(",");
		var VarCount=VarTempArray.length;
			for(i=1;i<=VarCount;i++)
			{	var Option0=document.createElement('option');
				Option0.value=VarTempArray[i-1];
				Option0.text=VarTempArray[i-1];
				eval(FrmName+'.'+CntrlName+'.add(Option0)')
			}	
	}	
}
/*
Author	:	Phani Varma N
Date	:	16-Dec-2004
Purpose :	For Applying Security
*/
function checkTagName(PermissionStr,FrmName)
{
	var Permissionlength=PermissionStr.length;
	for (k=0;k<=eval('document.'+FrmName+'.all.length-1');k++)
	{
		if(eval('document.'+FrmName+'.all[k].tagName') =='A')
		{
			var ObjID =eval('document.'+FrmName+'.all[k].id');
			var TempObjIDlength = ObjID.length
			if(TempObjIDlength>Permissionlength+2)
			{
				var TempVarPermissionStr=ObjID.slice(0,Permissionlength)
				if(TempVarPermissionStr==PermissionStr)
				{
					var Obj=document.getElementById(ObjID);
					//Obj.clearAttributes 
					Obj.removeAttribute('href');
					Obj.removeAttribute('style');
					
					for (var P=0;P<=Obj.attributes.length-1;P++)
					{	
						var a=(Obj.attributes[P].name).slice(0,2)
						if(a=="on")
						{
							//eval("Obj."+ Obj.attributes[P].name+"='function {}'");
							eval("Obj."+ Obj.attributes[P].name+"='false'");
						}
					}
				}
			}				
		}
	}

}
function perm()
{
	alert('hai');
}

// Calling the Help Files 

function MM_openBrWindow(theURL,winName,features)
 { //v2.0
  window.open(theURL,winName,features);
}
/*
Author	:	Phani Varma N
Date	:	2-Mar-2005
Purpose :	for checking filepath 
		
		Syn: Filename.asp		-----correct
			 Filename.asp.asp	-----wrong	
			 Filename.			-----Wrong
			 Filename			-----wrong			
*/
function CheckFilePath(Ctrl)
{
	var varlen=Ctrl.value;
	var pos1,pos,pos2,count;
	count = 0;
	pos = varlen.indexOf(".");
	pos1=varlen.indexOf(".");
	pos2=varlen.charAt(Ctrl.value.length-1);
	if(pos2!='.')
	{
		/*
		while ( pos != -1 ) 
			{	
				count++;
	  			pos = varlen.indexOf(".",pos+1);
			}
		*/	
	}		
if( pos1==-1 || count>1 || pos2=='.')
	{
		return 0
	}
else
	{
		return 1
	}
}


/*included by usha on 13/05/2005*/
var PopUpWindowFeatures;
PopUpWindowFeatures = 'scroll:yes;edge: Raised;dialogtop:1px;dialogleft:1px;help: No; resizable: No; status: No;';

//------------------------------------------------------------------------------------------
/*
	Author: Ravi Kumar N
	Date	: 20050317
	Purpose: This function is for validating the String Field with the Valid Values specified
	Inputs: strActualString = Field name that is to be validated (Ex:frmTest.txtTest)
					strValidValues = Valid Values (Ex:"ABCDEFGHIJKLMNOPQRSTUVWXYZ~! ")
	Return Value: 0
*/

function fnStringFieldValidate(strActualString,strValidValues){
	var iStringLength
	var iCount
	var iIndex
	var strActString = strActualString.value;		
	iStringLength = strActualString.value.length	// gets the length of the Actual String
	for(iCount=0;iCount < iStringLength;iCount++){
		strChar = strActString.charAt(iCount);			// get each character
		iIndex = 	strValidValues.indexOf(strChar.toUpperCase(),0);	// compare the character with each character of the given valid characters
		if(iIndex == -1)	
			return false;	// if the value not found returns false;
	}
}
//------------------------------------------------------------------------------------------

/*
		Global Message For Permission Alert
*/
function NoPermissionAlert(str)
{
	Glb_ShowAlert("Action Denied ! You Have No ' "+str+" ' Permission");
	return false;
}

//
/*
	Author: Ravi Kumar N
	Date	: 20050614
*/
function mouse_img(ObjID,flag){
	if(flag==0){
		document.getElementById(ObjID).className = "borderimg";
	}
	else{
		document.getElementById(ObjID).className = "borderimg_hover";
	}

}


/*   added by srikanth on 22 Dec 2006 Plz dont Modify this one it will effect in Existing pages */
/**********************************************************************************************/
		function fnGeneratePagesNo11(frmName)
			{
			var frmCommon= document.getElementById(frmName);
			//alert(frmCommon);
				frmCommon.hdnFlg.value ="N";
				if(parseInt(frmCommon.CountIndex.value) < parseInt(frmCommon.TotalIndexes.value))
				{ 
					frmCommon.CountIndex.value = parseInt(frmCommon.CountIndex.value) + 1
                }
			}
			function fnGeneratePagesNo21(frmName)
			{
				var frmCommon= document.getElementById(frmName);
				frmCommon.hdnFlg.value ="N";
				if(parseInt(frmCommon.CountIndex.value) > 1)
				{ 
					frmCommon.CountIndex.value = parseInt(frmCommon.CountIndex.value) - 1
					
                }
			}
			function fnGeneratePagesYes1(frmName)
			{
			
			var frmCommon= document.getElementById(frmName);
			frmCommon.hdnFlg.value ="";
			}
			
			function fnGeneratePagesNo31(frmName)
			{
				var frmCommon= document.getElementById(frmName);
				//alert(frmCommon);
				frmCommon.hdnFlg.value ="N";
				frmCommon.submit();
			}
			function fnGeneratePagesNo41(frmName)
			{
				var frmCommon= document.getElementById(frmName);
				//alert(frmCommon);
				frmCommon.hdnFlg.value ="N";
			}
/**********************************************************************************************/

/* Added by Vinod on 10/1/2007 for Country State City CallBack Raiseevent 
/************************************************************************************************/
var __callbackList = new Array();	
		//	Holds the asynchronous callback handler
		//	Add the Callback Handler to array list
function addToCallbackList(cb)
	{
		__callbackList[__callbackList.length] = cb;
	}
var __nonMSDOMBrowser = (window.navigator.appName.toLowerCase().indexOf('explorer') == -1);
var pageUrl = "";			//	Post Back URL
var __theFormPostData = "";	//	Form Data

function ShowResponse(ResponseText,context)
{
	if (ResponseText!='')
	{
		context.innerHTML = ResponseText;
	
	}
}		

function ShowErrorResponse(responseText, context)
{
	//if (context != null)
	return false;
}

function WebForm_OnClientCallbackComplete() 
{
	for(var i = 0; i < __callbackList.length; i++)
	{	
		var __cbObject = __callbackList[i];
		if (__cbObject != null && __cbObject.xmlRequest != undefined )
		{
			if (__cbObject.xmlRequest.readyState=='4') 
			{
				try
				{
					xmlText	 = __cbObject.xmlRequest.responseXML;
					
					var response1 = __cbObject.xmlRequest.responseText;
						
					var status =  Mid(response1,0,3)
					var response = Mid(response1,3,parseInt(response1.length)-2)
					if (status == "200") 
					{
						//alert(__cbObject.eventCallback+'(response, __cbObject.context)');
						ShowResponse(response, __cbObject.context);
																				
					}
					else
					{	
						ShowErrorResponse(response, __cbObject.context);
					}
				}
				catch(e)
				{
					ShowErrorResponse(e.message, __cbObject.context);
				}
				finally
				{
					__cbObject.xmlRequest = '';
					__cbObject = '';
					__callbackList[i] = '';
				}
			}	
		}
	}
}


function WebForm_InitClientCallback() 
{

	var theForm = document.forms[0];	//	ASP.NET currently support single form PostBack only
	count = theForm.elements.length;
	var element;
	re = new RegExp("\\x2B", "g");
	for (i = 0; i < count; i++)
	{
		element = theForm.elements[i];
		if (element.tagName.toLower == "input") 
		{
			__theFormPostData += element.name + "=" + element.value.replace(re, "%2B") + "&";
		}
		if (element.tagName.toLowerCase() == "select")
		{
			selectCount = element.children.length;
			for (j = 0; j < selectCount; j++) 
			{
				selectChild = element.children[j];
				if ((selectChild.tagName.toLowerCase() == "option") && (selectChild.selected == true)) 
				{
					__theFormPostData += element.name + "=" + selectChild.value.replace(re, "%2B") + "&";                
				}                
			}
		}
	}
}

function Getstates_Callback(eventTarget,eventArgument,context1,context2,callType,objState,objCity) 
{
	re = new RegExp("\\x2B", "g");
// eventTarget = document.getElementById(eventTarget);
	var context;
	objState = document.getElementById(objState);

	objCity = document.getElementById(objCity);
	
	var contextState = document.getElementById(context1);
	var ContextCity = document.getElementById(context2);
	
		
	if (__nonMSDOMBrowser)
	{
		
		if ( callType =='Country')
		{
			
			while (objState.options.length > 1)
			{
				objState.options[1] = null;
			}
			
			/*var strStates = "<select name='Country1:ddlState' onchange='javascript:return Getstates_Callback(&quot;Country1&quot;, &quot;Country1_ddlState&quot;, &quot;Country1_tdState&quot; , &quot;Country1_tdCity&quot;, &quot;State&quot;, &quot;Country1_ddlState&quot;, &quot;Country1_ddlCity&quot;);' language='javascript' id='Country1_ddlState' style='width:235px;' > "
			strStates = strStates + "<option value='--Select State--'>--Select State--</option>"
			strStates = strStates + "</select>"
			ShowResponse(strStates, contextState);*/
		}	
		
		while (objCity.options.length > 1)
		{
			objCity.options[1] = null;
		}
		
		/*var strCitys = "<select name='Country1:ddlCity' language='javascript' id='Country1_ddlCity'  onchange='javascript:return fnCity(&quot;Country1_ddlCity&quot;, &quot;Country1_hdnCityId&quot;);' style='width:235px;' > "
		strCitys = strCitys + "<option value='--Select City--'>--Select City--</option>"
		strCitys = strCitys + "</select>"
		ShowResponse(strCitys, ContextCity);*/
		if (document.getElementById(eventArgument).selectedIndex == '0')
		{
			document.body.style.cursor='';
			return false;
		}
		
		if ( callType =='Country')
		{
			context = document.getElementById(context1);
			
		}
		else
		{
			context = document.getElementById(context2);
		}	
			
	}
	else
	{
		if ( callType =='Country')
		{
			
			while (objState.options.length > 0)
			{
				objState.options[0] = null;
			}
			
			var oOption1 = document.createElement("OPTION");
			
			oOption1.text="--Select State--";
			oOption1.value="--Select State--";
			objState.add(oOption1);
		}	
		
		while (objCity.options.length > 0)
		{
			objCity.options[0] = null;
		}
		var oOption2 = document.createElement("OPTION");
		oOption2.text="--Select City--";
		oOption2.value="--Select City--";
		objCity.add(oOption2);
		
		if (document.getElementById(eventArgument).selectedIndex == '0')
		{	
			document.body.style.cursor='';
			return false;
		}
		
		if ( callType =='Country')
		{
			
			context = document.getElementById(context1);
			
		}
		else
		{
			context = document.getElementById(context2);
		}	
	}	
	if (window.XMLHttpRequest)   //For  IE7 , Mozilla and , Netscape......
	{	
		eventArgument = document.getElementById(eventArgument).value;
		
		var xmlRequest = new XMLHttpRequest();
		postData = __theFormPostData +
			"__SCRIPTCALLBACKID=" + eventTarget +
			"&_ScriptcallType=" + callType +
			"&__SCRIPTCALLBACKPARAM=" + escape(eventArgument + "$" + callType).replace(re, "%2B");
		
		if (pageUrl.indexOf("?") != -1)
		{
			xmlRequest.open("GET", pageUrl + "&" + postData, false);
		}
		else 
		{
			xmlRequest.open("GET", pageUrl + "?" + postData, false);
		}    
		xmlRequest.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		xmlRequest.send(null);
		try
		{
			var response1 = xmlRequest.responseText;
							
			var status =  Mid(response1,0,3)
			var response = Mid(response1,3,parseInt(response1.length)-2)
			
			if (status == "200") 
			{			
				ShowResponse(response, context);
			}
			else
			{
				ShowErrorResponse(response, context);
			}
		}
		catch(e)
		{
			ShowErrorResponse(e.message, context);
		}
	}
	else 
	{
		
		eventArgument = document.getElementById(eventArgument).value;
		var xmlRequest = new ActiveXObject("Microsoft.XMLHTTP");
		xmlRequest.onreadystatechange = WebForm_OnClientCallbackComplete;
		var __callbackObject = new Object();
		__callbackObject.xmlRequest = xmlRequest;
		__callbackObject.eventTarget = eventTarget;
		__callbackObject.eventArgument = eventArgument;
		__callbackObject.context = context;
		addToCallbackList(__callbackObject);
		postData = __theFormPostData +
				"__SCRIPTCALLBACKID=" + eventTarget +
				"&_ScriptcallType=" + callType +
				"&__SCRIPTCALLBACKPARAM=" + escape(eventArgument + "$" + callType).replace(re, "%2B");
		
		usePost = false;
		
		if (pageUrl.length + postData.length + 1 > 2067)
		{
			usePost = true;
		}
		if (usePost)
		{
			xmlRequest.open("POST", pageUrl, true);
			xmlRequest.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
			xmlRequest.send(postData);
		}
		else 
		{            
			if (pageUrl.indexOf("?") != -1) 
			{
				xmlRequest.open("GET", pageUrl + "&" + postData, true);
			}
			else 
			{
				xmlRequest.open("GET", pageUrl + "?" + postData, true);
			}
			xmlRequest.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
			xmlRequest.send();
		}
	}
}

 function checkValidNumeric(ctrlname,mxlen,decpoint,e)
 {
		if(document.all)
        { //it's IE 
            var e = window.event.keyCode; 
        }
        else
        { 
            e = e.which; 
        }
			var strNumeric = '1234567890'
			var str = ctrlname.value;	
			ctrLen=ctrlname.value.length + 1 ;
			ctrlname.maxLength = mxlen;
			if (decpoint == 0 || decpoint =='')
			{
			   if(e>0)
			   {
				if (strNumeric.indexOf(String.fromCharCode(e)) == -1 && e != 8) 
				{
					    return false;
				}		
			   }
			}
			
			if(decpoint > 0 && e != 8 )
			{	
				
				if (ctrlname.value.indexOf('.')!=-1)
				{
					
					if (e ==46)
					{
						return false;
					}
					if ((ctrlname.value.slice(ctrlname.value.indexOf('.')).length)> decpoint)
					{
					/*Added by Rakesh for text selection entry*/
					    var currentRange;
					    if(document.all)
					    {
					        currentRange=document.selection.createRange().text;
					    }
					    else
					    {
					         currentRange=ctrlname.value.substring(ctrlname.selectionStart,ctrlname.selectionEnd);
					    }
                        if(currentRange!='')
                         {
                             if (currentRange.indexOf('.')==-1)
                             {
                                if (ctrlname.value.indexOf('.')!=-1)
                                 {
                                	    var pos1=ctrlname.value.indexOf('.')
		                                var pos2 =doGetCaretPosition(ctrlname);
		                                if(e!=0)
		                                {   
		                                    if (ctrlname.value.length!=pos2)
		                                    {
		                                        if (pos2>pos1+1)
		                                        {
                                                     return false;					
		                                        }
		                                    }
		                                }  
                                 }
                              } 
                             
                         }    
                         else
                         {
                            if (ctrlname.value.indexOf('.')!=-1)
                             {
                            	    var pos1=ctrlname.value.indexOf('.')
	                                var pos2 =doGetCaretPosition(ctrlname);
	                                if(e!=0)
		                                {
		                                    if (pos2>pos1)
		                                    {
                                                 return false;					
		                                    }
		                                }  
                             }
                         } 
					}
				}
				if (strNumeric.indexOf(String.fromCharCode(e)) == -1 && e != 8 && e !=46 && e!=0) 
				{
					return false;
				}	
			}
 }
 
        function Allowtab(e)
		{
		   if(document.all)
	        { 
                var e = window.event.keyCode; 
            }
            else
            { 
                e = e.which; 
            }
            
            if(e>0 && e!=8)
            {
                 return false;
            }
            else
            {
            
            }
		}
		
/*Added by Rakesh for text selection entry*/



 function doGetCaretPosition (oField) 
 {
     var iCaretPos = 0;
     // IE Support
     if (document.selection) { 
       oField.focus ();
       // To get cursor position, get empty selection range
       var oSel = document.selection.createRange ();
       // Move selection start to 0 position
       oSel.moveStart ('character', -oField.value.length);
       // The caret position is selection length
       iCaretPos = oSel.text.length;
     }
     // Firefox support
     else if (oField.selectionStart || oField.selectionStart == '0')
       iCaretPos = oField.selectionStart;
     return (iCaretPos);
   }
/*End*/
		function checkValidDOB(e)
		{
			if(document.all)
	        { //it's IE 
                var e = window.event.keyCode; 
            }
            else
            { 
              var  e = e.which; 
            }
           // alert(e);
  			var strNumeric = ''				
				if (strNumeric.indexOf(String.fromCharCode(e)) == -1 && e!=46 && e!=9 && e!=16) 
				{
					return false;
				}	
          	
		}
		
		function checkNumeric(e)
		{
			 var keynum;
            var keychar;
            var numcheck;

            if(window.event) // IE
            {
                keynum = e.keyCode;                         
                if ((keynum >= 48 && keynum <= 57)|| keynum == 13)
                  e.keyCode = e.keyCode ;
                else
                  e.keyCode = 0;                 
                return true;
            }
            else if(e.which) // Netscape/Firefox/Opera
            {
                keynum = e.which;                
                keychar = String.fromCharCode(keynum);                
                if(keynum !=8)
                {                    
                    numcheck = /\d/;  // here d/  for number only. w/ for char and number                 
                    return numcheck.test(keychar);
                }
                else
                    return true;
            }
          	
		}
		function ValidZip(e)
		{
			 var keynum;
            var keychar;
            var numcheck;

            if(window.event) // IE
            {
                keynum = e.keyCode;                         
                if ((keynum >= 48 && keynum <= 57)|| keynum == 13 || (keynum >= 97 && keynum <= 122) || (keynum >= 65 && keynum <= 90))
                  e.keyCode = e.keyCode ;
                else
                  e.keyCode = 0;                 
                return true;
            }
            else if(e.which) // Netscape/Firefox/Opera
            {
                keynum = e.which;                
                keychar = String.fromCharCode(keynum);                
                if(keynum !=8 && keynum != 95)
                {                    
                    numcheck = /\w/;  // here d/  for number only. w/ for char and number                 
                    return numcheck.test(keychar);
                }
                else
                {
                    if(keynum != 95)
                        {
                        return true;
                        }
                    else
                        return false;
                }
                    
            }
          	
		}
		//Added by Samarendra on 1st Dec 2008 for Validating the max length of Multiline Text
		  function checkTextAreaMaxLength(textBox,e, length)
            {
                    var mLen = textBox["MaxLength"];
                    if(null==mLen)
                        mLen=length;
                    
                    var maxLength = parseInt(mLen);
                    if(!checkSpecialKeys(e))
                    {
                     if(textBox.value.length > maxLength-1)
                     {
                        if(window.event)//IE
                          e.returnValue = false;
                        else//Firefox
                            e.preventDefault();
                     }
                }   
            }
          function checkSpecialKeys(e)
                {
                    if(e.keyCode !=8 && e.keyCode!=46 && e.keyCode!=37 && e.keyCode!=38 && e.keyCode!=39 && e.keyCode!=40)
                        return false;
                    else
                        return true;
                }
                
   //Added By Samarendra on 5th March 2009
	function checkValidNames(ctrlname1,e)
		{
		
		 var ctrlname=document.getElementById(ctrlname1);
			if(document.all)
	        { //it's IE 
                var e = window.event.keyCode;
                 
            }
            else 
            { 
                e = e.which; 
                
            }
          
			var strNumeric = "ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz0123456789.',/-:;_.'";
			//alert(String.fromCharCode(event.keyCode));
			var str = ctrlname.value;	
			ctrLen=ctrlname.value.length + 1 ;
			if (strNumeric.indexOf(String.fromCharCode(e)) == -1 && e != 8 && e != 0) 
				{
					return false;
				}		
			}
			
			function ClearDate(CtrlName)
	    {
	       if(document.getElementById(CtrlName).value=='mm/dd/yyyy')
	       {
	         document.getElementById(CtrlName).value='';
	       }
	    }
	//Added By Rakesh for Check valid date		
		function CheckValidDate(ctrlname)
		{
		 
		   if(ctrlname.value.length > 0)
            {
                var date=ctrlname.value;
                var len=ctrlname.value.length;
	                for(var i=0; i<len; i++)
	                {	
    			    
		                var k=date.charAt(i);
		                var digits="0123456789/"; 
		                if((digits.indexOf(k,0))== -1)
		                {
			                Glb_ShowAlert('Enter valid date');
			                ctrlname.value='';
			                ctrlname.focus();
			                return false;
		                }
	                }
    			return ValidateForm(ctrlname);
            }
		}
		 //Added By Samarendra on 13th April 2009
	function checkValidPracticeNames(ctrlname1,e)
		{
		
		 var ctrlname=document.getElementById(ctrlname1);
			if(document.all)
	        { //it's IE 
                var e = window.event.keyCode;
                 
            }
            else 
            { 
                e = e.which; 
                
            }
          
			var strNumeric = "ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz0123456789.'@#$%^&(),/-:;_.'";
			//alert(String.fromCharCode(event.keyCode));
			var str = ctrlname.value;	
			ctrLen=ctrlname.value.length + 1 ;
			if (strNumeric.indexOf(String.fromCharCode(e)) == -1 && e != 8 && e != 0) 
				{
					return false;
				}		
			}
			//Added By Samarendra B. on 28th May 2009
			function stopSpaceKey(evt) 
            {  
            
                //alert(evt.keyCode);
                var evt = (evt) ? evt : ((event) ? event : null); 
                var node = (evt.target) ? evt.target : ((evt.srcElement) ? evt.srcElement : null); 

                if (evt.keyCode == 32)  
                {
                if(window.navigator.appName == "Microsoft Internet Explorer")
                {
                    Glb_ShowAlert('Spaces are not allowed');
                    return false;
                }
                else
                {
                return false;
                }
                } 

                else
                {
                    return true;
                }

            } 
            
  //Added By Rakesh.B on 13 june 2009              
            
 /* This function is for validating the date when user enters the date manually.*/
 
 function ValidateForm(dt){
	if (isDate(dt.value)==false){
		dt.focus()
		return false
	}
    return true
 }
    // Declaring valid date character, minimum year and maximum year
    var dtCh= "/";
    var minYear=1900;
    var maxYear=2060;

    function isInteger(s){
	    var i;
        for (i = 0; i < s.length; i++){   
            // Check that current character is number.
            var c = s.charAt(i);
            if (((c < "0") || (c > "9"))) return false;
        }
        // All characters are numbers.
        return true;
    }

    function stripCharsInBag(s, bag){
	    var i;
        var returnString = "";
        // Search through string's characters one by one.
        // If character is not in bag, append to returnString.
        for (i = 0; i < s.length; i++){   
            var c = s.charAt(i);
            if (bag.indexOf(c) == -1) returnString += c;
        }
        return returnString;
    }

    function daysInFebruary (year){
	    // February has 29 days in any year evenly divisible by four,
        // EXCEPT for centurial years which are not also divisible by 400.
        return (((year % 4 == 0) && ( (!(year % 100 == 0)) || (year % 400 == 0))) ? 29 : 28 );
    }
    function DaysArray(n) {
	    for (var i = 1; i <= n; i++) {
		    this[i] = 31
		    if (i==4 || i==6 || i==9 || i==11) {this[i] = 30}
		    if (i==2) {this[i] = 29}
       } 
       return this
    }
    
   function daysInMonth1(month, year) 
    {
         return new Date(year, month, 0).getDate();
    }

    function isDate(dtStr){
	    var daysInMonth = DaysArray(12)
	    var pos1=dtStr.indexOf(dtCh)
	    var pos2=dtStr.indexOf(dtCh,pos1+1)
	    var strMonth=dtStr.substring(0,pos1)
	    var strDay=dtStr.substring(pos1+1,pos2)
	    var strYear=dtStr.substring(pos2+1)
	    strYr=strYear
	    if (strDay.charAt(0)=="0" && strDay.length>1) strDay=strDay.substring(1)
	    if (strMonth.charAt(0)=="0" && strMonth.length>1) strMonth=strMonth.substring(1)
	    for (var i = 1; i <= 3; i++) {
		    if (strYr.charAt(0)=="0" && strYr.length>1) strYr=strYr.substring(1)
	    }
	    month=parseInt(strMonth)
	    day=parseInt(strDay)
	    year=parseInt(strYr)
	    if (pos1==-1 || pos2==-1){
		    Glb_ShowAlert("The date format should be : mm/dd/yyyy")
		    return false
	    }
	    if (strMonth.length<1 || month<1 || month>12){
		    Glb_ShowAlert("enter a valid month")
		    return false
	    }
	    if (strDay.length<1 || day<1 || day>31 || (month==2 && day>daysInFebruary(year)) || day > daysInMonth1(month,year)){
		    Glb_ShowAlert("Enter a valid day")
		    return false
	    }
	    if (strYear.length != 4 || year==0 || year<minYear || year>maxYear){
		    Glb_ShowAlert("Enter a valid 4 digit year between "+minYear+" and "+maxYear)
		    return false
	    }
	    if (dtStr.indexOf(dtCh,pos2+1)!=-1 || isInteger(stripCharsInBag(dtStr, dtCh))==false){
		    Glb_ShowAlert("Enter a valid date")
		    return false
	    }
    return true
    } 
            
 /* This function for user enter date manually it only allows the characters '1234567890/' */ 
 
 function ValidedateEntry(ctrlname,e)
 {
		if(document.all)
        { //it's for IE 
            var e = window.event.keyCode; 
        }
        else
        { 
            e = e.which; 
        }
			var strNumeric = '1234567890/'
			var str = ctrlname.value;	
			ctrLen=ctrlname.value.length + 1 ;
			   if(e>0)
			   {
				    if (strNumeric.indexOf(String.fromCharCode(e)) == -1 && e != 8) 
				    {
					        return false;
				    }		
			   }
}
function redirect(nodeid)
    {
        var strString=nodeid;
        if(strString.match('PatientFile1_')!=null)
        {
           strString=strString.replace('PatientFile1_','PatientFile1$')
        }
        if(strString.match('Childsections_')!=null)
        {
           strString=strString.replace('Childsections_','Childsections$')
        }
        if(strString.match('_lnksection')!=null)
        {
           strString=strString.replace('_lnksection','$lnksection')
        }
        if(strString.match('Uctrl_ClinicalDocument1_')!=null)
        {
           strString=strString.replace('Uctrl_ClinicalDocument1_','Uctrl_ClinicalDocument1$')
        }
        if(strString.match('User_NavigateSectionsVer3_1_')!=null)
        {
           strString=strString.replace('User_NavigateSectionsVer3_1_','User_NavigateSectionsVer3_1$')
        }
        if(strString.match('Topsections1_')!=null)
        {
           strString=strString.replace('Topsections1_','Topsections1$')
        }
        if(strString.match('Migrated_PatientTopSearch1_')!=null)
        {
           strString=strString.replace('Migrated_PatientTopSearch1_','Migrated_PatientTopSearch1$')
        }
       
        if(strString.match('../')!=null)
        {
           document.forms[0].submit();
        }
        else
        {
            __doPostBack(strString,'')
        }
        
    }
    
       function getScrollBottom(p_oElem)
        { //alert(p_oElem.scrollHeight)
            if (p_oElem.scrollHeight < 400)
            {// alert(p_oElem.scrollHeight)
            return 1;
            }
            else
            {
            return p_oElem.scrollHeight - p_oElem.scrollTop - p_oElem.clientHeight
            }
        }
 
            function  IAmShown(sender,args)
            {
             var comletionList='';
              comletionList=sender.get_completionList();;
              var obj1= document.getElementById(sender._completionListElement.id).style.width.split("px");
              //alert(parseFloat(obj1[0]));
              var obj2;
              var obj4;
              var obj6=0;
               obj2=parseFloat(parseFloat(obj1[0])/8);
                for(i=0;i<comletionList.childNodes.length;i++)
                {
                    var obj=comletionList.childNodes[i]._value.length;
                    //alert(obj);
                    if (obj>obj2)
                    {
                    var obj3=obj-obj2;
                        var obj5=parseFloat((obj3*parseFloat(obj1[0]))/obj2);
                         //alert(obj5);
                        if (obj5>200)
                        {
                        obj5=200;
                        }
                      //alert(obj5);
                         if (obj6<(parseFloat(obj1[0])+parseFloat(obj5)+10))
                         {
                         document.getElementById(sender._completionListElement.id).style.width=parseFloat(obj1[0])+parseFloat(obj5)+10+'px';
                         obj4='Y';
                         obj6=parseFloat(obj1[0])+parseFloat(obj5)+10;
                         }
                    }
                    else
                    {
                      if (obj4!='Y')
                      {
                      document.getElementById(sender._completionListElement.id).style.width=parseFloat(obj1[0])+'px';
                      }
                    }
                }
            }   
            
             function  IAmShowning(sender,args)
            {
             var comletionList='';
              comletionList=sender.get_completionList();;
              var obj1= document.getElementById(sender._completionListElement.id).style.width.split("px");
              //alert(parseFloat(obj1[0]));
              var obj2;
              var obj4;
              var obj6=0;
              obj2=parseFloat(parseFloat(obj1[0])/8);
                for(i=0;i<comletionList.childNodes.length;i++)
                {
                   var objk=comletionList.childNodes[i].innerHTML;
                   var objk1=comletionList.childNodes[i].innerHTML;
                       objk = objk.replace("<SPAN class=AutoComplete_ListItemHiliteText>","");
                       objk=ltrim(objk,"")
                        objk= objk.replace("</SPAN>","")
                        objk=rtrim(objk,"")
                        comletionList.childNodes[i].innerHTML=objk;
                    var obj=comletionList.childNodes[i].innerHTML.length;
                    //alert(obj);
                    if (obj>obj2)
                    {
                    var obj3=obj-obj2;
                    var obj5=parseFloat((obj3*parseFloat(obj1[0]))/obj2);
                     //alert(obj5);
                    if (obj5>200)
                    {
                    obj5=200;
                    }
                         if (obj6<(parseFloat(obj1[0])+parseFloat(obj5)+10))
                         {
                         document.getElementById(sender._completionListElement.id).style.width=parseFloat(obj1[0])+parseFloat(obj5)+10+'px';
                         obj4='Y';
                         obj6=parseFloat(obj1[0])+parseFloat(obj5)+10;
                         }
                    }
                    else
                    {
                      if (obj4!='Y')
                      {
                      document.getElementById(sender._completionListElement.id).style.width=parseFloat(obj1[0])+'px';
                      }
                    }
                    comletionList.childNodes[i].innerHTML=objk1;
                }
            }    
            
            
         function checkValidNumericCPT(ctrlname,mxlen,decpoint,e)
		{
		 if(document.all)
        { //it's IE 
            var e = window.event.keyCode; 
        }
        else
        { 
            e = e.which; 
        }
			var strNumeric = '1234567890'
			var str = ctrlname.value;	
			ctrLen=ctrlname.value.length + 1 ;
			if (ctrlname.value.length==3)
			{
			    if(e==46)
			    {
			      ctrlname.maxLength = mxlen-2;
			    }
			    else
			    {
			      ctrlname.maxLength = mxlen-3;
			    }
			}
			else
			{
			    ctrlname.maxLength = mxlen-3;
			}
			
			if (decpoint == 0 || decpoint =='')
			{
			   if(e>0)
			   {
				if (strNumeric.indexOf(String.fromCharCode(e)) == -1 && e != 8) 
				{
					    return false;
				}		
			   }
			}
			
			if(decpoint > 0 && e != 8 )
			{	
				
				if (ctrlname.value.indexOf('.')!=-1)
				{
					ctrlname.maxLength = mxlen;
					if (e ==46)
					{
						return false;
					}
					if ((ctrlname.value.slice(ctrlname.value.indexOf('.')).length)> decpoint)
					{
					/*Added by Rakesh for text selection entry*/
					    var currentRange;
					    if(document.all)
					    {
					        currentRange=document.selection.createRange().text;
					    }
					    else
					    {
					         currentRange=ctrlname.value.substring(ctrlname.selectionStart,ctrlname.selectionEnd);
					    }
                        if(currentRange!='')
                         {
                             if (currentRange.indexOf('.')==-1)
                             {
                                if (ctrlname.value.indexOf('.')!=-1)
                                 {
                                	    var pos1=ctrlname.value.indexOf('.')
		                                var pos2 =doGetCaretPosition(ctrlname);
		                                if(e!=0)
		                                {   
		                                    if (ctrlname.value.length!=pos2)
		                                    {
		                                        if (pos2>pos1+1)
		                                        {
                                                     return false;					
		                                        }
		                                    }
		                                }  
                                 }
                              } 
                             
                         }    
                         else
                         {
                            if (ctrlname.value.indexOf('.')!=-1)
                             {
                            	    var pos1=ctrlname.value.indexOf('.')
	                                var pos2 =doGetCaretPosition(ctrlname);
	                                if(e!=0)
		                                {
		                                    if (pos2>pos1)
		                                    {
                                                 return false;					
		                                    }
		                                }  
                             }
                         } 
					}
				}
				if (strNumeric.indexOf(String.fromCharCode(e)) == -1 && e != 8 && e !=46 && e!=0) 
				{
					return false;
				}	
			}
		}
		
		function ltrim(str, chars) {
	chars = chars || "\\s";
	return str.replace(new RegExp("^[" + chars + "]+", "g"), "");
}
 
function rtrim(str, chars) {
	chars = chars || "\\s";
	return str.replace(new RegExp("[" + chars + "]+$", "g"), "");
}

function fun_divcopyrigths(_obj,obj1)
	 	{
     	   var obj=document.getElementById(_obj);
     	  	var curtop = 0;
	        var curleft =0;
	        var strStyle='';
	         
               if (obj.offsetParent)
	           {
				    while (obj.offsetParent)
				    {
					    curtop += obj.offsetTop
					    curtop=curtop-63;
					    curleft +=obj.offsetLeft
			             curleft =curleft-90;
					    obj = obj.offsetParent;	
		            }
			    }
			    document.getElementById (obj1).style.display='';
			    document.getElementById (obj1).style.zIndex=1001;
			    document.getElementById (obj1).style.left =200 +'px';
			     document.getElementById (obj1).style.top =curtop +'px';
			     document.getElementById (obj1).style.position ='absolute';
			     document.getElementById (obj1).style.width =600 +'px';
			   return false;
	 	}
	function hidecopyrigthsdiv(obj)
	 	{
	 	document.getElementById (obj).style.display='none';
	 	return false;
	 	} 
	 	
	 	 
function fnGetXYPossCenter(_obj,_obj1,_obj2,_obj3)
{

	var obj=document.getElementById(_obj);
	document.getElementById (_obj).style.display='';
    var xyz=document.getElementById(_obj).offsetWidth;
    var xyz1=document.getElementById(_obj).offsetHeight;
    document.getElementById (_obj).style.display='none';
    showdeadcenterdiv(xyz,xyz1,_obj,_obj1,_obj2,_obj3);
}
function showdeadcenterdiv(Xwidth,Yheight,divid,hnid,maskid,hdnmaskid)
 {
 //Div align in center
// First, determine how much the visitor has scrolled
var scrolledX, scrolledY;
if( self.pageYoffset )
 {
scrolledX = self.pageXoffset;
scrolledY = self.pageYoffset;
}
 else if ( document.documentElement && document.documentElement.scrollTop )
  {
scrolledX = document.documentElement.scrollLeft;
scrolledY = document.documentElement.scrollTop;
} 
else if( document.body ) 
{
scrolledX = document.body.scrollLeft;
scrolledY = document.body.scrollTop;
}

// Next, determine the coordinates of the center of browser's window

var centerX, centerY;
if( self.innerHeight )
 {
centerX = self.innerWidth;
centerY = self.innerHeight;
} 
else if( document.documentElement && document.documentElement.clientHeight )
 {
centerX = document.documentElement.clientWidth;
centerY = document.documentElement.clientHeight;
}
 else if( document.body )
  {
centerX = document.body.clientWidth;
centerY = document.body.clientHeight;
}
//alert(centerX);
//alert(centerY);
//alert(Xwidth);
//alert(Yheight);
// Xwidth is the width of the div, Yheight is the height of the
// div passed as arguments to the function:
var leftoffset = scrolledX + (centerX - Xwidth) / 2;
var topoffset = scrolledY + (centerY - Yheight) / 2;
// The initial width and height of the div can be set in the
// style sheet with display:none; divid is passed as an argument to // the function
if (Yheight>centerY)
{
var topoffset = scrolledY +(Yheight-centerY)/2;
}

var o=document.getElementById(divid);
var r=o.style;
r.position='absolute';
r.top = topoffset + 'px';
r.left = leftoffset + 'px';
//r.display = "block";
//document.getElementById(hnid).value='Z-INDEX: 1005; LEFT:'+ leftoffset+'px;TOP: ' + topoffset + 'px';
document.getElementById(hnid).value='Z-INDEX: 1005;TOP:'+ r.top + ';LEFT:'+ r.left;
//alert(document.getElementById(hnid).value);

//for maskdiv getiing page width and heigth

if( window.innerHeight && window.scrollMaxY ) // Firefox 
{
pageWidth = window.innerWidth + window.scrollMaxX;
pageHeight = window.innerHeight + window.scrollMaxY;
}
else if( document.body.scrollHeight > document.body.offsetHeight ) // all but Explorer Mac
{
pageWidth = document.body.scrollWidth;
pageHeight = document.body.scrollHeight;
}
else // works in Explorer 6 Strict, Mozilla (not FF) and Safari
{ 
pageWidth = document.body.offsetWidth + document.body.offsetLeft; 
pageHeight = document.body.offsetHeight + document.body.offsetTop; 
}

if(navigator.appName!='Microsoft Internet Explorer')
{
 pageWidth=pageWidth-18;
}


document.getElementById (maskid).style.display='';
document.getElementById (maskid).style.visibility='visible';
document.getElementById (maskid).style.top='0px';
document.getElementById (maskid).style.left='0px';
document.getElementById (maskid).style.width= pageWidth +'px';
document.getElementById (maskid).style.height=pageHeight +'px';
//document.getElementById(hdnmaskid).value='WIDTH:'+ pageWidth+'px;HEIGTH: ' + pageHeight + 'px;LEFT:0px;TOP:0px;VISIBILITY:visible';
document.getElementById(hdnmaskid).value=pageWidth + ';' + pageHeight ;

} 	
/********************************************************************************************************/