if (typeof(window['top_level']) == "undefined") top_level = false;

function x_menu(p_root, p_url, p_text, p_alttext, p_current, p_display, p_level, p_parent, p_home, p_contact, p_contactLink, p_language, p_search ,p_image_off, p_image_over, p_image_selected, p_image_child_selected, p_disclaimer, p_lang, p_colorSchema) {

//p_home, p_contact, p_contactLink, p_language, p_search
	this.root = p_root;
	this.url = p_url;
	this.text = p_text;
	this.alttext = p_alttext;
	this.current = p_current;
	this.display = p_display;
	this.level = p_level;
	this.parent = p_parent;
	this.image_off = p_image_off;
	this.image_over = p_image_over;
	this.image_selected = p_image_selected;
	this.image_child_selected = p_image_child_selected;
	this.disclaimer = p_disclaimer;
	this.lang = p_lang;
	this.menugif = '';
	this.metaNav = new Array (p_home, p_contact, p_contactLink, p_language, p_search);
	this.children = Array();
	this.colorSchema=p_colorSchema; 
	return this;
}

x_menu.prototype.addchildren = function(nodes) {
	var tmp;
	for(var a=0; a<nodes.length; a++) {
		var tmp=nodes[a];
//alert(p_colorSchema+" "+colorSchema)
		this.children[this.children.length] = new x_menu(false,tmp.getAttribute('targetUrl'),tmp.getAttribute('text'),tmp.getAttribute('alttext'),tmp.getAttribute('currentWindow'),tmp.getAttribute('display'), this.level+1, this, tmp.getAttribute('p_home'), tmp.getAttribute('p_contact'), tmp.getAttribute('p_contactLink'), tmp.getAttribute('p_language'), tmp.getAttribute('p_search'),tmp.getAttribute('image_off'), tmp.getAttribute('image_over'), tmp.getAttribute('image_selected'), tmp.getAttribute('image_child_selected'), tmp.getAttribute('disclaimer'), tmp.getAttribute('language'), tmp.getAttribute('p_colorSchema'));
		this.children[this.children.length-1].addchildren(tmp.getElements('link'));
	}
}

x_menu.prototype.render = function() {
	var s_html = '';
	var tmp;
	for(var a=0; a<this.children.length; a++) {
		tmp = this.children[a];
		if(tmp.display == 'true') { 
			for(var i=0; i<this.level; i++) {
				s_html += '&nbsp;&nbsp;&nbsp;&nbsp;'		
			}
			s_html += '<a href="'+tmp.url
			s_html += '"';
			if(tmp.current == 'false') {
				s_html += 'target="_blank"';
			}
			s_html += '>'+tmp.text+'</a><br>\n';
			s_html += tmp.render();
		 }
	}
	return s_html;
}

/**
 * discriptio: this function searches to match the sent uri with a certain node uri then return the matched node object if no match it returns null
 * parameters: uri, for the searched page
 * return: a matched object of the searched page.
 */
x_menu.prototype.ref = function(uri) {
	var tmp;
	for(var a=0; a<this.children.length; a++) {
		tmp = this.children[a];
		if(tmp.url.toLowerCase() == uri) { return tmp; }
		tmp = tmp.ref(uri);
		if(tmp!=null) { return tmp; }
	}
	return null;
}

x_menu.prototype.crumb = function(uri) {
if (top_level) {
	uri = uri.toLowerCase()
	if (uri.indexOf('/corporates/docs/country/contacts/') == 0) uri = uri.replace(/contacts\//i, '')
	var tmp = this.ref(uri);
	var s_html = '';
	if(tmp != null) {
		while(tmp.parent != null) {
			var s_class = '';
			if(tmp.url.toLowerCase() == uri) {
				s_class = ' class="crumbthis"';
			}
			if(tmp.current == 'false') {
				s_tmp = ' target="_blank"';
			} else {
				s_tmp = '';
			}
			if (tmp.level == 1) {
				tmp.text = 'Home'
				s_html = '<a href="'+tmp.url+'"' + s_tmp + s_class + '>Home</a>' + s_html;
			}
			else {
				 if(tmp.display=='true')	
				 {
				s_html = '&nbsp;&nbsp;/&nbsp;&nbsp;<a href="'+tmp.url+'"' + s_tmp + s_class + '>'+tmp.text + '</a>' + s_html;
				}
			}
			tmp = tmp.parent;
		}
		return s_html;
	} else {
		return '';
	}
}
else {
	return '';
}
}

x_menu.prototype.home = function(uri) {
	uri = uri.toLowerCase()
	if (uri.indexOf('/corporates/docs/country/contacts/') == 0) uri = uri.replace(/contacts\//i, '')
	var tmp = this.ref(uri);
	var homeLink = '';
	if(tmp != null) {
		while(tmp.parent != null) {
			if(tmp.level == 1) {
				homeLink = tmp.url;
				break;
			}
			tmp = tmp.parent;
		}
		return homeLink;
	} else {
		return '';
	}
}

x_menu.prototype.disclaimerLink = function(uri) {
	uri = uri.toLowerCase();
	if (uri.indexOf('/corporates/docs/country/contacts/') == 0) uri = uri.replace(/contacts\//i, '');
	var tmp = this.ref(uri);
	var disclaimerLink = 'Please read our &lt;a class="footer" href="/corporates/docs/disclaimer.jsp"&gt;disclaimer&lt;img src="/country/resources/images/static/but_arrow_r.gif" alt="" border="0"/&gt;&lt;/a&gt; and &lt;a class="footer" href="/corporates/docs/privacy_statement.jsp"&gt;Privacy Statement&lt;img src="/country/resources/images/static/but_arrow_r.gif" alt="" border="0"/&gt;&lt;/a&gt; &lt;br/&gt;Copyright © 1998-2006 &lt;a href="/corporates/docs/imprint.jsp"&gt;ABN AMRO Bank N.V.&lt;/a&gt;&lt;br/&gt;All rights reserved.';
	if(tmp != null) {
		while(tmp.parent != null) {
			if(tmp.level == 1) {
				if (tmp.disclaimer && tmp.disclaimer != '') {
					return tmp.disclaimer.replace(/&amp;/g,'&').replace(/&lt;/g,'<').replace(/&gt;/g,'>').replace(/&quot;/g,'"');
				}
			}
			tmp = tmp.parent;
		}
	}

	disclaimerLink = disclaimerLink.replace(/&amp;/g,'&').replace(/&lt;/g,'<').replace(/&gt;/g,'>').replace(/&quot;/g,'"');
	return disclaimerLink;
}

x_menu.prototype.metaNavigation = function(uri) {
	uri = uri.toLowerCase();
	if (uri.indexOf('/corporates/docs/country/contacts/') == 0) uri = uri.replace(/contacts\//i, '');
	var tmp = this.ref(uri);
	if(tmp != null) {
		while(tmp.parent != null) {
			if(tmp.level == 1) {
				if (tmp.metaNav[0] != null) {
					return tmp.metaNav;
				}
			}
			tmp = tmp.parent;
		}
	}
	return new Array ("Home", "Contact", "/corporates/docs/contact.jsp", "Language", "Search");
}

x_menu.prototype.contextrender = function(uri) {
	uri = uri.toLowerCase();
	if (uri.indexOf('/corporates/docs/country/contacts/') == 0) uri = uri.replace(/contacts\//i, '')
	if (uri.indexOf('/corporates/docs/country/') == 0 && uri.indexOf('/corporates/docs/country/index.jsp') != 0) uri = unescape(document.location.href).replace(/http:\/\/.+\/corporates\/docs(\/.+)/,'/corporates/docs$1');

	var tmp = this.ref(uri);
	if(tmp != null) {
		if((tmp.display == 'true' || tmp.display == 'false') || (uri.indexOf('/corporates/docs/country/') == 0 && tmp.children.length>0)) {
			if (uri.indexOf('/corporates/docs/country/') == 0 && uri.indexOf('/corporates/docs/country/index.jsp') != 0) {
				if (this.countrycontextrenderaction(tmp) != '') {
					return '<table id="navigation" border="0" cellpadding="0" cellspacing="0"><tr><td class="LeftNavSpacer"></td></tr>' + this.countrycontextrenderaction(tmp) + '<tr><td>\n<table width="134" border="0" cellpadding="0" cellspacing="0">\n<tr><td height="3"><spacer type="block" height="3" /></td></tr><tr>\n<td height="1" class="navsep"><spacer type="block" height="1" /></td>\n</tr></table>\n</td></tr>\n</table>';
				}
				else {
					return '';
				}
			}
			else {
				if (this.countrycontextrenderaction(tmp) != '') {
					return '<table id="navigation" border="0" cellpadding="0" cellspacing="0"><tr><td class="LeftNavSpacer"></td></tr>' + this.countrycontextrenderaction(tmp) + '<tr><td>\n<table width="134" border="0" cellpadding="0" cellspacing="0">\n<tr><td height="3"><spacer type="block" height="3" /></td></tr><tr>\n<td height="1" class="navsep"><spacer type="block" height="1" /></td>\n</tr></table>\n</td></tr>\n</table>';
				}
				else {
					return '';
				}
			}
		} else {
			return '';
		}
	} else {
		return '';
	}
}

x_menu.prototype.contextrenderaction = function(childnode) {
	var s_html = '';
	// || 
	
	if(this.level>1 && childnode.nodeatlevel(1) == this.nodeatlevel(1)) {
		if(((this.level < childnode.level) || this.ischild(childnode) || this.url == childnode.url || this.parent.url == childnode.parent.url || this.parent == childnode)) {
			if(this.parent.ischild(childnode) || this.parent == childnode) {
				s_html += this.gethtml(childnode);
			}
		}	
	}

	for(var a=0; a<this.children.length; a++) {
		tmp = this.children[a];
		s_html += tmp.contextrenderaction(childnode);
	}
	return s_html;
}

x_menu.prototype.countrycontextrenderaction = function(childnode) {
	var s_html = '';
	// ||
	startlevel = (top_level) ? 2 : 1;

	if(this.level>startlevel && childnode.nodeatlevel(startlevel) == this.nodeatlevel(startlevel)) {
		if(((this.level < childnode.level) || this.ischild(childnode) || this.url == childnode.url || this.parent.url == childnode.parent.url || this.parent == childnode)) {
			if(this.parent.ischild(childnode) || this.parent == childnode) {
				s_html += this.getcountryhtml(childnode);
			}
		}	
	}
	
	for(var a=0; a<this.children.length; a++) {
		tmp = this.children[a];
		s_html += tmp.countrycontextrenderaction(childnode);
	}
	
	return s_html;
}

x_menu.prototype.nodeatlevel = function(level) {
	var tmp = this;
	while(tmp.level > level) {
		tmp = tmp.parent;
	}
	return tmp;
}


x_menu.prototype.gethtml = function(childnode) {
	
	var s_html='';
	var s_class = '';
	var i_levelindent = 10;
	var i_tindent = 0;
	
	s_html += '<tr><td>\n<table width="134" border="0" cellpadding="0" cellspacing="0">\n<tr>\n';
			
	var i_tindent = ((this.level-2) * i_levelindent);
	var w = 134-i_tindent;
	
	if (this.display == 'true') {
		if(this.level==2) { 
			s_html += '<td height="3"><spacer type="block" height="3" /></td></tr><tr><td height="1" class="navsep"><spacer type="block" height="1" /></td></tr><tr><td height="3"><spacer type="block" height="3" /></td></tr><tr>\n';
		}
		if(i_tindent>0) { 
			s_html += '<td class="nav" width="'+i_tindent+'"></td><td class="nav" width="'+w+'">';
		} else {
			s_html += '<td class="nav" width="134">';
		}
		if(this.current == 'false') {
			s_tmp = ' target="_blank"';
		} else {
			s_tmp = '';
		}
		if(this.level==2) { 
			s_class= 'levelonebnav'; 
			sel_cl = 'selectednavone';
		}
		else if(this.level==3) { 
			s_class='leveltwonav'; 
			sel_cl = 'selectednavtwo';
		}
		else { 
			s_class='levelthreenav'; 
			sel_cl = 'selectednavtwo';
		}
		if(this==childnode) { s_html += '<a class="'+sel_cl+'" href="'+this.url+'">'+this.text +'</a><br>\n'; } else
		{ s_html += '<a class="'+s_class+'" href="'+this.url+'"' + s_tmp + '>'+this.text + '</a>'; } 
	}

	s_html += '\n</tr>\n</table>\n</td></tr>\n';

	return s_html;
			
}

x_menu.prototype.getcountryhtml = function(childnode) {
	
	var s_html='';
	var s_class = '';
	
	extralevel = (top_level) ? 1 : 0;
	
	s_html += '<tr><td>\n<table width="134" border="0" cellpadding="0" cellspacing="0">\n<tr>\n';
	
	if (this.display == 'true') {
		if (this.level==2+extralevel) {
			s_html += '<td height="3"><spacer type="block" height="3" /></td></tr><tr><td height="1" class="navsep"><spacer type="block" height="1" /></td></tr><tr><td height="3"><spacer type="block" height="3" /></td></tr><tr>'
		}

		s_style = '';
		if(this.level==3+extralevel) s_style = 'padding-left: 10px';
		if(this.level==4+extralevel) s_style = 'padding-left: 20px';

		s_html += '<td width="134" class="nav" style="'+s_style+'">';
		if(this.current == 'false') {
			s_tmp = ' target="_blank"';
		} else {
			s_tmp = '';
		}
		s_class= 'levelonebnav'; 
		sel_cl = 'selectednavone';
		s_style = '';
		if(this.level==3+extralevel) { 
			s_class='leveltwonav'; 
			sel_cl = 'selectednavtwo';
		}
		if(this.level==4+extralevel) { 
			s_class='levelthreenav'; 
			sel_cl = 'selectednavthree';
		}
		if(this==childnode) {
		 s_html += '<a class="'+sel_cl+'" href="'+this.url+'">'+this.text +'</a><br>\n';
		} else {
		 s_html += '<a class="'+s_class+'" href="'+this.url+'"' + s_tmp + '>'+this.text + '</a>';
		} 
		s_html += '\n</td>';
	}

	s_html += '\n</tr>\n</table>\n</td></tr>\n';
		
	return s_html;
}

x_menu.prototype.isparent = function(childnode) {
	while(!childnode.parent == null) {
		if(childnode.url == this.url) { return true; }
		childnode = childnode.parent;
	}
	return false;
}

x_menu.prototype.ischild = function(childnode) {
	var tmp;
	for(var a=0; a<this.children.length; a++) {
		tmp = this.children[a];
		if(tmp.url == childnode.url || tmp.ischild(childnode)) { return true; }
	}
	return false;
}

x_menu.prototype.childat = function(node, level) {
	while(node.level>level) {
		node=node.parent;
	}
	return node;
}

x_menu.prototype.mgif = function() {
	if(this.menugif.length>0) {
		return '<img src="/country/resources/images/static/'+this.menugif+'" alt="" border="0" height="1">';
	} else {
		return '<spacer width="754" height="1" type="block"/>';
	}
}

selectedImage = ''
levOneNav = false;

x_menu.prototype.levelone = function(page) {
	if (top_level) {
		selectedImage = ' ';
		levOneNav = true;
		page = page.toLowerCase();
		if (page.indexOf('/corporates/docs/country/contacts/') == 0) page = page.replace(/contacts\//i, '')
		
		var topl = this.ref(page);
		var bhastoplevel = false;
		this.menugif = '';
		
		if(topl != null) {
			topl = this.childat(topl,1);
		}
		
		var s_html = '';
		s_html += '<table border="0" cellpadding="0" cellspacing="0" width="754" height="23" id="LevelOneNav"><tr><td valign="top" align="right" id="levelOneCell"><table border="0" cellpadding="0" cellspacing="0" height="18"><tr>';
//		s_html += '<td valign="top" width="6" height="18"><spacer width="6" height="1" type="block"></spacer></td>';
		var tmp;
		var ih;
		var selected=false;
		var pselected=false;
		var isSelectedGO=false;	
		//add new solution for menu display
		var menuDisCount=0;	
		for(var i=0; i<topl.children.length; i++)
 		{
			var tmp1 = topl.children[i];
				
			if(tmp1.display == 'false')
			{
			  continue;
			}
			menuDisCount++;
		}	
		var tabNumber=0;
		for(var a=0; a<topl.children.length; a++) {
			tmp = topl.children[a];

			if(tmp.display == 'false')
		{
			continue;
		}
			ih = '';
			image = tmp.image_off
			mouseOver = ' onmouseover="changeImage(\'levelonenav'+a+'\', \''+tmp.image_over+'\')"'
			mouseOut = ' onmouseout="changeImage(\'levelonenav'+a+'\', \''+tmp.image_off+'\')"'
			if(true) {
				if(tmp==topl.ref(page)) {
				
					selectedImage = 'levelonenav'+tabNumber;
					ih = 'f';
					image = tmp.image_selected;
					mouseOver = '';
					mouseOut = '';
					selected=true;
					pselected=false;
				}
				if(tmp.ischild(this.ref(page))) {
					
					selectedImage = 'levelonenav'+a;
					ih = 's';				
					image = tmp.image_child_selected;
					mouseOver = '';
					mouseOut = '';
					selected=true;
					pselected=false;
				}
			}
			//add this case
			if((menuDisCount==1))
			{
				if(selected||pselected) {

					s_html += '<td valign="top" width="6" height="18"><spacer width="6" height="1" type="block"></spacer></td>';
					s_html += '<td valign="top" width="2" height="18" class="navlevone"><img class="borderColor" name="option'+a+'" width="2" height="11" alt="" border="0" vspace="2"></td>\n';
					s_html += '<td valign="top" width="11" height="18"><spacer width="11" height="1" type="block"></spacer></td>';
					s_html += '<td valign="top" height="18" id="levelonenav'+tabNumber+'"><a class="levelonenav'+ih+'" href="'+tmp.url+'"'+mouseOver+mouseOut+'>'+tmp.text+'</a></td>\n';
					s_html += '<td valign="top" width="11" height="18"><spacer width="11" height="1" type="block"/></spacer></td>\n';
					if(selected){
					s_html += '<td valign="top" width="2" height="18" class="navlevone"><img class="borderColor" name="option'+a+'" width="2" height="11" alt="" border="0" vspace="2"></td>\n';
					}
					if(pselected){
//					//s_html += '<td valign="top" width="2" height="18"><img class="borderColor" name="option'+a+'" width="2" height="11" alt="" border="0" vspace="2"></td>\n';
					}
					selected=true;
					pselected=true;
				}
				else {


					//s_html += '<td valign="top" width="6" height="18"><spacer width="6" height="1" type="block"></spacer></td>';
					//s_html += '<td valign="top" width="2" height="18" ><img class="borderColor" name="option'+a+'" width="2" height="11" alt="" border="0" vspace="2"></td>\n';
					s_html += '<td valign="top" width="11" height="18"><spacer width="11" height="1" type="block"></spacer></td>';
					s_html += '<td valign="top" height="18" id="levelonenav'+a+'"><a class="levelonenav'+ih+'" href="'+tmp.url+'"'+mouseOver+mouseOut+'>'+tmp.text+'</a></td>\n';
					s_html += '<td valign="top" width="11" height="18"><spacer width="11" height="1" type="block"/></spacer></td>\n';
//					//s_html += '<td valign="top" width="2" height="18" ><img class="borderColor" name="option'+a+'" width="2" height="11" alt="" border="0" vspace="2"></td>\n';
					pselected=false;
				}

			}
		//alert(tabNumber +"== menuDisCount -1 "+menuDisCount )
			//if((a == topl.children.length-1)){
	
			else if((tabNumber==menuDisCount-1)){//add this


				//if(selected||pselected) {
				if(selected) {

		

					//s_html += '<td valign="top" width="6" height="18"><spacer width="6" height="1" type="block"></spacer></td>';
					s_html += '<td valign="top" width="2" height="18" class="navlevone"><img class="borderColor" name="option'+a+'" width="2" height="11" alt="" border="0" vspace="2"></td>\n';
					s_html += '<td valign="top" width="11" height="18"><spacer width="11" height="1" type="block"></spacer></td>';
					s_html += '<td valign="top" height="18" id="levelonenav'+tabNumber+'"><a class="levelonenav'+ih+'" href="'+tmp.url+'"'+mouseOver+mouseOut+'>'+tmp.text+'</a></td>\n';
					s_html += '<td valign="top" width="11" height="18"><spacer width="11" height="1" type="block"/></spacer></td>\n';
					if(selected){
					s_html += '<td valign="top" width="2" height="18" class="navlevone"><img class="borderColor" name="option'+a+'" width="2" height="11" alt="" border="0" vspace="2"></td>\n';
					}
					if(pselected){
//					s_html += '<td valign="top" width="2" height="18"><img class="borderColor" name="option'+a+'" width="2" height="11" alt="" border="0" vspace="2"></td>\n';
					}
					//selected=true;
					selected=false;
					pselected=true;
				}
				else {

					if(pselected)
					{
					pselected=false;	
					}else{	
					s_html += '<td valign="top" width="2" height="18" ><img class="borderColor" name="option'+a+'" width="2" height="11" alt="" border="0" vspace="2"></td>\n';
					}
					s_html += '<td valign="top" width="11" height="18"><spacer width="11" height="1" type="block"></spacer></td>';
					s_html += '<td valign="top" height="18" id="levelonenav'+a+'"><a class="levelonenav'+ih+'" href="'+tmp.url+'"'+mouseOver+mouseOut+'>'+tmp.text+'</a></td>\n';
					s_html += '<td valign="top" width="11" height="18"><spacer width="11" height="1" type="block"/></spacer></td>\n';
//					s_html += '<td valign="top" width="2" height="18" ><img class="borderColor" name="option'+a+'" width="2" height="11" alt="" border="0" vspace="2"></td>\n';
					pselected=false;
				}
			}
			// if(a<=topl.children.length-1){
			 else if(a<=topl.children.length-1){



				//if(selected||pselected) {
				if(selected) {
				
					if(tabNumber!=0){
						s_html += '<td valign="top" width="2" height="18" class="navlevone"><img class="borderColor" name="option'+a+'" width="2" height="11" alt="" border="0" vspace="2"></td>\n';
						s_html += '<td valign="top" width="11" height="18"><spacer width="11" height="1" type="block"></spacer></td>';
					} else {
			
						
						s_html += '<td valign="top" width="6" height="18"><spacer width="6" height="1" type="block"></spacer></td>';
						s_html += '<td valign="top" width="2" height="18" class="navlevone"><img class="borderColor" name="option'+a+'" width="2" height="11" alt="" border="0" vspace="2"></td>\n';		
						s_html += '<td valign="top" width="11" height="18"><spacer width="11" height="1" type="block"></spacer></td>';
					}
					s_html += '<td valign="top" height="18" id="levelonenav'+tabNumber+'"><a class="levelonenav'+ih+'" href="'+tmp.url+'"'+mouseOver+mouseOut+'>'+tmp.text+'</a></td>\n';
					
					
					s_html += '<td valign="top" width="11" height="18" ><spacer width="11" height="1" type="block"/></spacer></td>\n';
					s_html += '<td valign="top" width="2" height="18" class="navlevone"><img class="borderColor" name="option'+a+'" width="2" height="11" alt="" border="0" vspace="2"></td>\n';

					pselected=true;
					selected=false;
					isSelectedGO=true;
/*
					if(!selected){
						pselected=false;
					}
					else{
						pselected=true;
						selected=false;

					}*/
				}
				else{

					
					if(pselected)		
					{	
					pselected=false;
					}
					else if(tabNumber!=0  ){
						s_html += '<td valign="top" width="2" height="18" ><img class="borderColor" name="option'+a+'" width="2" height="11" alt="" border="0" vspace="2"></td>\n';
					}
					s_html += '<td valign="top" width="11" height="18"><spacer width="11 height="1" type="block"></spacer></td>';
					
					if(isSelectedGO)
					{
					s_html += '<td valign="top" height="18" id="levelonenav'+a+'"><a class="levelonenav'+ih+'" href="'+tmp.url+'"'+mouseOver+mouseOut+'>'+tmp.text+'</a></td>\n';
					}else{
					s_html += '<td valign="top" height="18" id="levelonenav'+tabNumber+'"><a class="levelonenav'+ih+'" href="'+tmp.url+'"'+mouseOver+mouseOut+'>'+tmp.text+'</a></td>\n';
					}
					s_html += '<td valign="top" width="11" height="18"><spacer width="11" height="1" type="block"/></spacer></td>\n';
					selected=false;
					pselected=false;
				}
			}
		  tabNumber++;
		}
		s_html += '</tr></table></td></tr><tr><td class="navlevone" height="1" align="right">'+o_menu.mgif()+'</td></tr><tr><td height="4"><spacer width="754" height="4" type="block"/></td></tr></table>';
		return s_html;
	}
	else {
		return '';
	}
}


x_menu.prototype.languages = function(page) {
 page = page.toLowerCase();
 var tmp = this.ref(page);
 var languages = 0;


if(tmp != null) {
	while(tmp.parent != null) {
		if (tmp.level == 1) {
			currLang = tmp.lang
		}
		tmp = tmp.parent;
	}
}

 s_html = '<div id="metalanguage" onMouseOver="showLayer(\'metalanguage\');" onMouseOut="hideLayer(\'metalanguage\');" style="position: absolute; visibility: hidden;">\n';
 s_html += ' <table border="0" cellpadding="5" cellspacing="0" class="borderColor">\n';
 s_html += '  <tr>\n';
 s_html += '   <td class="bodytext" style="padding-right: 20px;">\n';

 for(var a=0; a<tmp.children.length; a++) {
  childEl = tmp.children[a];
  if (childEl.lang) {
   if (childEl.lang != '') {
    languages++
    s_html += '    <a class="metanav" href="'+childEl.url+'">'+childEl.lang+'</a><br>\n';
   }
  }
 }

 s_html += '   </td>\n';
 s_html += '  </tr>\n';
 s_html += ' </table>\n';
 s_html += '</div>\n';
 
 s_html = '<td class="metanav" height="10"><img src="/country/resources/images/static/meta_sep.gif" border="0" class="metasep"/></td><td class="metanav" height="10">&#160;<a class="metanav" href="#"  onMouseOver="showLayer(\'metalanguage\');" onMouseOut="hideLayer(\'metalanguage\');">Language</a>'+s_html+'&#160;</td>\n<td class="metanav" height="10"><!--<img src="/corporates/resources/images/static/meta_sep.gif" border="0" class="metasep"/>--></td>';
 if (languages > 1) return s_html; 
 else return ''; 
  return '';
}

x_menu.prototype.Metalanguages = function(page,MetaLangName) {
	var s_html = this.metaLanguages (page,MetaLangName);
	return s_html;
	}

x_menu.prototype.metaLanguages = function(page,MetaLangName) {
	page = page.toLowerCase();
	var tmp = this.ref(page);
	var languages = 0;


	if(tmp != null) {
		while(tmp.parent != null) {
			if (tmp.level == 1) {
				currLang = tmp.lang
			}
			tmp = tmp.parent;
		}
	}

	 s_html = '<div class= "metanavlang" id="metalanguage" onMouseOver="showLayer(\'metalanguage\');" onMouseOut="hideLayer(\'metalanguage\');">\n';

	s_html += ' <table cellpadding="5" cellspacing="0" >\n';
	 s_html += '  <tr>\n';
	 s_html += '<td class="bodytext" >\n';

	for(var a=0; a<tmp.children.length; a++) {
		childEl = tmp.children[a];
		if (childEl.lang) {
			if (childEl.lang != '') {
				languages++
				s_html += '<a class="metanav" href="'+childEl.url+'">'+childEl.lang+'</a><br>\n';
			}
		}
	}

	 s_html += '   </td>\n';
	 s_html += '  </tr>\n';
	 s_html += ' </table>\n';
	  s_html += '</div>\n';

	 s_html =  '<td class="metanavsep" width= "2" height="10"></td><td class="metanav" height="10">&#160;<a class="metanav" href="#"  onMouseOver="showLayer(\'metalanguage\');" onMouseOut="hideLayer(\'metalanguage\');">'+MetaLangName+'</a>'+s_html+'&#160;</td>\n<td class="metanav" height="10"><!--<img src="/corporates/resources/images/static/meta_sep.gif" border="0" class="metasep"/>--></td>';
	if (languages > 1) return s_html; 
		else return ''; 
	return '';
}