
function x_menu(p_root, p_url, p_text, p_alttext, p_current, p_display, p_level, p_parent, p_image_off, p_image_over, p_image_selected, p_image_child_selected) {

	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.image_child_selected = p_image_selected;
	this.menugif = '';
	this.children = Array();
	return this;
}

x_menu.prototype.addchildren = function(nodes) {
	var tmp;
	for(var a=0; a<nodes.length; a++) {
		var tmp=nodes[a];
		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('image_off'), tmp.getAttribute('image_over'), tmp.getAttribute('image_selected'), tmp.getAttribute('image_child_selected'));
		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;
}

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) {
	uri = uri.toLowerCase()
	if (uri.indexOf('/corporates/docs/news/') == 0 && uri.indexOf('/corporates/docs/news/pressrelations.jsp') != 0 && uri.indexOf('/corporates/docs/news/exco/') != 0 && uri.indexOf('/corporates/docs/news/spokespeople') != 0 && uri.indexOf('/corporates/docs/news/conferences.jsp') != 0) uri = '/corporates/docs/news/index.jsp'
	if (uri.indexOf('/corporates/docs/news/spokespeople') == 0) uri = '/corporates/docs/news/spokespeople/index.jsp'
	if (uri.indexOf('/corporates/docs/event/') == 0) uri = '/corporates/docs/event/index.jsp'
	if (uri.indexOf('/corporates/docs/deal/') == 0) uri = '/corporates/docs/deal/index.jsp'
	if (uri.indexOf('/psg/') >= 0) uri = '/psg/index.jsp'
	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 = '';
			}
			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 '';
	}
}

x_menu.prototype.contextrender = function(uri) {
	uri = uri.toLowerCase();
	if (uri.indexOf('/corporates/docs/news/') == 0 && uri.indexOf('/corporates/docs/news/pressrelations.jsp') != 0 && uri.indexOf('/corporates/docs/news/exco/') != 0 && uri.indexOf('/corporates/docs/news/spokespeople') != 0 && uri.indexOf('/corporates/docs/news/conferences.jsp') != 0) uri = '/corporates/docs/news/index.jsp'
	if (uri.indexOf('/corporates/docs/news/spokespeople') == 0) uri = '/corporates/docs/news/spokespeople/index.jsp'
	if (uri.indexOf('/corporates/docs/event/') == 0) uri = '/corporates/docs/event/index.jsp'
	if (uri.indexOf('/corporates/docs/deal/') == 0) uri = '/corporates/docs/deal/index.jsp'
	if (uri.indexOf('/psg/') >= 0) uri = '/psg/index.jsp'
	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">' + 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 '';
				}
			}
			if ((uri.indexOf('/corporates/docs/product/') == 0 || uri.indexOf('/psg/') >= 0) && uri.indexOf('/corporates/docs/product/index.jsp') != 0) {
				if (this.productcontextrenderaction(tmp) != '') {
					return '<table id="navigation" border="0" cellpadding="0" cellspacing="0">' + this.productcontextrenderaction(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.contextrenderaction(tmp) != '') {
					return '<table id="navigation" border="0" cellpadding="0" cellspacing="0">' + this.contextrenderaction(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 = s_html + this.gethtml(childnode);
			}
		}	
	}

	for(var a=0; a<this.children.length; a++) {
		tmp = this.children[a];
		s_html = s_html + tmp.contextrenderaction(childnode);
	}
	return s_html;
}

x_menu.prototype.countrycontextrenderaction = function(childnode) {
	
	var s_html = '';
	// ||
	if(this.level>3 && 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 = s_html + this.getcountryhtml(childnode);
			}
		}	
	}
	
	for(var a=0; a<this.children.length; a++) {
		tmp = this.children[a];
		s_html = s_html + tmp.countrycontextrenderaction(childnode);
	}
	
	return s_html;
}

x_menu.prototype.productcontextrenderaction = function(childnode) {
	
	var s_html = '';
	// || 
	if(this.level>2 && 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 = s_html + this.getproducthtml(childnode);
			}
		}	
	}
	
	for(var a=0; a<this.children.length; a++) {
		tmp = this.children[a];
		s_html = s_html + tmp.productcontextrenderaction(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 = 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 = 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 = s_html + '<td class="nav" width="'+i_tindent+'"></td><td class="nav" width="'+w+'">';
		} else {
			s_html = 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 = s_html + '<a class="'+sel_cl+'" href="'+this.url+'">'+this.text +'</a><br>\n'; } else
		{ s_html = s_html + '<a class="'+s_class+'" href="'+this.url+'"' + s_tmp + '>'+this.text + '</a>'; } 
	}

	s_html = 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 = '';
	
	s_html = s_html + '<tr><td>\n<table width="134" border="0" cellpadding="0" cellspacing="0">\n<tr>\n';
	
	if (this.display == 'true') {
		if (this.level==4) {
			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==5) s_style = 'padding-left: 10px';
		if(this.level==6) s_style = 'padding-left: 20px';

		s_html = 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==5) { 
			s_class='leveltwonav'; 
			sel_cl = 'selectednavtwo';
		}
		if(this.level==6) { 
			s_class='levelthreenav'; 
			sel_cl = 'selectednavthree';
		}
		if(this==childnode) {
		 s_html = s_html + '<a class="'+sel_cl+'" href="'+this.url+'">'+this.text +'</a><br>\n';
		} else {
		 s_html = s_html + '<a class="'+s_class+'" href="'+this.url+'"' + s_tmp + '>'+this.text + '</a>';
		} 
		s_html = s_html + '\n</td>';
	}

	s_html = s_html + '\n</tr>\n</table>\n</td></tr>\n';
		
	return s_html;
}

x_menu.prototype.getproducthtml = function(childnode) {
	
	var s_html='';
	var s_class = '';
	var i_levelindent = 10;
	var i_tindent = 0;
	
	s_html = s_html + '<tr><td>\n<table width="134" border="0" cellpadding="0" cellspacing="0">\n<tr>\n';
			
	var i_tindent = ((this.level-3) * i_levelindent);
	var w = 134-i_tindent;

	if (this.display == 'true') {
		if (this.level==3) { 
			s_html = s_html + '</tr><tr><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 = s_html + '<td class="nav" width="'+i_tindent+'"></td><td class="nav" width="'+w+'">';
		} else {
			s_html = s_html + '<td class="nav" width="134">';
		}

		if(this.current == 'false') {
			s_tmp = ' target="_blank"';
		} else {
			s_tmp = '';
		}
		if(this.level==3) { 
			s_class= 'levelonebnav'; 
			sel_cl = 'selectednavone';
		}
		else if(this.level==4) { 
			s_class='leveltwonav'; 
			sel_cl = 'selectednavtwo';
		}
		else { 
			s_class='levelthreenav'; 
			sel_cl = 'selectednavtwo';
		}
		if(this==childnode) {
			s_html = s_html + '<a class="'+sel_cl+'" href="'+this.url+'">'+this.text +'</a><br>\n';
		}
		else { 
			s_html = s_html + '<a class="'+s_class+'" href="'+this.url+'"' + s_tmp + '>'+this.text + '</a>';
		} 
	}

	s_html = s_html + '</td>\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="/corporates/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) {
//	selectedImage = ' ';
	levOneNav = true;
	page = page.toLowerCase();
	if (page.indexOf('/corporates/docs/news/') == 0 && page.indexOf('/corporates/docs/news/pressrelations.jsp') != 0 && page.indexOf('/corporates/docs/news/exco/') != 0 && page.indexOf('/corporates/docs/news/spokespeople') != 0 && page.indexOf('/corporates/docs/news/conferences.jsp') != 0) page = '/corporates/docs/news/index.jsp'
	if (page.indexOf('/corporates/docs/news/spokespeople') == 0) page = '/corporates/docs/news/spokespeople/index.jsp'
	if (page.indexOf('/corporates/docs/event/') == 0) page = '/corporates/docs/event/index.jsp'
	if (page.indexOf('/corporates/docs/deal/') == 0) page = '/corporates/docs/deal/index.jsp'
	if (page.indexOf('/psg/') >= 0) page = '/psg/index.jsp'
	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 = s_html + '<td valign="top" width="6" height="18"><spacer width="6" height="1" type="block"></spacer></td>';
	var tmp;
	var ih;
	for(var a=0; a<this.children.length; a++) {
		tmp = this.children[a];
		ih = '';
		image = tmp.image_off
		mouseOver = ' onmouseover="changeImage(\'levelonenav'+a+'\', \''+tmp.image_over+'\')"'
		mouseOut = ' onmouseout="changeImage(\'levelonenav'+a+'\', \''+tmp.image_off+'\')"'
		if(tmp == topl) {
			if(topl==this.ref(page)) {
				selectedImage = 'levelonenav'+a;
				ih = 'f';
				image = tmp.image_selected;
				mouseOver = '';
				mouseOut = '';
			} else {
				selectedImage = 'levelonenav'+a;
				ih = 's';				
				image = tmp.image_child_selected;
				mouseOver = '';
				mouseOut = '';
			}
		}
		if (a==0 && selectedImage != '') {
//			s_html = s_html + '<td valign="top" width="2" height="18"';
//			if((this.children[a] == topl) || (this.children[a+1]) == topl) {
//				s_html = s_html + ' class="navlevone"';
//			}
//			s_html = s_html + '><img name="option'+a+'" src="/corporates/resources/images/static/levonenav_sep.gif" width="2" height="11" alt="" border="0" vspace="2"></td>\n';
//			s_html = s_html + '<td valign="top" width="11" height="18"><spacer width="11" height="1" type="block"></spacer></td>\n';
		}
//		s_html = s_html + '<td valign="top" height="18"><a class="levelonenav'+ih+'" href="'+tmp.url+'"'+mouseOver+mouseOut+'><img id="levelonenav'+a+'" src="'+image+'" border="0" alt="'+tmp.alttext+'"/></a></td>\n';
		s_html = s_html + '<td valign="top" height="18" id="levelonenav'+a+'"><a class="levelonenav'+ih+'" href="'+tmp.url+'"'+mouseOver+mouseOut+'>'+tmp.text+'</a></td>\n';
		if(a == this.children.length-1 && (this.children[a] == topl || this.children[a+1] == topl) && topl != null) {
			s_html = s_html + '<td valign="top" width="11" height="18"><spacer width="11" height="1" type="block"/></td>\n';
			s_html = s_html + '<td valign="top" width="2" height="18" class="navlevone"><img name="option'+a+'" src="/corporates/resources/images/static/levonenav_sep.gif" width="2" height="11" alt="" border="0" vspace="2"></td>\n';
		}
		if(a<this.children.length-1) {
			
			s_html = s_html + '<td valign="top" width="11" height="18"><spacer width="11" height="1" type="block"/></td>\n';
			s_html = s_html + '<td valign="top" width="2" height="18"';
			if((this.children[a] == topl) || (this.children[a+1]) == topl) {
				s_html = s_html + ' class="navlevone"';
			}
			s_html = s_html + '><img name="option'+a+'" src="/corporates/resources/images/static/levonenav_sep.gif" width="2" height="11" alt="" border="0" vspace="2"></td>\n';
			s_html = s_html + '<td valign="top" width="11" height="18"><spacer width="11" height="1" type="block"></spacer></td>\n';
		}
	}
	return s_html;
}

