function getNome(lang)
{
	if (lang == 'uk')
	{
		return "Invalid NAME";
	} else {
		return "NOME inválido";
	}
}

function getApelido(lang)
{
	if (lang == 'uk')
	{
		return "Invalid LAST NAME";
	} else {
		return "APELIDO inválido";
	}
}

function getTelefone(lang)
{
	if (lang == 'uk')
	{
		return "Invalid PHONE";
	} else {
		return "TELEFONE inválido";
	}
}

function getEmail(lang)
{
	if (lang == 'uk')
	{
		return "Invalid EMAIL";
	} else {
		return "EMAIL inválido";
	}
}

function getPassword(lang)
{
	if (lang == 'uk')
	{
		return "The PASSWORD must have at least 4 characters";
	} else {
		return "A PASSWORD deve conter pelo menos 4 caracteres";
	}
}

function getConfPassword(lang)
{
	if (lang == 'uk')
	{
		return "The PASSWORD CONFIRMATION must have at least 4 characters";
	} else {
		return "A CONFIRMAÇÃO da PASSWORD deve conter pelo menos 4 caracteres";
	}
}

function getCompPassword(lang)
{
	if (lang == 'uk')
	{
		return "The PASSWORD and CONFIRMATION have different values";
	} else {
		return "A PASSWORD e a sua CONFIRMAÇÃO têm valores diferentes";
	}
}

function getMachineID(lang)
{
	if (lang == 'uk')
	{
		return "The REGISTRATION NUMBER must be in the following format: dddd-dddd-dddd-dddd";
	} else {
		return "O NÚMERO DE REGISTO deve estar no seguinte formato: dddd-dddd-dddd-dddd";
	}
}

function getPergunta(lang)
{
	if (lang == 'uk')
	{
		return "The QUESTION must have at least 1 character";
	} else {
		return "A PERGUNTA deve conter pelo menos 1 caracter";
	}
}

function getResposta(lang)
{
	if (lang == 'uk')
	{
		return "The ANSWER must have at least 1 character";
	} else {
		return "A RESPOSTA deve conter pelo menos 1 caracter";
	}
}

function getEmailConf(lang)
{
	if (lang == 'uk')
	{
		return "Your confirmation email is different from the email you filled in the form.\n\nPlease verify if the confirmation email is correct or go back and correct the email in the form.";
	} else {
		return "O email de confirmação não é igual ao email colocado no formulário.\n\nVerifique se o email de confirmação está correcto ou volte atrás para corrigir o email do formulário.";
	}
}

function validateRegister(lang){
	var flag = true;
	
	var str;

	if (lang == 'uk')
	{
		str = "The following problems(s) were found:\n\n";
	}
	else
	{
		str = "Encontrado(s) o(s) seguinte(s) problema(s):\n\n";
	}

	if (!checkText(document.getElementById("firstName").value)){
		str += getNome(lang) + "\n";
		flag = false;
	}
	
	if (!checkText(document.getElementById("lastName").value)){
		str += getApelido(lang) + "\n";
		flag = false;
	}
	
	if ((document.getElementById("phone").value != "") && (!checkPhone(document.getElementById("phone").value))){
		str += getTelefone(lang) + "\n";
		flag = false;
	}
	
	if (!checkEmail(document.getElementById("email").value)){
		str += getEmail(lang) + "\n";
		flag = false;
	}
	
	if (!checkPassw(document.getElementById("password").value)){
		str += getPassword(lang) + "\n";
		flag = false;
	}

	if (!checkPassw(document.getElementById("passwordConf").value)){
		str += getConfPassword(lang) + "\n";
		flag = false;
	}

	if (document.getElementById("password").value != document.getElementById("passwordConf").value){
		str += getCompPassword(lang) + "\n";
		flag = false;
	}
		
	var machineID = document.getElementById("macID1").value +'-'+ document.getElementById("macID2").value
	 		+'-'+ document.getElementById("macID3").value +'-'+ document.getElementById("macID4").value;
	if (!checkMachineID(machineID)){
		str += getMachineID(lang) + "\n";
		flag = false;
	}
	
	if (document.getElementById("question").value.length < 1){
		str += getPergunta(lang) + "\n";
		flag = false;
	}
	
	if (document.getElementById("answer").value.length < 1){
		str += getPergunta(lang) + "\n";
		flag = false;
	}

	if (!flag){
		alert (str);
		return false;
	}

	return true;
}

function validateConfirm(lang)
{
	if(document.getElementById("email").value != document.getElementById("emailconf").value && document.getElementById("CMD").value != "")
	{
		alert(getEmailConf(lang));
		//document.getElementById("showEmail").value = "1";
		//document.getElementById("CMD").value = "";

		return false;
	}

	return true;
}

