/************************************************************************************
 * Name:		ValidateEmail
 * Descripion:	checks to see if the email address is in the correct format
 ************************************************************************************/
function ValidateEmail(sEmail, bAllowBlank)
{
	var chrArray, i, intPos
				
	/* validate email address */
	if(sEmail.length == 0 && bAllowBlank == true)
	{
		return true;
	}else if(sEmail.length == 0)
	{
		return false;
	}
				
	/* This array holds characters that cannot be included in an address */
	chrArray = new Array(";","~","`","!","#","$","%","^","&","*","(",")","+","=","{","}","[","]","|",":","'","<",",",">","?","/","\"","\\");
							   
	/* check to ensure to bad chars are in the address */
	for(i in chrArray)
	{
		if(sEmail.indexOf(chrArray[i]) != -1)
		{
			return false;
		}
	}
				
	intPos = sEmail.indexOf("@",2);
	if(intPos < 2) 
	{
		return false;
	}
					
	intPos = sEmail.indexOf(".",intPos+2);
	if(intPos == -1 || intPos == sEmail.length-1)
	{
		return false;
	}
				
	return true;
}


function ValidateMultipleEmails(sEmail, sDelimiter, bAllowBlank)
{
	var arrEmails = sEmail.split(sDelimiter)
         
    for (var loop=0; loop < arrEmails.length; loop++)
	{
	   if(!ValidateEmail(arrEmails[loop],bAllowBlank))
	   {
	   		return false;
	   }
	}
	
	return true;

}
