function ImageButton(sImg, sImgOver)
{
	this.normal = new Image();
	this.normal.src = sImg;
	this.over = new Image();
	this.over.src = sImgOver;
}

function changeImages(sImgName, sImgFile)
{	
	if (document.images && (preloadFlag == true))
	{
		document[sImgName].src = sImgFile;
	}
}





// Popup Menu ------------------------------------------------------------------------------------------------

function PopupMenu()
{
	this.top    = this;
	this.popups = new Array();

	this.addPopup   = PopupMenu_addPopup;
	this.getPopup   = PopupMenu_getPopup;
	this.initialize = PopupMenu_initialize;
}

function PopupMenu_addPopup(sName, iX, iY, iWidth, bIsSelected)
{
	var oLayer = createLayer("LAYER_" + sName, iX, iY, iWidth, false);
	//var oLayer = createLayer("LAYER_" + sName + "_BTNE04", 0, iY-5, 165, false);
	
	var oBtnLayer = createLayer("LAYER_" + sName + "_BTNE04", 0, iY-5, 165, false);
	var oPopup = new PopupMenu_Popup(this, sName, oLayer, oBtnLayer);

	this.popups[this.popups.length] = oPopup;

	if (document.all)
	{
		oLayer.style.zIndex = 100;
		oBtnLayer.style.zIndex = 50;
		oBtnLayer.style.height = 48;
		oBtnLayer.innerHTML = '<table width="165" height="48" border="0" cellspacing="0" cellpadding="0"><tr><td>&nbsp;</td></tr></table>';
	}
	else
	{
		oLayer.zIndex = 100;
		oBtnLayer.zIndex = 50;
		oLayer.captureEvents(Event.MOUSEOVER | Event.MOUSEOUT);
		oBtnLayer.captureEvents(Event.MOUSEOVER | Event.MOUSEOUT);
		oBtnLayer.resizeTo(165, 48);
	}

	oLayer.selfPopup = oPopup;
	oBtnLayer.selfPopup = oPopup;

	if (document.all)
	{
		/*---*/
		//oBtnLayer.style.backgroundColor = "red";
		/*---*/
		oLayer.onmouseover = new Function(oLayer.id + ".selfPopup.show(" + (bIsSelected != null ? bIsSelected : "") + ");return true");
		oLayer.onmouseout = new Function(oLayer.id + ".selfPopup.hide(" + (bIsSelected != null ? bIsSelected : "") + ");return true");
		oBtnLayer.onmouseover = new Function(oLayer.id + ".selfPopup.show(" + (bIsSelected != null ? bIsSelected : "") + ");return true");
		oBtnLayer.onmouseout = new Function(oLayer.id + ".selfPopup.hide(" + (bIsSelected != null ? bIsSelected : "") + ");return true");
	}
	else
	{
		oLayer.onmouseover = NSL_OnMouseOver;
		oLayer.onmouseout = NSL_OnMouseOut;
		oBtnLayer.onmouseover = NSBTN_OnMouseOver;
		oBtnLayer.onmouseout  = NSBTN_OnMouseOut;
	}

	return oPopup;
}

			function NSL_OnMouseOver(e)
			{
				if (e.target.selfPopup != null)
					e.target.selfPopup.show();
				return true;
			}

			function NSL_OnMouseOut(e)
			{
				if (e.target.selfPopup != null)
					e.target.selfPopup.hide();

				return true;
			}

			function NSBTN_OnMouseOver(e)
			{
				if (e.target.selfPopup != null);
					e.target.selfPopup.show();

				return true;
			}

			function NSBTN_OnMouseOut(e)
			{
				if (e.target.selfPopup != null);
					e.target.selfPopup.hide();

				return true;
			}



function PopupMenu_getPopup(sName)
{
	var i;

	for (i=0; i<this.popups.length; i++)
		if (this.popups[i].name == sName)
			return this.popups[i];

	return null;
}

function PopupMenu_initialize()
{
	var sHTML1 = "";
	var sHTML2 = "";
	var sHTML = "";
	var i, j;
	var oMenuItem;

	sHTML1 += '<table width="100%" border="0" cellspacing="0" cellpadding="1">';
	sHTML1 += '<tr>';
	sHTML1 += '<td bgcolor="#000000">';
		sHTML1 += '<table width="100%" border="0" cellspacing="0" cellpadding="5">';
		sHTML1 += '<tr>';
		sHTML1 += '<td bgcolor="#fffff0">';
			sHTML1 += '<table width="100%" border="0" cellspacing="5" cellpadding="0" style="cursor:default" class="Arial10pt">'
			sHTML2 += '</table>';
		sHTML2 += '</td>';
		sHTML2 += '</tr>';
		sHTML2 += '</table>';
	sHTML2 += '</td>';
	sHTML2 += '</tr>';
	sHTML2 += '</table>';

	for (i=0; i<this.popups.length; i++)
	{
		sHTML = sHTML1;
		oMenuItem = this.popups[i].menuItems;

		for (j=0; j<oMenuItem.length; j++)
		{
			sHTML += '<tr>';
			sHTML += '<td valign="top" onmouseover="this.style.backgroundColor=\'#e0d0b0\'" onmouseout="this.style.backgroundColor=\'#fffff0\'"' + (document.all ? ' onclick="self.location.href=\'' + oMenuItem[j].url + '\'"' : '') + ' style="cursor:hand">';
				if (!document.all)
					sHTML += '<font style="font-family:Arial; font-size:10pt"><a href="' + oMenuItem[j].url + '"' + (oMenuItem[j].target != null ? ' target="' + oMenuItem[j].target + '"' : '') + '>';

				sHTML += oMenuItem[j].title;

				if (!document.all)
					sHTML += '</a></font>';
			sHTML += '</td>';
			sHTML += '</tr>';
		}

		sHTML += sHTML2;

		if (document.all)
			this.popups[i].layer.innerHTML = sHTML;
		else
		{
			this.popups[i].layer.document.open();
			this.popups[i].layer.document.write(sHTML);
			this.popups[i].layer.document.close();
		}
	}
}

function PopupMenu_Popup(oParent, sName, oLayer, oLayerBtn)
{
	this.top    = oParent;
	this.parent = oParent;
	this.name   = sName;
	this.layer  = oLayer;
	this.layerBtn = oLayerBtn;
	this.menuItems = new Array();

	this.addItem = PopupMenu_Popup_addItem;
	this.show    = PopupMenu_Popup_show;
	this.hide    = PopupMenu_Popup_hide;
}

function PopupMenu_Popup_addItem(sTitle, sURL, sTarget)
{
	var oMenuItem = new PopupMenu_Popup_MenuItem(this, sTitle, sURL, sTarget);

	this.menuItems[this.menuItems.length] = oMenuItem;
	return oMenuItem;
}

function PopupMenu_Popup_show(bIsSelected)
{
	//window.status = ;

	if (document.all)
	{
		for (i=0; i<this.top.popups.length; i++)
		{
			this.top.popups[i].layer.style.visibility = "hidden";
			this.top.popups[i].layerBtn.style.visibility = "hidden";
		}
		this.layer.style.visibility = "visible";
		this.layerBtn.style.visibility = "visible";
	}
	else
	{
		this.layer.visibility = "show";
		this.layerBtn.visibility = "show";
	}
	if (!bIsSelected)
		changeImages("btn_" + this.name, eval("oBtn" + this.name + ".over.src"));
}

function PopupMenu_Popup_hide(bIsSelected)
{
	if (document.all)
	{
		this.layer.style.visibility = "hidden";
		this.layerBtn.style.visibility = "hidden";
	}
	else
	{
		this.layer.visibility = "hide";
		this.layerBtn.visibility = "hide";
	}
	if (!bIsSelected)
		changeImages("btn_" + this.name, eval("oBtn" + this.name + ".normal.src"));
}

function PopupMenu_Popup_MenuItem(oParent, sTitle, sURL, sTarget)
{
	this.top    = oParent.top;
	this.parent = oParent;
	this.title  = sTitle;
	this.url    = sURL;
	this.target = sTarget;
}





function createLayer(sLayerID, iX, iY, iWidth, bIsShowLayer)
{
	if (!iWidth) iWidth = 100;

	if (document.all)
	{
		document.body.insertAdjacentHTML('BeforeEnd', '<div id="' + sLayerID + '" style="position:absolute;visibility:' + (bIsShowLayer ? 'visible':'hidden') + '" class="popupmenu"></div>');

		document.all[sLayerID].style.left  = (iX != null ? iX : 0);
		document.all[sLayerID].style.top   = (iY != null ? iY : 0);
		document.all[sLayerID].style.width = iWidth;

		return document.all[sLayerID];
	}
	else
	if (document.layers)
	{
		var oLayer = document.layers[sLayerID] = new Layer(iWidth);
		oLayer.id = sLayerID;
		oLayer.left = (iX != null ? iX : 0);
		oLayer.top  = (iY != null ? iY : 0);

		if (bIsShowLayer)
			oLayer.visibility = "show";
		else
			oLayer.visibility = "hide";

		return document.layers[sLayerID];
	}
}


function getLayerPtr(oLayer)
{
	return (document.all ?
			(oLayer.substring ? document.all[oLayer] : oLayer) :
			(oLayer.substring ? document.layers[oLayer] : oLayer));
}


function showLayer(oLayer)
{
	var doc = getLayerPtr(oLayer);



	doc.visibility = (document.all ? "visible" : "show");
}


function hideLayer(oLayer)
{
	var doc = getLayerPtr(oLayer);

	doc.visibility = (document.all ? "hidden" : "hide");
}
