var timer = null;

function $(id) {
	return document.getElementById(id);
}

function purgeDOM(d) {
	var a = d.attributes, i, l, n;
	if (a) {
		l = a.length;
		for (i = 0; i < l; i += 1) {
            n = a[i].name;
            if (typeof d[n] === 'function') {
            	d[n] = null;
        	}
		}
	}

	a = d.childNodes;
	
	if (a) {
        l = a.length;
        for (i = 0; i < l; i += 1) {
        	purge(d.childNodes[i]);
    	}
	}
}

function showAdminTab(id,headID) {
	if(last != null) {
		$(last).style.display = 'none';
		$(lastHead).style.background = '#ccc';
	};
	
	$(id).style.display = 'block';
	$(headID).style.background = '#ffc';
	last = id;
	lastHead = headID;
}

function showTab(id) {
	if(last != null) {
		$('tabContent' + last).style.display = 'none';
		$('pageTab' + last).style.color = '#333';
		$('pageTab' + last).onmouseout = "this.style.color='#333'";
		$('pageTab' + last).style.background = "url('/images/tabbutton.gif') no-repeat top left";
	};
	
	$('tabContent' + id).style.display = 'block';
	$('pageTab' + id).style.color = '#900';
	$('pageTab' + id).onmouseout = "this.style.color='#900'";
	$('pageTab' + id).style.background = "url('/images/tabbutton_over.gif') no-repeat top left";
	last = id;
}

function tabHoverOver(id) { 
	$('pageTab' + id).style.color = '#900';
}

function tabHoverOut(id) {
	if(last != null && last == id) {
		$('pageTab' + id).style.color = '#900';
	} else {
		$('pageTab' + id).style.color = '#333';
	}
}

function treeHoverIn(id) {
	$('node' + id).style.backgroundColor = '#ff9';
	$('hoverMenu' + id).style.display = 'inline';
}

function treeHoverOut(id) {
	$('node' + id).style.backgroundColor = '#fff';
	$('hoverMenu' + id).style.display = 'none';
}

function dropbreadcrumb(id) {
	clearTimeout(timer);
	for(var i=0; i<menulist.length; i++) {
		$(menulist[i]).style.display = 'none';
	}
	$(id).style.display = 'block';
}

function closebreadcrumb(id) {
	timer = setTimeout("$('"+id+"').style.display = 'none';",500);
}
