function formCheck(formobj,data){
	// Enter name of mandatory fields
	var fieldRequired = Array("vnev", "var", "emil", "szov");
	// Enter field description to appear in the dialog box
	var fieldDescription = Array("Név", "Város", "E-mail", "Üzenet");
	// dialog message
	var alertMsg = "Kérjük töltse ki:\n";
	var alertMsgX = "";

	var l_Msg = alertMsg.length;

	for (var i = 0; i < fieldRequired.length; i++){
		var obj = formobj.elements[fieldRequired[i]];
		if (obj){
			switch(obj.type){
			case "select-one":
				if (obj.selectedIndex == 0 || obj.options[obj.selectedIndex].text == ""){
					alertMsgX = " - " + fieldDescription[i] + "\n";
				}
				break;
			case "select-multiple":
				if (obj.selectedIndex == -1){
					alertMsg += " - " + fieldDescription[i] + "\n";
				}
				break;
			case "text":
			case "textarea":
				if (obj.value == "" || obj.value == null){
					alertMsg += " - " + fieldDescription[i] + "\n";
				}
				break;
			default:
			}
			if (obj.type == undefined){
				var blnchecked = false;
				for (var j = 0; j < obj.length; j++){
					if (obj[j].checked){
						blnchecked = true;
					}
				}
				if (!blnchecked){
					alertMsg += " - " + fieldDescription[i] + "\n";
				}
			}
		}
	}
	alertMsg += alertMsgX;

	if (alertMsg.length == l_Msg){
		return true;
	}else{
		alert(alertMsg);
		return false;
	}
}

// Email Validation.
function check_email(e) {
ok = "1234567890qwertyuiop[]asdfghjklzxcvbnm.@-_QWERTYUIOPASDFGHJKLZXCVBNM";

for(i=0; i < e.length ;i++){
if(ok.indexOf(e.charAt(i))<0){
return (false);
}
}

if (document.images) {
re = /(@.*@)|(\.\.)|(^\.)|(^@)|(@$)|(\.$)|(@\.)/;
re_two = /^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/;
if (!e.match(re) && e.match(re_two)) {
return (-1);
}
}
} //end of check_email



function check_email_in_form(f) { // f is the form (passed using the this keyword)
// check the email address ( the exclamation means "not" )
if(!check_email(f.email.value)){
alert("Kérjük ellenőrizze e-mail címét.");
f.email.focus();
// if the browser is Netscape 6 or IE
if(document.all || document.getElementByID){
// change the color of text field
f.email.style.background = "yellow";
}
// make sure the form is not submitted
return false;
}
} // end of check_email_in_form

function right_fill_out(form_id,data) {
right = (formCheck(form_id,data)) && (check_email_in_form(form_id));
return right;
} // end of right_fill_out

