/*
 * date:	2002-12-13
 * info:	http://inspire.server101.com/js/xc/
 */

var xcNode = [];

function xcSet() {
	m = "nav2xc";
	c = "xc";
	if ((document.getElementById && document.getElementById(m) != null) && document.createElement && (navigator.userAgent.indexOf('MSIE 5.2') == -1 || navigator.userAgent.indexOf('Mac') == -1)) {
	m = document.getElementById(m).getElementsByTagName('ul');
	var d, p, x, h, i, j;
	for (i = 0; i < m.length; i++) {
		d = m[i].getAttribute('id');
		if (d) {
			x = xcCtrl(d, c, 'x', '/basemedia/images/sidemenu-item-expand-bg.gif', 'Show', m[i].getAttribute('title')+' (expand menu)');
			x = xcCtrl(d, c, 'c', '/basemedia/images/sidemenu-item-contract-bg.gif', 'Hide', m[i].getAttribute('title')+' (collapse menu)');
			
			p = m[i].parentNode;
			if (h = !p.className) {
				j = 2;
				while ((h = !(d == arguments[j])) && (j++ < arguments.length));
				if (h) {
					m[i].style.display = 'none';
					x = xcNode[d+'x'];
				}
			}

			p.className = c;
			p.insertBefore(x, p.firstChild);
		}
	}
}
}


function xcShow(m) {
	xcXC(m, 'block', m+'c', m+'x');
}


function xcHide(m) {
	xcXC(m, 'none', m+'x', m+'c');
}


function xcXC(e, d, s, h) {
	e = document.getElementById(e);
	e.style.display = d;
	e.parentNode.replaceChild(xcNode[s], xcNode[h]);
	xcNode[s].firstChild.focus();
}

//id, "som var", "xc", image path, state, title
function xcCtrl(m, c, s, v, f, t) {
	var a = document.createElement('a');
	a.setAttribute('href', 'javascript:xc'+f+'(\''+m+'\');');
	a.setAttribute('title', t);
	//a.appendChild(document.createTextNode(v));
	n = document.createElement("img");
	n.src = v;
	n.className = "icon";
	a.appendChild(n);

	var d = document.createElement('div');
	d.className = c+s;
	d.appendChild(a);

	return xcNode[m+s] = d;
}
