function Trim(s) {
	// Remove leading spaces and carriage returns
	while ((s.substring(0,1) == ' ') || (s.substring(0,1) == '\n') || (s.substring(0,1) == '\r')) {
		s = s.substring(1,s.length);
	}

	// Remove trailing spaces and carriage returns
	while ((s.substring(s.length-1,s.length) == ' ') || (s.substring(s.length-1,s.length) == '\n') || (s.substring(s.length-1,s.length) == '\r')) {
		s = s.substring(0,s.length-1);
	}

	return s;
}

function isEnglish(str) {
	if (str.search(/^([A-Za-z0-9]|\s|-|\,|\.|\&|\%|\!|\?|\(|\)|\[|\]|\+|\=|\$|\{|\}|\#|\;|\:|\@|\||\*|\/|\\|\<|\>|\~|\^|\'|\|")*$/)==-1 ) return false;
	return true;
}

function isGreek(str) {
	if (str.search(/^([��-���0-9]|\s|-|\,|\.|\&|\%|\!|\?|\(|\)|\[|\]|\+|\=|\$|\{|\}|\#|\;|\:|\@|\||\*|\/|\\|\<|\>|\~|\'|\")*$/)==-1 ) return false;
	return true;
}

function isFloat(str) {
	if (str.search(/^(-)?([0-9])*((\.)([0-9])+)?$/)==-1) return false;
	return true;
}

function isDigit(str) {
	if (str.search(/^(-)?([0-9])*$/)==-1) return false;
	return true;
}

function isTelephone(str) {
	if (str.search(/^([0-9]|\s|-|\+|\(|\)|\/)*$/)==-1) return false;
	return true;
}

function isEmail(str) {
	if (str.search(/^[A-Za-z0-9_]+((-[A-Za-z0-9_]+)|(\.[A-Za-z0-9_]+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/)==-1) return false;
	return true;
}

function validRequired(formField, fieldLabel, lang) {
	if (Trim(formField.value) == "") {
		if (lang=='gr') alert('Παρακαλώ εισάγετε ' + fieldLabel +'.');
		else alert('Please Enter ' + fieldLabel +'.');
		formField.focus();
		return false;
	}
	return true;
}

function validEmail(formField, fieldLabel, required, lang) {
	if (required && !validRequired(formField, fieldLabel, lang)) return false;
	if ( !isEmail(Trim(formField.value)) ) {
		if (lang=='gr') alert("Η διεύθυνση Email δέν ειναι σωστή ");
		else alert("Please Enter a Correct E-mail Address");

		formField.focus();
		return false;
	}
	return true;
}

function NewWindow(mypage, myname, w, h, myscroll) {
	var winl = (screen.width - w) / 4;
	var wint = (screen.height - h) / 4;
	var newWindow
	winprops = 'height='+h+',width='+w+',top=0,left=0,scrollbars='+myscroll;
	win = window.open(mypage, myname, winprops)
	if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }
	win.focus();
}

function SumbitOrderForm(){
	document.OrderForm.submit();
}