var sActive = "";
var item = null;
var t_id = null, s_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 (typeof(cells[i+1]) != 'undefined') 
			{
				//alert(cells[i+1]);
				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 (typeof(cells[i+1]) != 'undefined')
				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)
	{
		if (document.layers)
		{
			obj = document.layers[i];
			obj.left = DL_GetElementLeft(parentMenu);
			obj.top = DL_GetElementTop(parentMenu) + 24;
			obj.visibility = "visible";
		}
		else
		{
			obj = document.getElementById(i);
			obj.style.left = DL_GetElementLeft(parentMenu);
			obj.style.top = DL_GetElementTop(parentMenu) + 24;
			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)
{
	if (!document.layers && document.getElementById)
	{
		obj = a
		obj.className = s;
	}
	if (document.all && !document.getElementById)
	{
		obj = a;
		obj.className = s;
	}
}

function linkTo(a)
{
	window.location.href = a;
}
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  
    while (eParElement != null)
    {                                            // move up through element hierarchy
        nTopPos += eParElement.offsetTop;        // appending top offset of each parent
        eParElement = eParElement.offsetParent;  // until no more offset parents exist
    }
    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);
	newSrc = obj[i].src.substring(0, obj[i].src.indexOf("_")) + "_on.gif";
	obj[i].src = newSrc;
}
function lnavOff(img, i)
{
	obj = document.getElementsByName(img);
	newSrc = obj[i].src.substring(0, obj[i].src.indexOf("_")) + "_off.gif";
	obj[i].src = newSrc;
}
function initialiseSubs()
{
	for (i = 1; i < 9; i++)
	{
		obj = document.getElementById("sub" + i);
		obj.style.top = DL_GetElementTop(document.getElementById('menu'));
	}
}

function openMenu(index)
{
	var subs = new Array();
	var images = new Array();
	subs = document.getElementsByName('leftSub');
	imagesMain =  document.getElementsByName('closed');
	for (i = 0; i < subs.length; i++)
	{
		if (index == i)
		{
			subs[i].style.display = "block";
			parentRow = subs[i].parentNode.parentNode;
			parentRow.className = "leftNavOn"
		}
		else
		{
			subs[i].style.display = "none";
			parentRow = subs[i].parentNode.parentNode;
			parentRow.className = "leftNavOff";
			imagesMain[i].src = "images/bulletClosed_off.gif"
			imagesMain[i].vspace = "10";
		}
	}
	imagesMain[index].src = "images/bulletOpen_off.gif";
	imagesMain[index].vspace = "5";
}
function popWin()
{
	document.forms['f'].action="previewBCard.asp";
	document.forms['f'].target="popwin";
	window.open('', 'popwin', 'width=400, height=280, toolbar=no, status=no, scrollbars=no');
	document.forms['f'].submit();
}
function sbm()
{
	document.forms['f'].action="poster.asp";
	document.forms['f'].target="_self";
	document.forms['f'].submit();
}
function popup(url, w, h)
{
	var target = url.substr(0,url.indexOf("."));
	open(url, target, 'width='+w+', height='+h+', toolbar=no, status=no, scrollbars=no');
}
function popup_scrl(url, w, h)
{
	var target = url.substr(0,url.indexOf("."));
	open(url, target, 'width='+w+', height='+h+', toolbar=no, status=no, scrollbars=yes');
}
