// ***************************************************************************************************************************************
// Function - Used to remove trailing and leading spaces
function Trim(strString)
{
   return strString.replace(/^\s*|\s*$/g,"");
}
// ***************************************************************************************************************************************
// Function - Used to validate email address
function VlidateEmail(str)
{
    var at="@"
    var dot="."
    var lat=str.indexOf(at)
    var lstr=str.length
    var ldot=str.indexOf(dot)
    
    if (str.indexOf(at)==-1)
    {
       return false;
    }
    if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr)
    {
       return false;
    }
    if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr)
    {
        return false;
    }
    if (str.indexOf(at,(lat+1))!=-1)
    {
        return false;
    }
    if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot)
    {
        return false;
    }
    if (str.indexOf(dot,(lat+2))==-1)
    {
        return false;
    }
    if (str.indexOf(" ")!=-1)
    {
        return false;
    }
}
// ***************************************************************************************************************************************
// Function - Used to make a check whether supplied input is a number or not
function IsNumeric(strValue)
{
	var strChar;
	var IsNumber = true;
	var strValidChars = "0123456789";
	
	for (i = 0; i < strValue.length && IsNumber == true; i++) 
	{
		strChar = strValue.charAt(i); 
		if (strValidChars.indexOf(strChar) == -1) 
		{
			IsNumber = false;
		}
	}
	return IsNumber;
}
// ***************************************************************************************************************************************
// Add new option to the dropdown
function AddNewOption(strFormNControl, strDispOption, strOptionVal)
{
	var strNewOption = document.createElement('option');
	
	strNewOption.text = strDispOption;
	strNewOption.value = strOptionVal;
	
	strFormNControl.options.add(strNewOption);
}
// ***************************************************************************************************************************************
// Remove selected option from the dropdown
function RemoveOption(strFormNControl, intOptionIndex)
{
	var strRemoveOption = strFormNControl;
	strRemoveOption.remove(intOptionIndex);
}
// ***************************************************************************************************************************************
// Remove all options except the first one i.e. default one from the selected dropdown
function RemoveAllOptions(strFormNControl)
{
	if (strFormNControl.length > 1)
	{
		for (intCounter = strFormNControl.length; intCounter > 1; intCounter--)
		{
			RemoveOption(strFormNControl, (intCounter - 1));
		}
	}
}
// ***************************************************************************************************************************************