// Functions for email field validation
function emptyField(textObj) {
	if (textObj.value.length == 0) return true;
	for (var j=0; j<textObj.value.length; ++j) {
		var ch = textObj.value.charAt(j);
		if (ch != ' ' && ch != '\t') return false;
	}
	return true;
}

function emailVerify( valueObj ){
  if (ltrim( valueObj ) == "")
  	return false;
  else if ((valueObj.indexOf("@") == 0) || (valueObj.indexOf("@") == -1))
  	return false;
  else if ((valueObj.indexOf(".") <= 2) || (valueObj.indexOf(".") == -1))
  	return false;
//  Do not test the domain name of the email address since there are exceptions besides the followings
//  else if ((valueObj.indexOf(".com") == -1) && (valueObj.indexOf(".net") == -1) && (valueObj.indexOf(".gov") == -1) && (valueObj.indexOf(".org") == -1) && (valueObj.indexOf(".edu") == -1) && (valueObj.indexOf(".tv") == -1) && (valueObj.indexOf(".la") == -1))
//	return false;
  else 
  	return true;  	
  
}

function ltrim( varIn ){
  var varOut = "";
  
  if (varIn == ""){
  }
  else 
   for (k=0; k<varIn.length; k++){
   	if (varIn.charAt(k) != " "){
   		varOut = varIn.substring(k);
   		break;
   		}
   	}
   //alert ( varOut );
   return varOut;

}

// Validate at least one checkbox is checked
function checkBoxValidate( checkBoxObj ){
  var booleanReturn = false;
  for(var r=0; r<checkBoxObj.length; r++){
     if(checkBoxObj[r].checked == true)
     {
       return true;
     }
  }
  return false;
}
