	
	
	
	
	function validaFrm(frm){
  
	  var d 	   = eval('document.'+ frm);
	  var numCampo = d.elements.length;
	  var erro     = "";
	  
	  
	  for(i = 0; i < numCampo; i++){
	  
		  var cmp       = d.elements[i].title; // title - exibe o erro
		  var aCampo    = d.elements[i].alt;   // alt   - direfencia o tipo do campo
		  var nomeCampo = d.elements[i].name;  // name  - faz os testes
							  
		  if(cmp != ""){ //se houver title, valida o campo
		  
			  var campo = eval('document.' + frm + '.' + nomeCampo);
			  var valor = campo.value;
			  
			 switch(aCampo){
			  
				  //~~~~~~~~~~~~ Campo de Texto Simples
				  
				  case "": 
				  
					if(valor == ""){
					
					erro += "- O campo <b>" + cmp + "</b> esta vazio.<br/>";
					
					}
				  
				  break;
				  
				  
				  //~~~~~~~~~~~~ Campo de email
			  
				  case "email": 
				  
					if(valor != ""){
					
						var arroba = valor.indexOf("@");
						var ponto  = valor.indexOf(".");
						
						if( (arroba == -1) || (ponto == -1) ){
						erro += "- O campo <b>" + cmp + "</b> possui um e-mail invalido.<br/>";
						}
					
					}
					
					else{
					erro += "- O campo <b>" + cmp + "</b> esta vazio.<br/>";
					}
				  
				  break;
				  
				  
				  //~~~~~~~~~~~~ Campo de telefone
			  
				  case "fone": 
				  
					if(valor != ""){
					
						checkKeycode();			
						if( (arroba == -1) || (ponto == -1) ){
						erro += "- O campo <b>" + cmp + "</b> possui um e-mail invalido.<br/>";
						}
					
					}
					
					else{
					erro += "- O campo <strong>" + cmp + "</strong> esta vazio.<br/>";
					}
				  
				  break;
				  
				  
			  } //switch
		  
		  }	//if	
					  
	  } //for
	  
	  
	  
	  if(erro != "") { //exibe erro
	  
	  var divErr = document.getElementById('erros');
	  
	  var msgErro = "\
	  <div style='padding:10px; border: solid 1px #ccc; background: #fafafa;'><b>Erros encontrados:</b><br/><br/>" + erro + "</div><br clear='left'/>";
	  
	  divErr.innerHTML = msgErro;
	  
	  alert ("Ocorreu algum erro ao tentar enviar o formulario.\nPor favor, verifique os campos e tente novamente.");
	  }
	  
	  else { //envia formulário
	  
	  	  
	  var action = eval("document." + frm).action;
	  
	  
	  if(action == ""){ action = "envia.php"; }
	  
	  
	  eval("document." + frm).method = "post";
	  eval("document." + frm).submit();
	  }
  
	}



	function popup(pag,w,h,barra){
	
	
		wi = screen.width/2  - (w/2);
		he = screen.height/2 - (h/2);
		
			var win = window.open(pag, "Pop",
			"toolbar=no,location=no,directories=no,scrollbars="+barra+",resizable=no,width="+w+",height=" + h + ",status=no,top=" + he + ",left=" + wi );
			win.focus();
	
	}
 
 

	function popImg(){
	
		var wImg = document.images[0].width;
		var hImg = document.images[0].height;
		
		resizeTo(wImg+12,hImg+32);

	} 


	function hideShow(id)
	{
		
		var n1 = id.indexOf("Hide");
		
		if(n1 != "-1")
		{
			
			n = id.length;
			n2 = n-4;
		
		document.getElementById(id).style.display = 'none';
		document.getElementById(id.substr(0,n2)).style.display = '';
		}
		
		else
		{
		document.getElementById(id).style.display = 'none';
		document.getElementById(id + "Hide").style.display = '';
		}
		
		
	}







