var nc = !!(document.captureEvents && !document.getElementById);
var nc6 = !!(document.captureEvents && document.documentElement);
var op6 = !!(document.getElementById && !document.documentElement);
var op7 = !!(window.opera && /Opera( |\/)7/i.exec(navigator.userAgent));
var ie = !!document.all;
var ie4 = !!(document.all && !document.documentElement);
var ie5 = !!(document.all && document.documentElement);
var dom = !!document.getElementById;
var mac = !!(navigator.userAgent.indexOf("Mac")!=-1);
var docEl = (document.documentElement && document.all) ? "documentElement" : "body";

function findStyle(s) {
	obj = null;
	if(ie4) obj = document.all[s].style;
	else if(dom) obj = document.getElementById(s).style;
	return obj;
}

function findDiv(s) {
	obj = null;
	if(ie4) obj = document.all[s];
	else if(dom) obj = document.getElementById(s);
	return obj;
}

function findPos(el) {
	xPos = yPos = 0;
	while(el){
		xPos += el.offsetLeft;
		yPos += el.offsetTop;
		if(!(ie4 && mac)) el = el.offsetParent;
		else el = el.parentElement;
	}
	return {xPos: xPos, yPos: yPos};
}

function ShowMenu(img,name) {
	x = findPos(img).xPos;
	y = findPos(img).yPos;
	md = findStyle(name + "div");
	md.left = (x + 4) + ((dom && !op6)? "px" : "");
	md.top = (y + 0) + ((dom && !op6)? "px" : "");
	md.visibility = "visible";
	if(ie5 && !op7) {
		document.all[name + "iframe"].style.left = md.left; 
		document.all[name + "iframe"].style.top = md.top;
		document.all[name + "iframe"].style.width =  document.all[name + "div"].offsetWidth + ((dom && !op6)? "px" : "");
		document.all[name + "iframe"].style.height = document.all[name + "div"].offsetHeight + ((dom && !op6)? "px" : "");
		document.all[name + "iframe"].style.visibility = "visible";
	}
}

function ShowSPMenu(sp) {
	if(!spdiv[sp]) return;
	DisplayUSPMenu(0);
	findDiv('menudiv').innerHTML = spdiv[sp];
	ShowMenu(document.images["SPImg"+sp],"menu");
}

function DisplaySPMenu(s) {
	findStyle("menudiv").visibility = s ? "visible" : "hidden";
	if(ie5 && !op7) document.all["menuiframe"].style.visibility = s ? "visible" : "hidden";
}

function ShowUSPMenu(sp) {
	if(!uspdiv[sp]) return;
	findDiv('umenudiv').innerHTML = uspdiv[sp];
	ShowMenu(document.images["USPImg"+sp],"umenu");
}

function DisplayUSPMenu(s) {
	findStyle("umenudiv").visibility = s ? "visible" : "hidden";
	if(ie5 && !op7) document.all["umenuiframe"].style.visibility = s ? "visible" : "hidden";
}
