function checkregister(theForm) {
    var why = "";
	why += isEmptyName(theForm.name.value);
	why += checkemail(theForm.email.value);	
	why += isEmptyCountry(theForm.country.value);
	
    if (why != "") {
       alert(why);
       return false;
    }
return true;
}

function checkcontact(theForm) {
    var why = "";
	why += isEmptyName(theForm.name.value);
	why += isEmptyComname(theForm.com_name.value);
	why += checkemail(theForm.email.value);	
	why += isEmptyIndustry(theForm.industry.value);
	why += isEmptySoft(theForm.what_soft_cad.value);
	why += isEmptyHelp(theForm.how_help_you.value);
    if (why != "") {
       alert(why);
       return false;
    }
return true;
}

function checklost(theForm) {
    var why = "";
	why += isEmptyUName(theForm.username.value);
	why += checkemail(theForm.email.value);	
    if (why != "") {
       alert(why);
       return false;
    }
return true;
}

function checksubmitfile(myform) {
    var why = "";
	why += isEmptySentto(myform.sent_to.value);
	why += isEmptyPid(myform.pid.value);	
    if (why != "") {
       alert(why);
       return false;
    }
return true;
}

function checkempfile(myform){
	var why = "";
	why += isEmptyPid(myform.pid.value);	
    if (why != "") {
       alert(why);
       return false;
    }
return true;	
}

function checkprojects(theForm) {
    var why = "";
	why += isEmptyClient(theForm.pfrom.value);
	why += isEmptyPName(theForm.pname.value);	
	why += isEmptyPRefNum(theForm.pref_num.value);	
    if (why != "") {
       alert(why);
       return false;
    }
return true;
}

function checkbilling(theForm) {
    var why = "";
	why += isEmptyClient(theForm.id.value);
	why += isEmptyUFile(theForm.bfile.value);	
    if (why != "") {
       alert(why);
       return false;
    }
return true;
}

function isEmptyUFile(strng) {
	var error = "";
	  if (strng.length == 0) {
		 error = "Please select File to Upload \n"
	  }
	return error;	  
}

function isEmptyClient(strng) {
	var error = "";
	  if (strng.length == 0) {
		 error = "Please select Client Name \n"
	  }
	return error;	  
}
function isEmptyPName(strng) {
	var error = "";
	  if (strng.length == 0) {
		 error = "Please enter project name \n"
	  }
	return error;	  
}
function isEmptyPRefNum(strng) {
	var error = "";
	  if (strng.length == 0) {
		 error = "Please enter reference number \n"
	  }
	return error;	  
}



function isEmptySentto(strng) {
	var error = "";
	  if (strng.length == 0) {
		 error = "Enter Your Client or Staff Name \n"
	  }
	return error;	  
}

function isEmptyPid(strng) {
	var error = "";
	  if (strng.length == 0) {
		 error = "Enter Your Project Name or Reference Number \n"
	  }
	return error;	  
}

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

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

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

function isEmptyIndustry(strng) {
	var error = "";
	  if (strng.length == 0) {
		 error = "Enter Industry \n"
	  }
	return error;	  
}

function isEmptySoft(strng) {
	var error = "";
	  if (strng.length == 0) {
		 error = "Enter software you use. \n"
	  }
	return error;	  
}

function isEmptyHelp(strng) {
	var error = "";
	  if (strng.length == 0) {
		 error = "How can we help you? \n"
	  }
	return error;	  
}

function isEmptyCountry(strng) {
	var error = "";
	  if (strng.length == 0) {
		 error = "Please select a country. \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 == "") {
	   error = "You didn't enter a username.\n";
	}
	
		var illegalChars = /\W/; // allow letters, numbers, and underscores
		if ((strng.length < 4) || (strng.length > 10)) {
		   error = "Username is empty.\n";
		}
		else if (illegalChars.test(strng)) {
			error = "The username contains illegal characters.\n";
		} 
	return error;
}       

function isEmptyPassword(strng) {
	var error = "";
	if (strng == "") {
	   error = "You didn't enter a password.\n";
	}
	
		var illegalChars = /[\W_]/; // allow only letters and numbers
		
		if ((strng.length < 3) || (strng.length > 8)) {
		   error = "Password is empty.\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;     
}


