<!--
//**************************************************************
//***********************
//**************************************************************


//**************************************************************
//*******************D E C L A R A T I O N S**************************
//**************************************************************

//stale
IE4 = navigator.appName == "Microsoft Internet Explorer" && parseInt(navigator.appVersion) >= 4;        
NS4 = navigator.appName.substring(0,8) == "Netscape" && parseInt(navigator.appVersion) >= 4;

if(navigator.platform.indexOf("Mac") == 0)
	Mac = true;
else
	Mac = false;

var NS6;
	
if(NS4){
	window.captureEvents(Event.RESIZE);
	window.onresize = ns_reload;
	
	if(parseInt(navigator.appVersion) >= 5){
		NS4 = false;
		NS6 = true;
	}
}

//globalne
var objRef;
var overMenu;
var overTop;
var menuIndex;
var timeID;
var timeID2;
var navIndex;

//**************************************************************
//**************M E N U   O B J E C T   C O N S T R U C T O R**************
//**************************************************************

//I N I T   M E N U   O B J E C T
function MenuTop(initTopDef, initMenuDef)
{
	this.topDef = initTopDef;
	this.menuDef = initMenuDef;
	
	this.topItemCount = 0;
	this.menuItemCount = new Array();
	this.topItem = new Array();
	this.menuItem = new Array();
	this.arrowOver = new Image();
	this.arrowOver.src = "strzalka.gif";
	this.subArrowOver = new Image();
	this.subArrowOver.src = "";
	this.arrowOff = new Image();
	this.arrowOff.src = "czysc.gif";

	this.addTopMenu = addTopMenu;
	this.addMenuItem = addMenuItem;
	this.drawTopItemLayer = drawTopItemLayer;
	this.drawTopItem = drawTopItem;
	this.drawMenuItemLayer = drawMenuItemLayer;
	this.drawMenuItem = drawMenuItem;
	this.drawSubMenuLayer = drawSubMenuLayer;
	this.drawSubMenuItem = drawSubMenuItem;
	this.drawLayerClose = drawLayerClose;
	
	objRef = this;
}

//**************************************************************
//**********************B U I L D    M E N U S************************
//**************************************************************

//A D D   T O P   M E N U   I T E M S
function addTopMenu(graphicOn, graphicOff, itemPosX, itemPosY, hRefer)
{
	this.topItem[this.topItemCount] = new Array(4);
	this.topItem[this.topItemCount][0] = new Image();
	this.topItem[this.topItemCount][0].src = graphicOn;
	this.topItem[this.topItemCount][1] = new Image();
	this.topItem[this.topItemCount][1].src = graphicOff;
	this.topItem[this.topItemCount][2] = itemPosX;
	this.topItem[this.topItemCount][3] = itemPosY;
	this.topItem[this.topItemCount][4] = hRefer;

	this.drawTopItemLayer();
	this.drawTopItem();
	this.drawLayerClose();
		
	this.menuItem[this.topItemCount] = new Array();
	this.menuItemCount[this.topItemCount] = 0;

	this.topItemCount += 1;
}

//A D D   M E N U   I T E M S
function addMenuItem(topMenuItem, linkText, itemPosX, itemPosY, hRefer, subX, subY)
{
	this.menuItem[topMenuItem][this.menuItemCount[topMenuItem]] = new Array(5);
	this.menuItem[topMenuItem][this.menuItemCount[topMenuItem]][0] = linkText;
	this.menuItem[topMenuItem][this.menuItemCount[topMenuItem]][1] = itemPosX;
	this.menuItem[topMenuItem][this.menuItemCount[topMenuItem]][2] = itemPosY;
	this.menuItem[topMenuItem][this.menuItemCount[topMenuItem]][3] = hRefer;
	
	if(subX != null){
		this.menuItem[topMenuItem][this.menuItemCount[topMenuItem]][4] = subX;
	}
	
	this.drawMenuItemLayer(topMenuItem);
	this.drawMenuItem(topMenuItem);
	this.drawLayerClose();
	
	if(topMenuItem == objRef.topDef){
		this.drawSubMenuLayer(topMenuItem);
		this.drawSubMenuItem(topMenuItem);
		this.drawLayerClose();
	}
	
	this.menuItemCount[topMenuItem] += 1;
}

//**************************************************************
//*********************D R A W    M E N U***************************
//**************************************************************

//D R A W   V I S I B L E   M E N U   T O P   L A Y E R 
function drawTopItemLayer()
{
	if(IE4 || NS6)
		document.write('<div id="top' + this.topItemCount +'" style="left: ' + this.topItem[this.topItemCount][2] 
			+ '; top: ' + this.topItem[this.topItemCount][3] + '; width: 99; position: absolute; background-color: #FFFFF;">');
			
	if(NS4)
		 document.write('<layer name="top' + this.topItemCount +'" left="' + this.topItem[this.topItemCount][2]
			 + '" top="' + this.topItem[this.topItemCount][3] + '" visibility="show" bgcolor="#FFFFFF" width="99">');
}

//D R A W   M E N U   T O P   I T E M S
function drawTopItem()
{
	document.write('<a href="' + this.topItem[this.topItemCount][4] + '" onmouseover="activateMenu(' + this.topItemCount + ')" onmouseout="deactivateMenu(' + this.topItemCount + ')" class="white">');
	document.write('<img src="' + this.topItem[this.topItemCount][1].src + '" name="navImg' + this.topItemCount + '" border="0">' + '</a>');
}

//D R A W   V I S I B L E   M E N U   I T E M   L A Y E R - **SUBNAV ROLLOVER CALLOUTS**//kolor tła menu wysuwanego
function drawMenuItemLayer(index)
{
	if(IE4 || NS6)
		document.write('<div id="itemOn' + index + this.menuItemCount[index] + '" style="left: ' + this.menuItem[index][this.menuItemCount[index]][1] 
			+ '; top: ' + this.menuItem[index][this.menuItemCount[index]][2] + '; width: 137; position: relative; visibility: hidden; height: 22; background-color: #003162;">');
			
	if(NS4)
		 document.write('<layer name="itemOn' + index + this.menuItemCount[index] + '" left="' + this.menuItem[index][this.menuItemCount[index]][1]
			 + '" top="' + this.menuItem[index][this.menuItemCount[index]][2] + '" visibility="hide" width="137" height="22" z-index="100" bgcolor="#003162">');
}

//D R A W   M E N U   I T E M S//kolor obramowania menu wysuwanego
function drawMenuItem(index)//5e6a77
{
	if(NS6 || Mac)
		wid = 23;
	else
		wid = 23;
		
	document.write('<table cellpadding="0" cellspacing="0" border="0" width="100%"><tr><td colspan="3" height="1" bgcolor="#81BBF5"><img src="" height="1" width="1"></td></tr><tr><td width="1" bgcolor="#2E7673"><img src="" height="1" width="1"></td><td>');
	document.write('<table border="0" cellpadding="0" cellspacing="0" width="137"><tr><td width="4"><img src="" height="1" width="4"></td><td width="5"><img src="" height="9" width="5" name="arrow' + index + this.menuItemCount[index] + '"></td><td width="4"><img src="" height="' + wid + '" width="4"></td><td width="147">');
	document.write('<a href="' + this.menuItem[index][this.menuItemCount[index]][3] + '" onmouseover="activateItem(' + index + ', ' + this.menuItemCount[index] + ')" onmouseout="deactivateItem(' + index + ', ' + this.menuItemCount[index] + ')" class="white" name="ln' + index + this.menuItemCount[index] + '">');
	document.write(this.menuItem[index][this.menuItemCount[index]][0] + '</a></td></tr></table>');
	document.write('</td><td width="1" bgcolor="#2E7673"><img src="" height="1" width="1"></td></tr><tr><td colspan="3" height="1" bgcolor="#2E7673"><img src="" height="1" width="1"></td></tr></table>')
}
//D R A W   S U B   M E N U   L A Y E R S
function drawSubMenuLayer(index)
{
	if(IE4 || NS6)
		document.write('<div id="sub' + index + this.menuItemCount[index] + '" style="left:' + this.topItem[index][2] + '; top:' + this.menuItem[index][this.menuItemCount[index]][4] + '; width: 136; position: absolute; background-color: #003162">');

	if(NS4)
		document.write('<layer name="sub' + index + this.menuItemCount[index] + '" left="' + this.topItem[index][2] + '" top="' + this.menuItem[index][this.menuItemCount[index]][4] + '" width="136" bgcolor="#728d87">');
}

//D R A W   S U B   M E N U   I T E M S
function drawSubMenuItem(index)
{
	document.write('<table cellpadding="0" cellspacing="0" border="0" width="100%"><tr><td width="2"><img src="clear.gif" height="1" width="2"></td><td width="10"><img src="clear.gif" height="1" width="10"></td><td width="5"><img ');

	if(this.menuItemCount[index] == this.menuDef)
		document.write('src="nav_sub_arrow.gif"');
	else
		document.write('src="clear.gif"');

	document.write(' height="9" width="5" name="subArrow' + index + this.menuItemCount[index] + '"></td>');
	document.write('<td width="4"><img src="clear.gif" height="1" width="4"></td><td width="153"><a href="' + this.menuItem[index][this.menuItemCount[index]][3] + '" ');

	if(this.menuItemCount[index] != this.menuDef)
		document.write('onmouseover="activateItem(' + index + ', ' + this.menuItemCount[index] + ')" onmouseout="deactivateItem(' + index + ', ' + this.menuItemCount[index] + ')" ');


	
	if(this.menuItemCount[index] == this.menuDef)
		document.write(' class="black">' );
	else
		document.write(' class="white">' );
	
	document.write(this.menuItem[index][this.menuItemCount[index]][0] + '</a></td><td width="1" bgcolor="#000000"><img src="clear.gif" height="1" width="1"></td></tr>');
	document.write('<tr><td width="2"><img src="clear.gif" height="1" width="2"></td><td width="132" colspan="4"><img src="clear.gif" height="10" width="132"></td><td width="1" bgcolor="#000000"><img src="clear.gif" height="1" width="1"></td></tr></table>');
}

//D R A W   L A Y E R   C L O S E
function drawLayerClose()
{
	if(IE4 || NS6)
		document.write('</div>');
	
	if(NS4)
		document.write('</layer>');
}

//**************************************************************
//********************H A N D L E    M E N U S************************
//**************************************************************

//S H O W   L A Y E R S 
function showLayer(obj)
{
	if(IE4)
		document.all[obj].style.visibility = "visible";
			
	if(NS4)
		document.layers[obj].visibility = "show";
		
	if(NS6)
		document.getElementById(obj).style.visibility = "visible";
}

//H I D E   L A Y E R S
function hideLayer(obj)
{
	if(IE4)
		document.all[obj].style.visibility = "hidden";
		
	if(NS4)
		document.layers[obj].visibility = "hide";
		
	if(NS6)
		document.getElementById(obj).style.visibility = "hidden";
}

//A C T V A T E   M E N U
function activateMenu(index)
{	
	overTop = true;
	timeID2 = setTimeout("checkTop()", 300);
	navIndex = index;
	menuIndex = index;
	
	for(i = 0; i < objRef.topItemCount; i++){
				if(i != navIndex){
					
					for(j = 0; j < objRef.menuItemCount[i]; j++)
						hideLayer("itemOn" + i + j);
				}
			}
		navImg = "navImg" + index;
		document[navImg].src = objRef.topItem[index][0].src;
}

//D E A C T I V A T E   M E N U
function deactivateMenu(index)
{
	overTop = true;
	clearTimeout(timeID2);
	
	if(index != objRef.topDef){
		overMenu = false;
		menuInex = index;
		
		navImg = "navImg" + index;
		document[navImg].src = objRef.topItem[index][1].src;
		
		timeID = setTimeout("checkMenu()", 300);
	}
}

//A C T I V A T E   I T E M
function activateItem(topRef, index)
{
	if(topRef != objRef.topDef){
		overMenu = true;
		clearTimeout(timeID);
	}
	
	pic = (topRef == objRef.topDef) ? "subArrow" + topRef + index : "arrow" + topRef + index;
	document[pic].src = (topRef == objRef.topDef) ? objRef.subArrowOver.src : objRef.arrowOver.src;
	
}

//D E A C T I V A T E   I T E M//menu wysuwane aktywne
function deactivateItem(topRef, index)
{
	overMenu = true;
	
	pic = (topRef == objRef.topDef) ? "subArrow" + topRef + index : "arrow" + topRef + index;
	document[pic].src = objRef.arrowOff.src;
	
	if(topRef != objRef.topDef)
		timeID = setTimeout("checkMenu()", 450);
}

//R E D R A W   M E N U   O N   R E S I Z E   E V E N T   F O R   N E T S C A P E
function ns_reload()
{
	//window.location.href = "menu_test.html"; 
}

function checkMenu()
{
	
	
	if(!overMenu){
		for(i = 0; i < objRef.menuItemCount[menuIndex]; i++)
			hideLayer("itemOn" + menuIndex + i);
	}
	
	
}

function checkTop()
{
	if(overTop)
		if(navIndex != objRef.topDef){
			overMenu = true;
			menuIndex = navIndex;
			clearTimeout(timeID);
			
			for(i = 0; i < objRef.topItemCount; i++){
				if(i != navIndex){
					navImg = "navImg" + i;
					document[navImg].src = objRef.topItem[i][1].src;
				}
			}
			
			
		
			for(i = 0; i < objRef.menuItemCount[navIndex]; i++)
				showLayer("itemOn" + navIndex + i);
	}
}
//-->

