// JavaScript Document

//Visualiza a foto ampliada em popup
//Usar o link javascript:verimg('caminho/nome.jpg')
		function verimg(img){
		  foto1= new Image();
		  foto1.src=(img);
		  Controlla(img);
		}
		function Controlla(img){
		  if((foto1.width!=0)&&(foto1.height!=0)){
			viewFoto(img);
		  }
		  else{
			funzione="Controlla('"+img+"')";
			intervallo=setTimeout(funzione,20);
		  }
		}
		function viewFoto(img){
		  largh=foto1.width+20;
		  altez=foto1.height+20;
		  stringa="width="+largh+",height="+altez;
		  finestra=window.open(img,"",stringa);
		}
		
		function escolha(imagem,alt){
			document.getElementById('imagemdescricao').innerHTML = (alt);
			document.getElementById('imagemg').src=(imagem);
			document.getElementById('imagemg').alt = (alt);
		}
		
		function Validar_Email(email)
		{
			if(email.length < 6) {
				return false;
			}
			var x = 0;
			for (var c=0;c<email.length;c++) {
				if (email.substring(c,c+1) == '@') {
					x = c;
				}
			}
			var y = 0;
			if (x > 0) {
				for (c=x;c<email.length;c++) {
					if (email.substring(c,c+1)=='.') {
						y = c;
						var valida = 1;
					}
				}
				if (y > 0) {
					var dominio = '';
					for (c=x;c<y;c++) {
						dominio = dominio + email.substring(1,c);
					}
				}
			}
			else {
				return false;
			}					
			if (y <= x+2){
				return false;
			}				
			if (valida == 1){
				return true;
			}
		}
		
		
		function Validar()
		{
			if (document.form.nome.value == "") {
				document.form.nome.focus();
				alert("Informe seu nome!");
				return;
			}
			if (document.form.email.value == "") {
				document.form.email.focus();
				alert("Informe seu email!");
				return;
			}
			
			if (!Validar_Email(document.form.email.value)) {
				document.form.email.focus();
				alert("E-mail inválido!");
				return;
			}			
			
			if (document.form.mensagem.value == "") {
			document.form.mensagem.focus();
			alert("Escreva a mensagem!");
			return;
			}

			document.form.submit();
		}
