function checkEmptyContact(theForm) {
    var why = "";
	why += isEmptyName(theForm.name.value);
	why += checkemail(theForm.email.value);	
	why += isEmptyAddress(theForm.address.value);
	why += isEmptyMessage(theForm.msg.value);
	why += isEmptySCode(theForm.security_code.value);
    if (why != "") {
       alert(why);
       return false;
    }
return true;
}

function checkEmptyTesti(theForm) {
    var why = "";
	why += checkemail(theForm.email.value);	
	why += isEmptyFinancial(theForm.financial.value);
	why += isEmptyTesti(theForm.testimony.value);
	why += isEmptySCode(theForm.security_code.value);
	why += isEmptyTerms(theForm.agree.value);
    if (why != "") {
       alert(why);
       return false;
    }
return true;
}

function checkEmptyReg(theForm) {
    var why = "";
	why += isEmptyUsername(theForm.username.value);
	why += isEmptyPassword(theForm.password.value);
	why += isEmptyFname(theForm.fname.value);
	why += isEmptyLname(theForm.lname.value);
	why += checkemail(theForm.email.value);	
	why += isEmptyAboutme(theForm.aboutme.value);
	//why += isEmptyPhoto(theForm.photo.value);
	why += isEmptySCode(theForm.security_code.value);
	why += isEmptyTerms(theForm.agree.value);
    if (why != "") {
       alert(why);
       return false;
    }
return true;
}

function checkEmptyTopic(theForm) {
    var why = "";
	why += isEmptyTitle(theForm.title.value);
	why += isEmptyTopic(theForm.topic.value);
	why += isEmptySCode(theForm.security_code.value);
    if (why != "") {
       alert(why);
       return false;
    }
return true;
}

function checkEmptyReply(theForm) {
    var why = "";
	why += isEmptyReplies(theForm.replies.value);
	why += isEmptySCode(theForm.security_code.value);
    if (why != "") {
       alert(why);
       return false;
    }
return true;
}

function isEmptyTerms(strng) {
	var error = "";
	if(!document.form1.agree.checked){
		error = "Please read the Terms and Agreement and \ncheck the box below";
	}	
	return error;
}

function isEmptyReplies(strng) {
	var error = "";
	  if (strng.length == 0) {
		 error = "Reply is required. \n"
	  }
	return error;	  
}
function isEmptyTitle(strng) {
	var error = "";
	  if (strng.length == 0) {
		 error = "Topic Title is required. \n"
	  }
	return error;	  
}
function isEmptyTopic(strng) {
	var error = "";
	  if (strng.length == 0) {
		 error = "Topic is required. \n"
	  }
	return error;	  
}
function isEmptyFname(strng) {
	var error = "";
	  if (strng.length == 0) {
		 error = "Firstname is required. \n"
	  }
	return error;	  
}
function isEmptyLname(strng) {
	var error = "";
	  if (strng.length == 0) {
		 error = "Lastname is required. \n"
	  }
	return error;	  
}
function isEmptyAboutme(strng) {
	var error = "";
	  if (strng.length == 0) {
		 error = "About me is required \n"
	  }
	return error;	  
}
function isEmptySCode(strng) {
	var error = "";
	  if (strng.length == 0) {
		 error = "Security Code is required \n"
	  }
	return error;	  
}

function isEmptyTesti(strng) {
	var error = "";
	  if (strng.length == 0) {
		 error = "Testimony cannot be empty \n"
	  }
	return error;	  
}

function isEmptyPhoto(strng) {
	var error = "";
	  if (strng.length == 0) {
		 error = "Enter Photo Please \n"
	  }
	return error;	  
}

function isEmptyName(strng) {
	var error = "";
	  if (strng.length == 0) {
		 error = "Enter Your Name Please \n"
	  }
	return error;	  
}

function isEmptyAddress(strng) {
	var error = "";
	  if (strng.length == 0) {
		 error = "Enter Your Personal Address \n"
	  }
	return error;	  
}

function isEmptyMessage(strng) {
	var error = "";
	  if (strng.length == 0) {
		 error = "Message Cannot be empty. \n"
	  }
	return error;	  
}

function isEmptyFinancial(strng) {
	var error = "";
	  if (strng.length == 0) {
		 error = "Please select category option. \n"
	  }
	return error;	  
}

//IMportant Validators---------------------------------------------------------

function checkemail (strng) {
	var error="";
	if (strng == "") {
	   error = "Enter your email address?.\n";
	}
	
		var emailFilter=/^.+@.+\..{2,3}$/;
		if (!(emailFilter.test(strng))) { 
		   error = "Please enter a valid email address.\n";
		}
		else {
	//test email for illegal characters
		   var illegalChars= /[\(\)\<\>\,\;\:\\\"\[\]]/
			 if (strng.match(illegalChars)) {
			  error = "The email address contains illegal characters.\n";
		   }
		}
	return error;    
}

function isEmptyMPhone(strng) {
	var error = "";
	if (strng == "") {
	   error = "You didn't enter a phone number.\n";
	}
	
	var stripped = strng.replace(/[\(\)\.\-\ ]/g, ''); //strip out acceptable non-numeric characters
		if (isNaN(parseInt(stripped))) {
		   error = "The phone number contains illegal characters.";
	  
		}
		if (!(stripped.length == 10)) {
		error = "Invalid Phone Number. Make sure you included an area code.\n";
		} 
	return error;
}

function isEmptyUsername (strng) {
	var error = "";
	
	if (strng.length == "" || strng.length == null) {
	   error = "You didn't enter a username.\n";
	}
	
		/*var illegalChars = /\W/; // allow letters, numbers, and underscores
		if ((strng.length < 4) || (strng.length > 10)) {
		   error = "Password should be in 4 characters.\n";
		}
		else if (illegalChars.test(strng)) {
			error = "The username contains illegal characters.\n";
		} */
	return error;
}       

function isEmptyPassword(strng) {
	var error = "";
	if (strng.length == "") {
	   error = "You didn't enter a password.\n";
	}
	
		//var illegalChars = /[\W_]/; // allow only letters and numbers
		
		if (strng.length < 6) {
		   error = "Password should be in 6 characters.\n";
		}
		/*else if (illegalChars.test(strng)) {
		  error = "The password contains illegal characters.\n";
		} 
		else if (!((strng.search(/(a-z)+/)) && (strng.search(/(A-Z)+/)) && (strng.search(/(0-9)+/)))) {
		   error = "The password must contain at least one uppercase letter, \n one lowercase letter, and one numeral.\n";
		} */ 
	return error;     
}



