// JavaScript Document

function checkform() {
	var why = "";
	why += isEmpty(document.getElementById('email'));
	why += isEmpty(document.getElementById('message'));
	if (why != "") {
		 document.getElementById('errormsg').style.display = 'block';
		 return false;
	}
return true;
}

function isEmpty(strng) {
	var error = "";
		if (strng.value == "") {
			error = "The mandatory text area has not been filled in.\n"
			strng.style.borderWidth = '2px';
			strng.style.borderColor = '#990000';
			strng.style.borderStyle = 'solid';
		}
		else {
			strng.style.borderWidth = '1px';
			strng.style.borderColor = '#7F9DB9';
			strng.style.borderStyle = 'solid';
		}
	return error;	  
}


/*function checkform(){
	// Make quick references to our fields
	var email = document.getElementById('email');
	var message = document.getElementById('message');
	
	// Check each input in the order that it appears in the form!
	if(isEmpty(email, "Please complete 'e-mail' field.")){
		if(isEmpty(message, "Please complete 'question' field.")){
			if(emailValidator(email, "Please enter a valid email address")){
				return true;
			}
		}
	}
	return false;
}

function isEmpty(elem, helperMsg){
	if(elem.value.length == 0){
		//document.getElementById('errormsg').innerText = helperMsg;
		alert(helperMsg);
		elem.focus(); // set the focus to this input
		return true;
	}
	return false;
}

function emailValidator(elem, helperMsg){
	var emailExp = /^[\w\-\.\+]+\@[a-zA-Z0-9\.\-]+\.[a-zA-z0-9]{2,4}$/;
	if(elem.value.match(emailExp)){
		return true;
	}else{
		//alert(helperMsg);
		document.getElementById('errormsg').innerText = helperMsg;
		elem.focus();
		return false;
	}
}*/
