 // **********JScript File **********// 
    //**********Manali JS Code **********// 
    //**********GENERIC VALIDATIONS **********//

//Check Alphabets ==== 
    function isAlphabet() 
    {
        //debugger;
        var ls_Char;
        ls_Char =  event.keyCode;

        //Char between A-Z and a-z
        if ((ls_Char >= 65 && ls_Char <= 90) || (ls_Char >= 97 && ls_Char <= 122)) 
        {
	        return true;
        }
        else
        {
	        return false;
        }
    }

//Check Numbers ==== 
    function isNumeric() 
    {
        //Char between 0-1
        if ( event.keyCode >= 48 && event.keyCode <= 57 )
        {
	        return true;
        }
        else
        { 
            return false; 
        }
    }
//Check Dot ==== 
    function isDot() 
    {
        //Char . 
        if ( event.keyCode == 46 ) 
        {
	        return true;
        }
        else
        {
            return false; 
        }
    }
//Check Hyphen ==== 
    function isHyphen() 
    {
        //Char -
        if ( event.keyCode == 45 ) 
        {
	        return true;
        }
        else
        {
            return false; 
        }
    }

//Check Enter ==== 
    function isEnter() 
    {
        //Char -
        if ( event.keyCode == 13 ) 
        {
	        return true;
        }
        else
        {
            return false; 
        }
    }

//Check UnderScore ==== 
    function isUnderScore() 
    {
        //Char -
        if ( event.keyCode == 95 ) 
        {
	        return true;
        }
        else
        {
            return false; 
        }
    }
    
//Check AtRate ==== 
    function isAtRate() 
    {
        //Char -
        if ( event.keyCode == 64 ) 
        {
	        return true;
        }
        else
        {
            return false; 
        }
    }
    
//Check FrontSlash ==== 
    function isFSlash() 
    {
        //Char / 
        if ( event.keyCode == 47 ) 
        {
	        return true;
        }
        else
        {
            return false; 
        }
    }
//Check Singlr Quote ==== 
    function isSQuote() 
    {
        //Char -
        if ( event.keyCode == 39 ) 
        {
	        return true;
        }
        else
        {
            return false; 
        }
    }
    
 //Check Space ==== 
    function isSpace() 
    {
        //Char -
        if ( event.keyCode == 32 ) 
        {
	        return true;
        }
        else
        {
            return false; 
        }
    }
    
    //Check Comma ==== 
    function isComma() 
    {
        //Char -
        if ( event.keyCode == 44 ) 
        {
	        return true;
        }
        else
        {
            return false; 
        }
    }
     
//Check if TextBox is not blank
    function CheckText(txtName)
    {
        //debugger;
        var txtCtrl = document.getElementById(txtName);         
        var sName = TrimString(txtCtrl.value);
        
        if(sName == "")
        {
            txtCtrl.focus();
            return false;
        }
        
        txtCtrl.value = sName;	  
        return true;  
    }

//Check if Dropdownlista are not set to --Select--
    function CheckDDL(ddlName)
    {
        //debugger;
        var ctrlName = document.all(ddlName);            
                    
        if(ctrlName.selectedIndex == 0)
            return false;
        else 
            return true;
    }
      
// Delete Confirmation   for MASTERS
    function ConfirmDeleteForMasters(FieldName,FieldValue)
    {
       //debugger;
       return confirm("You had chosen: "+ FieldName + " - " + FieldValue + "\nAre you sure you want to Delete this Record?")
    }
       
// Delete Confirmation   
    function ConfirmDelete()
    {
       //debugger;
       return confirm("Are you sure you want to Delete this Record?")
    }
// =========  End of GENERIC VALIDATIONS =========




  //Allow 'Alphabets', '.', '_', and numbers  Only 
    
    function allowAlphaDUNCharsOnly()  //(allowed chars is(numbers, aphabets, dot and underscore)
   {
        if (!(isNumeric() || isAlphabet() || isEnter() || isDot() || isUnderScore()))
        {
	        event.keyCode = 0;
	        //alert('Please enter Alpha-Numeric characters only.'); 
        }
    }
    //END
    
   
  //Allow 'Alphabets',  '.',  '_',  '-', '/' and numbers  Only(apha,dot,hyphen,underscore,slash,numbers) 
    
    function allowAlphaDHUSNCharsOnly()  //(allowed chars is(numbers, aphabets, dot and underscore)
   {
        if (!(isNumeric() || isAlphabet() || isEnter() || isDot() || isUnderScore() || isHyphen() || isFSlash() ))
        {
	        event.keyCode = 0;
	        //alert('Please enter Alpha-Numeric characters only.'); 
        }
    }
    //END
     
    
    

//Allow Numbers ==== 
    function allowNumericsOnly()
    {
        if (!(isNumeric() || isEnter()))
        {
	        event.keyCode = 0;
            //alert('Please enter Numbers only .');
        }
    }
    
//Allow Numbers ==== 
    function allowNumerics(txtName)
    {
        var txtCtrl = document.getElementById(txtName);
        if (isNumeric() || isDot() || isEnter())
        {
            if (isNumeric())
            {
                if(txtCtrl.value.lastIndexOf('.') == -1)
                {
                    if (txtCtrl.value.length >= 2)
				    { 
				        event.keyCode = 0;
				        alert('Only two digits are permissible.'); 
				    }
				}
				else if(txtCtrl.value.lastIndexOf('.') > 0)
				{
				    if(txtCtrl.value.length >= 5)
				    { 
				        event.keyCode = 0;
				        alert('Value exceeds the permissible character length.'); 
				    }
				}
            }
	        else if(isDot())
	        {   
	            if(txtCtrl.value.length == 0)
				{ 
				    event.keyCode = 0;
				    alert('Numeric value should not start with a Dot.'); 
				}
				
				if(txtCtrl.value.lastIndexOf('.') > 0)
				{
				    event.keyCode = 0;
				    alert('Dot can occur only once in this numeric field.'); 
				}			
	        }
        }
        else
		{ 
		    event.keyCode = 0;
		    alert('Numeric value should not start with a Dot.'); 
		}
    }
    
//Allow 'Alphabets' and 'Numbers'  Only ==== Alert if any Special Characters
    function allowAlphaNumericsOnly() 
    {
        //debugger;
        //Char between 0-1, A-Z and a-z
        if (!(isNumeric() || isAlphabet() || isEnter()))
        {
	        event.keyCode = 0;
	        //alert('Please enter Alpha-Numeric characters only.'); 
        }
    }
    
//Allow 'Alphabets' and 'Numbers'  Only ==== Alert if any Special Characters
    function allowAlphaHNumericsOnly(txtName) 
    {
        var txtCtrl = document.getElementById(txtName);
        
        //Char between 0-1, A-Z and a-z
        if (isNumeric() || isAlphabet() || isHyphen() || isEnter())
        {
            if(isHyphen())
		    {
	            if(txtCtrl.value.length == 0)
		        { 
                    event.keyCode = 0;
                    alert('Hyphen should not be the first character.'); 
                }
                else if(txtCtrl.value.lastIndexOf('-') >= 0)
				{
				    event.keyCode = 0;
				    
//				    if(txtCtrl.value.lastIndexOf('-') == 0)
//				        alert('Hyphen should not be first character and \r\nHyphen can occur only once in this field.'); 
//				    else if(txtCtrl.value.lastIndexOf('-') == 9)
//				        alert('Hyphen should not be last character and \r\nHyphen can occur only once in this field.'); 
//				    else

				    alert('Hyphen can occur only once in this field.'); 
				}
            }
        }
        else
        {
            event.keyCode = 0;
            alert('Please enter Alpha-Numeric/Hyphen characters only.'); 
        }
    }
    
  
    

//Allow Alphabets ==== 
    function allowAlphabetsOnly()       //FName(R), LName(R), MemberFName(MMD)
    {
        //Char between A-Z and a-z
        if (!(isAlphabet() || isEnter()))
        {
	        event.keyCode = 0;
	        //alert('Please enter Alphabet characters only.'); 
        }
    }
    
    
//Allow 'Alphabets' and 'Spaces' Only ==== Alert if any other Special Character or number
    function allowAlphaSCharsOnly(txtName)     //(R)RCity, OCity ; CountryName; StateName; Search-StartedBy; ViewMembers-SearchUser
    {
        var txtCtrl = document.getElementById(txtName);
        //Char between A-Z and a-z
        if (!(isAlphabet() || isEnter()))
        {
	        if(isSpace())
            {
                if(txtCtrl.value.length == 0)
				{ 
				    event.keyCode = 0;
				    alert('Field value should not start with a Space.'); 
				}
            }
            else
            {
                event.keyCode = 0;
	            alert('Please enter Alphabet/Space characters only.'); 
	        }
        }        
    }
    
//Allow 'Alphabets', and '.'  Only ==== Alert if any other Special Character or number
    
    function allowAlphaDCharsOnly(txtName)  //(R) MName, (MAA) MName, Salutation Name
   {
        var txtCtrl = document.getElementById(txtName);
        //Chars between A-Z, a-z and .
        if (isAlphabet() || isDot() || isEnter())
        {
            if(isDot())
            {   
                if(txtCtrl.value.length == 0)
                { 
                    event.keyCode = 0;
                    if(txtName == 'txtMidName')
                        alert('Middle Name cannot start with a Dot.'); 
                    else
                        alert('Salutation cannot start with a Dot.'); 
                }
                else if(txtCtrl.value.lastIndexOf('.') > 0)
                {
                    event.keyCode = 0;
                    alert('Dot can occur only once in this field.'); 
                }                                         
            }
        }
        else
        {
            event.keyCode = 0;
            alert('Please enter Alphabets/Dot only.'); 
        }
    }
    
    
    
    
    


    //ADDED on 03-07-2008 By Preeti P
    //Allow 'Alphabets', and '.' and 'Space' Only ==== Alert if any other Special Character or number 
    
    function allowAlphaDSCharsOnly(txtName)  //(R) MName, (MAA) MName, Salutation Name
    {
        var txtCtrl = document.getElementById(txtName);
        //Chars between A-Z, a-z and .
        if (!(isAlphabet() || isEnter()))
        {
            if(isDot())
	        {   
	            if(txtCtrl.value.length == 0)
				{ 
				    event.keyCode = 0;
				    alert('Field value should not start with a Dot.'); 
				}										
	        }
	        else if(isSpace())
            {
                if(txtCtrl.value.length == 0)
				{ 
				    event.keyCode = 0;
				    alert('Field value should not start with a Space.'); 
				}
            }	   
	        else
            {
			    event.keyCode = 0;
                alert('Please enter Alphabet/Dot/Space characters only.'); 
            }
        }        
    }
    
    
    
//Allow 'Alphabets', '.' and '-'  Only ==== Alert if any other Special Character or number
    function allowAlphaDHSCharsOnly(txtName)    //(R) OtherInd, DeptName, OrgName
    {
        var txtCtrl = document.getElementById(txtName);
        //Chars between A-Z, a-z, - and .
        if (!(isAlphabet() || isEnter()))
        {
            if(isDot())
	        {   
	            if(txtCtrl.value.length == 0)
				{ 
				    event.keyCode = 0;
				    alert('Field value should not start with a Dot.'); 
				}
			}
			else if(isHyphen())
			{
			    if(txtCtrl.value.length == 0)
				{ 
                    event.keyCode = 0;
                    alert('Field value should not start with a Hyphen.'); 
                }
            }
            else if(isSpace())
            {
                 if(txtCtrl.value.length == 0)
				{ 
				    event.keyCode = 0;
				    alert('Field value should not start with a Space.'); 
				}
            }	         
		    else
            {
                event.keyCode = 0;
                alert('Please enter Alphabet/Dot/Hyphen/Space characters only.'); 
            }
        }
    }

//Allow 'Alphabets', '.', '-' and '/'  Only ==== Alert if any other Special Character or number
    function allowAlphaHSCharsOnly(txtName) 
    {
        var txtCtrl = document.getElementById(txtName);
        //Char between A-Z, a-z, . and /
        if (!(isAlphabet() || isEnter()))
        {
	        if(isSpace())
            {
                 if(txtCtrl.value.length == 0)
				{ 
				    event.keyCode = 0;
				    alert('Field value should not start with a Space.'); 
				}
            }
            
            else if(isHyphen())
			{
			    if(txtCtrl.value.length == 0)
				{ 
                    event.keyCode = 0;
                    alert('Field value should not start with a Hyphen.'); 
                }
            }
		    else
            {
                event.keyCode = 0;
                alert('Please enter Alphabet/Hyphen/Space characters only.'); 
            }
        }
    }
    
//Allow 'Alphabets', '.', '-' and ','  Only ==== Alert if any other Special Character or number
    function allowAlphaCDHSCharsOnly(txtName)   //(R) Profession
    {
        var txtCtrl = document.getElementById(txtName);
        //Char between A-Z, a-z, . and /
        if (!(isAlphabet() || isEnter()))
        {
            if(isComma())
			{
			    if(txtCtrl.value.length == 0)
				{ 
                    event.keyCode = 0;
                    alert('Field value should not start with a Comma.'); 
                }
            }
	        else if(isDot())
	        {   
	            if(txtCtrl.value.length == 0)
				{ 
				    event.keyCode = 0;
				    alert('Field value should not start with a Dot.'); 
				}
			}
			else if(isHyphen())
			{
			    if(txtCtrl.value.length == 0)
				{ 
                    event.keyCode = 0;
                    alert('Field value should not start with a Hyphen.'); 
                }
            }
            else if(isSpace())
            {
                 if(txtCtrl.value.length == 0)
				{ 
				    event.keyCode = 0;
				    alert('Field value should not start with a Space.'); 
				} 
            }
		    else
            {
                event.keyCode = 0;
                alert('Please enter Alphabet/Comma/Dot/Hyphen/Space characters only.'); 
            }
        }
    }
    
//Allow 'Alphabets', '.', '-' and ''' Only ==== Alert if any other Special Character or number
    function allowAlphaDHQCharsOnly(txtName) 
    {
        var txtCtrl = document.getElementById(txtName);
        //Char between -, A-Z, a-z and .
        if (!(isAlphabet() || isSpace()  || isEnter()))
        {
	        if(isDot())
	        {   
	            if(txtCtrl.value.length == 0)
				{ 
				    event.keyCode = 0;
				    alert('Field value should not start with a Dot.'); 
				}
			}
			else if(isHyphen())
			{
			    if(txtCtrl.value.length == 0)
				{ 
                    event.keyCode = 0;
                    alert('Field value should not start with a Hyphen.'); 
                }
            }
            else if(isSQuote())
			{
			    if(txtCtrl.value.length == 0)
				{ 
                    event.keyCode = 0;
                    alert('Field value should not start with a Single-Quote.'); 
                }
            }
		    else
            {
                event.keyCode = 0;
                alert('Please enter Alphabet/Dot/Hyphen/Single-Quote only.'); 
            }
        }
    }
    
    //Allowable characters for Other category in Org Type and Dept.
    
    function allowEntryForOther(ddlName, txtName)
    {
        var txtCtrl = document.getElementById(txtName);
        
        if(document.all(ddlName).options[document.all(ddlName).selectedIndex].text == 'OTHERS')
        {
            //Char between 0-1, A-Z, a-z, -, space, comma
            if (!(isNumeric() || isAlphabet() || isEnter()))
            {
	            if(isDot())
			    {
			        if(txtCtrl.value.length == 0)
				    { 
                        event.keyCode = 0;
                        alert('Field value should not start with a Dot.'); 
                    }
                }
			    else if(isHyphen())
			    {
			        if(txtCtrl.value.length == 0)
				    { 
                        event.keyCode = 0;
                        alert('Field value should not start with a Hyphen.'); 
                    }
                }
			    else if(isSpace())
			    {
			        if(txtCtrl.value.length == 0)
				    { 
                        event.keyCode = 0;
                        alert('Field value should not start with a Space.'); 
                    }
                }
                else
			    {
			        event.keyCode = 0;
	                alert('Please enter Alpha-Numeric/Dot/Hyphen/Space characters only.'); 
                }
            }
        }
        else 
        {   
            if (isEnter())
            {    
                if(txtCtrl.value != '')
                {
                    event.keyCode = 0;
                    //alert('Select \"OTHERS\" from the available list and then specify your details.');
                    
                    if(ddlName == 'ddlOrgType')                    
                        alert('Other Organization Type can be specified only when \"OTHERS\" option is selected.');
                    else if(ddlName == 'ddlOrgType')
                        alert('Other Department can be specified only when \"OTHERS\" option is selected.');
                }
            }
            else
            {
                event.keyCode = 0;
                if(ddlName == 'ddlOrgType')                    
                    alert('Other Organization Type can be specified only when \"OTHERS\" option is selected.');
                else if(ddlName == 'ddlDepartment')
                    alert('Other Department can be specified only when \"OTHERS\" option is selected.');
            }
            
        }
    }
    
    function allowEntryOQualification(txtName)
    {
        var txtCtrl = document.getElementById(txtName);
        if(frmRegistration.chkOthers.checked)
        {
            //Char between 0-1, A-Z, a-z, -, space, comma
            if (!(isNumeric() || isAlphabet() || isEnter()))
            {
	            if(isComma())
	            {   
	                if(txtCtrl.value.length == 0)
				    { 
				        event.keyCode = 0;
				        alert('Field value should not start with a Comma.'); 
				    }
			    }
			    else if(isDot())
	            {   
	                if(txtCtrl.value.length == 0)
				    { 
				        event.keyCode = 0;
				        alert('Field value should not start with a Dot.'); 
				    }
			    }
			    else if(isHyphen())
			    {
			        if(txtCtrl.value.length == 0)
				    { 
                        event.keyCode = 0;
                        alert('Field value should not start with a Hyphen.'); 
                    }
                }
                else if(isSpace())
                {
                     if(txtCtrl.value.length == 0)
				    { 
				        event.keyCode = 0;
				        alert('Field value should not start with a Space.'); 
				    } 
                }
			    else
			    {
			        if(txtCtrl.value != '')
                    {
                        event.keyCode = 0;
	                    alert('Please enter Alpha-Numeric/Comma/Dot/Hyphen/Space characters only.'); 
	                }
                }
            }
        }
        else
        {          
            if(isEnter())
            {
                if(txtCtrl.value != '')
                {
                    event.keyCode = 0;
                    alert('Other Qualification(s) can be specified only when \"Others\" option is checked.');
                }
            }
            else
            {
                event.keyCode = 0;
                alert('Other Qualification(s) can be specified only when \"Others\" option is checked.');
            }
        }
    }
    
    
    function blockSpace()
    {

        if(isSpace())
        {
            alert('Space character is not allowed in this field.');
            event.keyCode = 0;
            return false;
        }
    }
    
    //On Change functions
    // Upper + Title case
    function convertToUpper(objName) 
    {                                                                 
         var newWord=false;                                                                 
         var newName="";                                                                 
         var name=document.all(objName).value;                                                                 
         for (i=0;i<name.length;i++) 
         {                                                                 
	        if (i==0 || newWord==true)                                                                 
              newName=newName+name.charAt(i).toUpperCase();                                                                 
            else
              newName=newName+name.charAt(i);                                                                 
            if (name.charAt(i)==" ")                                                                 
              newWord=true;                                                                 
            else                                                                 
              newWord=false;                                                                 
	     }                                                                 
         document.all(objName).value=newName;                                                                 
    }
    
    // Title case
    function convertToTitle(objName) 
    {                                                                 
         var newWord=false;                                                                 
         var newName="";                                                                 
         var name=document.all(objName).value;                                                                 
         for (i=0;i<name.length;i++)
         {                                                                 
	        if (i==0 || newWord==true)                                                                 
              newName=newName+name.charAt(i).toUpperCase();                                                                 
            else
              newName=newName+name.charAt(i).toLowerCase();                                                                     
            if (name.charAt(i)==" ")                                                                 
              newWord=true;                                                                 
            else                                                                 
              newWord=false;                                                                 
	     }                                                                 
         document.all(objName).value=newName;                                                                 
    }
    
    // Correct case
    function convertToUpperTitle(objName) 
    {                                                                 
         var newWord=false;                                                                 
         var newName="";                                                                 
         var name=document.all(objName).value;                                                                 
         for (i=0;i<name.length;i++) 
         {                                                                 
	        if (i==0 || newWord==true)                                                                 
              newName=newName+name.charAt(i).toUpperCase();                                                                 
            else
              newName=newName+name.charAt(i);                                                                 
            if (name.charAt(i)==" " || name.charAt(i)==".")                                                                 
              newWord=true;                                                                 
            else                                                                 
              newWord=false;                                                                 
	     }                                                                 
         document.all(objName).value=newName;                                                                 
    }

    function convertTitle4Reason(objName) 
    {                                                              
         var newWord = false;                                                                 
         var newName = "";                                                                 
         var name = document.all(objName).value;    
                                                                      
         for (i=0; i<name.length; i++) 
         {                                                                 
	        if (i == 0 || newWord == true)                                                                 
                newName = newName+name.charAt(i).toUpperCase();                                                                 
            else
                newName = newName+name.charAt(i);  
                                                                               
            if (name.charAt(i) == ".")                                                                 
                newWord = true;                                                                 
            else                                                                 
                newWord = false;                                                                 
	     }      
	                                                                
         document.all(objName).value = newName;                                                                 
    }
    function TrimString(str)
    {  
        while(str.charAt(0) == (" ") )
        {  
            str = str.substring(1);
        } 
        while(str.charAt(str.length-1) == " " )
        {
            str = str.substring(0,str.length-1);
        }
        return str;
    }
    
    function CheckFirstChar(strValue)
    {                    
        if(strValue.charAt(0) == ('.') )
        {
            alert('Field value should not start with a Dot.');
            return true;
        }
        else if(strValue.charAt(0) == ('-') )
        {
            alert('Field value should not start with a Hyphen.');
            return true;
        }
        else if(strValue.charAt(0) == (',') )
        {
            alert('Field value should not start with a Comma.');
            return true;
        }
        else if(strValue.charAt(0) == ('@') )
        {
            alert('Field value should not start with an \" @ \" sign.');
            return true;
        }
        else if(strValue.charAt(0) == ('_') )
        {
            alert('Field value should not start with Underscore.');
            return true;
        }
        else 
            return false;
    }
        
    function CheckLastChar(strValue)
    {                       
        if(strValue.charAt(strValue.length - 1) == ('.') )
        {
            alert('Field value should not end with a Dot.');
            return true;
        } 
        else if(strValue.charAt(strValue.length - 1) == ('-') )
        {
            alert('Field value should not end with a Hyphen.');
            return true;
        } 
        else if(strValue.charAt(strValue.length - 1) == (',') )
        {
            alert('Field value should not end with a Comma.');
            return true;
        } 
        else if(strValue.charAt(strValue.length - 1) == ('@') )
        {
            alert('Field value should not end with an \" @ \" sign.');
            return true;
        } 
        else if(strValue.charAt(strValue.length - 1) == ('_') )
        {
            alert('Field value should not end with an Underscore.');
            return true;
        } 
        else 
            return false;
    } 
  
    //------------End of On Change functions-------------
    // ToolTip for DropDowmListBox
    /*
        <asp:DropDownList ID="ddlSearchIn" runat="server" onmouseover="javascript:showDropDownToolTip(this, 'Select Seacrh Zone');" onmouseout="javascript:hideDropDownToolTip();" CssClass="formelements" TabIndex="2" Width="123px">
            <asp:ListItem Value="0">Topic Title</asp:ListItem>
            <asp:ListItem Value="1">Topic Description</asp:ListItem>
            <asp:ListItem Value="2">Both</asp:ListItem>
        </asp:DropDownList>
        
    */
    ns4 = (document.layers)? true:false;
    ie4 = (document.all)? true:false;
    var mouseX=0; 
    var mouseY=0;
    
    function init() 
    {
        if (ns4) 
        {
            document.captureEvents(Event.MOUSEMOVE);
        }            
        document.onmousemove=mousemove; 
    }
    
    function mousemove(e)
    {
        if (ns4) 
        {
            mouseX=e.pageX; 
            mouseY=e.pageY;
        }
        if (ie4) 
        {
            mouseX=event.x; 
            mouseY=event.y;
        }
    }
               
    function showDropDownToolTip(ddlName, divName, infoTextName, Y) 
    //function showDropDownToolTip(ddlName) 
    {

        //init();
        var ddlCtrl = document.getElementById(ddlName);
        var toolTipRef = document.getElementById(divName);
        var informationSpanRef = document.getElementById(infoTextName);
        
        // Set to information text...
        if (ddlCtrl.options[ddlCtrl.selectedIndex].text.toUpperCase() == '--SELECT--' )
        {
            if(ddlName == 'ddlTitle')
                informationSpanRef.innerHTML = 'Select Title.';
            else if(ddlName == 'ddlGender')
                informationSpanRef.innerHTML = 'Select Gender.';
            else if(ddlName == 'ddlCountry' || ddlName == 'ddlRCountry' || ddlName == 'ddlOCountry')
                informationSpanRef.innerHTML = 'Select Country.';
            else if(ddlName == 'ddlState' || ddlName == 'ddlRState' || ddlName == 'ddlOState')
                informationSpanRef.innerHTML = 'Select State.';
            else if(ddlName == 'ddlOrgType')
                informationSpanRef.innerHTML = 'Select Organization Type.';
            else if(ddlName == 'ddlDepartment')
                informationSpanRef.innerHTML = 'Select Department.';
            else if(ddlName == 'ddlStatus')
                informationSpanRef.innerHTML = 'Select Member Status.';
            else if(ddlName == 'ddlLogCategory')
                informationSpanRef.innerHTML = 'Select Log Category.';
        }
        else
        {
            if(ddlName == 'ddlSearchIn')
                informationSpanRef.innerHTML = 'Search in ' + ddlCtrl.options[ddlCtrl.selectedIndex].text + '.';    
            else if(ddlName.toUpperCase() == 'DDLCOLUMNNAME')
                informationSpanRef.innerHTML = ddlCtrl.options[ddlCtrl.selectedIndex].text;  
            else if(ddlName.toUpperCase() == 'DDLSORTORDER')
            {
                if(ddlCtrl.options[ddlCtrl.selectedIndex].value == 'ASC')
                    informationSpanRef.innerHTML = 'Sort in Ascending Order';  
                else if(ddlCtrl.options[ddlCtrl.selectedIndex].value == 'DESC')
                    informationSpanRef.innerHTML = 'Sort in Descending Order';              
            }
                
            informationSpanRef.innerHTML = ddlCtrl.options[ddlCtrl.selectedIndex].text;
            //informationSpanRef.innerHTML = toolTipText;
        }
        
        toolTipRef.style.top = Y;
        toolTipRef.style.left = event.clientX;
        
        if(ddlName == 'ddlRCountry' || ddlName == 'ddlOCountry' || ddlName == 'ddlRState' || ddlName == 'ddlOState')
            //toolTipRef.style.left = 480;
            toolTipRef.style.left = 532;
        else if(ddlName == 'ddlOrgType' || ddlName == 'ddlDepartment')
            //toolTipRef.style.left = 282;    
            toolTipRef.style.left = 335;    
            
        toolTipRef.style.display = 'inline';
    }
     
    function hideDropDownToolTip(divName)
    {
        document.getElementById(divName).style.display = 'none';
    }
    //--------End of Tool Tip Code -------------
    
    //**********END of Manali JS Code **********//  
    
    function CheckEmail( objEmail)
    {
        var Em = document.getElementById(objEmail);
        if(Em.value == "")
        {
            return true;
        }
        else
        {
            var emailadd=/^[a-z][a-z_0-9\.]+@[a-z_0-9\.]+\.[a-z]{3}$|^[a-z][a-z_0-9\.]+@[a-z_0-9\.]+\.[a-z]{2}$|^[a-z][a-z_0-9\.]+@[a-z_0-9\.]+\.[a-z]{2}\.+\.[a-z]{2}$/i;
            if(emailadd.test(Em.value) == false)
            {
                alert("Please enter valid Email ID as your Login Email ID.");
                document.all(objEmail).focus;
                return false;
            }
        }
    }
        
   
    
    
    

    // EMAIL Validation ===========
    
    function AllowEmail(txtName)
     {	
        var is_char;
        var txtCtrl = document.getElementById(txtName);
        is_char = event.keyCode;
        if((is_char>=65 && is_char<=90) ||(is_char>=97 && is_char<=122)||(is_char>=48 && is_char<=57)||is_char==95||is_char==13||is_char==46||is_char==64||is_char==45)
        {
            //Char between 0-1, A-Z, a-z, -, space, comma
            if (!(isNumeric() || isAlphabet()|| isEnter()))
            {
	            if( (txtCtrl.value.length == 0) || (txtName == 'txtEmailUserID' && txtCtrl.value == 'Type your Login Email ID here.') || (txtName == 'txtConfirmEmail' && txtCtrl.value == 'Re-Type your Login Email ID here.') || (txtName == 'txtMemberName' && txtCtrl.value == 'Search by First Name') || (txtName == 'txtUserCode' && txtCtrl.value == 'Search by Login Email ID') )
	            {
	                if(isDot())
			        {
			            event.keyCode = 0;
                        alert('Field value should not start with a Dot.'); 
                        txtCtrl.select();
                        return false;
                    }
                    else if(isHyphen())
			        {
			            event.keyCode = 0;
                        alert('Field value should not start with a Hyphen.'); 
                        txtCtrl.select();
                        return false;
                        
                    }
                    else if(isAtRate())
			        {
			            event.keyCode = 0;
                        alert('Field value should not start with an \" @ \" sign.'); 
                        txtCtrl.select();
                        return false;
                     
                    }                
                    else if(isUnderScore())
			        {
			            event.keyCode = 0;
                        alert('Field value should not start with an Underscore.'); 
                        txtCtrl.select();
                        return false;
                 
                    }
                }
            }

            return true;
        }
        else
        {
            if( (txtCtrl.value.length == 0) || (txtName == 'txtEmailUserID' && txtCtrl.value == 'Type your Login Email ID here.') || (txtName == 'txtConfirmEmail' && txtCtrl.value == 'Re-Type your Login Email ID here.') || (txtName == 'txtMemberName' && txtCtrl.value == 'Search by First Name') || (txtName == 'txtUserCode' && txtCtrl.value == 'Search by Login Email ID') )
            {
                event.keyCode=0;
                alert('Invalid character.'); 
                txtCtrl.select();
                return false;
            }
            else
            {
                event.keyCode=0;
                alert('Invalid character.'); 
                txtCtrl.focus();
                return false;
            }
        }
        
    }
     //********************************************************** Check Email ID *****************************************************
     function isValidEmail(oEMailField, txtName) 
     {// function for check mail validation
        try
        {
	        if(oEMailField.value == "")
	        {
		        return true;
	        }

	            var good_chars_arr	= "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";

	            var MailArray		= oEMailField.value.split(",");
	            var iMailIndex		= 0;
	            var retval			= true;
	
	            for (iMailIndex = 0; iMailIndex < MailArray.length; iMailIndex++) {

		        if ((MailArray[iMailIndex]).length == 0) 
		        {//if (trim(MailArray[iMailIndex]).length == 0) {
		            if(txtName == 'txtConfirmEmail')
		                alert("Each of the string literals separated by commas should be valid Confirm Email IDs.");
		            else
		                alert("Each of the string literals separated by commas should be valid Login Email IDs.");
			        oEMailField.focus();
			        return false;
		        }   
		        else if (MailArray[iMailIndex].substring(MailArray[iMailIndex].length - 1, MailArray[iMailIndex].length) == "@")
		        {
			        if(txtName == 'txtConfirmEmail')
		                alert("Please provide a valid Confirm Email ID.");
		            else
		                alert("Please provide a valid Login Email ID.");
			        oEMailField.focus();
			        //retval = false;
			        return false;
		        }
		        else if (MailArray[iMailIndex].substring(0, 1) == "@")
		        {
			        if(txtName == 'txtConfirmEmail')
		                alert("Please provide a valid Confirm Email ID.");
		            else
		                alert("Please provide a valid Login Email ID.");
			        oEMailField.focus();
			        //retval = false;
			        return false;
		        }
		        else if (MailArray[iMailIndex].substring(MailArray[iMailIndex].length - 1, MailArray[iMailIndex].length) == ".") 
		        {
			        if(txtName == 'txtConfirmEmail')
		                alert("Please provide a valid Confirm Email ID.");
		            else
		                alert("Please provide a valid Login Email ID.");
			        oEMailField.focus();		
			        //retval = false;
			        return false;
		        }
		        else if (MailArray[iMailIndex].substring(0, 1) == ".") 
		        {
			        if(txtName == 'txtConfirmEmail')
		                alert("Please provide a valid Confirm Email ID.");
		            else
		                alert("Please provide a valid Login Email ID.");
			        oEMailField.focus();
			        //retval = false;
			        return false;
		        }
		        else if (MailArray[iMailIndex].substring(MailArray[iMailIndex].length - 1, MailArray[iMailIndex].length) == "-") 
		        {
			        if(txtName == 'txtConfirmEmail')
		                alert("Please provide a valid Confirm Email ID.");
		            else
		                alert("Please provide a valid Login Email ID.");
			        oEMailField.focus();		
			        //retval = false;
			        return false;
		        }
		        else if (MailArray[iMailIndex].substring(0, 1) == "-") 
		        {
			        if(txtName == 'txtConfirmEmail')
		                alert("Please provide a valid Confirm Email ID.");
		            else
		                alert("Please provide a valid Login Email ID.");
			        oEMailField.focus();
			        //retval = false;
			        return false;
		        }
		        else if (MailArray[iMailIndex].substring(MailArray[iMailIndex].length - 1, MailArray[iMailIndex].length) == "_") 
		        {
			        if(txtName == 'txtConfirmEmail')
		                alert("Please provide a valid Confirm Email ID.");
		            else
		                alert("Please provide a valid Login Email ID.");
			        oEMailField.focus();		
			        //retval = false;
			        return false;
		        }
		        else if (MailArray[iMailIndex].substring(0, 1) == "_") 
		        {
			        if(txtName == 'txtConfirmEmail')
		                alert("Please provide a valid Confirm Email ID.");
		            else
		                alert("Please provide a valid Login Email ID.");
			        oEMailField.focus();
			        //retval = false;
			        return false;
		        }
		        else
		        {
			        var flag1 = 1;
			        if (MailArray[iMailIndex] != "") 
			        {
				        var flag = 0;
				        for (var i = 0; i < MailArray[iMailIndex].length; i++) 
				        {
					        if (MailArray[iMailIndex].substring(i, i + 1) == "@") 
					        {
						        flag = 1;           //check occurence of @ if any
					        }
				        }
				        if (flag == 0)              // No @
				        {
					        flag1 = 0;
					        if(txtName == 'txtConfirmEmail')
		                        alert("Please provide a valid Confirm Email ID.");
		                    else
		                        alert("Please provide a valid Login Email ID.");
					        oEMailField.focus();
				        } 
				        else 
				        {
					        flag = 0;
					        for (var i = 0; i < MailArray[iMailIndex].length; i++) 
					        {
						        if (MailArray[iMailIndex].substring(i, i + 1) == ".") 
						        {
							        flag = 1;     //check occurence of . if any  
						        }
					        }
					        if (flag == 0)      // No .
					        {
						        flag1 = 0;
						        if(txtName == 'txtConfirmEmail')
		                            alert("Please provide a valid Confirm Email ID.");
		                        else
		                            alert("Please provide a valid Login Email ID.");
						        oEMailField.focus();
					        }
				        }
				        
				        if (flag != 0) 
				        {
					        if (MailArray[iMailIndex].indexOf('@') !=  MailArray[iMailIndex].lastIndexOf('@')) //check for single @
					        {
						        flag1 = 0;
						        if(txtName == 'txtConfirmEmail')
		                            alert("Please provide a valid Confirm Email ID.");
		                        else
		                            alert("Please provide a valid Login Email ID.");
						        oEMailField.focus();
					        } 
					        else if ((MailArray[iMailIndex].charAt(MailArray[iMailIndex].indexOf('@') + 1) ==  '.') || 
							         (MailArray[iMailIndex].charAt(MailArray[iMailIndex].indexOf('@') - 1) ==  '.') ||
							         (MailArray[iMailIndex].charAt(MailArray[iMailIndex].indexOf('@') + 1) ==  '-') || 
							         (MailArray[iMailIndex].charAt(MailArray[iMailIndex].indexOf('@') - 1) ==  '-') ||
							         (MailArray[iMailIndex].charAt(MailArray[iMailIndex].indexOf('@') + 1) ==  '_') || 
							         (MailArray[iMailIndex].charAt(MailArray[iMailIndex].indexOf('@') - 1) ==  '_') ||
							         (MailArray[iMailIndex].charAt(MailArray[iMailIndex].indexOf('.') + 1) ==  '-') || 
							         (MailArray[iMailIndex].charAt(MailArray[iMailIndex].indexOf('.') - 1) ==  '-') ||
							         (MailArray[iMailIndex].charAt(MailArray[iMailIndex].indexOf('.') + 1) ==  '_') || 
							         (MailArray[iMailIndex].charAt(MailArray[iMailIndex].indexOf('.') - 1) ==  '_') ||
							         (MailArray[iMailIndex].charAt(MailArray[iMailIndex].indexOf('-') + 1) ==  '_') || 
							         (MailArray[iMailIndex].charAt(MailArray[iMailIndex].indexOf('-') - 1) ==  '_')) 
						    {
						        flag1 = 0;
						        if(txtName == 'txtConfirmEmail')
		                            alert("Please provide a valid Confirm Email ID.");
		                        else
		                            alert("Please provide a valid Login Email ID.");
						        oEMailField.focus();
					        } 
					        else if (MailArray[iMailIndex].indexOf('@') > MailArray[iMailIndex].lastIndexOf('.')) 
					        {
						        flag1 = 0;
						        if(txtName == 'txtConfirmEmail')
		                            alert("Please provide a valid Confirm Email ID.");
		                        else
		                            alert("Please provide a valid Login Email ID.");
						        oEMailField.focus();
					        } 
					        else if (MailArray[iMailIndex].indexOf('..') > 0 || MailArray[iMailIndex].indexOf('--') > 0 || MailArray[iMailIndex].indexOf('__') > 0) 
					        {
						        flag1 = 0;
						        if(txtName == 'txtConfirmEmail')
		                            alert("Please provide a valid Confirm Email ID.");
		                        else
		                            alert("Please provide a valid Login Email ID."); 
						        oEMailField.focus();
					        }
				        }
			        }

			        if (flag1 == 0) 
			        {
				        //retval = retval && false;
				        return false;
			        } 
			        else 
			        {
				        retval = retval && true;
				        //return true;
			        }
		        }
	        }
	            //alert('retval from email check=' + retval);
	        return retval;
	    }
	    catch(e){return false;}
    }
        
//********************************************************** alertkey *****************************************************       
 
//Enable buttons
function alertkey(txtName, btn1Name, btn2Name, e) 
{            
    var i=0;
    if( !e )
    {
        if( window.event )
        {
            e = window.event;   //Internet Explorer
        } 
        else 
        {
            return;
        }
    }

    if( typeof( e.keyCode ) == 'number'  ) 
    {
        e = e.keyCode;  //DOM
    }
    else if( typeof( e.which ) == 'number' )
    {
        e = e.which;    //NS 4 compatible
    }
    else if( typeof( e.charCode ) == 'number'  )
    {
        e = e.charCode; //also NS 6+, Mozilla 0.9+
    } 
    else 
    {
        return; //total failure, we have no way of obtaining the key code
    }

    // window.alert('The key pressed has keycode ' + e + ' and is key ' + String.fromCharCode( e ) );
    var txt = document.getElementById(txtName);
    var btn1 = document.getElementById(btn1Name);
    var btn2 = document.getElementById(btn2Name);
    
    if(txt.value=="")
    {
        btn1.disabled=true;
        btn2.disabled=true;
        i=0;
    }
    if(i==0)
    {
        if ((e>=65 && e<=90) ||(e>=48 && e<=57) || (e>=96 && e<=105) || e==32)
        {
            i++;
            btn1.disabled=false;
            btn2.disabled=false;
            //  alert(i);
        }
    }
}

//********************************************************** Change *****************************************************    

function Change(txtName, btn1Name, btn2Name)
{
    var txt = document.getElementById(txtName);
    var btn1= document.getElementById(btn1Name);
    var btn2= document.getElementById(btn2Name);
    
    if(txt.value == "")
    {
        btn1.disabled=true;
        btn2.disabled=true;
    }
    else
    {
        btn1.disabled=false;
        btn2.disabled=false;
    }
}

//********************************************************** ChangeDDL *****************************************************  

function ChangeDDL(ddlName, btn1Name, btn2Name)
{
    var txt = document.getElementById(ddlName);
    var btn1= document.getElementById(btn1Name);
    var btn2= document.getElementById(btn2Name);
    
    if(ddlName.selectedIndex == 0)
    {
        btn1.disabled=true;
        btn2.disabled=true;
    }
    else
    {
        btn1.disabled=false;
        btn2.disabled=false;
    }
}

//********************************************************** CheckAll *****************************************************  

function CheckAll(checkAll)
{
    var frm = document.form1;
    e=frm.elements[checkAll];
    for(i=0;i< frm.length;i++)
    {
        ec=frm.elements[i];
        if(e.checked && ec.type=='checkbox')
            ec.checked = true;   
        else if(!e.checked && ec.type=='checkbox')
            ec.checked = false;
    }
}     
            
            

//********************************************************** Match Dates ****************************************************


    function MatchDates(fromDate, toDate)
        {				       				      			        			        
            var arrFromDate = fromDate.split('/');
            var ddFrom = parseInt(arrFromDate[0], 10);            
            var mmFrom = parseInt(arrFromDate[1], 10);  
            var yyFrom = parseInt(arrFromDate[2], 10);  
            
            var arrToDate = toDate.split('/');
            var ddTo = parseInt(arrToDate[0], 10);        
            var mmTo = parseInt(arrToDate[1], 10);        
            var yyTo = parseInt(arrToDate[2], 10);        
                       
            if(yyFrom < yyTo)
			{
			    return true;
			}
			else if(yyFrom > yyTo)
			{
//			    alert('From-Date should be less than To-Date.');
			    return false ;
            }
			else if(yyFrom == yyTo)
			{
    		    if(mmFrom < mmTo)
    		        return true;
	            else if(mmFrom > mmTo)
                {
				    //alert('From-Date should be less than To-Date.');
				    return false ;
                }
                else if(mmFrom == mmTo)
			    {
    		        if(ddFrom < ddTo)
    		            return true;
	                else if(ddFrom > ddTo)
                    {
				        //alert('From-Date should be less than To-Date.');
				        return false ;
                    }
			    }
			}	        
        }                
        
        
         //***************Preeti CCode**************
    
    // Set Default Values ======
    function SetDefault(obj,objText)
    {
        if(obj.value=="")
        {
            obj.value=objText;
        }
    }
    function RemoveDefault(obj,objText)
    {
        if(obj.value==objText)
        {
            obj.value='';
        }
    }
    
