// 26/10/2010 R Norton-Hall 
/*
Main Functions
checkIsEmail(str) receives string to check basic email format
stripVowelAccent(str) - strip those pesky foreign accents and return clean string
validateThisEmailAddress(email) receives string to validate email and return message on failure
*/
//===================================================
	function checkIsEmail(str) 
	{
		return (str.indexOf(".") > 2) && (str.indexOf("@") > 0); // checks for a period (.) character anywhere after the 3rd character in the string
	}	
/////////////////////////////////////////////////////
	// strip those pesky accents
	function stripVowelAccent(str)
	{
		//alert('called'+str);
		var s=str;
		
		var rExps=[ /[\xC0-\xC2]/g, /[\xE0-\xE2]/g,	/[\xC8-\xCA]/g, /[\xE8-\xEB]/g,	/[\xCC-\xCE]/g, /[\xEC-\xEE]/g,	/[\xD2-\xD4]/g, /[\xF2-\xF4]/g, /[\xD9-\xDB]/g, /[\xF9-\xFB]/g ];
		
		var repChar=['A','a','E','e','I','i','O','o','U','u'];
		
		for(var i=0; i<rExps.length; i++)
		s=s.replace(rExps[i],repChar[i]);
		
		return s;
	}
/////////////////////////////////////////////////////
	function validateThisEmailAddress(email) {
	// this is present in the event handler and is sent to the function
	// obj now refers to the HTML element, so we can do
		var email		= email;
		if (!email.length)
		{
		   	alert('You must insert your Email address');
		   	return false;
		}
			    
		if(!checkIsEmail(email))
		{
		  	alert('Please input a valid email address');
		  	return false;
		}
		return true;
	}
	
//////////////////////////////////////////////////
//////////////////////////////////////////////////	

