var emptyFromName;
var emptyToEmailId;
var emptyFromEmailId;
var invalidEmailMsg;
var invalidCharacterMsg;

function ValidateSend()
{
	var name=document.getElementById("txtName");
	var frindsMailId=document.getElementById("txtFriendsEmailId");
	var mailId=document.getElementById("txtEmailId");
	
	
	if(TrimString(name.value).length ==0)
	{
	  alert(emptyFromName);
	  name.focus();
	  return false;
	}
	else if(TrimString(frindsMailId.value).length ==0)
	{
	  alert(emptyToEmailId);
	  frindsMailId.focus();
	  return false;
	}
	else if(TrimString(mailId.value).length ==0)
	{
	  alert(emptyFromEmailId);
	  mailId.focus();
	  return false;
	}
	if (FilterWildCharactersEmail('txtName','','')==false)
		return false;
		
	if (!FilterNumericData('txtName'))
	    return false;
		
	if ( ValidateEmail('txtEmailId','')==false )
		return false;
		
	if ( ValidateEmail('txtFriendsEmailId','')==false )
		return false;
		
	return true;
	
}
function FilterNumericData(ControlName)
{	
	if(ControlName != null)
	{
		var intNo="";
		var ctrl=document.getElementById(ControlName);
		intNo = ctrl.value;
		var NumberList ="1234567890";
		if (intNo!=null && intNo.length!=0 )
		{
			for(iCount=0;iCount<intNo.length;iCount++)
			{
				if(NumberList.indexOf(intNo.charAt(iCount))!= -1)
				{
					alert( invalidCharacterMsg + " " + intNo.charAt(iCount));
					ctrl.select();
					ctrl.focus();
					return false;
				}
			}
		}
	}
	
	return true;
}
function FilterWildCharactersEmail(Control,AllowedList,Rowind)
{
	var strValue;
	if (Rowind !="")
    {
	 Control = Rowind + "_" + Control;
	 strValue = document.getElementById(Control).value;
    }
	else
	 strValue = document.getElementById(Control).value;
	var allowedListArray=AllowedList.split(",");
	if(allowedListArray.length>1)
		{for(var i=0;i<allowedListArray.length;i++)
		{
			if(allowedListArray[i]=="")
			allowedListArray[i]=",";
		}
	}
	var wildCharacters = new Array( "^","~",'"',"`","<",">","%","@","#","$","&","*","{","}","[","]","?",",",".",";",":","'","/","|","!","(",")","_","-","+","=");
	var index="";
	if(AllowedList.length>0)
	{
		for(count=0;count<allowedListArray.length;count++)
		{
		  index= wildCharacters.indexOf(allowedListArray[count]);
		   if ( index == null )
		   {
			continue ;
		   }
		  wildCharacters.splice(index,1);
		}   
	}
	if(strValue!="")
	  {
		 for(iCount=0;iCount<wildCharacters.length;iCount++)
		 {
			if(strValue.indexOf(wildCharacters[iCount])!=-1)
			{
				alert(invalidCharacterMsg + " " + wildCharacters[iCount]);
				document.getElementById(Control).select();
				document.getElementById(Control).focus();
				return false;
				
			}
		 }
       }  
    return true;
}				
