// JavaScript Document
function strip(filter,str){
	var i,curChar;
	var retStr = '';
	var len = str.length;
	for(i=0; i<len; i++){
		curChar = str.charAt(i);
		if(filter.indexOf(curChar)<0) //not in filter, keep it
			retStr += curChar;
	}
	return retStr;
}

function notEmpty(str){
	if(strip(" \n\r\t",str).length ==0) {
		return false;
	}
	else {
		return true;
	}
}

function validateEMail(str){
	str = strip(" \n\r\t",str);
	if(str.indexOf("@")>-1 && str.indexOf(".")>-1)
		return true;
	else
		return false;
}







function validator(form){
	if(notEmpty(form.txtFName.value)==false){
		hideAllErrors();
		document.getElementById("fnameError").style.display = "inline";
		form.txtFName.focus();
	return false;
	}
	if(notEmpty(form.txtLName.value)==false){
		hideAllErrors();
		document.getElementById("lnameError").style.display = "inline";
		form.txtLName.focus();
	return false;
	}
	if(validateEMail(form.txtBlah.value)==false){
		hideAllErrors();
		document.getElementById("emailError").style.display = "inline";
		form.txtBlah.focus();
		return false;
	}
	if(notEmpty(form.txtSubject.value)==false){
		hideAllErrors();
		document.getElementById("subjectError").style.display = "inline";
		form.txtSubject.focus();
	return false;
	}
	if(notEmpty(form.txtComment.value)==false){
		hideAllErrors();
		document.getElementById("commentError").style.display = "inline";
		form.txtComment.focus();
	return false;
	}
	else {
		return true;
	}
}

function hideAllErrors() {
document.getElementById("fnameError").style.display = "none"
document.getElementById("lnameError").style.display = "none"
document.getElementById("emailError").style.display = "none"
document.getElementById("subjectError").style.display = "none"
document.getElementById("commentError").style.display = "none"
}