var contentWin =null;
var xy = new Array(2);

function dialogEffect(){
	//new Effect.Shake(Windows.focusedWindow.getId());
	contentWin.destroy();
}

function closeWindow(){
	Dialog.alert("Remember to close the window before opening it again!",{className: "mac_os_x", width:320, height:70,
					onShow:dialogEffect, ok:function(win) {
						//debug("validate confirm panel");
						return true;
					}});
}

function closeMe(){
	contentWin = null;
	//debug("...closing");
	//debug("window status: " + contentWin);
	$('menuIX').hide();
	$('menuVIII').hide();
	$('menuVII').hide();
	$('menuVI').hide();
	$('menuV').hide();
	$('menuIV').hide();
	$('menuIII').hide();
	$('menuII').hide();
	$('menuI').hide();
	$('menuAMB').hide();
	$('menuAMB2').hide();
	$('menuAMB3').hide();
	$('menuSD').hide();
	$('menuSD2').hide();
	$('menuSD3').hide();
	$('menuSD4').hide();
	$('menuSD5').hide();
	$('menu2055').hide();
	$('menuST').hide();
	$('menuAF1').hide();
	$('menuVIIILow').hide();
	$('menuVIILow').hide();
	$('menuVILow').hide();
	$('menuVLow').hide();
	$('menuIIILow').hide();
	$('menuIILow').hide();
	$('menuILow').hide();
}

function initMenu(){
	//showDebug();
	contentWin  = new Window('1', {onDestroy: closeMe, className: "mac_os_x", title: "Navigation", maximizable: false,
											 minimizable: false, resizable: false, maxWidth: 430, top:70, left:100,
											 //wiredDrag: true, showEffect: Effect.BlindDown, hideEffect: Element.DropOut,
											 opacity: 0.9}); 
	contentWin.setDestroyOnClose();
}

function showLbjMenu(contextElementId, contentElementId, popupTitle) {
	if (contentWin != null) { closeWindow(); }
	else {
		initMenu();
		contentWin.setDestroyOnClose();
		xy = Position.cumulativeOffset($(contextElementId));
		contentWin.setContent(contentElementId, true, true);
		contentWin.setTitle(popupTitle);
		contentWin.show();
		contentWin.setConstraint(true, {left:xy[0]+120, top:xy[1]})
		//contentWin.showCenter(true);
		contentWin.toFront();
	}
}

function showLbjMenuForReviews(contextElementId, contentElementId, popupTitle) {
	if (contentWin != null) { closeWindow(); }
	else {
		initMenu();
		contentWin.setDestroyOnClose();
		xy = Position.cumulativeOffset($(contextElementId));
		contentWin.setContent(contentElementId, true, true);
		contentWin.setTitle(popupTitle);
		contentWin.show();
		//contentWin.setConstraint(true, {left:xy[0]+120, top:xy[1]})
		contentWin.showCenter(true);
		contentWin.toFront();
	}
}

function getThX(directUrl, prefix, type, active) {
	if (active) {
		document.write('<th style="padding: 3px;"><a href="http://nikelebron.net/'+directUrl+'" onMouseOver="document.reflbj'+prefix+type+'.src=\'http://nikelebron.net/nikelebron/images/xmenus/icon-'+type+'-hover.jpg\'" onMouseOut="document.reflbj'+prefix+type+'.src=\'http://nikelebron.net/nikelebron/images/xmenus/icon-'+type+'-normal.jpg\'"><img alt="'+type+'" src="http://nikelebron.net/nikelebron/images/xmenus/icon-'+type+'-normal.jpg" name="reflbj'+prefix+type+'" /></a></th>');
	} else {
		document.write('<th style="padding: 3px;"><img alt="'+type+'" src="http://nikelebron.net/nikelebron/images/xmenus/icon-'+type+'-inactive.jpg" name="'+prefix+type+'"/></th>');
	}
}

function getTitles(){
	document.write('<tr><th>Listing</th><th>Gallery</th><th>Showcase</th><th>Low ver.</th><th>Review</th><th>Timeline</th><th>Fakes</th></tr>');
	}
