/*
 * date:	2002-10-11
 * info:	http://inspire.server101.com/js/tp/
 */

var tp = [];
var tpl = [];

function tpSet(i, c, d, z) {
if (document.createElement) {
	var e = document.getElementById(i);
	var l = document.createElement('ul');
	var p = document.createElement('div');
	e.className = l.className = p.className = c;

	var a, j, t;
	for (j = 4; j < arguments.length; j++) {
		c = document.getElementById(t = arguments[j]);
		tp[t] = c.parentNode.removeChild(c);

		a = l.appendChild(document.createElement('li'));
		a.className = c.className;
		if (t == 'Informations') {
			tpl[t] = a = a.appendChild(document.createElement('a'));
			a.setAttribute('href', 'javascript:tpShow(\''+i+'\', \''+t+'\',\''+z+'\');');
			var newiframe = document.createElement('iframe');
			newiframe.setAttribute('id', 'NewInformations');
			newiframe.setAttribute('name', 'NewInformations');
			newiframe.setAttribute('scrolling', 'no');
			newiframe.style.border = '0px';
			newiframe.width = '100%';
			newiframe.height = '20';
			newiframe.src = 'users/func.805.newinformations.php';
			a.appendChild(newiframe);
		}
		else if (t == 'Tasks') {
			tpl[t] = a = a.appendChild(document.createElement('a'));
			a.setAttribute('href', 'javascript:tpShow(\''+i+'\', \''+t+'\',\''+z+'\');');
			var newiframe = document.createElement('iframe');
			newiframe.setAttribute('scrolling', 'no');
			newiframe.setAttribute('id', 'NewTasks');
			newiframe.setAttribute('name', 'NewTasks');
			newiframe.style.border = '0px';
			newiframe.width = '100%';
			newiframe.height = '20';
			newiframe.src = 'users/func.806.newtasks.php';
			a.appendChild(newiframe);
		}
		else {
			tpl[t] = a = a.appendChild(document.createElement('a'));
			a.setAttribute('href', 'javascript:tpShow(\''+i+'\', \''+t+'\',\''+z+'\');');
			a.appendChild(document.createTextNode(c.getAttribute('title')));
		}
		c.style.display = 'block';
		
	}

	p.appendChild(tp[arguments[2]]);
	tpl[arguments[2]].className = 'active';

	while (e.firstChild) e.removeChild(e.firstChild);
	e.appendChild(l);
	e.appendChild(p);
	e.style.display = 'block';
	tpShow(i, d, z);
}}


function tpShow(e, p, z) {
	if (tpl[p] == null)
		return;
	e = document.getElementById(e).lastChild;
	hiddenfield = document.getElementById(z);
	if (hiddenfield.value == p)
		return;
	var reloadInformations = false;
	if (p == 'Informations' || hiddenfield.value == 'Informations')
		reloadInformations = true;
	var reloadTasks = false;
	if (p == 'Tasks' || hiddenfield.value == 'Tasks')
		reloadTasks = true;
	tpl[e.replaceChild(tp[p], e.firstChild).getAttribute('id')].className = null;
	tpl[p].className = 'active';
	hiddenfield.value = p;
//	alert('a' + window.frames[p+'Frame'].document);
//	var frame = window.frames[p+'Frame'];
	var frame = document.frames[p+'Frame'];
	if (frame != null && frame.reloader_form != null) {
		frame.reloader_form.submit();
	}
	if (reloadInformations)
		document.frames['NewInformations'].reload();
	if (reloadTasks)
		document.frames['NewTasks'].reload();
}
