/**
 * If the document is not in a Frame,
 * add a link that allows to open the document in Frames.
 */
function createTOCLink() {
	
	var relativeURL=getRelativeURL(location.href);
	if (!relativeURL) return;
	
	if (self == top) {
 		// no frame detected 
		var html='<a href="frames.html?url='+relativeURL+'" alt="'+openFrameLinkAlt+'"><< '+openFrameLinkLabel+'</a>';  
		document.writeln(html);
	}else{
		var html='<a target="_top" href="'+relativeURL+'" alt="'+closeFrameLinkAlt+'">>> '+closeFrameLinkLabel+'</a>';  
		document.writeln(html);
	}
}

/**
 * Synchronize content with TOC:
 * select currently displayed item in TOC
 */
function synchronize() {
		// frame detected, synchronize content
		if (self != top) {
			setTimeout("top.toc.synchronizeFrames()",200);
		}
}

function getRelativeURL(anURL) {
		var lastSlashIndex=anURL.lastIndexOf("/"); 
		if (lastSlashIndex>0) {
			return anURL.substring(lastSlashIndex+1);
		}
}

// ******** Tree functions **************
// Expands enough nodes to expose an LI with a given ID
function expandToURL(treeId,anURLObj) {
	var anURL = anURLObj.href;
	var ul = document.getElementById(treeId);
	if (ul == null) { return false; }
	var ret = expandCollapseListToURL(ul,nodeOpenClass,anURL,0,99);
	
	// Scrolling to show hidden items is not that good
	/*if (ret) {
			anURLObj.scrollIntoView(false);
	}*/
}

function expandCollapseListToURL(ul,cName,anURL,currentDepth,maxDepth) {
	if (currentDepth>=maxDepth) return true;
	
	if (!ul.childNodes || ul.childNodes.length==0) { return false; }
	// Iterate LIs
	for (var itemi=0;itemi<ul.childNodes.length;itemi++) {
		var item = ul.childNodes[itemi];
		if (item.nodeName == "LI") {
			// Iterate things in this LI
			var subLists = false;
			for (var sitemi=0;sitemi<item.childNodes.length;sitemi++) {
				var sitem = item.childNodes[sitemi];
				if (sitem.nodeName=="UL") {
					subLists = true;
					var ret = expandCollapseListToURL(sitem,cName,anURL,currentDepth+1,maxDepth );
					if (anURL!=null && ret) {
						item.className=cName;
						return true;
					}
				}else if (sitem.nodeName=="A") {
					if (anURL!=null && sitem.href==anURL) { 
						// Link found !!!
						return true; 
					}
				}
			}
			if (subLists && anURL==null) {
				item.className = cName;
			}
		}
	}
}

function displayMail(prefix,suffix) 
{
	if (!suffix) 
	{
		suffix="neotys.com"
	}
	var mail=prefix + "@" + suffix
	document.write("<a href=mailto:"+mail+">"+mail+"</a>")
}
