/*
javascript for moderation area
19/09/02 Michael Horwood (Alfresco Design)
*/

function Login (theForm) {
	var error = 0;
	with (theForm) {
		if ( username.value.length == 0 || password.value.length == 0 ) {
			alert("Please enter your username and password");
			document.form1.username.focus();
		} else {
			theForm.submit();
		}
	}
}

function unCheckAll(theForm, cBoxName) {
	with (theForm) {
		for (var i = 0; i < elements.length; ++i) {
			if (elements[i].name.search(cBoxName) != -1) {
				elements[i].checked = 0;
			}
		}
	}
}
function isValidPwd(pwd){
var AlphaNumeric =/^[a-z0-9]+$/;
	if(pwd.value.length < 6) {
		alert("A valid password must be between 6 and 8 Characters.");
		return false;
	} else if(!AlphaNumeric.test(pwd.value)) {
		alert("A valid password must be lower case and alphanumeric characters. (a-z,0-9)");
		return false;
	}else {return true;}
}
// Check whether string s is empty.
function isEmpty(s) {
   return ((s == null) || (s.length == 0))
}

function isEmail (s) {
 var reEmail = /^.+\@.+\..+$/
 	if (isEmpty(s)) {
       alert("The email is required.");
	} else {
       return reEmail.test(s);
    }
}

//Limit the number of characters per textarea
function textCounter(field,cntfield,maxlimit) {
	if (field.value.length > maxlimit) {// if too long...trim it!
		field.value = field.value.substring(0, maxlimit);		
		alert("Oops! You have exceeded the allowable entry limit!");
	} else {// otherwise, update 'characters left' counter
		cntfield.value = maxlimit - field.value.length;
	}
}