var caminho_base='http://www.conselheirodeviagens.com.br/';
var valor_tipo = 1;
function set_tipo(tipo){
  valor_tipo = tipo;
}

// Formatação de Início
function iniciar(){
  cp_nome				= document.getElementById("news_nome");  
  cp_email     			= document.getElementById("news_email");
  cp_alerta     		= document.getElementById("div_alerta"); 
  cp_alerta.innerHTML   = '<span style=" color:#000">informe:</span>';
  cp_nome.className 	= 'alerta';
  cp_email.className 	= 'alerta';  
}

// Concluído com sucesso
function concluido(){
  cp_tipo				= document.getElementById("tipo_select");  
  tipo_dsc = 'Email removido da lista';
  tipo_ico = 'remove.png';  
  if(cp_tipo.value=='1'){
    tipo_dsc = 'Assinatura efetuada';
    tipo_ico = 'accept16.png';  	
  }

  cp_alerta     		= document.getElementById("div_alerta"); 
  cp_ok          		= document.getElementById("imagefliper_ok");   
  cp_alerta.innerHTML   = '<table width="100%" border="0" cellspacing="0" cellpadding="0"><tr><td width="4%"><img src="'+ caminho_base + "personal/images/" +'accept16.png"/></td><td><span style="margin-left:2px; ">'+ tipo_dsc +'</span></td></tr></table>';  
  cp_ok.src = "../personal/images/newsletter/ok_normal.jpg";  
  cp_ok          		= document.getElementById("imagefliper_ok");    	
  cp_loading    		= document.getElementById("loading");    		
  cp_ok.style.display = '';
  cp_loading.style.display = 'none';   
}

// Envio AJAX
function enviar(nome, email){ 
  caminho 	= 'personal/processos/proc_registro.php?nome=' +  nome +
  			  '&email=' +  email +
  			  '&tipo=' +  valor_tipo;
			  
  //alert(caminho);
  ajax(caminho);
} 	

// Validação dos Campos
function validar(){
  cp_nome		= document.getElementById("news_nome");  
  cp_email     	= document.getElementById("news_email");

  r				= true;	
  erro_msg		= '';
  
  if (r){ //NOME
  if ((cp_nome.value.length <= 3) || (cp_nome.value=='nome')){
    r=false;	
	cp_nome.className = 'alerta_ativo';
    erro_msg = '<table width="100%" border="0" cellspacing="0" cellpadding="0"><tr><td width="4%"><img src="'+ caminho_base + "personal/images/" +'legacy.png"/></td><td><span style="color:#F00">Informe o seu nome</span></td></tr></table>';
  }}
  
  
  if (r){ //EMAIL
  if ((cp_email.value.length <= 3) || (cp_email.value=='email')){
    r=false;
	cp_email.className = 'alerta_ativo';		
    erro_msg = '<table width="100%" border="0" cellspacing="0" cellpadding="0"><tr><td width="4%"><img src="'+ caminho_base + "personal/images/" +'legacy.png"/></td><td><span style="color:#F00">seu email est&aacute; faltando</span></td></tr></table>';
  }}  
  

				  		  		  
  if (r){
    cp_ok          		= document.getElementById("imagefliper_ok");    	
    cp_loading    		= document.getElementById("loading");    		
    cp_ok.style.display = 'none';
    cp_loading.style.display = '';
    enviar(cp_nome.value, cp_email.value);
    cp_nome.value 		= "nome";
    cp_email.value 		= "email";
    cp_nome.className 	= 'alerta';
    cp_email.className 	= 'alerta';		
    concluido();
  }else{
    cp_alerta     		= document.getElementById("div_alerta"); 	  
	cp_alerta.innerHTML = erro_msg; 
  }
}

function select_tipo(value){
	cp_tipo = document.getElementById("tipo_select");  
	cp_tipo.value = value;
}
