function TrimString(input_string) {
	input_string=input_string.replace(/&nbsp;/, " ");
	while (input_string.indexOf("  ")!=-1) input_string=input_string.replace(/  /, " ");
	input_string=input_string.replace(/^ /, "");
	input_string=input_string.replace(/ $/, "");
	return input_string;
}

function InputText(input_string) {
	input_string=TrimString(input_string);
	input_string=input_string.replace(String.fromCharCode(337), String.fromCharCode(245));
	input_string=input_string.replace(String.fromCharCode(336), String.fromCharCode(213));
	input_string=input_string.replace(String.fromCharCode(369), String.fromCharCode(251));
	input_string=input_string.replace(String.fromCharCode(368), String.fromCharCode(219));
	input_string=input_string.replace(String.fromCharCode(245), "o");
	input_string=input_string.replace(String.fromCharCode(213), "O");
	input_string=input_string.replace(String.fromCharCode(251), "u");
	input_string=input_string.replace(String.fromCharCode(219), "U");
	return input_string;
}

function ValidUsername(username) {
	if (username=="") return true;
	regular_expression=/^[a-z0-9αινσφυϊόϋρΰθοςη ]{3,15}$/i;
	return (regular_expression.test(username));
}

function ValidPassword(password) {
	if (password=="") return true;
	regular_expression=/^[a-z0-9αινσφυϊόϋρΰθοςη]{5,15}$/i;
	return (regular_expression.test(password));
}

function ValidEmail(email) {
	if (email=="") return true;

	if (email.indexOf("@")==-1) return false;
	if (email.indexOf("--")!=-1) return false;

	email=email.split("@");
	if (email[2]!=null) return false;

	regular_expression=/^[a-z0-9_\+\.\!\&\-]+$/i;
	if (!regular_expression.test(email[0])) return false;

	regular_expression=/^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$/;
	if (regular_expression.test(email[1])) return true;

	last_dot=email[1].lastIndexOf(".");
	domain=email[1].substr(0, last_dot);
	territory=email[1].substr(last_dot+1, email[1].length);

	regular_expression=/^[a-z0-9αινσφυϊόϋ][a-z0-9αινσφυϊόϋ_\.\-]*[a-z0-9αινσφυϊόϋ]$/i;
	if (!regular_expression.test(domain)) return false;

	regular_expression=/^[a-z]{2,4}$/i;
	if (!regular_expression.test(territory)) return false;

	return true;
}

function ValidZip(zip) {
	if (zip=="") return true;
	regular_expression=/^[a-z0-9-]{4,10}$/i;
	return (regular_expression.test(zip));
}

function ValidDate(month, day, year) {
	if (month==0 && day==0) return true;
	if (month<1 || month>12 || day<1 || day>31) return false;
	february_days = (year%4==0 && year%100!=0 || year%400==0) ? 29 : 28;
	if (month==2 && day>february_days) return false;
	else if ((month==4 || month==6 || month==9 || month==11) && day>30) return false;
	return true;
}

mt="34#19#29#33#44#36";

function EMail(email) {
	alphabet = new Array("@", " ", ".", "!", "-", "_", "&#34;", "<", ">", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "a", "α", "b", "c", "d", "e", "ι", "f", "g", "h", "i", "ν", "j", "k", "l", "m", "n", "o", "σ", "φ", "υ", "p", "q", "r", "s", "t", "u", "ϊ", "ό", "ϋ", "v", "w", "x", "y", "z", "A", "Α", "B", "C", "D", "E", "Ι", "F", "G", "H", "I", "Ν", "J", "K", "L", "M", "N", "O", "Σ", "Φ", "Υ", "P", "Q", "R", "S", "T", "U", "Ϊ", "ά", "Ϋ", "V", "W", "X", "Y", "Z");
	email_array=email.split("#");
	email="";
	for (i=0; i<email_array.length; i++) {
		j=email_array[i];
		email+=alphabet[j];
	}
	return email;
}
