function validateForm(objForm){

var sErrMsg = "";

	if (objForm.txtFirstName == ""){
		sErrMsg += "Please enter your first name.\n";
		}

	if (objForm.txtLastName == ""){
		sErrMsg += "Please enter your last name.\n";
		}

	if (objForm.txtAddress.value == ""){
		sErrMsg += "Please enter your address.\n";
		}

	if (objForm.txtCity.value == ""){
		sErrMsg += "Please specify the city in your address details.\n";
		}
		
	if (objForm.txtPostCode.value == ""){
		sErrMsg += "Please enter your post code or zip code.\n";
		}

	return sErrMsg;

}


function validateQTY(textControl) {
var remainder;

	if (isNaN(textControl)) {
		return false;
		}
	else {
		remainder = textControl % 1;
		if (remainder!=0) {
			return false;
			}
		else {		
			return true;
			}
	}

}



function validatePhone(sPhone) {

if (sPhone=="") {
	return "Please enter a phone number.\n";
	}

var stripped = sPhone.replace(/[\(\)\.\-\ ]/g, '');
//strip out acceptable non-numeric characters
if (isNaN(parseInt(stripped))) {
   return "Please enter a valid phone number.\n";
   }
else {
	return "";
	}

	

}

function validateFax(sFax) {

	//If a fax number have been entered then validate it
	if (sFax!="") {
		if (validatePhone(sFax)!=""){
			return "Please enter a valid fax  number.\n";
			}
		}
		
	return "";

}


function isOnlyLetters(sString){
var i;
var curr_char;
var tmpString;
var tmpLength;


	//Check for blank string
	if (sString==""){
		return false;
		}

	vowelChars=/[aeiouyAEIOUY]+/;
	
	tmpLength = sString.length;
	tmpString = sString
	tmpString = tmpString.replace(vowelChars,'');
	
	if (tmpLength==tmpString.length || tmpString.length==0){
		//Either no vowels or only vowels have been entered
		return false;
		}
	
	//Check for all numeric string
	numericChar=/\d*/;
	//Remove all characters other than numeric
	tmpStr = sString.replace(numericChar,'');
	
	//if length = 0 then only numerics passed
	if (tmpStr.length==0) {
		return false;
		}

	//Only valid alpha numerics allowed
	validChars=/\w+\s*/;
	
	//Strip out all valid characters
	sString=sString.replace(validChars,'');
	
	//If there are still character in the sting then invalid characters
	//have been entered
	if (sString.length > 0) {
		return false;
			}
	else {
		return true;
		}
	
}


function validateFirstName(sFirstName){

	if (sFirstName==""){
		return "Please enter your first name.\n";
		}
		
	//Check that numbers and other characters have not been entered
	if (isOnlyLetters(sFirstName)==false) {
		return "Please enter a valid first name.\n"
		}

	return "";

}


function validateLastName(sLastName){

	if (sLastName==""){
		return "Please enter your last name.\n";
		}

	//Check that numbers and other characters have not been entered
	if (isOnlyLetters(sLastName)==false) {
		return "Please enter a valid last name.\n"
		}

	return "";


}


function validateAddress(sAddress){

	
	if (sAddress==""){
		return "Please enter your address.\n";
		}
		
	return "";

}


function validateCity(sCity){

	if (sCity==""){
		return "Please enter the name your city or town.\n";
		}

	//Check that numbers and other characters have not been entered
	if (isOnlyLetters(sCity)==false) {
		return "Please enter a valid city or town.\n"
		}


	return "";

}


function validateEmail(sEmail){


	if (sEmail=="") {
		return "Please enter your email address.\n";
	}

var emailFilter=/^.+@.+\..{2,3}$/;
if (!(emailFilter.test(sEmail))) { 
       return "Please enter a valid email address.\n";
	}

var illegalChars= /[\(\)\<\>\,\;\:\\\/\"\[\]]/
if (sEmail.match(illegalChars)) {
   return "The email address contains illegal characters.\n";
	}
else {
	return "";
	}


}

function validateSubject(sSubject){
	if (sSubject.length==0){
		return "Please enter a subject for this message.";
		}
	else {
		return "";
	}
}

function ValidateSendmail(form){
var response="";

	response = validateEmail(form.txtFrom.value);	
	response += validateSubject(form.txtSubject.value);
	if (response!=""){
		alert(response);
		return false;
		}
	else {
		return true;
	}



}
