
function checkform_select(x, y)
{
	if(document.getElementById(x)) {
		a=document.getElementById(x).options[document.getElementById(x).selectedIndex].value;
		if (a=="-1") {alert ("Παρακαλώ συμπληρώστε το πεδίο \""+y+"\"."); return false;}
		return true;
	}
	else {
		return false;
	}
}

function checkform_name(x, y)
{
	if(document.getElementById(x)) {
		a=document.getElementById(x).value;
		if (a=="") {alert ("Παρακαλώ συμπληρώστε το πεδίο \""+y+"\"."); return false;}
		return true;
	}
	else {
		return false;
	}
}

function checkform_name2(x, y, l)
{
	if(document.getElementById(x)) {
		a=document.getElementById(x).value;
		if (a=="") {alert ("Παρακαλώ συμπληρώστε το πεδίο \""+y+"\"."); return false;}
		if (a.length<l) {alert ("Tο πεδίο \""+y+"\" πρέπει να είναι τουλάχιστον "+l+" χαρακτήρες."); return false;}
		return true;
	}
	else {
		return false;
	}
}

function checkform_name3(x, y, l)
{
	if(document.getElementById(x)) {
		a=document.getElementById(x).value;
		a=trim_str(a);
		if (a=="") {alert ("Παρακαλώ συμπληρώστε το πεδίο \""+y+"\"."); return false;}
		if (a.length<l) {alert ("Tο πεδίο \""+y+"\" πρέπει να είναι τουλάχιστον "+l+" χαρακτήρες."); return false;}
		return true;
	}
	else {
		return false;
	}
}


function checkform_email(x, y, z)
{
	if(document.getElementById(x)) {
		a=document.getElementById(x).value;
		if (a=="" && z==true) return true;
		if (a=="") {alert ("Παρακαλώ συμπληρώστε το πεδίο \""+y+"\"."); return false;}
		if (a.length<6) {alert ("Το email που εισάγατε στο πεδίο \""+y+"\" δεν είναι έγκυρο."); return false;}
		if (a.lastIndexOf(".")<3) {alert ("Το email που εισάγατε στο πεδίο \""+y+"\" δεν είναι έγκυρο."); return false;}
		if (a.indexOf("@")<1) {alert ("Το email που εισάγατε στο πεδίο \""+y+"\" δεν είναι έγκυρο."); return false;}
		if (a.lastIndexOf(".")-a.lastIndexOf("@")<2) {alert ("Το email που εισάγατε στο πεδίο \""+y+"\" δεν είναι έγκυρο."); return false;}
		if (a.lastIndexOf("@")!=a.indexOf("@")) {alert ("Το email που εισάγατε στο πεδίο \""+y+"\" δεν είναι έγκυρο."); return false;}
		if (a.lastIndexOf(".")==a.length-1) {alert ("Το email που εισάγατε στο πεδίο \""+y+"\" δεν είναι έγκυρο."); return false;}
		if (a.indexOf(" ")>-1) {alert ("Το email που εισάγατε στο πεδίο \""+y+"\" δεν είναι έγκυρο.\nΠαρακαλώ μήν χρησιμοποιήτε διαστήματα."); return false;}
		return true;
	}
	else {
		return false;
	}
}

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