function SetFocus() {
	try {document.EmailForm.realname.focus();}
	catch(iErr) {}
	finally {}
} 
function formValidate(sLanguage, lCategoryID) {
	var oForm = new Object();
	var sMsg = "";
	var oFocus = new Object();
	
	oForm = document.EmailForm;
	
	if (sLanguage == "IT") {
	
	 	if (emptyValidate(oForm.realname) == false)
		{	sMsg += "Il vostro nome va specificato.\n";
			oFocus = oForm.realname;
		}
	 	if ((oForm.phone.value.length == 0) && (oForm.email.value.length == 0))
		{	sMsg += 'Il vostro numero di telefono o il vostro indirizzo email vanno specificati.\n';
			if (oFocus.name == undefined) oFocus = oForm.phone;
		}
	 	if (emailValidate(oForm.email) == false)
		{	sMsg += "Il indirizzo email e non valido.\n";	
			if (oFocus.name == undefined) oFocus = oForm.email;
		}
	 	if (emptyValidate(oForm.message) == false)
		{	sMsg += "Il vostro messaggio va specificato.\n";
			if (oFocus.name == undefined) oFocus = oForm.message;
		}
		if ((lCategoryID == 0) || (lCategoryID == 1)) {		// Property only
			if (oForm.tandc.checked == false)
			{	sMsg += "Vi preghiamo di confermare che avete letto e compreso il nostro Esonero dalle responsabilit\u00E0.\n";
				if (oFocus.name == undefined) oFocus = oForm.tandc;
			}
		}
			
	} else { 
	
	 	if (emptyValidate(oForm.realname) == false)
		{	sMsg += "Name must be specified.\n";
			oFocus = oForm.realname;
		}
	 	if ((oForm.phone.value.length == 0) && (oForm.email.value.length == 0))
		{	sMsg += 'Either your telephone number or email address must be specified.\n';
			if (oFocus.name == undefined) oFocus = oForm.phone;
		}
	 	if (emailValidate(oForm.email) == false)
		{	sMsg += 'Invalid email address format.\n';	
			if (oFocus.name == undefined) oFocus = oForm.email;
		}
	 	if (emptyValidate(oForm.message) == false)
		{	sMsg += "Message must be specified.\n";
			if (oFocus.name == undefined) oFocus = oForm.message;
		}
		if ((lCategoryID == 0) || (lCategoryID == 1)) {		// Property only
			if (oForm.tandc.checked == false)
			{	sMsg += "Please confirm you have read and understood our Disclaimer.\n";
				if (oFocus.name == undefined) oFocus = oForm.tandc;
			}
		}
	}
	
	if (sMsg.length > 0)
	{	alert(sMsg);
		oFocus.focus();
		return false;
	}
	else {return true};
}

