﻿function initIndiqueAmigo() {
  var vButton = $$('processar');
  
  $hide('mensagem-sucesso-indique');
  
  function send(){
	with( document.indiqueAmigo ) {
 	 action  = '/indiqueAmigo.cfm';
   	 method  = 'post';
   	 target  = 'tIndiqueAmigo';
	 enctype = 'application/x-www-form-urlencoded';
	
		if( fnc_verifica_form( document.indiqueAmigo ) ){
			disableCampo('processar');
			submit();
			reset();
			enableCampo('processar');
			alert('O link foi compartilhado com sucesso!');
		}
	} 
  }
 
  // onkeyup="onSend"
  function onSend() { 
	vForm.onkeyup = function( e ) { 
      var key = ( window.event)?window.event.keyCode:e.which;
      if( key  == 13 || key  == 10 ) return send(); 
    };
  }
  
  // onkeypress="BloqueiaLetras()"
  function BloqueiaLetras(){
	var codTecla = parseInt(window.event.keyCode);
	var tecla = String.fromCharCode(codTecla);
	
	if (!(codTecla >= 48 && codTecla <= 57 ) && ( !(codTecla == 44 ) && !(codTecla == 45 ) ) ) {
		window.event.keyCode=0;
	}  
  }
    
  //addEvent( vForm,'keyup'  ,onSend,false );
  addEvent( vButton,'click', send ,false );

  fnc_controla_campos( document.forms['formIndiqueAmigo'] );   
}
