var currentLanguageSet="PT";

function I18N(id, type, textportuguese, textenglish, textspanish) {
	this.id=id;
	this.type=type;
	this.textportuguese=textportuguese;
	this.textenglish=textenglish;
	this.textspanish=textspanish;
	return this;
}

function varsI18N() {
return new Array(

// Title Bars
new I18N("printTitle", "var", "Imprimir Mapa", "Print Map", "Imprimir el Mapa"),
new I18N("searchTitle", "var", "Resultado da Pesquisa", "Search Results", "Resultados de la Pesquisa"),
new I18N("helpTitle", "var", "Ajuda", "Help", "Ayuda"),
new I18N("fotoTitle", "var", "Fotografia", "Photo", "Foto"),
new I18N("recTitle", "var", " Reclamação / Sugestão", "", ""),

// HELPS
new I18N("helpTitle1", "var", "Guia de utilização", "User instructions", "Guia de utilización"),
new I18N("helpTitle2", "var", "Ajuda à instalação", "Installation Help", "Ayuda a la instalacion"),

// Alerts
new I18N("invalidRef", "var", "O endereço é inválido,\nou já não existe!", "The link is invalid,\nor no longer exists!", "¡El URL es inválido,\no existe no más de largo!"),
new I18N("userDataSaved", "var", "Dados do utilizador gravados.", "User data saved.", "Datos del usuario almacenados."), //FIXME espanhol duvidoso
new I18N("saveUserDataQuestion", "var", "Os dados do utilizador não foram gravados.\nDeseja gravar-los agora?", "The user data wasn't saved.\nDo you wish to save it now?", "Los datos del usuario no fueron ahorrados.\n¿Usted desea ahora ahorrarlos?"), //FIXME espanhol duvidoso
new I18N("noResults", "var", "Nenhum resultado.", "No results.", "Ningunos resultados.") //FIXME espanhol duvidoso

	)
}

function getI18N() {
return new Array(

// IMPRIMIR
//-----------------------------------------------------
new I18N("imgPrint", "hint", "Imprimir esta página", "Print this page", "Imprimir lá página"),


// PDAS
//-----------------------------------------------------

new I18N("pdasEscolha", "innerHTML", "Escolha a cidade", "Choose a city", "Escojer la ciudad"),
new I18N("pdasBack1", "innerHTML", "MAPA", "MAP", "MAPA"),
new I18N("pdasBack2", "innerHTML", "Voltar à navegação", "Back to navigation", "Volver al mapa"),
new I18N("pdasHeader1", "innerHTML", "Todas as cidades do Euro2004 na palma da sua mão!!", "All the cities of the Euro2004 in your palm!!", "Todas las ciudades del Euro2004 en su mano!!"),
new I18N("pdasMsgDownload", "innerHTML",
			"Caso disponha de um telemóvel ou uma agenda electrónica (PDA) da lista abaixo indicada poderá efectuar o download do CityHelp, que lhe permitirá visualizar e navegar as cidades no seu terminal!",
			"If you have Mobile Phone or a PDA from the list below, you can download CityHelp in order to navigate those cities in your device!",
			"Caso tenga un telefono o un (PDA) de la lista abajo puede bajar el Cityhelp que permitirá navegar por la ciudad en su terminal!"),
new I18N("pdasMsgHelp1", "innerHTML", "Clique", "Click", "Click"),
new I18N("pdasMsgHelp2", "innerHTML", "aqui", "here", "aqui"),
new I18N("pdasMsgHelp3", "innerHTML",
			"para obter ajuda na instalação após o download.",
			"to get help on install process after download.",
			"para obtener ayuda de instalacion despues de bajar la aplicacion."),
new I18N("pdasDuvidas", "innerHTML", "Em caso de dúvidas consulte o manual do seu terminal.", "If you have any doubts, check your device manual.", "En caso de duda investigar en el manual de su terminal."),
new I18N("pdasMsgOS", "innerHTML", "Sistema Operativo:", "Operating System:", "Sistema Operativo:"),
new I18N("pdasMsgList", "innerHTML", "Lista não exaustiva de modelos:", "Devices non exclusive list:", "Lista no exaustiva de modelos:"),



// MAIN
//-----------------------------------------------------

new I18N("go1", "innerHTML", "GO", "GO", "Ir"),
new I18N("go2", "innerHTML", "GO", "GO", "Ir"),
new I18N("go3", "innerHTML", "GO", "GO", "Ir"),

new I18N("mapsTab", "innerHTML", "Mapas", "Maps", "Mapas"),

new I18N("lbHeaderTxt", "innerHTML", "EM PORTUGAL, O PROLONGAMENTO<br/>É SEMPRE A MELHOR PARTE DO JOGO.", "IN PORTUGAL, EXTRA TIME IS ALWAYS<br/>THE BEST PART OF THE GAME.", "EN PORTUGAL, EL TIEMPO AÑADIDO<br/>ES SIEMPRE LA MEJOR PARTE DEL JUEGO."),

new I18N("localidade", "hint", "Mudar cidade", "Change city", "Seleccionar ciudad"),
new I18N("mudarCidade", "innerHTML", "Mudar cidade", "Change city", "Seleccionar ciudad"),
new I18N("mudarCidadeArrow", "hint", "Mudar cidade", "Change city", "Seleccionar ciudad"),

new I18N("switchToPDAs", "innerHTML", "Para Telemoveis/PDAs", "For Phones/PDAs", "Para telefonos/PDAs"),

new I18N("lbAjuda", "both", "Ajuda", "Help", "Ayuda"),
new I18N("lbContacts", "both", "Contactos", "Contacts", "Contactos"),
new I18N("mapa", "both", "Mapa", "Map", "Mapa"),
new I18N("pdas", "both", "PDAs/Telemóveis", "PDAs/Phones", "PDAs/Telefonos"),
new I18N("procurarRua", "innerHTML", "Procurar Rua", "Find Street", "Buscar Calle"),
new I18N("procurarRuaArrow", "hint", "Procurar Rua", "Find Street", "Buscar Calle"),
new I18N("procurarLugar", "innerHTML", "Procurar Lugar", "Find Place", "Buscar lugar"),
new I18N("procurarLugarArrow", "hint", "Procurar Lugar", "Find Place", "Buscar Lugar"),
new I18N("procurarLugarCheck", "both", "Pesquisa Detalhada", "Full Search", "Pesquisa Detallada"),

new I18N("eating", "hint", "Restauração", "Eating", "Comida"),
new I18N("nightlife", "hint", "Noite", "Night", "Noche"),
new I18N("nature", "hint", "Natureza", "Nature", "Naturaleza"),
new I18N("shopping", "hint", "Compras", "Shopping", "Compras"),
new I18N("health", "hint", "Saúde", "Health", "Salud"),
new I18N("safety", "hint", "Segurança", "Security", "Securidad"),
new I18N("transports", "hint", "Transportes", "Transportation", "Transportes"),
new I18N("utilities", "hint", "Utilidades", "Utilities", "Utilidades"),
new I18N("culture", "hint", "Cultura", "Culture", "Cultura"),
new I18N("sports", "hint", "Desporto", "Sports", "Deporte"),
new I18N("sleeping", "hint", "Alojamento", "Sleeping", "alojamiento"),
new I18N("government", "hint", "Estado", "State", "Estado"),
new I18N("education", "hint", "Educação", "Education", "Educação"),
new I18N("tourism", "hint", "Turismo", "Tourism", "Turismo"),
new I18N("sightseeing", "hint", "Passear", "Sightseeing", "Pasear"),
new I18N("monuments", "hint", "Monumentos", "Monuments", "Monumentos"),

new I18N("SelectNoneButton", "hint", "Seleccionar nenhum", "Select none", "Seleccionar ninguno"),
new I18N("SelectAllButton", "hint", "Seleccionar todos", "Select all", "Seleccionar todos"),

new I18N("norte", "hint", "Norte", "North", "Norte"),
new I18N("nordeste", "hint", "Nordeste", "Northeast", "Nordeste"),
new I18N("este", "hint", "Este", "East", "Este"),
new I18N("sudeste", "hint", "Sudeste", "Southeast", "Sudeste"),
new I18N("sul", "hint", "Sul", "South", "Sul"),
new I18N("sudoeste", "hint", "Sudoeste", "Southwest", "Sudoeste"),
new I18N("oeste", "hint", "Oeste", "West", "Oeste"),
new I18N("noroeste", "hint", "Nordoeste", "Northwest", "Nordoeste"),

new I18N("standard1", "hint", "Informação", "Information", "Informacion"),
new I18N("standard2", "hint", "Imprimir", "Print", "Imprimir"),
new I18N("standard3", "hint", "Copiar", "Copy", "Copiar"),
new I18N("standard4", "hint", "E-mail", "E-mail", "E-mail"),
new I18N("standard5", "hint", "Ajuda", "Help", "Ayuda"),

new I18N("cartografia1", "hint", "Mover", "Move", "Moverse"),
new I18N("cartografia2", "hint", "Aproximar", "Zoom In", "Aproximar"),
new I18N("cartografia3", "hint", "Afastar", "Zoom Out", "Afastar"),
new I18N("cartografia4", "hint", "Ampliar zona", "Amplify Area", "Ampliar zona"),
new I18N("cartografia5", "hint", "Lupa", "Zoom", "Lupa"),
new I18N("cartografia6", "hint", "Ver tudo", "Zoom All", "mirar todo"),

new I18N("pessoal1", "hint", "Inserir ponto", "Insert Point", "Introducir ponto"),
new I18N("pessoal2", "hint", "Inserir texto", "Insert Text", "Introducir texto"),
new I18N("pessoal3", "hint", "Desenhar linha", "Draw Line", "Deburar linea"),
new I18N("pessoal4", "hint", "Apagar objecto", "Erase Object", "Borrar objecto"),
new I18N("pessoal5", "hint", "Guardar configuração pessoal", "Save Personal Configuration", "Guardar configuracion personal"),

new I18N("queixa1", "hint", "Reclamação / Sugestão", "", ""),

new I18N("percursos1", "hint", "Ponto de partida", "Start Point", "Ponto de partida"),
new I18N("percursos2", "hint", "Ponto de chegada", "End Point", "Ponto de llegada"),
new I18N("percursos3", "hint", "Calcular percurso", "Trace Route", "Calcular trayecto"),

new I18N("bPoisLegenda", "innerHTML", "Clique nos ícones para mostrar/esconder os elementos no mapa (pode clicar depois nos elementos para obter mais informações)", "Click on the icons to show/hide elements on the map", "Pinche en el recuadro para que aparezcan en el mapa los puntos de interés que desee"),

// showConteudo
new I18N("fotosStr", "innerHTML", "Fotografias", "Photos", "Fotos"),
new I18N("obsStr", "innerHTML", "Observações", "Observations", "Observaciones"),


// results
new I18N("setStart", "hint", "Marcar como ponto de partida", "Set as start point", "Fije como punto del comienzo"),
new I18N("setEnd", "hint", "Marcar como ponto de chegada", "Set as end point", "Fije como punto del llegada"),
new I18N("ClickSelect", "multi_hint", "Clique para seleccionar no mapa", "Click to select on the map", "Clique para seleccionar en el mapa"),
new I18N("btnFechar", "innerHTML", "Fechar", "Close", "Cerrar"),
new I18N("procuraPor", "innerHTML", "Procura por", "Look for", "Procura por"),
new I18N("resultados", "innerHTML", "resultado", "result", "resultado")

	)
}

function updateI18N(currentLanguage) {
	currentLanguageSet = currentLanguage;
	var targets = getI18N();
	for (i = 0; i < targets.length; i++) {
			var txt = "";
			if(currentLanguage=="PT") {
				txt=targets[i].textportuguese;
			} else if (currentLanguage=="EN") {
				txt=targets[i].textenglish;
			} else if (currentLanguage=="ES") {
				txt=targets[i].textspanish;
			}
		if (txt != "") {
			if (document.getElementById(targets[i].id) != null) {
				if (targets[i].type=="innerHTML") {
					document.getElementById(targets[i].id).innerHTML=txt;
				} else if (targets[i].type=="hint") {
					if (document.getElementById(targets[i].id).alt != null)
						document.getElementById(targets[i].id).alt=txt;
					else
						document.getElementById(targets[i].id).title=txt;
				} else if (targets[i].type=="both") {
					document.getElementById(targets[i].id).innerHTML=txt;
					if (document.getElementById(targets[i].id).alt != null)
						document.getElementById(targets[i].id).alt=txt;
					else
						document.getElementById(targets[i].id).title=txt;
				}  
			} else if (targets[i].type=="multi_innerHTML") {
				for(j=0; document.getElementById(targets[i].id+j)!=null; j++){
					document.getElementById(targets[i].id+j).innerHTML=txt;
			}
			} else if (targets[i].type=="multi_hint") {
			for(j=0; document.getElementById(targets[i].id+j)!=null; j++){
				if (document.getElementById(targets[i].id+j).alt != null)
					document.getElementById(targets[i].id+j).alt=txt;
				else
					document.getElementById(targets[i].id+j).title=txt;
			}
		}
	}
	}
}

function getVarI18N(currentLanguage,varName){
	var targets = varsI18N();
	for (i = 0; i < targets.length; i++) {
		if (targets[i].id==varName && targets[i].type=="var") {
			var txt = "";
			if(currentLanguage=="PT") {
				txt=targets[i].textportuguese;
			} else if (currentLanguage=="EN") {
				txt=targets[i].textenglish;
			} else if (currentLanguage=="ES") {
				txt=targets[i].textspanish;
			}
			return txt;
		}
	}
}
