/* Form validation functions */
function isNotEmpty(elem, popout, helperMsg){
	if(elem.value.length == 0){
		errorMessage(helperMsg);
		elem.focus();
		if(popout)
			popOut(elem);
		return false;
	}
	if(popout)
		popBack(elem);
	return true;
}

function emailValidator(elem, popout, helperMsg){
	var emailExp = /^[\w\-\.\+]+\@[a-zA-Z0-9\.\-]+\.[a-zA-Z0-9]{2,4}$/;
	if(!elem.value.match(emailExp)){
		errorMessage(helperMsg);
		elem.focus();
		if(popout)
			popOut(elem);
		return false;
	}
	if(popout)
		popBack(elem);
	return true;
}

function domainValidator(elem, popout, helperMsg){
	var domainExp = /^http:\/\/([a-zA-Z0-9]*\.)*[a-zA-Z0-9\-]*\.[a-zA-Z0-9]{2,4}$/;
	if(!elem.value.match(domainExp)){
		errorMessage(helperMsg);
		elem.focus();
		if(popout)
			popOut(elem);
		return false;
	}
	if(popout)
		popBack(elem);
	return true;
}

function passwordValidator(elema, elemb, popout, helperMsg){
	if(elema.value != elemb.value){
		errorMessage(helperMsg);
		elema.focus();
		elema.value="";
		elemb.value="";
		if(popout){
			popOut(elema);
			popOut(elemb);
		}
		return false;
	}
	if(popout){
		popBack(elema);
		popBack(elemb);
	}
	return true;
}

function checkBoxValidator(elem, helperMsg){
	if(!elem.checked){
		errorMessage(helperMsg);
		elem.focus();
		return false;
	}
	return true;
}

function popOut(elem){
	elem.style.borderWidth="5px";
	elem.style.fontSize="1.25em";
}

function popBack(elem){
	elem.style.borderWidth="2px";
	elem.style.fontSize="1em";
}

function errorMessage(message){
	showdiv("errorBox");
	document.getElementById("errorBox").innerHTML = message;
}

function showdiv(id) {
	//safe function to show an element with a specified id
		  
	if (document.getElementById) { // DOM3 = IE5, NS6
		document.getElementById(id).style.display = 'block';
	}
	else {
		if (document.layers) { // Netscape 4
			document.id.display = 'block';
		}
		else { // IE 4
			document.all.id.style.display = 'block';
		}
	}
}