

function checkvalues()
{
	if (window.document.step1.newtitle.value == "")
	{
		alert('Το πεδίο τίτλος πρέπει να συμπληρωθεί');
		return false;
	}
	if (window.document.step1.newdescription.value == "")
	{
		alert('Το πεδίο περιγραφή πρέπει να συμπληρωθεί');
		return false;
	}
	if (window.document.step1.code.checked == true)
	{
		if (window.document.step1.newcode.value=="")
		{
			alert('Το πεδίο κωδικός πρέπει να συμπληρωθεί εφόσον έχει επιλεγεί η ανάθεση κωδικού');
			return false;
		}
		else
		{
			var s = window.document.step1.newcode.value;
			for (var i=0; i<s.length; i++)
			{
				if (!isDigit(s.charAt(i)))
				{
					alert('Το πεδίο κωδικός πρέπει να είναι αριθμός');
					return false;
				}
			}
		}
	}
	return true;
}

function activatecode()
{
	if (window.document.step1.code.checked == true)
		window.document.step1.newcode.disabled = false;
	else
		window.document.step1.newcode.disabled = true;
}

function activateqcode()
{
if (document.update.protectme.value == 'Ναί')
	document.update.qcode.disabled = false;
else
	document.update.qcode.disabled = true;
}

function login_check(){
	if (window.document.login_ch.login.value == "")
	{
		alert('Το πεδίο login πρέπει να συμπληρωθεί');
		return false;
	}
	if (window.document.login_ch.password.value == "")
	{
		alert('Το πεδίο password πρέπει να συμπληρωθεί');
		return false;
	}
	return true;
}

function registration_check(){
	if (window.document.registration_ch.login.value == "")
	{
		alert('Το πεδίο login πρέπει να συμπληρωθεί');
		return false;
	}
	if (window.document.registration_ch.password.value == "")
	{
		alert('Το πεδίο password πρέπει να συμπληρωθεί');
		return false;
	}
	if (window.document.registration_ch.confpassword.value == "")
	{
		alert('Το πεδίο confirm password πρέπει να συμπληρωθεί');
		return false;
	}
	if (window.document.registration_ch.secrquest.value == "")
	{
		alert('Το πεδίο secret question πρέπει να συμπληρωθεί');
		return false;
	}
	if (window.document.registration_ch.email.value == "")
	{
		alert('Το πεδίο e-mail question πρέπει να συμπληρωθεί');
		return false;
	}
	if (window.document.registration_ch.password.value != "" && window.document.registration_ch.confpassword.value != "")
	{
		if(window.document.registration_ch.password.value != window.document.registration_ch.confpassword.value){
			alert('Το πεδίo confirm password δεν είναι ίδιο με το πεδίο password');
			return false;
		}
	}
	return true;
}

function forgotpass_check(){
	if (window.document.forgotpass_ch.login.value == "")
	{
		alert('Το πεδίο login πρέπει να συμπληρωθεί');
		return false;
	}
	if (window.document.forgotpass_ch.secrquest.value == "")
	{
		alert('Το πεδίο secret question πρέπει να συμπληρωθεί');
		return false;
	}
	return true;
}

function goto_valid(name,page){
	var form_name = "window.document." + name;
	var form = eval(form_name);
	form.action = page;
}

function goback(now,check)
{
	switch (now)
	{
		case 'step2':
			window.document.step2.action = 'index.php';
			break;
		case 'step3':
			if (check=='on')
			{
				window.document.step3.action = 'index2.php';
				break;
			}
			else
			{
				window.document.step3.action = 'index.php';
				break;
			}
	}
}

function isempty(form,control,for_alert)
{
	var to_check = "window.document." + form + "." + control+".value";
	//document.write(to_check);
	if (eval(to_check)=="")
	{
		var tmp = 'Το πεδίο '+ for_alert + ' πρέπει να συμπληρωθεί';
		alert(tmp);
		return false;
	}
	else{
		//document.write(to_check);
		return true;
	}
}

function allnotempty(for_alert)
{
	var len = window.document.forms[0].elements.length;
	var to_check = new Array(len);
	for (var i=0; i<len ; i++)
	{
		to_check[i] = "window.document.forms[0].elements["+i+"].value";
		//document.write(to_check[i]+"\n");
	}
	for (var i=0; i<len ; i++)
	{
		document.write(to_check[i]+"<br>");
	}
	for (var i=0; i<to_check.length ; i++)
	{
		if (to_check[i]=="")
		{
			alert ("Not allowed empty value");
			return false;
		}
	}
	return true;
}

function check_field(field)
{
	if (field.value == "")
	{
		var msg = "Το πεδίο " + field.name + " πρέπει να συμπληρωθεί"
		alert(msg);
		field.focus();
		field.blur();
		field.select();
	}
}

function key_check(form_name,text_name){
	var fn = "window.document." + form_name + "." + text_name;
	var form = eval(fn);
	if (form.value == "")
	{
		alert('Το πεδίο key πρέπει να συμπληρωθεί');
		return false;
	}
	return true;
}

function popup(windowW,windowH,url)
{
	var windowX = (screen.width/2)-(windowW/2);
	var windowY = (screen.height/2)-(windowH/2);
	s = "width="+windowW+",height="+windowH;
	var popup_ref = window.open(url,"","location=no,status=no,resizable=yes,"+s);
	popup_ref.moveTo(windowX,windowY);
	popup_ref.location = url;
	popup_ref.focus();
}

function list_digit()
{
	var index = document.addquestion.questionkind.selectedIndex;
	if (document.addquestion.questionkind.options[index].text == 'Απάντησης με λίστα επιλογής από αριθμούς')
	{
		window.document.open();
		var t = document.addquestion.questionkind.options[index].text;
		document.write(t);
		document.close();
	}
}

function isDigit(num) {
	var string="1234567890";
	if (string.indexOf(num) != -1) {
		return true;
	}
	return false;
}

function email_check(){
	if (window.document.email_ch.email.value == "")
	{
		alert('Το πεδίο email πρέπει να συμπληρωθεί');
		return false;
	}
	return true;
}