function eCheckEMail(sn){
		s= sn.value;
		if (s.indexOf("@") == -1) return false;
		if (s.indexOf(".") == -1) return false;
		at=false;
		dot=false;
		for (var i = 0; i < s.length; i++) {
				ch = s.substring(i, i + 1)
				if ((ch >= "A" && ch <= "Z") || (ch >= "a" && ch <= "z")
								|| (ch == "@") || (ch == ".") || (ch == "_")
								|| (ch == "-") || (ch >= "0" && ch <= "9")) {
								if (ch == "@"){
									if (at) return false;
									else at=true;
								}
								if ((ch==".") && at)
									 dot=true;
				}
				else return false;
		}
	 return dot;
}

function CheckEMail(theForm){
//	 for(var i=1; i<CheckEMail.arguments.length; i++) {
				 if (!eCheckEMail(theForm.messemail)){
						alert("Невалиден email!");
						theForm.messemail.focus();
						return false;
				}
//	 }
	 return true;
}

function CheckRequiredFields(theForm)
{
	 for(i=1; i<CheckRequiredFields.arguments.length; i++) {
//				alert(i+"-- "+theForm.elements[CheckRequiredFields.arguments[i]].value);
				if(theForm.elements[CheckRequiredFields.arguments[i]].value==""){
						alert("Непопълнено поле!");
						theForm.elements[CheckRequiredFields.arguments[i]].focus();
						return false;
				}
	 }
	 return true;
}

function CheckForm(theForm){
		 if(CheckRequiredFields(theForm, 0, 1, 2, 3))
		 if(CheckEMail(theForm))
					return true;
	return false;
}
