//Function to check form is filled in correctly before submitting
window.status=".: A Póvoa de Varzim mais perto de si - www.povoadevarzim.com.pt :.";

function open_window(votre_page)
{
	var hauteur_popup=400;
	var H = (screen.height - hauteur_popup) / 2;
	var largeur_popup=600;
	var L = (screen.width - largeur_popup) / 2;
	pop_up = window.open(votre_page,"Popup","status=yes,scrollbars=yes,resizable=yes,height="+hauteur_popup+",width="+largeur_popup+",top="+H+",left="+L);

}

<!--
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}
//-->


function open_window1(theURL,winName,features,largura,altura)
{
	var H = (screen.height - altura) / 2;
	var L = (screen.width - largura) / 2;
	pop_up = window.open(theURL,"winName","status=no,scrollbars=yes,resizable=yes,height="+altura+",width="+largura+",top="+H+",left="+L);

}

function verificar_pesquisa() {
var themessage = "Para fazer a pesquisa precisa de preencher o campo de: ";
if (document.form.q.value==""){
themessage = themessage + " Pesquisa";
alert(themessage);
return false;}

else {

return true;
   }
}

function Contar1() {
	document.form1.conta.value = document.form1.descricao1.value.length;
}


function valida () {

	//Intialise variables
	var errorMsg = "";
	var errorMsgLong = "";
	var erro="";
	//Verifica se o comprimento da descrição está correcto
	if (document.form1.descricao1.value.length > 200){
		errorMsgLong += "\n- A sua descricação tem " + document.form1.descricao1.value.length + " caracteres, tem que colocar menos que 200.";
	}
	//Verifica o comprimento das palavras na descrição
	palavras = document.form1.descricao1.value.split(' ');
	for (var loop = 0; loop <= palavras.length - 1; ++loop){
		if (palavras[loop].length > 30){
		errorMsgLong += "\n- Uma palavra na sua descrição contém " + palavras[loop].length + " caracteres. Corrija o problema.";
		}	
	}	
	//Verifica a existência de TAGS na descrição
	for (var count = 0; count <= 3; ++count){
		if ((document.form1.elements[count].value.indexOf("<", 0) >= 0) && (document.form1.elements[count].value.indexOf(">", 0) >= 0)){
			errorMsgLong += "\n- HTML tags não são permitidas, remova todas as HTML tags.";
		}			
	}
	
	//If there is aproblem with the form then display an error
	if ((errorMsg != "")||(errorMsgLong != "")){
		msg = "________________________________________________________\n\n";
		msg += "\tOcorreram o seguintes erros no seu formulário:         \n\n";
		msg += "-A Descrição que inseriu não pode ser adicionada pois não é válida.\n";
		msg += "Por favor corrija o problema.\n";
		msg += "_______________________________________________________________\n";
				
		errorMsg += alert(msg + errorMsg + errorMsgLong);
		return false;
	}
	if(erro!="")
	{
		alert(erro);
		return false;
	}
	
	return true;
}



