﻿

//This Function will check or Uncheck all the checkboxes in Grid when user wll check or uncheck Master Check box
 function SelectAllCheckBox()
    {
       try
       {
            var objChkMain = document.getElementById('chkItem');
            var objs = document.getElementsByTagName('input');
            for(var i=0;i<objs.length;i++)
               {
                    if(objs[i].type=="checkbox" && objs[i].id.indexOf('chkItems')>0)
                    {   
                        if(objChkMain.checked)
                        {
                            if(objs[i].disabled==false)
                            {
                                objs[i].checked = true;
                            }
                            
                        }
                        else
                        {
                            objs[i].checked = false;
                        }
                     
                    }    
               }
       }
       catch(err)
       {
            txt="There was an error on this page in 'SelectAllCheckBox' function.\n\n";
            txt+="Error description: " + err.description + "\n\n";
            txt+="Click OK to continue.\n\n";
            alert(txt);
       }
    }
    function UnSelectMainCheckBox(ObjChk)
    {
        try
        {
            var varObjMailChk = document.getElementById('chkItem')
            if(!ObjChk.checked)
             {
                varObjMailChk.checked = false;
             }
        }
        catch(err)
        {
            txt="There was an error on this page in 'UnSelectMainCheckBox' function.\n\n";
            txt+="Error description: " + err.description + "\n\n";
            txt+="Click OK to continue.\n\n";
            alert(txt);
        }
    }
///*****************************************************************************************************************
    
    ///This function will Confirm from user for an action.
    function ChkForSelectedRecord(obj)
    {
        try
        {
        
             var objs = document.getElementsByTagName("input");
             var status='no';
             for(i=0;i<objs.length;i++)
                {   
                    if(objs[i].type=="checkbox" && objs[i].id.indexOf('chkItems')>0)
                    {   
                        if(objs[i].checked)
                          status='yes';
                    }    
                }
                if(  status=='yes')
                {
                    if(obj.value = 'Deactivate')
                    {
                            if(confirm("Are you sure to DEACTIVATE selected record ?"))
                              {
                                return true; 
                              }
                            else
                            {
                                return false;
                            }
                  }
                  else
                  {
                    if(confirm("Are you sure to RESTORE selected record ?"))
                            {
                                return true; 
                            }
                            else
                            {
                                return false;
                            }
                  }
                }
                else
                {
                    alert('No Record Selected');
                    return false;
                }
            }
            catch(err)
            {
                 txt="There was an error on this page in 'ChkForSelectedRecord' function.\n\n";
                 txt+="Error description: " + err.description + "\n\n";
                 txt+="Click OK to continue.\n\n";
                 alert(txt);
            }
    }
    
 // *********************************************************************************************************************   
    //*****This function will confirm to Activate or Deactivate a particular record 
    
    function ConfirmDelete(obj)
    {
        try
        {
            
            if(confirm("Are you sure to change ACTIVE STATUS of selected record ?"))
                {
                    return true; 
                }
                else
                {
                     return false;
                }
        }
        catch(err)
        {
               txt="There was an error on this page in 'ConfirmDelete' function.\n\n";
               txt+="Error description: " + err.description + "\n\n";
               txt+="Click OK to continue.\n\n";
               alert(txt);
        }
    }
//  *****************************************************************************************************************
    
    //****** This function will return True if textbox is not blank otherwise it will alert 
    //****** the messsage passed to it and return false
    function CheckForBlank(txtID,msz)
    {
        try
        {    
                 
            if( txtID.value=="")
            {  
                alert(msz);
                return false
                
            }
            else
            {
                return true
            }
        }
        catch(err)
        {
               txt="There was an error on this page in 'CheckForBlank' function.\n\n";
               txt+="Error description: " + err.description + "\n\n";
               txt+="Click OK to continue.\n\n";
               alert(txt);
               
        }
    }
    function CheckDropdown(ddID,msz)
    {
        try
        {    
                 
            if( ddID.selectedIndex == 0)
            {  
                alert(msz);
                return false
                
            }
            else
            {
                return true
            }
        }
        catch(err)
        {
               txt="There was an error on this page in 'CheckDropdown' function.\n\n";
               txt+="Error description: " + err.description + "\n\n";
               txt+="Click OK to continue.\n\n";
               alert(txt);
               
        }
    }
    function OnlyAlphabets(txtID,msz)
    {
        var strValidChars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"; 
        for (i = 0; i < txtID.value.length; i++)
        {
            var strChar;
            strChar = txtID.value.charAt(i);
            if (strValidChars.indexOf(strChar) == -1)
            {
                alert(msz);
                return false;
            }
            else
            {
                return true;
            }
        }
    }
    function MatchPassword(txt1,txt2,msz)
    {
        if(txt1.value==txt2.value)
        {
            return true;
        }
        else
        {
          alert(msz);
          return false;
        }
    }
//// *****************************************************************************************************************
function checkMail(obj,msz)
{
    var email=obj.value;
   
    var filter=/^([a-zA-Z0-9_\.\-\+])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
    if(filter.test(email))
    {
        return true;
    }
    else
    {
        alert(msz);
        return false;
    }
}




     function CheckDropdownMinMax(objMemMinAge,objMemMaxAge,msz)
    {
        try
        {    
        
        
          
            if( objMemMinAge.selectedIndex > objMemMaxAge.selectedIndex)
            {  
                alert(msz);
                return false
                
            }
            else
            {
                return true
            }
        }
        catch(err)
        {
               txt="There was an error on this page in 'CheckDropdown' function.\n\n";
               txt+="Error description: " + err.description + "\n\n";
               txt+="Click OK to continue.\n\n";
               alert(txt);
               
        }
    } 



 
function MyFCKClass()
{
        this.UpdateEditorFormValue = function()
        {
                for ( i = 0; i < parent.frames.length; ++i )
                        if ( parent.frames[i].FCK )
                                parent.frames[i].FCK.UpdateLinkedField();
        }
}
    
    
    
   
    

