// 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 validaNumber(obj, valor_min, valor_max){
	//check if an value is number and if is on the interval
   if (isNaN(obj.value)){
      alert ("Valores Não Numéricos!");
      return false;
   }

	if (valor_min != 0 && valor_max != 0)
	   // check age range
	   if (parseInt(obj.value) < valor_min || parseInt(obj.value) > valor_max)
	   {
		  alert ("Valores fora do limite estabelecido! min:"+valor_min+" max:"+valor_max);
		  return false;
	   }
	
	return true;
}
//______________________________________________________________
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;

	}		

}