function verifica_recrutamento() {
	if(isEmpty('nome', 'Nome', 'RecrutamentoForm') &&
	isEmpty('email', 'E-mail', 'RecrutamentoForm') &&
	isEmail('email', 'E-mail', 'RecrutamentoForm') &&
	isEmpty('data_nascimento', 'Data de Nascimento', 'RecrutamentoForm') &&
	isEmpty('morada', 'Morada', 'RecrutamentoForm') &&
	isEmpty('curriculo', 'Currículo', 'RecrutamentoForm') &&
	isEmpty('codigo_postal', 'C\xF3digo Postal', 'RecrutamentoForm') &&
	isEmpty('codigo_verificacao', 'C\xF3digo de verificação', 'RecrutamentoForm')) {			

	return true;
	}

	return false;
}

// Base
function psd_showErr(name) {
	var obj = document.getElementById("err_"+name);
	if (!obj) { 
		return;
	}
	obj.style.display = 'block';
}

function psd_hideErr(name) {
	var obj = document.getElementById("err_"+name);
	if (!obj) { 
		return;
	}
	obj.style.display = 'none';
}

// Verify field is empty, false focus it
function isEmpty(field, name, form) {
	
	var argv = isEmpty.arguments;

	if (argv[2]=='' || argv[2]==null)
	{
		argv[2]=0;
	}

	x = document.forms[argv[2]].elements[argv[0]];

	if (x == undefined || x.value == '0' || x.value == '') {
    	psd_showErr(field);
		x.focus();
	    return false;
	}
	else {
    	psd_hideErr(field);	
	}

	return true;
}

//verifies field is numeric
function isNumeric(field, name, form)
{
	x = document.forms[form].elements[field];
	if (x.value == "")
	{
		return true;
	}
	
	if (x.value.match (/[^\d^\.]/))	{
    	psd_showErr(field);
        x.focus();
		return false;
	}
	else {
    	psd_hideErr(field);	
	}

	return true;
}

function isEmail(field, name, form) {
	var argv = isEmail.arguments;
	if (argv[2]=='' || argv[2]==null) {
		argv[2]=0;
	}

	var email = document.forms[argv[2]].elements[argv[0]];
	valid = /^.*\@.*\..*$/i;

	if (email.value.search (valid) == -1) {
		psd_showErr(field+'_2');
		email.focus();
		return false;
	}
	else {
    	psd_hideErr(field+'_2');
	}
	return true;
}
