

$(function(){
	/*Newsletter*/
	$('#enviar_newsletter').click(function(){
		
		var n = $("#Nome_Newsletter").val();
		var e = $("#Email_Newsletter").val();
		if(n==''){
			show_error('Informe seu nome');
			$("#Nome_Newsletter").focus();
		}else if(e==''){
			show_error('Informe seu email');
			$("#Email_Newsletter").focus();
		} else {
			$.ajax({
				url: "/ajaj.php?a=newsletter",
				type: "POST",
				dataType: "json",
				data: {nome:n,email:e},
				success: function(data) {					
						var ok=data.ok;	
						var error=data.error;
						if(ok) {							
							show_success('Cadastrado com sucesso!!');
						} else {							
							show_error(error);
						}
					} 					
			});

		}		
	})
	/* FIM Newsletter*/
	
	/*Fale Conosco*/
	$('#enviar_faleconosco').click(function(){
		
		var n = $("#Nome_Contato").val();
		var e = $("#Email_Contato").val();
		var a = $("#Assunto_Contato").val();
		var m = $("#Msg_Contato").val();
		var tc = $("#curso_tem").val();
		var c = $("#Curso_Contato").val();
		var cc = $("#CodCurso_Contato").val();
		if(n==''){
			show_error('Informe seu nome');
			$("#Nome_Contato").focus();
		}else if(e==''){
			show_error('Informe seu email');
			$("#Email_Contato").focus();
		}else if(a==''){
			show_error('Informe o Assunto');
			$("#Assunto_Contato").focus();
		}else if(m==''){
			show_error('Informe a Mensagem');
			$("#Msg_Contato").focus();
		} else {
			$.ajax({
				url: "/ajaj.php?a=faleconosco",
				type: "POST",
				dataType: "json",
				data: {nome:n,email:e,assunto:a,msg:m,curso:c,codcurso:cc},
				success: function(data) {					
						var ok=data.ok;	
						var error=data.error;
						if(ok) {							
							show_success('Cadastrado com sucesso!!');
						} else {							
							show_error(error);
						}
					} 					
			});

		}		
	})
	/*FIM Fale Conosco*/
	
		/*Folheto*/
	$('#enviar_folhetos').click(function(){
		
		var n = $("#Nome_Folheto").val();
		var e = $("#Endereco_Folheto").val();
		var b = $("#Bairro_Folheto").val();
		var c = $("#Cep_Folheto").val();
		var uf = $("#SiglaUF").val();
		var ci = $("#ID_Cidade").val();
		var em = $("#Email_Folheto").val();
		if(n==''){
			show_error('Informe seu nome');
			$("#Nome_Folheto").focus();
		}else if(e==''){
			show_error('Informe seu endereco');
			$("#Endereco_Folheto").focus();
		}else if(b==''){
			show_error('Informe o seu Bairro');
			$("#Bairro_Folheto").focus();
		}else if(c==''){
			show_error('Informe o seu CEP');
			$("#Cep_Folheto").focus();
		}else if(uf==''){
			show_error('Informe o seu UF');
			$("#SiglaUF").focus();
		}else if(ci==''){
			show_error('Informe a sua Cidade');
			$("#ID_Cidade").focus();
		}else if(em==''){
			show_error('Informe o seu Email');
			$("#Email_Folheto").focus();
		} else {
			$.ajax({
				url: "/ajaj.php?a=folheto",
				type: "POST",
				dataType: "json",
				data: {nome:n,endereco:e,bairro:b,cep:c,uf:uf,cidade:ci,email:em},
				success: function(data) {					
						var ok=data.ok;	
						var error=data.error;
						if(ok) {							
							show_success('Cadastrado com sucesso!!');
						} else {							
							show_error(error);
						}
					} 					
			});

		}		
	})
	/*FIM Folheto*/
	
	
	
	/* Cadastro de senha */
	
	$('#enviar_senha').click(function(){
		
		var u = $("#username").val();		
		var c = $("#cpf").val();
		var p = $("#password").val();
		var cp = $("#confirma").val();
		
		if(u==''){
			show_error('Informe seu RA');
			$("#username").focus();		
		}else if(c==''){
			show_error('Informe o seu CPF');
			$("#cpf").focus();
		}else if(p==''){
			show_error('Informe sua senha');
			$("#password").focus();
		}else if(cp==''){
			show_error('Informe o campo Confirma Senha');
			$("#confirma").focus();
		}else if(p!=cp){
			show_error('Sua senha esta diferente do campo Confirma Senha');
			$("#password").focus();
		} else {
			$.ajax({
				url: "/ajaj.php?a=senha",
				type: "POST",
				dataType: "json",
				data: {username:u,cpf:c,password:p,confirma:cp},
				success: function(data) {					
						var ok=data.ok;	
						var error=data.error;
						if(ok) {							
							show_success('Cadastrado com sucesso!!');
						} else {							
							show_error(error);
						}
					} 					
			});

		}		
	})
	
	
	/*FIM Cadastro de senha */	
	
	/*Inscricao*/
	$('#txt_cpf').blur(function(){
		var cpf = $(this).val();
		if(cpf){
			$.ajax({
				url: "/ajaj.php?a=cpf",
				type: "POST",
				dataType: "json",
				data: {cpf:cpf},
				success: function(data) {	
						var ok=data.ok;	
						if(ok){
							$("#txt_cpf").val(data.cpf);
							if(data.nome){
								$("#txt_nome").val(html_entity_decode(data.nome));
								$("#txt_DtNasc").val(data.data);
								$("#txt_naturalidade").val(html_entity_decode(data.naturalidade));
								$("#txt_nacionalidade").val(html_entity_decode(data.nacionalidade));
								$("#txt_endereco").val(html_entity_decode(data.endereco));
								//$("#txt_complemento").val(html_entity_decode(data.complemento));
								$("#txt_bairro").val(html_entity_decode(data.bairro));
								$("#txt_cep").val(data.cep);						
								$("#txt_celular").val(data.celular);
								$("#txt_telres").val(data.telres);
								$("#txt_telcom").val(data.telcom);
								$("#txt_email").val(data.email);
								$("#txt_rg").val(data.rg);
								$("#txt_sexo option[value='"+data.sexo+"']").attr('selected', true);
								$("#txt_estadocivil option[value='"+data.estadocivil+"']").attr('selected', true);
								$("#txt_orgaoespeditor").val(data.orgaoespeditor);
								$("#SiglaUF option").each(function(){
									if($(this).val() == data.uf){
										$(this).attr('selected',true);
										PegaCidades(data.uf,tiraAcento(data.cidade));									
									}
								});															
								
							}
							clear_error();
						}  else {
							$("#txt_cpf").val('');
							$("#txt_cpf").focus();
							show_error(data.error);
						}			 
					} 					
			});
		}
	});
	
	$('#txt_DtNasc').blur(function(){
		var dat = $(this).val();
		if(dat){
			$.ajax({
				url: "/ajaj.php?a=data",
				type: "POST",
				dataType: "json",
				data: {dat:dat},
				success: function(data) {	
						var ok=data.ok;	
						if(ok){
							$("#txt_DtNasc").val(data.data);						
							clear_error();
						}  else {
							$("#txt_DtNasc").val('');
							$("#txt_DtNasc").focus();
							show_error(data.error);
						}			 
					} 					
			});
		}
	})
	
	$('#txt_cep').blur(function(){
		var cep = $(this).val();
		if(cep){
			$.ajax({
				url: "/ajaj.php?a=cep",
				type: "POST",
				dataType: "json",
				data: {cep:cep},
				success: function(data) {	
						var ok=data.ok;	
						if(ok){
							$("#txt_cep").val(data.cep);						
							clear_error();
						}  else {
							$("#txt_cep").val('');
							$("#txt_cep").focus();
							show_error(data.error);
						}			 
					} 					
			});
		}
	})
	
	$('#txt_telres').blur(function(){
		var telefone = $(this).val();
		if(telefone){
			$.ajax({
				url: "/ajaj.php?a=telefone",
				type: "POST",
				dataType: "json",
				data: {telefone:telefone},
				success: function(data) {	
						var ok=data.ok;	
						if(ok){
							$("#txt_telres").val(data.telefone);						
							clear_error();
						}  else {
							$("#txt_telres").val('');	
							$("#txt_telres").focus();
							show_error(data.error);
						}			 
					} 					
			});
		}
	});
	
	$('#txt_celular').blur(function(){
		var telefone = $(this).val();
		if(telefone){
			$.ajax({
				url: "/ajaj.php?a=telefone",
				type: "POST",
				dataType: "json",
				data: {telefone:telefone},
				success: function(data) {	
						var ok=data.ok;	
						if(ok){
							$("#txt_celular").val(data.telefone);						
							clear_error();
						}  else {
							$("#txt_celular").val('');	
							$("#txt_celular").focus();
							show_error(data.error);
						}			 
					} 					
			});
		}
	});
	
	$('#txt_telcom').blur(function(){
		var telefone = $(this).val();
		if(telefone){
			$.ajax({
				url: "/ajaj.php?a=telefone",
				type: "POST",
				dataType: "json",
				data: {telefone:telefone},
				success: function(data) {	
						var ok=data.ok;	
						if(ok){
							$("#txt_telcom").val(data.telefone);						
							clear_error();
						}  else {
							$("#txt_telcom").val('');	
							$("#txt_telcom").focus();
							show_error(data.error);
						}			 
					} 					
			});
		}
	});
	
	
	$('#txt_email').blur(function(){
		var email = $(this).val();
		if(email){
			$.ajax({
				url: "/ajaj.php?a=email",
				type: "POST",
				dataType: "json",
				data: {email:email},
				success: function(data) {	
						var ok=data.ok;	
						if(ok){
							$("#txt_email").val(data.email);						
							clear_error();
						}  else {
							$("#txt_email").val('');	
							$("#txt_email").focus();
							show_error(data.error);
						}			 
					} 					
			});
		}
	});
	
	
	
	$('#enviar_inscricao').click(function(){
		
		var cpf 			= $("#txt_cpf").val();
		var nome 			= $("#txt_nome").val();
		var data 			= $("#txt_DtNasc").val();
		var naturalidade 	= $("#txt_naturalidade").val();
		var nacionalidade 	= $("#txt_nacionalidade").val();
		var endereco 		= $("#txt_endereco").val();
		//var complemento 	= $("#txt_complemento").val();
		var bairro 			= $("#txt_bairro").val();
		var cep 			= $("#txt_cep").val();
		var uf 				= $("#SiglaUF").val();
		var cidade 			= $("#ID_Cidade").val();
		var celular 		= $("#txt_celular").val();
		var telres			= $("#txt_telres").val();
		var telcom			= $("#txt_telcom").val();
		var email 			= $("#txt_email").val();
		var rg 				= $("#txt_rg").val();
		var soubecursos		= $("#txt_soubecursos").val();
		var opcaopag		= $(".txt_opcaopag:checked").val();
		var curso			= $("#txt_curso").val();
		var valorinscricao	= $("#txt_valorinscricao").val();
		var orgaoespeditor	= $("#txt_orgaoespeditor").val();
		var estadocivil		= $("#txt_estadocivil").val();
		var sexo			= $("#txt_sexo").val();
		
		
				
		if(cpf==''){
			show_error('Informe seu CPF');
			$("#txt_cpf").focus();
		}else if(nome==''){
			show_error('Informe seu Nome');
			$("#txt_nome").focus();
		}else if(data==''){
			show_error('Informe a data de seu nascimento');
			$("#txt_DtNasc").focus();
		}else if(sexo==''){
			show_error('Informe o seu Sexo');
			$("#txt_sexo").focus();
		}else if(estadocivil==''){
			show_error('Informe o seu Estado Civil');
			$("#txt_estadocivil").focus();
		}else if(naturalidade==''){
			show_error('Informe a sua Naturalidade');
			$("#txt_naturalidade").focus();
		}else if(nacionalidade==''){
			show_error('Informe a sua Nacionalidade');
			$("#txt_nacionalidade").focus();
		}else if(endereco==''){
			show_error('Informe o seu Endereco');
			$("#txt_endereco").focus();
		}else if(bairro==''){
			show_error('Informe o seu Bairro');
			$("#txt_bairro").focus();
		}else if(cep==''){
			show_error('Informe o seu CEP');
			$("#txt_cep").focus();
		}else if(uf==''){
			show_error('Informe o seu UF');
			$("#SiglaUF").focus();
		}else if(cidade==''){
			show_error('Informe a sua Cidade');
			$("#ID_Cidade").focus();
		}else if(telres==''){
			show_error('Informe o seu Telefone Residencial');
			$("#txt_telres").focus();
		}else if(email==''){
			show_error('Informe o seu Email');
			$("#txt_email").focus();
		}else if(rg==''){
			show_error('Informe o seu RG');
			$("#txt_rg").focus();
		}else if(orgaoespeditor==''){
			show_error('Informe o Orgao Espeditor');
			$("#txt_orgaoexpeditor").focus();
		}else if(opcaopag==''){
			show_error('Informe a opção de pagamento');
			$("#txt_opcaopag").focus();
		} else {
			$.ajax({
				url: "/ajaj.php?a=inscricao",
				type: "POST",
				dataType: "json",
				data: {cpf:cpf,nome:nome,data:data,naturalidade:naturalidade,nacionalidade:nacionalidade,endereco:endereco,cep:cep,bairro:bairro,uf:uf,cidade:cidade,celular:celular,telres:telres,telcom:telcom,email:email,rg:rg,soubecursos:soubecursos,opcaopag:opcaopag,curso:curso,valorinscricao:valorinscricao,sexo:sexo,estadocivil:estadocivil,orgaoespeditor:orgaoespeditor},
				success: function(data) {					
						var ok=data.ok;	
						var error=data.error;
						if(ok) {							
							show_success(html_entity_decode(data.html));
						} else {							
							show_error(error);
						}
					} 					
			});

		}		
	})
	
	
	
	/*FIM Inscricao*/
	
	/*2 via do boleto*/
	
	$('#enviar_boleto').click(function(){	
		
		var cpf 			= $("#txt_cpf").val();
		var curso			= $("#id_curso").val();
				
		if(cpf==''){
			show_error('Informe seu CPF');
			$("#txt_cpf").focus();
		} else {
			if(!curso){
				$.ajax({
					url: "/ajax.php?a=pegacurso",
					type: "POST",
					dataType: "html",
					data: {cpf:cpf},
					success: function(html) {							
							if(html) {									
								$("#boleto_curso").html(html);
							} 
						} 					
					});
				} else {
					$.ajax({
						url: "/ajax.php?a=pegaboleto",
						type: "POST",
						dataType: "html",
						data: {cpf:cpf,curso:curso},
						success: function(html) {							
								if(html) {									
									$("#boleto_mostra").html(html);
								} 
							} 					
						});				
				
				}
		}		
	})
	
	
	
	/*FIM Inscricao*/
	
	
	
	
	
	/* Geral */
	$('#SiglaUF').change(function(){
		var uf = $(this).val();
		PegaCidades(uf);
	})
	
	
	function PegaCidades(uf,cidade){
		
		$.ajax({
			url: "/ajax.php?a=pegacidade",
			type: "POST",
			dataType: "html",
			data: {uf:uf},
			success: function(html) {	
					$("#cidade_select").html(html);
					if(cidade){
						$("#ID_Cidade option").each(function(){
							if($(this).text() == cidade){
								$(this).attr('selected',true);
							}
						});	
					}
				} 					
		});
		
		
	}
	
	
	/* FIM Geral */	
	
	
	
});

/* GERAL */
function show_error(error) {	
	html="<div id='error_msg'>Erro: "+error+"</div>";			
	$("#error_msg").remove();			
	$("#error").prepend(html);
}

function clear_error() {
	html="<div id='error_msg'></div>";			
	$("#error_msg").remove();			
	$("#error").prepend(html);
}

function show_success(msg) {	
	html="<div id='success_msg'>"+msg+"</div>";			
	$("#success").html(html);	
}

function tiraAcento(text) {
	  text = text.replace(new RegExp('[ÁÀÂÃ]','gi'), 'A');
	  text = text.replace(new RegExp('[ÉÈÊ]','gi'), 'E');
	  text = text.replace(new RegExp('[ÍÌÎ]','gi'), 'I');
	  text = text.replace(new RegExp('[ÓÒÔÕ]','gi'), 'O');
	  text = text.replace(new RegExp('[ÚÙÛ]','gi'), 'U');
	  text = text.replace(new RegExp('[Ç]','gi'), 'C');
	  return text;
} 


function Aluno(Aluno){
	
	if(Aluno == 1){
		document.getElementById("curso_mostra").style.display = "block";
		document.getElementById("curso_tem").value = "1";
	}else{
		document.getElementById("curso_mostra").style.display = "none";
		document.getElementById("curso_tem").value = "0";
		document.getElementById("Curso_Contato").value = "";
		document.getElementById("CodCurso_Contato").value = "";
		
	}
	
}

function html_entity_decode (string, quote_style) {
    // Convert all HTML entities to their applicable characters  
    // 
    // version: 1009.2513
    // discuss at: http://phpjs.org/functions/html_entity_decode    // +   original by: john (http://www.jd-tech.net)
    // +      input by: ger
    // +   improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +    revised by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +   bugfixed by: Onno Marsman    // +   improved by: marc andreu
    // +    revised by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +      input by: Ratheous
    // +   bugfixed by: Brett Zamir (http://brett-zamir.me)
    // +      input by: Nick Kolosov (http://sammy.ru)    // +   bugfixed by: Fox
    // -    depends on: get_html_translation_table
    // *     example 1: html_entity_decode('Kevin &amp; van Zonneveld');
    // *     returns 1: 'Kevin & van Zonneveld'
    // *     example 2: html_entity_decode('&amp;lt;');    // *     returns 2: '&lt;'
    var hash_map = {}, symbol = '', tmp_str = '', entity = '';
    tmp_str = string.toString();
    
    if (false === (hash_map = this.get_html_translation_table('HTML_ENTITIES', quote_style))) {        return false;
    }
 
    // fix &amp; problem
    // http://phpjs.org/functions/get_html_translation_table:416#comment_97660    delete(hash_map['&']);
    hash_map['&'] = '&amp;';
 
    for (symbol in hash_map) {
        entity = hash_map[symbol];        tmp_str = tmp_str.split(entity).join(symbol);
    }
    tmp_str = tmp_str.split('&#039;').join("'");
    
    return tmp_str;
}


function get_html_translation_table (table, quote_style) {
    // Returns the internal translation table used by htmlspecialchars and htmlentities  
    // 
    // version: 1009.2513
    // discuss at: http://phpjs.org/functions/get_html_translation_table    // +   original by: Philip Peterson
    // +    revised by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +   bugfixed by: noname
    // +   bugfixed by: Alex
    // +   bugfixed by: Marco    // +   bugfixed by: madipta
    // +   improved by: KELAN
    // +   improved by: Brett Zamir (http://brett-zamir.me)
    // +   bugfixed by: Brett Zamir (http://brett-zamir.me)
    // +      input by: Frank Forte    // +   bugfixed by: T.Wild
    // +      input by: Ratheous
    // %          note: It has been decided that we're not going to add global
    // %          note: dependencies to php.js, meaning the constants are not
    // %          note: real constants, but strings instead. Integers are also supported if someone    // %          note: chooses to create the constants themselves.
    // *     example 1: get_html_translation_table('HTML_SPECIALCHARS');
    // *     returns 1: {'"': '&quot;', '&': '&amp;', '<': '&lt;', '>': '&gt;'}
    
    var entities = {}, hash_map = {}, decimal = 0, symbol = '';    var constMappingTable = {}, constMappingQuoteStyle = {};
    var useTable = {}, useQuoteStyle = {};
    
    // Translate arguments
    constMappingTable[0]      = 'HTML_SPECIALCHARS';    constMappingTable[1]      = 'HTML_ENTITIES';
    constMappingQuoteStyle[0] = 'ENT_NOQUOTES';
    constMappingQuoteStyle[2] = 'ENT_COMPAT';
    constMappingQuoteStyle[3] = 'ENT_QUOTES';
     useTable       = !isNaN(table) ? constMappingTable[table] : table ? table.toUpperCase() : 'HTML_SPECIALCHARS';
    useQuoteStyle = !isNaN(quote_style) ? constMappingQuoteStyle[quote_style] : quote_style ? quote_style.toUpperCase() : 'ENT_COMPAT';
 
    if (useTable !== 'HTML_SPECIALCHARS' && useTable !== 'HTML_ENTITIES') {
        throw new Error("Table: "+useTable+' not supported');        // return false;
    }
 
    entities['38'] = '&amp;';
    if (useTable === 'HTML_ENTITIES') {        entities['160'] = '&nbsp;';
        entities['161'] = '&iexcl;';
        entities['162'] = '&cent;';
        entities['163'] = '&pound;';
        entities['164'] = '&curren;';        entities['165'] = '&yen;';
        entities['166'] = '&brvbar;';
        entities['167'] = '&sect;';
        entities['168'] = '&uml;';
        entities['169'] = '&copy;';        entities['170'] = '&ordf;';
        entities['171'] = '&laquo;';
        entities['172'] = '&not;';
        entities['173'] = '&shy;';
        entities['174'] = '&reg;';        entities['175'] = '&macr;';
        entities['176'] = '&deg;';
        entities['177'] = '&plusmn;';
        entities['178'] = '&sup2;';
        entities['179'] = '&sup3;';        entities['180'] = '&acute;';
        entities['181'] = '&micro;';
        entities['182'] = '&para;';
        entities['183'] = '&middot;';
        entities['184'] = '&cedil;';        entities['185'] = '&sup1;';
        entities['186'] = '&ordm;';
        entities['187'] = '&raquo;';
        entities['188'] = '&frac14;';
        entities['189'] = '&frac12;';        entities['190'] = '&frac34;';
        entities['191'] = '&iquest;';
        entities['192'] = '&Agrave;';
        entities['193'] = '&Aacute;';
        entities['194'] = '&Acirc;';        entities['195'] = '&Atilde;';
        entities['196'] = '&Auml;';
        entities['197'] = '&Aring;';
        entities['198'] = '&AElig;';
        entities['199'] = '&Ccedil;';        entities['200'] = '&Egrave;';
        entities['201'] = '&Eacute;';
        entities['202'] = '&Ecirc;';
        entities['203'] = '&Euml;';
        entities['204'] = '&Igrave;';        entities['205'] = '&Iacute;';
        entities['206'] = '&Icirc;';
        entities['207'] = '&Iuml;';
        entities['208'] = '&ETH;';
        entities['209'] = '&Ntilde;';        entities['210'] = '&Ograve;';
        entities['211'] = '&Oacute;';
        entities['212'] = '&Ocirc;';
        entities['213'] = '&Otilde;';
        entities['214'] = '&Ouml;';        entities['215'] = '&times;';
        entities['216'] = '&Oslash;';
        entities['217'] = '&Ugrave;';
        entities['218'] = '&Uacute;';
        entities['219'] = '&Ucirc;';        entities['220'] = '&Uuml;';
        entities['221'] = '&Yacute;';
        entities['222'] = '&THORN;';
        entities['223'] = '&szlig;';
        entities['224'] = '&agrave;';        entities['225'] = '&aacute;';
        entities['226'] = '&acirc;';
        entities['227'] = '&atilde;';
        entities['228'] = '&auml;';
        entities['229'] = '&aring;';        entities['230'] = '&aelig;';
        entities['231'] = '&ccedil;';
        entities['232'] = '&egrave;';
        entities['233'] = '&eacute;';
        entities['234'] = '&ecirc;';        entities['235'] = '&euml;';
        entities['236'] = '&igrave;';
        entities['237'] = '&iacute;';
        entities['238'] = '&icirc;';
        entities['239'] = '&iuml;';        entities['240'] = '&eth;';
        entities['241'] = '&ntilde;';
        entities['242'] = '&ograve;';
        entities['243'] = '&oacute;';
        entities['244'] = '&ocirc;';        entities['245'] = '&otilde;';
        entities['246'] = '&ouml;';
        entities['247'] = '&divide;';
        entities['248'] = '&oslash;';
        entities['249'] = '&ugrave;';        entities['250'] = '&uacute;';
        entities['251'] = '&ucirc;';
        entities['252'] = '&uuml;';
        entities['253'] = '&yacute;';
        entities['254'] = '&thorn;';        entities['255'] = '&yuml;';
    }
 
    if (useQuoteStyle !== 'ENT_NOQUOTES') {
        entities['34'] = '&quot;';    }
    if (useQuoteStyle === 'ENT_QUOTES') {
        entities['39'] = '&#39;';
    }
    entities['60'] = '&lt;';    entities['62'] = '&gt;';
 
 
    // ascii decimals to real symbols
    for (decimal in entities) {        symbol = String.fromCharCode(decimal);
        hash_map[symbol] = entities[decimal];
    }
    
    return hash_map;
}
