// JavaScript Document__________________________________________


function submit_newsletter() 
{

aux=0;
if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(f_subscrever.email_newsletter.value))
   	 {
     return true;            
	 }

	if (aux==0)
	{
		alert("Endereço de E-mail inválido!")
            f_subscrever.email_newsletter.focus();
    		return false;
	}

return true;
}

function aceitaNums_telf()
{
	//alert(event.keyCode)// pra saber kal a tecla ke se carrega
	if (event.keyCode != 43) // tecla +
		{
		if ((event.keyCode < 48) || (event.keyCode > 57)  )
			event.returnValue = false
		}
}
//______________________________________________________________
function valid_Email(email, msg){			

	email2='%'+email+'%';

	var re=/\%[a-z\-\_0-9]+(\.[a-z\-\_0-9]+)*@[a-z\-\_0-9]+(\.[a-z\-\_0-9]+)*\%/i;

	if (!email2.match(re)) {

		return false;

	}	

	var tam = email.length;

	var varA=0;

	var varB=0;

	for (i=0;i < tam;i++){

		caracter = email.substr(i,1);

		if(caracter == '@' && varA==0){

			varA = i;				

		}

		if(caracter == '.' && varA>0 && varB==0){

			varB = i;				

		}		

	}

	var str1 = email.substr(0,varA);

	var str2 = email.substr(varA+1,varB-(varA+1));

	var str3 = email.substr(varB+1,tam);

			

	if(str1.length < 2 || str2.length < 2 || str3.length < 2){

		return false;

	}

	return true;

	}		
//___________________________________________________________________________

function valid(){					

	if (document.forms.Contacto.nome.value.length < 3){

		alert('Por favor introduza o seu  nome!');

		return false;				

	}

	if (!valid_Email(document.forms.Contacto.email.value,'O Email que indicou não é válido.') || document.forms.Contacto.email.value.length < 7) {

		alert('Por favor introduza um e-mail válido!');

		return false;					

	}

	if (document.forms.Contacto.assunto.value.length < 5) {

		alert('Por favor introduza sua mensagem!');

		return false;

	}		

}

//Create a center popup
function createwindow(url, largura, altura,Scroll,nome){
	esq = (screen.availWidth - largura ) / 2 ;
	cim  = (screen.availHeight - altura) / 2 -10 ;	
	janela = window.open(url,nome,"toolbar=no,width="+ largura + ",height=" + altura + ",left=" + esq + ",top=" + cim + ",scrollbars="+ Scroll +",directories=no,status=no,resize=no,menubar=no")
	return janela;
} 

/*
function toggleLayer(whichLayer,AlterLayer){
	
	if (document.getElementById){
		// this is the way the standards work
		var style2 = document.getElementById(whichLayer).style;
		var style3 = document.getElementById(AlterLayer).style;
		style2.display = style2.display? "":"block";
	}else if (document.all){
		// this is the way old msie versions work
		var style2 = document.all[whichLayer].style;
		style2.display = style2.display? "":"block";
	}else if (document.layers){
		// this is the way nn4 works
		var style2 = document.layers[whichLayer].style;
		style2.display = style2.display? "":"block";
	}
	style3.display = "";
}
*/
function toggleLayer(whichLayer){
	
	if (document.getElementById){
		// this is the way the standards work
		var style2 = document.getElementById(whichLayer).style;
		
		style2.display = style2.display? "":"block";
	}else if (document.all){
		// this is the way old msie versions work
		var style2 = document.all[whichLayer].style;
		style2.display = style2.display? "":"block";
	}else if (document.layers){
		// this is the way nn4 works
		var style2 = document.layers[whichLayer].style;
		style2.display = style2.display? "":"block";
	}
	
}