var xmlLesCols;
var idiomaGlobal = 'ca';

function cargarXML(fichero) {
		$.ajax({
			type : "GET",
			url : fichero,
			async: false,
			dataType : "xml",
			success : function(xml) {
				xmlLesCols = xml;
				//refrescarContenido();
				//alert("XML CARGADO");
			},
			error: function (e1,e2,e3){
				//alert(e1+" , "+e2+" , "+e3);
			}
		});
	}

	function textoPorID(idCapa) {
		aux = idCapa.split('_');
		texto = traduccion(idiomaGlobal, aux[1], aux[2]);		
		return texto;
	}

	function refrescarTraducciones() {
		$(document).find(".traduccion").each(function() {
			idCapa = $(this).attr('id');			
			texto=textoPorID(idCapa);
			$(this).html(texto);
		});
	}


	
	function traduccion(idioma, seccion, clave) {
		//alert(idioma+" , "+seccion+" , "+clave);
		if (xmlLesCols != null) {
			xmlIdioma = $(xmlLesCols).find("xml").find(idioma);
			texto = $(xmlIdioma).find(seccion).find(clave).text();
			return texto;
		} 
	}

	function precio(clave) {
		if (xmlLesCols != null) {
			xmlPrecio = $(xmlLesCols).find("xml").find("precios");
			texto = parseFloat($(xmlPrecio).find(clave).text());
			return texto;
		} 
	}

	function refrescarContenido()
	{
		refrescarTraducciones();
	}
	
	function mensajeAlert(id ,msg){
		if (xmlLesCols != null) {
			xmlIdioma = $(xmlLesCols).find("xml").find(idiomaGlobal);
			mensaje = $(xmlIdioma).find(id).find(msg).text();
			return mensaje;
			} 
	}
	

