//***********************************************************
//this function is used to find whether string contains numbers.
function isHaveNumber(str)
{
	var i;
	for(i=0;i<str.length;i=i+1)
	{
		//alert(str + "  " + str.charAt(i));
		//alert(str.charAt(i).valueOf());
		if(!isNaN(str.charAt(i)))
			return true;
	}
	return false;
}
//****************************************************************************************************
//this function is used to validate email id string
function echeck(str) {

		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		var lostdot=str.lastIndexOf(dot)
		var first = str.charCodeAt(0)
		if(!((first>64&&first<91)||+(first>96&&first<123))){

			alert("Email ID should start with Character");
			return false;
		}
		if((lstr-lostdot)<=2){
			 alert("Invalid E-mail ID")
		   return false
	   }
	   if((lstr-lostdot)>2)
	   {
				var str2=str.substring(lostdot+1);
				//alert("sending " + str2);
				if(isHaveNumber(str2))
		        {
					alert("Invalid E-mail ID");
					return false;
				}
				if((str.charAt(lostdot+1)=='.')||(str.charAt(lostdot-1)=='.'))
		        {
					alert("Invalid E-mail ID");
					return false;
				}
		}
		if (str.indexOf(at)==-1){
		   alert("Invalid E-mail ID")
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   alert("Invalid E-mail ID")
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr-1){
		    alert("Invalid E-mail ID")
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    alert("Invalid E-mail ID")
		    return false
		 }
		

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    alert("Invalid E-mail ID")
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    alert("Invalid E-mail ID")
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		    alert("Invalid E-mail ID")
		    return false
		 }

 		 return true					
	}
//***************************************************************************
//this function is used to check string contains special symbols except  dot,space,characters.
function isContainsSpecialChars(str)
{
	for(i=0;i<str.length;i=i+1)
	{
			var code = str.charCodeAt(i);
			//alert(str.charAt(i) + "="+ code);
			if((str.charAt(i) != ".")&&(code != 32))
			{
				if(!(code>=65&&code<=90))
				{
					if(!(code>=97&&code<=122))
					{
						//document.comments.name.focus();
						return false;
					}
				}
			}
	}
	return true;
		   
}
//***************************************************************************
