var Menus=new Array();
var shown=-1;		// index to currently displayed menu


function openWin(url,name,width,height,prop)
{
    var tTop=(screen.height/2)-(height/2);
    var tLeft=(screen.width/2)-(width/2);
    if (prop == null)
        win=window.open(url,name,'resizable=yes,scrollbars=yes,status=yes,top='+tTop+',left='+tLeft+',width='+width+',height='+height);
    else win=window.open(url,name,prop+',top='+tTop+',left='+tLeft+',width='+width+',height='+height);
    win.focus();
    return win;
}
function getPageX (element) {
  var x = 0;
  do
    x += element.offsetLeft;
  while ((element = element.offsetParent));
  return x;
}
function getPageY (element) {
  var y = 0;
  do
    y += element.offsetTop;
  while ((element = element.offsetParent));
  return y;
}

function goPage(idx, url) {
	Menus[idx].mpop.hide();
	shown=-1;
	parent.hidePhotos();
	window.tmp.location=url;
//	updateContent(window.frames["tmp"].document.body.innerHTML);
}
function goPage1(url){
	tango = false;
	if (url.indexOf('javascript') == -1)
		document.location=url;
	else setTimeout("eval ("+url.substring(11)+")", 120); // skip past javascript:
	return true;
}
function goWin(url,name,width,height,prop) {
	tango=false;
	openWin(url,name,width,height,prop)
}
function initMenus() {
x=getPageX(document.images["mm"]);
y=getPageY(document.images["mm"]);
	Menus[0]=new Menu(0,getPageX(document.images["a0"]),y-51,160,46,2);
	Menus[1]=new Menu(1,getPageX(document.images["a1"]),y-73,80,68,3);
	Menus[2]=new Menu(2,getPageX(document.images["a2"]),y-51,80,46,2);
//	Menus[2]=new Menu(2,492,38,130,68,2);
//	Menus[3]=new Menu(3,624,38,80,68,3);
}
function Menu(idx,x,y,w,h,rows){
	this.mpop=window.createPopup();
	this.shown=false;
	this.mpop.document.body.innerHTML = eval("menu"+idx+".innerHTML");
	this.x=x;
	this.y=y;
	this.w=w;
	this.h=h;
	this.rows=rows;
	this.idx=idx;
}
Menu.prototype.show=MenuShow;
Menu.prototype.hide=MenuHide;

function MenuShow(){
	for (var i=0; i<this.rows;i++)
		this.mpop.document.getElementById("menus"+this.idx+"Item"+i).style.filter='';
	var newy = this.y - document.body.scrollTop;
	//var newy = this.y;
	this.mpop.show(this.x, newy, this.w, this.h, document.body);
	shown=this.idx;
}
function MenuHide(){
	// do nothing for now
//	this.mpop.hide();
}
// Static Methods
function showMenu(idx, move){
	var lefter = 10;
	var topper = 50;
	Menus[idx].show();
}
function hideMenu(idx){
	shown=-1;
	Menus[idx].hide();
}


