var sActive = "";
var item = null;
var t_id = null;
var mIndex = null;

function switchOn(parentObj, index, c)
{
	var obj, cells;
	//alert("ON " + index);
	switchOff('menu', mIndex, 'menu');
	obj = document.getElementById(parentObj);
	cells = obj.getElementsByTagName('td');
	for (i=0; i<cells.length; i++)
	{
		if (index == i)
		{
			cells[i].className = c + "On";
			//if (cells[i+1] != null) 
			//	cells[i+1].className = c + "On";
		}
	}
}
function switchOff(parentObj, index, c)
{
	var obj, cells;
	//alert("OFF " + index);
	obj = document.getElementById(parentObj);
	cells = obj.getElementsByTagName('td');
	for (i=0; i<cells.length; i++)
	{
		if (index == i)
		{
			cells[i].className = c + "Off";
			//if (cells[i+1] != null)
			//	cells[i+1].className = c + "Off";
		}
	}
	//mIndex = null;
}
/*function switchOffAll(parentObj, index, c)
{
	var obj, cells;
	//alert("OFF " + index);
	obj = document.getElementById(parentObj);
	cells = obj.getElementsByTagName('td');
	for (i=0; i<cells.length; i++)
	{
		if (index != i)
		{
			cells[i].className = c + "Off";
			if (cells[i+1] != null)
				cells[i+1].className = c + "Off";
		}
	}
}*/


function hoverOn (i, parentMenu)
{
	
	if (t_id != null && item != null)
	{
		if (document.layers)
		{
			obj = document.layers[item];
			obj.visibility = "hidden";
			//switchOff('menu', mIndex, 'menu');
		}
		else
		{
			obj = document.getElementById(item);
			obj.style.visibility = "hidden";
			//switchOff('menu', mIndex, 'menu');
		}
	}
	if (i != null)
	{
		obj = document.getElementById(i);
		obj.style.left = DL_GetElementLeft(parentMenu) + 140 + "px"
		obj.style.top = DL_GetElementTop(parentMenu) + "px";
		obj.style.visibility = "visible";
	}
}
function delay (i, ind)
{
	item = i;
	mIndex = ind;
	t_id = setTimeout ("hoverOff (item)", 50);
}
function hoverOff (i)
{
	if (item != null)
	{
		if (i != null && sActive=="")
		{
			if (document.layers)
			{
				obj = document.layers[i];
				obj.visibility = "hidden";
			}
			else
			{
				obj = document.getElementById(i);
				obj.style.visibility = "hidden";
			}
			switchOff('menu', mIndex, 'menu');
			//alert("here");
			//document.images[i].src = "/images/menus/"+i+".gif";
		}
	}
	clearTimeout (t_id);
	item = null;
}
function setClass(a, s)
{
	obj = a
	obj.className = s;
}

function linkTo(a)
{
	window.location.href = a + ".html";
}
function DL_GetElementLeft(eElement)
{
    var nLeftPos = eElement.offsetLeft;          // initialize var to store calculations
    var eParElement = eElement.offsetParent;     // identify first offset parent element  
    while (eParElement != null)
    {                                            // move up through element hierarchy
        nLeftPos += eParElement.offsetLeft;      // appending left offset of each parent
        eParElement = eParElement.offsetParent;  // until no more offset parents exist
    }
    return nLeftPos;                             // return the number calculated
}
function DL_GetElementTop(eElement)
{
    var nTopPos = eElement.offsetTop;            // initialize var to store calculations
    var eParElement = eElement.offsetParent;     // identify first offset parent element  
	//a = window.open();
	//a.document.open();
    while (eParElement != null)
    {                                            // move up through element hierarchy
		//a.document.writeln(eParElement.tagName + " " + eParElement.offsetTop);
        nTopPos += eParElement.offsetTop;        // appending top offset of each parent
        eParElement = eParElement.offsetParent;  // until no more offset parents exist
    }
	//a.document.close();
    return nTopPos;                              // return the number calculated
}
function preloader()
{
	var a, i;
	a = preloader.arguments;
	img = new Array(a.length)
	for (i=0; i<a.length; i++)
	{
		img[i] = new Image();
		img[i].src = a[i];
	}
		
}
function rnavOn(img)
{
	document.images[img].src = "images/rnav_" + img + "_on.gif";
}
function rnavOff(img)
{
	document.images[img].src = "images/rnav_" + img + "_off.gif";
}
function lnavOn(img, i)
{
	obj = document.getElementsByName(img);
	obj[i].src = "images/bullet_leftNav_" + img + "_on.gif";
}
function lnavOff(img, i)
{
	obj = document.getElementsByName(img);
	obj[i].src = "images/bullet_leftNav_" + img + ".gif";
}
function initialiseSubs()
{
	for (i = 1; i < 9; i++)
	{
		obj = document.getElementById("sub" + i);
		obj.style.top = DL_GetElementTop(document.getElementById('menu'));
	}
}
function printArticle(id)
{
	window.name='main'; //names the main window       
  
var w=window.open('printArticle.aspx?id=' + id, 'popup', 'scrollbars=yes,resizable=0,width=680,height=520,left=20,top=10');    
  
w.focus(); // popped window opens on top of other windows
}