var clickwindow = null;
var pdfwindow = null;

var xmlDoc = new Array(null, null, null, null, null);
function loadXmlDoc(index, filename, nextfunction)
{
	if (window.ActiveXObject)  {
		xmlDoc[index] = new ActiveXObject("Microsoft.XMLDOM");
		xmlDoc[index].async = false;
		xmlDoc[index].load(filename);
		nextfunction();
	}  else  {
		xmlDoc[index] = document.implementation.createDocument("", "", null);
		xmlDoc[index].onload = nextfunction;
		xmlDoc[index].load(filename);
	}
}

var menuFile = null;
var menuCurrent = null;
var menuXml = null;
var menuXsl = null;

function loadMenu(file, current)
{
	menuFile = file;
	menuCurrent = current;
	loadXmlDoc(0, "/library/include/xsl/zmenu.xsl", loadMenu2);
}

function loadMenu2()
{
	//if (!window.ActiveXObject)
	//	alert("MO?");
	menuXsl = xmlDoc[0];
	loadXmlDoc(0, menuFile, loadMenu3);
}

function loadMenu3()
{
	menuXml = xmlDoc[0];
	if (window.ActiveXObject)  {
		if (menuCurrent != null && menuCurrent != "") {
			var node = menuXml.selectSingleNode("document/items/item[@link='" + menuCurrent + "']");
			node.attributes.getNamedItem("selected").value = "1";
		}
		document.getElementById("menu").innerHTML = menuXml.transformNode(menuXsl);
	}  else  {
		if (menuCurrent != null && menuCurrent != "") {
			var node = menuXml.evaluate("document/items/item[@link='" + menuCurrent + "']", menuXml, null, XPathResult.ANY_TYPE, null).iterateNext();
			node.attributes.getNamedItem("selected").value = "1";
		}
		var processor = new XSLTProcessor();
		processor.importStylesheet(menuXsl);
		document.getElementById("menu").appendChild(processor.transformToDocument(menuXml).documentElement);		
	}
}

/*function loadMenu(file, current)
{
	var xsl = new ActiveXObject("Microsoft.XMLDOM");
	xsl.async = false;
	xsl.load("/library/include/xsl/zmenu.xsl");

	var xml = new ActiveXObject("Microsoft.XMLDOM");
	xml.async = false;
	xml.load(file);
	if (current != null && current != "") {
		var node = xml.selectSingleNode("document/items/item[@link='" + current + "']");
		node.attributes.getNamedItem("selected").value = "1";
	}
	document.getElementById("menu").innerHTML = xml.transformNode(xsl);
}*/

var listFile = null;
var listXml = null;
var listXsl = null;

function loadList(file, type)
{
	listFile = file;
	loadXmlDoc(1, "/library/include/xsl/" + type + ".xsl", loadList2);
}

function loadList2()
{
	listXsl = xmlDoc[1];
	loadXmlDoc(1, listFile, loadList3);
}

function loadList3()
{
	listXml = xmlDoc[1];
	if (window.ActiveXObject)  {
		document.getElementById("list").innerHTML = listXml.transformNode(listXsl);
	}  else  {
		var processor = new XSLTProcessor();
		processor.importStylesheet(listXsl);
		document.getElementById("list").innerHTML = processor.transformToDocument(listXml).documentElement.innerHTML;		
	}
}

/*function loadList(file, type)
{
	var xsl = new ActiveXObject("Microsoft.XMLDOM")
	xsl.async = false
	xsl.load("/library/include/xsl/" + type + ".xsl")

	var xml = new ActiveXObject("Microsoft.XMLDOM")
	xml.async = false
	xml.load(file)
	document.getElementById("list").innerHTML = xml.transformNode(xsl);
}*/

function overItem(o)
{
	o.style.backgroundColor = "#FFFFFF";
	o.style.color = "#0C4B80";
	o.style.borderColor = "#0C4B80";
}
		
function outItem(o)
{
	o.style.backgroundColor = "#0C4B80";
	o.style.color = "#FFFFFF";
	o.style.borderColor = "#FFFFFF";
}
		
function outItem2(o)
{
	o.style.backgroundColor = "#C0F0FC";
	o.style.color = "#0C4B80";
	o.style.borderColor = "#0C4B80";
}
		
function clickItem(page)
{
	window.location.href = page;
}

function clickItem2(page)
{
	w = window.open(page, "NIDA", "status=no,toolbar=no,menubar=no");
	w.focus();
}

function clickItem3(page)
{
	pdfwindow = window.open(page, "NIDAPDF", "status=no,toolbar=no,menubar=no", false);
	try {
		if (pdfwindow != null)
			pdfwindow.focus();
	} catch (e) {
	}
}

function clickItem4(page)
{
	w = window.open(page, "NIDAPDF", "status=no,toolbar=no,menubar=no,resizable=yes,scrollbars=yes,width=700,height=400");
	w.focus();
}

function clickItem5(page) {
	w = window.open(page, "NIDALINK", "status=no,toolbar=yes,menubar=yes,resizable=yes,scrollbars=yes,width=800,height=500");
	w.focus();
}

function openObjectives(file)
{
	w = window.open("objectives.html?file=" + file, "NIDAXML", "status=no,toolbar=no,menubar=no,resizable=yes,scrollbars=yes,width=700,height=400");
	w.focus();
}

