//Checking for String should not have space within the word
function IsSpaceInBetween(param2)
{
	var str;
	str = param2;
    
    str  = str.toUpperCase();
	nLen = str.length;

	fValid = true;
	for(i=0; i<nLen; ++i)
	{
		if (str.charAt(i) == ' ')
		{
			fValid = false;
			break;
		}
	}
	
	if ( fValid == true )
	{
		return true;
	}
	else
	{
		return false;
	}
}

//Checking for string should not have any special character
function IsString(param1, param2)
{
	var str;
	str = param1;
    var str1;
    var str2;
    var fValid;
    
    fValid = true;    
    str1 = "A";
    str2 = "Z";
    str3 = "0";
    str4 = "9";
    str5 = " ";
    
    str  = str.toUpperCase();
	nLen = str.length;
	
	if (param2 == 1)
	{
		str6 = "-";
		str7 = "_";
		str8 = "."
		for(i=0; i<nLen; ++i)
		{
			if(((str.charCodeAt(i)  < str1.charCodeAt(0)
			 || str.charCodeAt(i) > str2.charCodeAt(0)) 
			 && (str.charCodeAt(i)< str3.charCodeAt(0) 
			 || str.charCodeAt(i) > str4.charCodeAt(0)))
		  	 && str.charCodeAt(i) != str5.charCodeAt(0)
		  	 && str.charCodeAt(i) != str6.charCodeAt(0)
			 && str.charCodeAt(i) != str7.charCodeAt(0)
			 && str.charCodeAt(i) != str8.charCodeAt(0))
		  	{
		  	  fValid = false;
		  	  break;
		  	}
		}
	}
	else
	{
		for(i=0; i<nLen; ++i)
		{
			if(((str.charCodeAt(i)  < str1.charCodeAt(0)
			 || str.charCodeAt(i) > str2.charCodeAt(0)) 
			 && (str.charCodeAt(i)< str3.charCodeAt(0) 
			 || str.charCodeAt(i) > str4.charCodeAt(0)))
		  	 && str.charCodeAt(i) != str5.charCodeAt(0))
		  	{
		  	  fValid = false;
		  	  break;
		  	}
		}
	
	}
	return fValid;
}

function IsEmptyString(str)
{
	nLen = str.length;
	for(i=0; i<nLen; ++i)
	{
		if(str.charAt(i) != " ")
		{
			return false;
		}
	}

	return true;
}


//Validating email Id
function IsValidEmail(strEmail)
{
	var nLen = strEmail.length;
	
	if(nLen<5)
		return false;
	var nStartIndex=0;
	var nIndex=0;
	nIndex=strEmail.indexOf("@",nStartIndex);
	if(nIndex == -1 || nIndex== 0)
		return false;
	nStartIndex=nIndex;
	nIndex=strEmail.indexOf(".",nStartIndex);
	if(nIndex== -1 || nIndex<=nStartIndex+1)
		return false;
	if(nLen==nIndex)
		return false;
	if ( strEmail.charAt(strEmail.length-1) == "."  || strEmail.charAt(0) == "." )
	{
		return false;
	}
	
	var natposition;
	natposition = strEmail.indexOf("@");
	if (strEmail.charAt(natposition+1) == ".")
	{
		return false;
	}
	
	var natlastposition;
	natlastposition = strEmail.lastIndexOf("@");
	if (natlastposition > natposition )
	{
		return false;
	}
	
	var nlast_dot_pos;
	nlast_dot_pos = strEmail.lastIndexOf(".");
	if ((strEmail.length - nlast_dot_pos) <= 2)
	{
		return false;
	}
	
	var ndot_pos;
	ndot_pos = strEmail.indexOf(".");
	if (strEmail.charAt(ndot_pos+1) == ".")
	{
		return false;
	}
	else  
	{
		ndot_pos = strEmail.lastIndexOf(".");
		if (strEmail.charAt(ndot_pos - 1) == ".")
		{
			return false;
		}
	}
	// Following code for checking special characters except ".", "_", "@"
	var str;
	var nLen;
	var i;
	
	str  = strEmail.toUpperCase();
	nLen = str.length;
	
	var str1;
	var str2;
	var str3;
	var str4;
	var str5;
	var str6;
	var str7;
	
	str1 = ".";
	str2 = "_";
	str3 = "@";
	str4 = "0";
	str5 = "9";
	str6 = "A";
	str7 = "Z";
	str8 = " "; 
	str9 = "-" 
		
	//Checking for 1st char return false if it is not char(a-z)
	if (str.charCodeAt(0) < str6.charCodeAt(0) || str.charCodeAt(0) > str7.charCodeAt(0))
	{
		return false;
	}
	
	for(i=0; i<nLen; ++i)
	{
		if  (str.charCodeAt(i) < str4.charCodeAt(0))
		{
		//str9 added on 06/07/2000 to allows - Ref Ananth mail 6/7/00 XXX-XXX@XXX.XXX
			if (str.charCodeAt(i) != str1.charCodeAt(0) && str.charCodeAt(i) != str9.charCodeAt(0))
			{
				return false;
				break;
			}
		}
		if  ((str.charCodeAt(i) > str5.charCodeAt(0)) && (str.charCodeAt(i) < str3.charCodeAt(0)))
		{
			return false;
			break;
		}
		if ((str.charCodeAt(i) > str7.charCodeAt(0)))
		{
			if ((str.charCodeAt(i) != str2.charCodeAt(0)))
			{
				return false;
				break;
			} 
		}
		if  ((str.charCodeAt(i) == str8.charCodeAt(0))) 
		{
			return false;
			break;
		}
	}
	return true;
}

//Checking handle should not have special characters
function IsValidHandle(param1)
{
    var str;
    str = param1;
	var fValid;
    
    fValid = true;    
    str1 = "A";
    str2 = "Z";
    str3 = "0";
    str4 = "9";
    str5 = " ";
    
   
    
    str  = str.toUpperCase();
	nLen = str.length;
		str6 = "-";
		str7 = "_";
		str8 = ".";
		for(i=0; i<nLen; ++i)
		{
			if(((str.charCodeAt(i)  < str1.charCodeAt(0)
			 || str.charCodeAt(i) > str2.charCodeAt(0)) 
			 && (str.charCodeAt(i)< str3.charCodeAt(0) 
			 || str.charCodeAt(i) > str4.charCodeAt(0)))
		  	 && str.charCodeAt(i) != str5.charCodeAt(0)
		  	 && str.charCodeAt(i) != str6.charCodeAt(0)
			 && str.charCodeAt(i) != str7.charCodeAt(0)
			 && str.charCodeAt(i) != str8.charCodeAt(0))
		  	{
		  	  fValid = false;
		  	  break;
		  	}
		}
	
	return fValid;
}

