function isValidMultipleEmail(str) {
//if (str == null) {      return false;      }
 

var totalLen = str.length; //total length
var newStart = 0;	//start of the string.

//1. we must look through the string to find delimitors
for(i = 0; i <= totalLen; i++)
{
	if( (str.charAt(i) == ' ') || (str.charAt(i)== ',' ) || (str.charAt(i) == ';' ) || ( i == totalLen) )
	 {
		
		var working = str.substr(newStart, (i - newStart));
		if (working.indexOf('@') < 1)	{	return false;      }
		if (working.indexOf('.') == -1) {   return false;      }
		//if the next character is a space we must move on.
		if( (str.charAt(i + 1) == ' ') || (str.charAt(i+1)== ',' ) || (str.charAt(i+1) == ';' ) )
		 {		newStart = i+1; i++;		}
		else{   newStart = i;		}
	}
}

   return true;
}


function isValidEmail(str) {
	try {
   if (str == null) {
      return false;
      }
   if (str.indexOf( ' ' ) != -1 ) {
      return false;
      }
   if (str.indexOf('@') < 1) {
      return false;
      }
	   if (str.lastIndexOf('.') < str.indexOf('@') ) {
      return false;
      }
	} catch ( e ) {
		return true; // No point penalising the customer for our mistake.
	}
   return true;
}


function isEmpty(aTextField) {
   if ( (aTextField==null) || (aTextField.value==null) || (aTextField.value.length==0) ) {
      return true;
   }
   else { return false; }
}


function isEmptyWhenTrimmed(aTextField) {

   if ((aTextField==null) || (aTextField.value==null) || (aTextField.value.replace(/^\s*/, '').replace(/\s*$/, '').length<1) ) {
      return true;
   }
   else { return false; }
}


function isNumeric(sText)
{
   var ValidChars = "0123456789.-+ ";
   var IsNumber=true;
   var Char;

   for (i = 0; i < sText.length && IsNumber == true; i++) 
      { 
      Char = sText.charAt(i); 
      if (ValidChars.indexOf(Char) == -1) 
         {
         IsNumber = false;
	 continue;
         }
      }
   return IsNumber;
}

function isInteger(sText)
{
   var ValidChars = "0123456789-+";
   var IsNumber=true;
   var Char;

   for (i = 0; i < sText.length && IsNumber == true; i++) 
      { 
      Char = sText.charAt(i); 
      if (ValidChars.indexOf(Char) == -1) 
         {
         IsNumber = false;
	 continue;
         }
      }
   return IsNumber;
}

function isPositiveInteger(sText)
{
   var ValidChars = "0123456789";
   var IsNumber=true;
   var Char;

   for (i = 0; i < sText.length && IsNumber == true; i++) 
      { 
      Char = sText.charAt(i); 
      if (ValidChars.indexOf(Char) == -1) 
         {
         IsNumber = false;
	 continue;
         }
      }
   return IsNumber;
}

function isGreaterThanZero(sText)
{
   var ValidChars = "0123456789";
   var IsNumber=true;
   var IsLargerThanZero=false;
   var Char;

   for (i = 0; i < sText.length && IsNumber == true; i++) 
      { 
      Char = sText.charAt(i);
      if (ValidChars.indexOf(Char) == -1)
         {
         IsNumber = false;
	 continue;
         }
      if ( sText.charAt(i) > '0') {
         IsLargerThanZero=true;
         }
      }

   if ( IsNumber == false ) {
      return false;
   }

   return IsLargerThanZero;
   }


/* How To Use: onblur="cleanString(this)" */
function cleanString( aTextField) {
var theString = aTextField.value;
if ( theString != null ) { aTextField.value = theString.replace ( "'", "" ) ; }
}


function isRadioChecked(aRadioButton) {
	if ( aRadioButton == null ) { // If what is passed is rubbish, then return false.
		return false ;
	}
	if ( aRadioButton.length == null ) { // If there is only one entry, then length is undefined.
		return aRadioButton.checked
	}
  for (counter = 0; counter < aRadioButton.length; counter++){
    if (aRadioButton[counter].checked){
      return true;
    }
  }
  return false;
}

function isValidPhone(sText) {
	var validChars = "0123456789-+() ";
	for (var i = 0; i < sText.length; i++) {
		if (validChars.indexOf( sText.charAt(i) ) == -1) {
			return false;
		}
	}
	return true;
}