<!-- <% //' <!-- -->
/* new in version 1.1:
	* value can be retrieved as attribute or content of node 
	* page can be dynamically updated with language elements
   new in version 1.2:
   	* ability to load "sections"
*/
function Language(strUrl) {
	this.version="1.1";
	this.elements = createXMLDocument();	
	this.tmp = createXMLDocument();	

	if (strUrl) {
		this.load(strUrl);
	}
}
Language.prototype.load				= Language_load;
Language.prototype.addSection		= Language_addSection;
Language.prototype.getSection		= Language_getSection;
Language.prototype.get				= Language_get;
Language.prototype.updateHTMLpage	= Language_updateHTMLpage;

/********************************************************************************
 description : loads the language elements 
 input : strUrl - the name of the file to load
 *******************************************************************************/
function Language_load(strUrl) {
	this.elements.load(strUrl);
}
/********************************************************************************
 description : adds a section to the current language elements
 input : strUrl - the name of the file containing the section to add
 *******************************************************************************/
function Language_addSection(strUrl) {
	this.tmp.load(strUrl);
	var n=this.tmp.selectSingleNode("//section");
	if (n) this.elements.documentElement.appendChild(n);
}
/********************************************************************************
 description : returns the specified section if exists, otherwise false
 input : strSection - the section name
 output : 
 *******************************************************************************/
function Language_getSection(strSection) {
	return this.elements.selectSingleNode("//section[name='" + strSection +"']");
}
/********************************************************************************
 description : returns the label of a specific language element
 input : strLabel - the name of the label
 		 strSection - the section that this label is in (optional)
 *******************************************************************************/
function Language_get(strLabel, strSection) {
	//' returns a message from the specified language file, using the given strLabel
	//' the label is searched in the language file
	if (this.elements.xml!="") {
		if (strSection) {
			var n=this.elements.selectSingleNode("//section[@name='" + strSection + "']/element[@label='" + strLabel + "']");
		} else {
			var n=this.elements.selectSingleNode("//element[@label='" + strLabel + "']");
		}
		if (n) {
			if (n.getAttribute("value")) {
				return n.getAttribute("value")
			} else {
				if (n.childNodes.length==1) {
					return n.childNodes[0].nodeValue;
				} else if (n.childNodes.length==3) {
					//' in Mozilla
					return n.childNodes[1].nodeValue;
				}
			}
		} else {
			if (strSection) {
				return ("Language element in section not defined.\r\n" + strSection + "/" + strLabel);
			} else {
				return ("Language element not defined.\r\n" + strLabel);
			}
		}
	} else {
		return ("Language not defined.\r\n" + strLabel);
	}
}
/********************************************************************************
 description : updates the elements of a HTML page to show the correct language
 input : doc - the document object that contains HTML elements to scan
 *******************************************************************************/
function Language_updateHTMLpage(doc) {

	function setLanguage(strTagName, intMethod, doc, objLanguage) {
		var els=doc.getElementsByTagName(strTagName);
		for (var i=0; i<els.length; i++) {
			if (els[i].getAttribute("language")) {
				if (intMethod==1) {
					els[i].innerHTML=objLanguage.get(els[i].getAttribute("language"), els[i].getAttribute("language_section"));
				} else if (intMethod==2) {
					els[i].value=objLanguage.get(els[i].getAttribute("language"), els[i].getAttribute("language_section"));
				}
			}
			if (els[i].getAttribute("language_title")) {
				els[i].title=objLanguage.get(els[i].getAttribute("language_title"), els[i].getAttribute("language_section"));
			}
		}
	}	
		
	setLanguage("a", 1, doc, this);
	setLanguage("span", 1, doc, this);
	setLanguage("div", 1, doc, this);
	setLanguage("input", 2, doc, this);
	setLanguage("textarea", 2, doc, this);
}
<!-- %> -->
