// JavaScript Document
function showAd(n) {
	if (n.style.visibility=='visible') {
		n.style.position='absolute';
		n.style.visibility='hidden';
	}
	else {
		n.style.position='relative';
		n.style.visibility='visible';	
	}
}
//-----------------------------------------------------------------------------------------------
function checkSearchForm(x) {
	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.R1[0].checked) {
			x.target='_self';
			x.pesq.value=6
			x.action='result3.asp'; }
		if (x.R1[1].checked) {
			x.target='_blank';
			x.pesq.value=1;
//			x.action='http://e-lista.pt/searchresults1.asp';
			x.action='http://www.e-lista.pt/default.asp?page=results&strToSearch='+x.toSearch.value+'&pag=1';
			}
		return true;
		}
}
//-----------------------------------------------------------------------------------------------
function checkAddRegForm(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 nş telefone'); returnvalue=false; theForm.telefone.focus(); }
	if (theForm.empresa.value.length<2) { alert('É necessário o nome da empresa!'); returnvalue=false; theForm.empresa.focus(); }
	if (returnvalue==true) {
		window.open("","wconf","height=300,width=300,menubar=no,resizable=no,status=0,left=350,top=250,scrollbars=0");
		}
	return returnvalue;
}
//-----------------------------------------------------------------------------------------------
function checkp2Form() {
	if ((formPD.C1.checked==false) && (formPD.C2.checked==false) && (formPD.C3.checked==false) && (formPD.C4.checked==false)) {
		alert('Tem que escolher pelo menos uma zona!');
		return false;
		}
	else
		{ return true; }
}
//-----------------------------------------------------------------------------------------------
function checkNewAdForm(x) {
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('6a linha do texto com caracteres a mais (max. 40)');
		x.linha6.focus();
		trueorfalse=false;
		}
	if ( x.linha5.value.length>40 ) {
		alert('5a linha do texto com caracteres a mais (max. 40)');
		x.linha5.focus();
		trueorfalse=false;
		}
	if ( x.linha4.value.length>40 ) {
		alert('4a linha do texto com caracteres a mais (max. 40)');
		x.linha4.focus();
		trueorfalse=false;
		}
	if ( x.linha3.value.length>40 ) {
		alert('3a linha do texto com caracteres a mais (max. 40)');
		x.linha3.focus();
		trueorfalse=false;
		}
	if ( x.linha2.value.length>40 ) {
		alert('2a linha do texto com caracteres a mais (max. 40)');
		x.linha2.focus();
		trueorfalse=false;
		}
	if ( x.linha1.value.length>40 ) {
		alert('1a linha do texto com caracteres a mais (max. 40)');
		x.linha1.focus();
		trueorfalse=false;
		}		
	return trueorfalse;
}
//-----------------------------------------------------------------------------------------------
// newAd
function charcount(obj) {
	if (obj.name=='titulo') { t1.innerText=obj.value.length+'/50'; }
	if (obj.name=='linha1') { l1.innerText=obj.value.length+'/40'; }
	if (obj.name=='linha2') { l2.innerText=obj.value.length+'/40'; }
	if (obj.name=='linha3') { l3.innerText=obj.value.length+'/40'; }
	if (obj.name=='linha4') { l4.innerText=obj.value.length+'/40'; }
	if (obj.name=='linha5') { l5.innerText=obj.value.length+'/40'; }
	if (obj.name=='linha6') { l6.innerText=obj.value.length+'/40'; }
}
//-----------------------------------------------------------------------------------------------
function checkNewUserForm(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 checkpw(x) {
	if (x.pw_new.value != x.pw_conf.value) {
		alert('Erro na password!');
		return false;
	}
	else {
		return true;
	}
}
//-----------------------------------------------------------------------------------------------
function addBookmark() {
	if (document.all) {
		window.external.AddFavorite( document.location, document.title )
	}
}
//-----------------------------------------------------------------------------------------------
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;
}
//-----------------------------------------------------------------------------------------------
function display_info(id) {
	var leftpos = ( screen.width - 750 ) / 2;
	window.open('info.asp?id='+id,'_blank','height=550,width=750,menubar=no,resizable=no,status=0,left='+leftpos+',top=0,scrollbars=1');
	}
//-----------------------------------------------------------------------------------------------