// Trim leading and trailing spaces
function Trim(strToTrim) {
	while(strToTrim.charAt(0)==' '){strToTrim = strToTrim.substring(1,strToTrim.length);}
	while(strToTrim.charAt(strToTrim.length-1)==' '){strToTrim = strToTrim.substring(0,strToTrim.length-1);}
	return strToTrim;
}

//validate email address
function EmailIsValid(str){
	var emailAddressFormat = /^[a-zA-Z0-9._-]+@([a-zA-Z0-9.-]+\.)+[a-zA-Z0-9.-]{2,3}$/;
	if (!(emailAddressFormat.test(str))){
		return false;
	}
	return true;
}

// Validate search form
function CheckSearch(frm)
{
	if (Trim(frm.key.value) == "") { alert("Va rugam introduceti cel putin un cuvant cheie!"); frm.key.focus(); return false; }
	if ((Trim(frm.key.value).length < 3) || (Trim(frm.key.value).length > 50)) { alert("Cautarea trebuie sa contina intre 3 si 50 de caractere!"); frm.key.focus(); return false; }
	return true;
}