// contact_form.js

//////////////////////////////////////////////
function LTrim(str) 
{
	for (var i=0; str.charAt(i)==" "; i++);
	return str.substring(i,str.length);
}

function RTrim(str) 
{
	for (var i=str.length-1; str.charAt(i)==" "; i--);
	return str.substring(0,i+1);
}

function Trim(str) 
{
	return LTrim(RTrim(str));
}


function checkfield(echoForm) {

	if (echoForm.Name.value == "") {
		alert("Please enter your name.");
			echoForm.Name.focus();
        return false;   
	}


	if(echoForm.Email.value == "")
	{
		alert("Please enter your email address.");
		echoForm.Email.focus();
		return(false);
	}
	
	var value = Trim(echoForm.Email.value);
	var pattern = /[^@_\.\w\d\-]|@@|\.\.|__|^@|^\.|^_|@$|\.$|_$|@\.|\.@|@_|_@|\._|_\.|(@)[^@]*\1/g;
	
	if((((value.match(/@/)) && (value.match(/\./))) == null)||(value.match(pattern) != null))
	{
		alert("Please double check the E-mail address.");
		echoForm.Email.focus();
		return(false);
	}
	    
	/////////////////////////////////////////////	 
		
	//if (echoForm.Email.value == "") {
	//    alert("Please enter your E-mail address.");
	//        echoForm.Email.focus();
	//        return false;   
	//	}


	if (echoForm.Department.value == "") {
		alert("Please select a department.");
			echoForm.Department.focus();
			return false;   
		}
		

	if (echoForm.Comments.value == "") {
		alert("Please enter your comments.");
			echoForm.Comments.focus();
			return false;   
		}
		
	return true;
}

