function checkMail(email) {
	var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/
	if (filter.test(email)) return true
	else return false
}

function trim(sString) {
	while (sString.substring(0,1) == ' ') {
		sString = sString.substring(1, sString.length);
	}
	while (sString.substring(sString.length-1, sString.length) == ' ') {
		sString = sString.substring(0,sString.length-1);
	}
	return sString;
}

function mailCheck() {
	sender = trim(document.getElementById('sender').value)
	email = trim(document.getElementById('email').value)
	message = trim(document.getElementById('message').value)
	
	normalColor = '#d1b378';
	highlightColor = '#ff1515';
	
	document.getElementById('sender').style.borderColor = normalColor;
	document.getElementById('email').style.borderColor = normalColor;
	document.getElementById('message').style.borderColor = normalColor;		
		
	err = false;
	myFocus = null;
	if (sender == "") {
		document.getElementById('sender').style.borderColor = highlightColor;
		if (myFocus == null) myFocus = document.getElementById('sender');		
		err = true;		
	}
	if (email == "") {
		document.getElementById('email').style.borderColor = highlightColor;
		if (myFocus == null) myFocus = document.getElementById('email');
		err = true;	
	}
	if (checkMail(email) == false) {	
		document.getElementById('email').style.borderColor = highlightColor;	
		if (myFocus == null) myFocus =  document.getElementById('email');
		err = true;	
	}
	if (message == "") {
		document.getElementById('message').style.borderColor = highlightColor;
		if (myFocus == null) myFocus = document.getElementById('message');
		err = true;	
	}
	if (myFocus != null) myFocus.focus();
	return !err;	
}

function logout() {
	if (confirm("Biztosan kijelentkezel?")) {	
		document.location.href = "index.php?op=logout"		
	}	
}
