﻿function trim(inputString) {
	if (typeof inputString != "string") { return inputString; }
	var retValue = inputString;
	var ch = retValue.substring(0, 1);
	while (ch == " ") {
		retValue = retValue.substring(1, retValue.length);
		ch = retValue.substring(0, 1);
	}
	ch = retValue.substring(retValue.length-1, retValue.length);
	while (ch == " ") {
		retValue = retValue.substring(0, retValue.length-1);
		ch = retValue.substring(retValue.length-1, retValue.length);
	}
	while (retValue.indexOf("  ") != -1) {
		retValue = retValue.substring(0, retValue.indexOf("  ")) + retValue.substring(retValue.indexOf("  ")+1, retValue.length);
	}
	return retValue;
}

function CheckFeedback(theForm) { 

	if (trim(theForm.linkman.value)=="")
	{
		alert("Please fill in the contact person!");
		theForm.linkman.focus();
		theForm.linkman.select();
		return false;
	}
	if (trim(theForm.address.value)=="")
	{
		alert("Please fill in the address!");
		theForm.address.focus();
		theForm.address.select();
		return false;
	}
	if (trim(theForm.phone.value)=="")
	{
		alert("Please fill in the phone!");
		theForm.phone.focus();
		theForm.phone.select();
		return false;
	}
	if (trim(theForm.email.value)=="")
	{
		alert("Please fill in the email!");
		theForm.email.focus();
		theForm.email.select();
		return false;
	}
	var str1 = theForm.email.value
	if(str1.indexOf("@") == -1 || str1.indexOf(".") == -1)
	{
		alert("Sorry, your email format was not correct!");
		theForm.email.focus();
		theForm.email.select();
		return false;
	}
	if (trim(theForm.content.value)=="")
	{
		alert("Please fill in the content!");
		theForm.content.focus();
		theForm.content.select();
		return false;
	}
	if (trim(theForm.verifycode.value)=="")
	{
		alert("Please fill in the verifycode!");
		theForm.verifycode.focus();
		theForm.verifycode.select();
		return false;
	}
	return true;
}
