// JavaScript Document
function checkSearchForm(x) {
	
	if ( x.toSearch.value == "palavra ou frase" ) {
		
		return false;
		
	}
	
	if (x.toSearch.value.length<2) {

		alert('Mínimo 2 caracteres!');
		x.toSearch.focus();
		return false;
		
	} else {
		
		x.n.value=x.toSearch.value;
		
		if (x.D1.value==0) {
			x.target='_self';
			x.action='default.asp';
		}

		if (x.D1.value==1) {
			x.target='_blank';
			x.action='http://www.e-lista.pt/default.asp?page=results&strToSearch='+x.toSearch.value+'&pag=1';
		}

		return true;
	}
}
//-----------------------------------------------------------------------------------------
function checkPW(theForm) {
	if (theForm.pw_new.value != theForm.pw_conf.value) {
		alert('Erro na password!');
		return false;
	}
	else {
		return true;
	}
}
//-----------------------------------------------------------------------------------------
function checkAdForm(x) { // nao confundir com checkAddForm
var trueorfalse=true;
	if ( x.titulo.value=="" || x.titulo.value==null || x.titulo.value.length<3 ) {
		alert('O campo <título> é obrigatório!');
		x.titulo.focus();
		trueorfalse=false;
		}
	if ( x.linha6.value.length>40 ) {
		alert('6ª linha do texto com caracteres a mais (max. 40)');
		x.linha6.focus();
		trueorfalse=false;
		}
	if ( x.linha5.value.length>40 ) {
		alert('5ª linha do texto com caracteres a mais (max. 40)');
		x.linha5.focus();
		trueorfalse=false;
		}
	if ( x.linha4.value.length>40 ) {
		alert('4ª linha do texto com caracteres a mais (max. 40)');
		x.linha4.focus();
		trueorfalse=false;
		}
	if ( x.linha3.value.length>40 ) {
		alert('3ª linha do texto com caracteres a mais (max. 40)');
		x.linha3.focus();
		trueorfalse=false;
		}
	if ( x.linha2.value.length>40 ) {
		alert('2ª linha do texto com caracteres a mais (max. 40)');
		x.linha2.focus();
		trueorfalse=false;
		}
	if ( x.linha1.value.length>40 ) {
		alert('1ª linha do texto com caracteres a mais (max. 40)');
		x.linha1.focus();
		trueorfalse=false;
		}		
	return trueorfalse;
}
//-----------------------------------------------------------------------------------------
function charcount(obj) {
	if (obj.name=='titulo') { t1.innerText=obj.value.length; }
	if (obj.name=='linha1') { l1.innerText=obj.value.length; }
	if (obj.name=='linha2') { l2.innerText=obj.value.length; }
	if (obj.name=='linha3') { l3.innerText=obj.value.length; }
	if (obj.name=='linha4') { l4.innerText=obj.value.length; }
	if (obj.name=='linha5') { l5.innerText=obj.value.length; }
	if (obj.name=='linha6') { l6.innerText=obj.value.length; }
}
//-----------------------------------------------------------------------------------------
function checkpavform() {
	var returnvalue=true;
	if (formpa.loc.value.length<2) {
		alert('Tem de indicar a localidade!');
		formpa.loc.focus();
		returnvalue = false;
		}
	else
		{ returnvalue = true; }
	return returnvalue;
}
//-----------------------------------------------------------------------------------------
function checkRegForm(x) {
var trueorfalse=true;
	if ( x.email.value=="" || x.email.value==null || x.email.value.length<3 || 	x.email.value.indexOf("@")<0 ) {
		alert('O campo <email> é obrigatório!');
		x.email.focus();
		trueorfalse=false;
		}

	if (x.nome.value.length<2) {
		alert('O campo <nome> é obrigatório!');
		trueorfalse=false;
		x.nome.focus();
		}
	return trueorfalse;
}
//-----------------------------------------------------------------------------------------
function showAd(n) {
	if ( n.style.visibility == 'hidden' ) {
		n.style.visibility='visible';
		n.style.position='relative';
		}
	else
		{
		n.style.visibility='hidden';
		n.style.position='absolute';
		}
}
//-----------------------------------------------------------------------------------------
function checkAddForm(theForm) {
	var returnvalue=true;
	theForm.actividade.value = theForm.cod[theForm.cod.selectedIndex].text;
	if (theForm.responsavel.value.length < 2) {
		alert('É necessário o nome do responsável!');
		returnvalue=false;
		theForm.responsavel.focus();
	}
	if (theForm.telefone.value.length < 9) {
		alert('É necessário o no telefone');
		returnvalue=false;
		theForm.telefone.focus();
	}
	if (theForm.empresa.value.length < 2) {
		alert('É necessário o nome da empresa!');
		returnvalue=false;
		theForm.empresa.focus();
	}
	return returnvalue;
}
//-----------------------------------------------------------------------------------------
function checkNLForm(theForm) {
	var returnvalue = true;
	if ( theForm.nl_mail.value=="" || theForm.nl_mail.value.indexOf("@")<0 ) {
		returnvalue=false;
		alert('e-mail incorrecto');
		theForm.nl_mail.focus();
	}
	if (theForm.nl_nome.value=="") {
		returnvalue=false;
		alert('Falta o nome');
		theForm.nl_nome.focus();
		}		
	return returnvalue;
}
//-----------------------------------------------------------------------------------------
//-----------------------------------------------------------------------------------------