
// JScript File

/// <summary>
/// Function : Remove the Leading space from string
/// </summary>
/// <param name="OriString">Original string which contains Leading space at left and right side</param>
/// <returns>String which does not contains and leading space in it</returns>
function Trim(OriString) 
{
    while ((OriString.substring(0,1) == ' ') || (OriString.substring(0,1) == '\n') || (OriString.substring(0,1) == '\r'))
    {
        OriString = OriString.substring(1,OriString.length);
    }
    while ((OriString.substring(OriString.length-1,OriString.length) == ' ') || (OriString.substring(OriString.length-1,OriString.length) == '\n') || (OriString.substring(OriString.length-1,OriString.length) == '\r'))
    {
        OriString = OriString.substring(0,OriString.length-1);
    }
    return OriString;
}

function CheckPDF(str) {
    var filter = /^.+(.pdf|.PDF)$/i;

    if (filter.test(str))
        return true;
    else
        return false;
}

function CheckImage(str) {
    var filter = /^.+(.jpeg|.JPEG|.jpg|.JPG|.jpe|.JPE|.png|.PNG|.gif|.GIF)$/i;


    if (filter.test(str))
        return true;
    else
        return false;
}


/// <summary>
/// Function : Check the id is empty or not
/// </summary>
/// <param name="id">id</param>
/// <returns>boolean value based on id is empty or not</returns>
function IsEmpty(ID)
{
    if(document.getElementById(ID))
    {
        if(Trim(document.getElementById(ID).value) == '')
             return true;
    }
    return false;
}

/// <summary>
/// Function : Check Email is valid or not
/// </summary>
/// <param name="EmailString">String contains EmailID</param>
/// <returns>boolean value based on Email format validation</returns>
function IsValidEmail(EmailString)
{
    var FilterString=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;
	if (FilterString.test(EmailString))
        return true;
    return  false;
}

/// <summary>
/// Function : Find the ClientID from the aspx page 
/// </summary>
/// <param name="PassedID">String contains ID of the element</param>
/// <returns>Client id of the associate control with passed parameter</returns>
function GetOriginalID(PassedID)
{
    var LoopCounter;
    var FormElements = document.aspnetForm.elements;
    for(LoopCounter=0;LoopCounter<FormElements.length; LoopCounter++)
    {
        if(FormElements[LoopCounter].id.indexOf(PassedID) >= 0)
            return FormElements[LoopCounter].id;
    }
    return 'NotFound';        
}

/// <summary>
/// Function : Generate Error message for the required field 
/// </summary>
/// <param name="ID">ID</param>
/// <param name="Message">Error Message to display at client side</param>
/// <returns>String which contains Error message for the required field</returns>
function RequiredFieldMessage(ID,Message)
{
    ID = GetOriginalID(ID)
    if(document.getElementById(ID))
    {
        document.getElementById(ID).value = Trim(document.getElementById(ID).value);
        if(IsEmpty(ID))
            return '#  Required field [' + Message + ']\n';    
    }
    return '';            
}

/// <summary>
/// Function : Check that passed string should contains numeric value 
/// </summary>
/// <param name="PassedString"></param>
/// <returns>boolean value based on PassedString contains only numeric values or not</returns>

function KeyPhone(e)    //This is for Phone No. textbox. Numeric with ( ) and - 
{
    var KeyID = (window.event) ? event.keyCode : e.which;
    if ((KeyID >= 65 && KeyID <= 90) || (KeyID >= 97 && KeyID <= 122) || (KeyID >= 33 && KeyID <= 39) || KeyID == 42 || KeyID == 44 || KeyID == 46 || KeyID == 47 ||
   (KeyID >= 58 && KeyID <= 64) || (KeyID >= 91 && KeyID <= 96) || (KeyID >= 123 && KeyID <= 126)) {
        return false;
    }
    if (KeyID == 32) {
        return false;
    }
}

function NumericValidationWithComma(e)    //Only Numeric value with comma
{
    var KeyID = (window.event) ? event.keyCode : e.which;

    if ((KeyID >= 48 && KeyID <= 57) || (KeyID == 8) || (KeyID == 0) || (KeyID == 44)) {
        return true;
    }
    else {
        return false;
    }
}


function IsNumeric(PassedString)
{
    var ValidChars = "0123456789";
    var IsNumber=true;
    var Char;
    var LoopCounter;
    for (LoopCounter = 0; LoopCounter < PassedString.length && IsNumber == true; LoopCounter++) 
    { 
        Char = PassedString.charAt(LoopCounter); 
        if (ValidChars.indexOf(Char) == -1) 
        {
            IsNumber = false;
        }
    }
    return IsNumber;
}

/// <summary>
/// Function : Check that passed string should contains floating type value 
/// </summary>
/// <param name="PassedString"></param>
/// <returns>boolean value based on PassedString contains only floating type value or not</returns>
function IsFloat(PassedString)
{
    var ValidChars = "0123456789.";
    var IsNumber=true;
    var Char;
    var LoopCounter;
    for (LoopCounter = 0; LoopCounter < PassedString.length && IsNumber == true; LoopCounter++) 
    { 
        Char = PassedString.charAt(LoopCounter); 
        if (ValidChars.indexOf(Char) == -1) 
        {
            IsNumber = false;
        }
    }
    return IsNumber;
}

/// <summary>
/// Function : It checks all the checkbox based on top checkbox
/// </summary>
/// <param name=""></param>
/// <returns></returns>
function CheckAll()
{
    var LoopCounter;
    if(document.getElementById("chkAll"))
    {
        for(LoopCounter=0; LoopCounter < (document.getElementsByName('chkBox').length);LoopCounter++)
        {
            document.getElementsByName("chkBox")[LoopCounter].checked = document.getElementById("chkAll").checked;
        }
    }
}

/// <summary>
/// Function : It automatically checks top checkbox when all the checkbox is checked
/// </summary>
/// <param name=""></param>
/// <returns></returns>
function AutoCheckTopCheckbox()
{
    var LoopCounter, CheckedValue;
    CheckedValue = 1;
    if(document.getElementById("chkAll"))
    {
        for(LoopCounter=0; LoopCounter < (document.getElementsByName('chkBox').length); LoopCounter++)
        {
            if(document.getElementsByName("chkBox")[LoopCounter].checked == false)
                CheckedValue = 0;
        }
        if(CheckedValue == 1)
            document.getElementById("chkAll").checked = true;
        else
            document.getElementById("chkAll").checked = false;
    }
}

/// <summary>
/// Function : Check search fields are empaty or not
/// </summary>
/// <param name="SearchField">optional parameter, by default it takes search dattabase field as ddlSearchField</param>
/// <param name="SearchText">optional parameter, by default it takes search text field as txtSearchText</param>
/// <returns></returns>
function SearchValidation(SearchField,SearchText)
{
if(SearchField == null)
   SearchField = 'ddlSearchField'
if(SearchText == null)
   SearchText = 'txtSearchText'
    if(document.getElementById(GetOriginalID(SearchField)))
    {
        if(document.getElementById(GetOriginalID(SearchField)).value == "0")
        {
            alert("Please select search field.");
            document.getElementById(GetOriginalID(SearchField)).focus();
            return false;
        }
    }
    if(document.getElementById(GetOriginalID(SearchText)))
    {
        if(document.getElementById(GetOriginalID(SearchText)).style.display == '')
        {
            if(Trim(document.getElementById(GetOriginalID(SearchText)).value) == "")
            {
                alert("Please enter search text.");
                document.getElementById(GetOriginalID(SearchText)).value = Trim(document.getElementById(GetOriginalID(SearchText)).value);
                document.getElementById(GetOriginalID(SearchText)).focus();
                return false;
            }
        }
    }
}

/// <summary>
/// Function : Display the message in listing page if not any checkbox is selected in the grid
/// </summary>
/// <param name="MsgType">Type of the message e.g. Active,Inactive,Delete</param>
/// <returns></returns>
function GetMessage(MsgType)
 {
     var LoopCounter,Flag;
     Flag=0;
     var Element = document.forms[0].elements;
     for(LoopCounter=0;LoopCounter<Element.length;LoopCounter++)
     {
        if(Element[LoopCounter].id.indexOf('chkBox') == 0)
        {
            if(Element[LoopCounter].checked==false)
            { 
                Flag=0;
            } 
            else
            { 
                Flag=1;
                break; 
            }
        }
     }

     if(Flag==0)
     {
        alert('Please select atleast one record.');
     }
     else
     {
        if (MsgType.toLowerCase() == "active" || MsgType.toLowerCase() == "inactive")
        {
            if (confirm('Are you sure you want to set selected record(s) to ' + MsgType + ' status?')) 
            return true;
        }
        else
        {
            if (confirm('Are you sure you want to ' + MsgType + ' selected record(s)?')) 
            return true;
        }
        
     }
     return false;
 }
function GetMailAlert()
 {
     var LoopCounter,Flag;
     Flag=0;
     var Element = document.forms[0].elements;
     for(LoopCounter=0;LoopCounter<Element.length;LoopCounter++)
     {
        if(Element[LoopCounter].id.indexOf('chkBox') == 0)
        {
            if(Element[LoopCounter].checked==false)
            { 
                Flag=0;
            } 
            else
            { 
                Flag=1;
                break; 
            }
        }
     }

     if(Flag==0)
     {
        alert('Please select atleast one record.');
     }
 return true;
}

/// <summary>
/// Function : Used to hide and show the searchText field according to selection of search field
/// </summary>
/// <param name=""></param>
/// <returns></returns>
function HideShowStatus()
{
    if(document.getElementById(GetOriginalID('ddlSearchField')))
    {
        if(document.getElementById(GetOriginalID('ddlSearchField')).value == "bStatus")
        {
            if(document.getElementById(GetOriginalID('ddlStatus')))
                document.getElementById(GetOriginalID('ddlStatus')).style.display='';
            if(document.getElementById(GetOriginalID('txtSearchText')))
                document.getElementById(GetOriginalID('txtSearchText')).style.display='none';
        }
        else
        {
            if(document.getElementById(GetOriginalID('ddlStatus')))
            {
                document.getElementById(GetOriginalID('ddlStatus')).style.display='none';        
                document.getElementById(GetOriginalID('ddlStatus')).value = "1";
            }        
            if(document.getElementById(GetOriginalID('txtSearchText')))
                document.getElementById(GetOriginalID('txtSearchText')).style.display='';
        }
    }
    return false;
}

/// <summary>
/// Function : For Validate all control
/// </summary>
/// <param name="ControlId"></param>
/// <param name="Message"></param>
/// <param name="ValidationType"></param>
/// <param name="CharacterSize">pass to Check for Minimum character length required</param>
/// <returns></returns>
function IsValidate(OriginalControlId,Message,ValidationType,CharacterSize)
{   
    
    if(CharacterSize == null)
       CharacterSize = 6;
       
    var ControlId = GetOriginalID(OriginalControlId);
    
    if(document.getElementById(ControlId))
    {  
        if(ValidationType.toLowerCase()  == 'required')
        {
            if(document.getElementById(ControlId).type=='select-one')
            {
                if (Trim(document.getElementById(ControlId).value)=='-1')
                {
                    alert('Please select ' +  Message + '.');
                    document.getElementById(ControlId).focus();
                    return false;
                }
            }
            else if(document.getElementById(ControlId).type=='select-multiple')
            {
                if (document.getElementById(ControlId).selectedIndex < 0)
                {
                    alert('Please select ' +  Message + '.');                
                    document.getElementById(ControlId).focus();
                    return false;
                }
            } 
            else if(document.getElementById(ControlId).type=='file')
            {
                if (Trim(document.getElementById(ControlId).value)=='')
                {
                    alert('Please ' +  Message + '.');                
                    document.getElementById(ControlId).focus();
                    return false;
                }
            }         
            else
            {
                if (Trim(document.getElementById(ControlId).value)=='')
                {
                    alert('Please enter ' +  Message + '.');
                    document.getElementById(ControlId).value = '';
                     document.getElementById(ControlId).focus();
                    return false;
                }
            }
        }
        else if(ValidationType.toLowerCase()  == 'email')
        {
            if (!IsValidEmail(Trim(document.getElementById(ControlId).value)))
            {
                alert('Please enter valid ' +  Message + '.');
                document.getElementById(ControlId).focus();
                return false;
            }
        }
        else if(ValidationType.toLowerCase()  == 'numeric')
        {
            if (!IsNumeric(Trim(document.getElementById(ControlId).value)))
            {
                alert('Please enter numeric value in ' +  Message + '.');
                document.getElementById(ControlId).focus();
                return false;
            }
        }
        else if(ValidationType.toLowerCase()  == 'float')
        {
            if (!IsFloat(Trim(document.getElementById(ControlId).value)))
            {
                alert('Please enter numeric value in ' +  Message + '.');
                document.getElementById(ControlId).focus();
                return false;
            }
        }
        else if(ValidationType.toLowerCase()  == 'fileupload')
        {
            var FileName = Trim(document.getElementById(ControlId).value);
            var LenFile = FileName.length;
            var Result =  FileName.substring(LenFile-3,LenFile) 
            Result = Result.toLowerCase()  
        
            if(Result=="jpg" || Result=='gif') 
            {
            
            }
            else
            {
                alert("Please upload valid format in " + Message + "(jpg, gif).")
                return false;
            }   
        }
        else if(ValidationType.toLowerCase()  == 'requiredcheckboxlist')
        {
            if (!CheckBoxListValidatation(OriginalControlId))
            {
                alert('Please select atleast one checkbox in ' +  Message + '.');
                document.getElementById(ControlId).focus();
                return false;
            }
        }
        else if(ValidationType.toLowerCase()  == 'checklength')
        {
            var characterlen;           
            characterlen = Trim(document.getElementById(ControlId).value).length;
            if(characterlen < CharacterSize)
            {
                alert(Message + ' ' + CharacterSize + ' characters' + '.');
                document.getElementById(ControlId).focus();
                return false;
            }
        }
        else if(ValidationType.toLowerCase()  == 'requiredlistbox')
        {
            if (document.getElementById(ControlId).options.length == 0)
            {
                alert('Please select ' +  Message + '.');
                document.getElementById(ControlId).focus();
                return false;
            }
            
        }
        return true;
    } 
    return false;
} 

/// <summary>
/// Function : For the set focus of the Control
/// </summary>
/// <param name="ControlId"></param>
/// <returns></returns>
function SetFocus(ControlId)
{
    if(document.getElementById(GetOriginalID(ControlId)))
        document.getElementById(GetOriginalID(ControlId)).focus();
    return false;
}

/// <summary>
/// Function : For the confirmation of delete
/// </summary>
/// <param name=""></param>
/// <returns>true if usre gets confirmation to delete else false</returns>
function ConfirmForDelete(StrMessage)
{
    return confirm(StrMessage);
}

/// <summary>
/// Function : Execute this function when any javascript error occur
/// </summary>
/// <param name=""></param>
/// <returns>dont show the annoying javascript function</returns>
/*window.onerror = StopError;*/

/// <summary>
/// Function : For the stoping error messgage
/// </summary>
/// <param name=""></param>
/// <returns>true if javascript error occurs in the page </returns>
function StopError() 
{
  return true;
}


/// <summary>
/// Function : For Compare the StartDate and EndDate validation
/// </summary>
/// <param name="CtrlSDate">Control Id of Start Date</param>
/// <param name="CtrlEDate">Control Id of End Date</param>
/// <param name="StartDateName">Caption for Start Date that will display in the message</param>
/// <param name="EndDateName">Caption for End Date that will display in the message.</param>
/// <param name="IsEqual">If value for this is "1" then both date should be equal else end date must be grether then start date.</param>
/// <returns>true if  EndDate greater then StartDate else display message.</returns>
function IsValidDate(CtrlSDate,CtrlEDate,StartDateName,EndDateName,IsEqual)
{
    CtrlSDate = GetOriginalID(CtrlSDate);
    CtrlEDate = GetOriginalID(CtrlEDate);
    
    if(document.getElementById(CtrlSDate) && document.getElementById(CtrlEDate))
    {
        var SDate = document.getElementById(CtrlSDate).value;    	
        var EDate =  document.getElementById(CtrlEDate).value;
              
        var AlertMessage =  EndDateName + ' date must be later than ' + StartDateName + '.' 
    	
        var EndDate = new Date(EDate);    	
        var StartDate= new Date(SDate);
        
        if(IsEqual == 1)
        { 
            if(SDate != '' && EDate != '' && StartDate >= EndDate)
            {
	            alert(AlertMessage);
	            document.getElementById(CtrlEDate).value = "";
	            return false;
            }
        }
        else
        {
            if(SDate != '' && EDate != '' && StartDate > EndDate)
            {
	            alert(AlertMessage);
	            document.getElementById(CtrlEDate).value = "";
	            return false;
            } 
        }
        return true;
    }
    return false;
}


/// <summary>
/// Function : Check the any of the checkbox is selected in the checkbox list or not
/// </summary>
/// <param name="ControlID">String contains ID of the element</param>
/// <returns>True if any checkbox is selected in checkbox list other wise false</returns>
function CheckBoxListValidatation(ControlID)
{
    var LoopCounter;
    var FormElements = document.aspnetForm.elements;
    for(LoopCounter=0;LoopCounter<FormElements.length; LoopCounter++)
    {
        if(FormElements[LoopCounter].type == 'checkbox')
        {
            if(FormElements[LoopCounter].id.indexOf(ControlID) >= 0)
            {
                if(FormElements[LoopCounter].checked ==true)
                    return true;
            }
        }
    }
    return false;        
}

/// <summary>
/// Function : It checks all the checkbox based on top checkbox ( For Asp CheckboxList )
/// </summary>
/// <param name="ControlID">String contains ID of the element</param>
/// <returns>True if any checkbox is selected in checkbox list other wise false</returns>
function CheckAllCheckBoxList(ControlID)
{
    var LoopCounter;
    var FormElements = document.aspnetForm.elements;
    if(document.getElementById("chkAll"))
    {
        for(LoopCounter=0;LoopCounter<FormElements.length; LoopCounter++)
        {
            if(FormElements[LoopCounter].type == 'checkbox')
            {
                if(FormElements[LoopCounter].id.indexOf(ControlID) >= 0)
                {
                    FormElements[LoopCounter].checked = document.getElementById("chkAll").checked;
                }
            }
        }
        return true;
    }
    return false;   
}

/***********Start : Functions Related to Move Item Left-Right and viceversa in Listbox Control and Get Item Ids in Comma seperate from any Listbox *******/

/// <summary>
/// Function : Return string of listbox item values in comma seperate
/// </summary>
/// <param name="hidLstIds">Hidden Control name where to set comma seperate value of listbox</param>
/// <param name="lstBox">Listbox</param>
/// <returns>True if suucessfully done</returns>
function setListBoxIds(hidLstIds, lstBox)
{
    var varLstBox = document.getElementById(GetOriginalID(lstBox));
    var varHidLstIds = document.getElementById(GetOriginalID(hidLstIds));
    varHidLstIds.value = "";
    if(varLstBox != null &&  varHidLstIds != null)
    {
        for(var lstItem=0; lstItem < varLstBox.length; lstItem++)
        {
            if(varHidLstIds.value == "")
                varHidLstIds.value += varLstBox.options[lstItem].value;
            else
                varHidLstIds.value += "," + varLstBox.options[lstItem].value;
        }
    }
    return true;
}

/// <summary>
/// Function : Check whether there is any item in list box or not
/// </summary>
/// <param name="lstbx">From Listbox ID</param>

function fnChkListBoxEmpty(lstbx)
{   
    var varLstBox = document.getElementById(GetOriginalID(lstbx));
    if (varLstBox != null)
    { 
        if(varLstBox.length < 1)
        {
            alert('Please move users to be cloned into the selected user(s) box first.');
            return false;
        }        
    }
    return true;
}
/// <summary>
/// Function : Move single or Multiple listbox item 
/// </summary>
/// <param name="lstbxFrom">From Listbox ID</param>
/// <param name="lstbxTo">To Listbox ID</param>

function fnMoveItems(lstbxFrom, lstbxTo)
{               
    var varFromBox = document.getElementById(GetOriginalID(lstbxFrom));
    var varToBox = document.getElementById(GetOriginalID(lstbxTo));
    if ((varFromBox != null) && (varToBox != null))
    { 
        if(varFromBox.length < 1)
        {
            alert('There are no items in the source listbox.');
            return false;
        }
        if(varFromBox.options.selectedIndex == -1) // when no Item is selected the index will be -1
        {
            alert('Please select an item to move.');
            return false;
        }
        while(varFromBox.options.selectedIndex >= 0)
        { 
            var newOption = new Option(); // Create a new instance of ListItem 
            newOption.text = varFromBox.options[varFromBox.options.selectedIndex].text; 
            newOption.value = varFromBox.options[varFromBox.options.selectedIndex].value; 
            varToBox.options[varToBox.length] = newOption; //Append the item in Target Listbox
            varFromBox.remove(varFromBox.options.selectedIndex); //Remove the item from Source Listbox 
        }
    }
    return false;
}

/// <summary>
/// Function : Move All listbox item 
/// </summary>
/// <param name="lstbxFrom">From Listbox ID</param>
/// <param name="lstbxTo">To Listbox ID</param>
              
function fnMoveAllItems(lstbxFrom, lstbxTo)
{
    var varFromBox = document.getElementById(GetOriginalID(lstbxFrom));
    var varToBox = document.getElementById(GetOriginalID(lstbxTo));
    if ((varFromBox != null) && (varToBox != null))
    { 
        if(varFromBox.length < 1)
        {
            alert('There are no items in the source listbox.');
            return false;
        }                      
        for (var i = 0; i < varFromBox.length; i++)
        { 
            var newOption = new Option(); // Create a new instance of ListItem 
            newOption.text = varFromBox.options[i].text; 
            newOption.value = varFromBox.options[i].value; 
            varToBox.options[varToBox.length] = newOption; //Append the item in Target Listbox                          
        }
        while(varFromBox.length > 0)
        {                         
            varFromBox.remove(0); //Remove the item from Source Listbox 
        }
    }
    return false;
}


function isNumberKey(evt)
{
     var charCode = (evt.which) ? evt.which : event.keyCode
     if (charCode > 31 && (charCode < 48 || charCode > 57))
        return false;

     return true;
}


/***********END : Functions Related to Move Item Left-Right and viceversa in Listbox Control and Get Item Ids in Comma seperate from any Listbox *******/

/// <summary>
/// Function : Redirect the page to given page url from the double click of list box item
/// </summary>
/// <param name="ListBoxID">Object of the List box</param>
/// <param name="PageName">To which redirect the page</param>
/// <param name="QueryParam">Query String used to redirect back to this page</param>
function RedirectFromListBox(ListBoxID,PageName,QueryParam)
{            
    if (ListBoxID.selectedIndex != -1)
    {
        var RedirectUrl='';
        var ObjectID = ListBoxID.options[ListBoxID.selectedIndex].value
        RedirectUrl = PageName + '?id=' + ObjectID;
        if(QueryParam)
            RedirectUrl = RedirectUrl  + '&returnurl=' + QueryParam;
        else
                RedirectUrl = RedirectUrl  + '&returnurl=';
            
        location.href = RedirectUrl;
        //location.href = PageName + '?id=' + ObjectID + '&returnurl=' + QueryParam;
    }
    return false;
}

/// <summary>
/// Function : For the confirmation of rejection of user registration
/// </summary>
/// <param name=""></param>
/// <returns>true if usre gets confirmation to reject else false</returns>
function ConfirmForRejection()
{
    return confirm('Are you sure you want to reject user registration?');
}

function KeyCheck(e)
{

    var KeyID = (window.event) ? event.keyCode : e.which;    	    
   	if((KeyID >= 65 && KeyID <= 90) || (KeyID >= 97 && KeyID <= 122) || (KeyID >= 33 && KeyID <= 47 && KeyID != 46) ||
	    (KeyID >= 58 && KeyID <= 64) || (KeyID >= 91 && KeyID <= 96) || (KeyID >= 123 && KeyID <= 126) ) 
	    {
			return false;
		}
		
}

function KeyCheckInt(e)
{
    var KeyID = (window.event) ? event.keyCode : e.which;	    
	if((KeyID >= 65 && KeyID <= 90) || (KeyID >= 97 && KeyID <= 122) || (KeyID >= 33 && KeyID <= 47) ||
	    (KeyID >= 58 && KeyID <= 64) || (KeyID >= 91 && KeyID <= 96) || (KeyID >= 123 && KeyID <= 126) ) 
	    {
			return false;
		}
} 

function KeyCheckDecimal(e, obj)
{
    var KeyID = (window.event) ? event.keyCode : e.which;	    
    var strval = obj.value;
    if(strval.indexOf(".") > -1 && KeyID == 46)
    {
        return false;
    }
	if((KeyID >= 65 && KeyID <= 90) || (KeyID >= 97 && KeyID <= 122) || (KeyID >= 33 && KeyID <= 47 && KeyID != 46) ||
	    (KeyID >= 58 && KeyID <= 64) || (KeyID >= 91 && KeyID <= 96) || (KeyID >= 123 && KeyID <= 126) ) 
	    {
			return false;
		}
} 


function KeyCheckPhone(e)
{
    var KeyID = (window.event) ? event.keyCode : e.which;
	if((KeyID >= 65 && KeyID <= 90) || (KeyID >= 97 && KeyID <= 122) || (KeyID >= 33 && KeyID <= 39) ||
	    (KeyID == 42) || (KeyID == 44) || (KeyID >= 46 && KeyID <= 47) ||(KeyID >= 58 && KeyID <= 64) || 
	    (KeyID >= 91 && KeyID <= 96) || (KeyID >= 123 && KeyID <= 126) ) 
	    {
			return false;
		}
} 


function RoundDecimal( X ) 
{
	with (new Object(Math.round(100*X)+''))
	{ 
		return substring(0,length-2)+'.'+substring(length-2,length);
	} 
}


///Validation for not to enter date where Calender control is set
function KeyValidation(e)    //Only Keyboard Validation
{	
    var KeyID = (window.event) ? event.keyCode : e.which;
    if ((KeyID ==9)|| (KeyID == 46))
	{
	    return true;
	}
    else
    {
        return false;
    }
}


// This Function reset the FCK Editor text
function resetEditors() {
    // If the editor API does not exist, there are no editors
    if (typeof FCKeditorAPI == "undefined") return;

    // Loop through all FCK instances, in case there are several editors
    for (var sEditorName in FCKeditorAPI.__Instances) {
        // The initial value that was set when the form was created
        // is stored in a hidden <INPUT> with the same name as the
        // editor (the editor itself is in an <IFRAME> with ___Frame
        // appended to the name.  Check whether that INPUT exists
        if (document.getElementById(sEditorName)) {
            // Get the initial value
            var sInitialValue = document.getElementById(sEditorName).value;

            // Overwrite the editor's current value
            FCKeditorAPI.__Instances[sEditorName].SetHTML(sInitialValue);
        }
    }
} 
