//******************************************************************************
//       Apycom DHTML-menu v2.80
//         www.dhtml-menu.com
//       E-mail: dhtml@apycom.com
//------------------------------------------------------------------------------
// New:
//     1: Crossframe support!
//           @ apy_initFrame(framesetID, mainFrameN, subFrameN, orientation); - into top menu page;
//                framesetID - id of frameset;
//                mainFrameN - main frame number (top menu frame) >=0;
//                subFrameN  - sub frame number (frame with submenus) >=0;
//                orientation - 0/1 - horizontal/vertical.
//     2: apy_changeItem (n,m,i, newText,newTarget,newTip, newImgOver,newImgOut)
//           - n - menu, m - submenu, i - item. All >= 0.
//     3: hidding objects for floatable menu, if it intersects them
//     4: hidding objects for movable menu, if it intersects them
//     5: submenus positioning in Mozilla/Netscape fixed
//     6: corrected toggle mode for non-crossframe mode
//     7: toggle mode for crossframe
//     8: crossframe for OP5 & OP6
//     9: works with <!DOCTYPE> tag
//    -------- v2.15 ---------------
//    10: personal item width in itemStyles:  "itemWidth=value".
//    11: partially fixed submenu positioning with crossframe mode (need fix in MZ, NS)
//    12: fixed onLoad event
//    13: increase loading speed of big menus up to 40% in IE!!!
//    14: fixed bug with <!DOCTYPE> tag in OP5
//    15: begining of popup mode: var popupMode=1;
//    16: top menu shadow: var shadowTop=0/1; (default is 1)
//    -------- v2.16 ---------------
//    17: fixed some problems with object intersection in NS (flash, applet, etc.)
//    18: popup mode.
//        Initialization:
//           onContextMenu="return apy_popup([menuN>=0], [hidePause>0], event)"
//           ------------------------------------------------------------------
//        Note: Popup mode doesn't support Opera, because Opera doesn't support
//        ~~~~  onContextmenu event and can't determine mouse button,
//              even if onMouseDown event occured.
//    -------- v2.50 ---------------
//    19: CSS support!
//          var cssStyle=0/1;                         // off/on css mode
//          var cssClass="className";                 // css class name (e.g.: .myClass {...} => var cssClass="myClass";)
//          var menuStyles = [ ["CSS=className"] ];       // individual css class for submenu
//          var itemStyles = [                            // individual css class for item
//              ["CSS=classNameNormal,classNameOver"]
//          ];
//    -------- v2.60 ---------------
//    20: fixed bug with seperator sizes in NS4
//    21: added 15 new transition effects:
//            var transition=[0..39];
//            var transOptions="param1=value1,param2=value2"; - for more details go to www.msdn.com
//    -------- v2.62 ---------------
//    22: fixed positioning in MAC IE
//    -------- v2.63 ---------------
//    23: fixed last item clipping bug when menu build in <TD>.
//           Problem in document.write() of top menu insted of document.body.insertAdjacentHTML() in <td> tag.
//    -------- v2.64 ---------------
//    24: disabled <OBJECT> hidding (<PARAM NAME=wmode VALUE=opaque>)
//    -------- v2.70 ---------------
//    25: code optimization
//    26: corrections for NS4
//    27: corrections in popup mode
//    28: corrections for OP5
//    29: corretions for positioning in crossframe mode
//    -------- v2.71 ---------------
//    30: fixed <!DOCTPYE> in crossframe moe
//    31: corrections for positioning in crossframe mode
//    32: fixed bug with <!DOCTYPE> tag in Mozilla
//           (Mozilla doesn't make differences between BackCompat & CSS1Compat).
//    -------- v2.72 ---------------
//    33: Absolute/relative paths for a crossframe mode.
//           Syntax:
//             var pathPrefix = "..."; - path prefix for item links and images.
//    34: Submenus' dX, dY offset:
//             var topDX = 0;
//             var topDY = 0;
//             var DX = -5;
//             var DY = 0;
//    35: Saving submenu navigation path (items highlight during menu navigation):
//           var saveNavigationPath = 0/1;
//    -------- v2.73 ---------------
//    36: fix for crossframe mode with multiple menus
//    -------- v2.74 ---------------
//    37: var orientation = 0/1; (vertical/horizontal). Default is 0;
//    38: columnPerSubmenu = 1; columns count per submenu. Default is 1. Works if orientation=1 only.
//             Included into individual menu styles:  ["columnPerSubmenu=3"]
//    39: corrections for Mozilla/Firefox in apy_getClientSize();
//    -------- v2.75 ---------------
//    40: correction for IE<5.5 (submenus don't appear for filter in apy_showMenu())
//    41: MAC fix! (IE and Safari). Add new params for MAC IE:
//          macIEoffX, macIEoffY - global menu offset relatively to page.
//          macIEtopDX, macIEtopDY, macIEDX, macIEDY - submenus offset.
//    -------- v2.80 ---------------
//    42: new apy_popup() syntax:
//                apy_popup(menuN, hidePause, event, x, y);
//                  x,y - coords where menu will appear. If empty - gets coords from event.
//    43: new param: var bottomUp=1; - submenus appear on the top of horizontal menu (Win taskbar like mode).
//    44: fix pathPrefix problem: pathPrefix isn't added if url has http://, https://, ftp://
//    45: show submenus by click: var showByClick=1;
//    46: "itemPadding" and "itemSpacing" for each submenu in var menuStyles.
//    47: problems with <meta charset=utf-8>. Solution: add charset=iso-8859-1 into <script> tag.
//    48: fixed problems with <!DOCTYPE> for floatable & moveable menus in Mozilla/FireFox
//******************************************************************************
//new var names
var b_IE  = 0;
var b_IE5 = 0;
var b_NS  = 0;
var b_NS4 = 0;
var b_OP  = 0;
var b_MZ  = 0;
var b_VER = 0;
var b_DOM = 0;
var b_MAC = 0;
var b_IEComp = 0;

var isLoaded   = 0;                               // are submenus loaded
var regexp_m   = /apy([0-9]+)m([0-9]+)/;          // mask to extact indexes from menu id
var regexp_i   = /apy([0-9]+)m([0-9]+)i([0-9]+)/; // mask to extact indexes from item id

var iMenu  = 0;   // n of menus on page
var iSMenu = 0;   // n of submenus with one menu
var iSItem = 0;   // n of items with one submenu
var apy_o  = [];  // menu object
var hidID  = [];  // array of hidden objects (select, applet, object, iframe)

var moveFlag = false;     // true if menu is in moving process
var mdX, mdY;             // start coords for movable menu
var mMenu;                // current operating menu object (for moving, etc.)
var mMenuVar;             // current operating menu variable (for moving, etc.)

var curPressedI_  = -1;   // current pressed item -> none
var loadFunc = null;      // temp var for remembering user onLoad event

var s     = "";
var out_  = "";
var zind  = 1000;

// Document object variable depending on <DOCTYPE> (detects in apy_tLoad())
// Using as document.body object.
var docElement;

//-------------

apy_getBrowser();
var subMenu_dir;
// Detect measuring units
if (!(b_OP && b_VER<6))
var dUnits = "px";
else
var dUnits = "";
//------------------------
document.write("<input type=hidden id=xposition>");

function apy_getPageScroll() {
	var sx = b_IEComp?docElement.scrollLeft:pageXOffset;
	var sy = b_IEComp?docElement.scrollTop:pageYOffset;
	return [sx,sy]
}

function apy_getObjectStyleXY(obj) {
	with (obj) return [(b_NS4)?left:parseInt(style.left), (b_NS4)?top:parseInt(style.top)];
}

function apy_setObjectStyleXY(obj, nx, ny) {
	with (obj)
	{
		if (b_NS4) {
			left = nx;
			top  = ny;
		}
		else {
			style.left = nx + dUnits;
			style.top  = ny + dUnits;
		}
	}
}

function apy_scrollWindow() { // Assign to scroll page event (for floatable menu)
	if (moveFlag) return;
	for (var j=0; j<apy_o.length; ++j)
	if (apy_o[j] && apy_o[j].floating && apy_o[j].abspos)
	{
		var mnu = apy_getObjectByID("apy" + j + "m0");
		var mnuXY   = apy_getObjectStyleXY(mnu);                 // get current coords from object.style
		var pageOff = apy_getPageScroll();                       // get page scroll offset
		var l = pageOff[0] + apy_o[j].left;                      // calculate absolute menu coords
		var t = pageOff[1] + apy_o[j].top;                       // ---

		if (mnuXY[0]!=l || mnuXY[1]!=t)                          // if coords must be changed
		{
			var dx = (l - mnuXY[0])/apy_o[j].iterations;           // calculate delta coords
			var dy = (t - mnuXY[1])/apy_o[j].iterations;           // ---

			if (!b_NS4)
			with (Math)
			{
				if (abs(dx)<1) dx = abs(dx)/dx;
				if (abs(dy)<1) dy = abs(dy)/dy;
			}
			else
			{
				if (dx>-1 && dx<0) dx = -1;                                  // check if |delta-coord x|<1 -> correct to 1/-1
				else if (dx>0 && dx<1) dx = 1;                               // ---
				if (dy>-1 && dy<0) dy = -1;                                  // ---
				else if (dy>0 && dy<1) dy = 1;                               // ---
			}
			apy_setObjectStyleXY(mnu, mnuXY[0] + ((mnuXY[0]!=l)?dx:0), mnuXY[1] + ((mnuXY[1]!=t)?dy:0));
			apy_checkMainMenuIntersection (apy_o[j]);      // if coords have been changed -> hide intersect objects
		}
	}
}

var crossType = 1;  // 0: script in main page with frameset;
// 1: script in main frame with main menu;
// 3: script in main frame and submenus will resize main frame (IE only)

function apy_onload() {
	// Detect document object according to <DOCTYPE> specification
	docElement = (document.compatMode=="CSS1Compat" && !b_MZ)?document.documentElement:document.body;

	if (b_NS4) document.layers[0].visibility = "show";

	//===== Initialize floatable menu ==========================================
	if (!(b_OP && b_VER<6))                // cancel floatable mode for Opera 5: links don't work if enabled
	for (var j=0; j<apy_o.length; ++j)
	if (apy_o[j] && !apy_o[j].cross && apy_o[j].floating && apy_o[j].abspos)
	{
		window.setInterval ("apy_scrollWindow()", 20);         // call floatable function
		break;                                                                  //   only once
	}
	//==========================================================================

	s    = "";
	out_ = "";
	isLoaded = 1;	                                                // submenus loaded
	apy_setMoveEvent();                                           // set mousemove event for moveable menu
	if (loadFunc)                                                 // execute user's onLoad event
	loadFunc();
	onerror = apy_error;
}

//---------------------
var crossframe     = 0;
var crossFrameset  = "";
var crossMainFrame = 0;
var crossSubFrame  = 1;
var crossView      = 0;
//---------------------

//****************************************************************************//
//******************** Init crossframe mode **********************************//
//****************************************************************************//
function apy_initFrame(fsetID, mainFrameInd, subFrameInd, view) {
	if (b_NS4 || (b_OP && b_VER<7) || (b_IE && b_VER<5))   // crossframe mode is always turn off for these browsers
	{
		crossframe = 0;
		crossType  = 1;
	}
	else
	{
		crossframe = 1;
		crossType  = 1;
		crossFrameset  = fsetID;
		crossMainFrame = mainFrameInd;
		crossSubFrame  = subFrameInd;
		crossView      = view;
		if (iMenu<1000) iMenu = 1000;
	}
	apy_init();
}
//****************************************************************************//

function apy_setOnLoad() {
	if (window.attachEvent)
	window.attachEvent("onload", apy_onload);
	else
	{
		loadFunc = (typeof(onload)=='function')?onload:null;            // remember user's onLoad event one time
		onload = apy_onload;                                            // set own onLoad event one time
	}
}

var pos, vis;
// ----------- Define Global Params --------------------------------------------
function apy_checkGlobalParams() {
	if (typeof(popupMode)=="undefined" || b_NS4) popupMode = 0; // turn off popup mode for Netscape4

	pos = (absolutePos || popupMode)?"absolute":"static"; //absolutePos || popupMode
	vis = (b_NS4)?"show":((popupMode)?"hidden":"visible");

	// alert(pos);

	if (typeof(pressedItem)=="undefined")
	pressedItem = -2;                       // by default toggle mode is turn off (-2)
	else
	if (pressedItem >= 0)
	curPressedI_ = pressedItem;           // else set current pressed item

	if (b_NS4)
	{
		separatorWidth   = " " + separatorWidth;
		separatorHeight  = " " + separatorHeight;
		separatorVWidth  = " " + separatorVWidth;
		separatorVHeight = " " + separatorVHeight;
		if (separatorWidth.indexOf("%")   >= 0) separatorWidth   = separatorWidth.substring (0, separatorWidth.indexOf("%"));
		if (separatorHeight.indexOf("%")  >= 0) separatorHeight  = "";
		if (separatorVWidth.indexOf("%")  >= 0) separatorVWidth  = "1";
		if (separatorVHeight.indexOf("%") >= 0) separatorVHeight = "1";
	}

	if (typeof(crossframe)    =="undefined") crossframe     = 0;
	if (typeof(crossMainFrame)=="undefined") crossMainFrame = 0;
	if (typeof(crossSubFrame) =="undefined") crossSubFrame  = 1;
	if (typeof(crossView)     =="undefined") crossView      = 0;
	if (typeof(crossFrameset) =="undefined") crossFrameset  = "";
	if (typeof(shadowTop)     =="undefined") shadowTop    = 1;
	if (typeof(cssStyle)      =="undefined") cssStyle     = 0;
	if (typeof(transOptions)  =="undefined") transOptions ="";

	if (typeof(cssClass)=="undefined" || b_NS4) // turn off CSS mode for Netscape4
	{
		cssStyle = 0;
		cssClass = "";
	}

	// Define links' and images' path prefix
	if (typeof(pathPrefix)=="undefined") pathPrefix = "";

	// Define submenus' dX and dY offset
	if (typeof(DX)=="undefined") DX = -5;
	if (typeof(DY)=="undefined") DY = 0;
	if (typeof(topDX)=="undefined") topDX = 0;
	if (typeof(topDY)=="undefined") topDY = 0;

	if (typeof(macIEoffX)=="undefined")   macIEoffX  = 10;
	if (typeof(macIEoffY)=="undefined")   macIEoffY  = 15;
	if (typeof(macIEtopDX)=="undefined")  macIEtopDX = 0;
	if (typeof(macIEtopDY)=="undefined")  macIEtopDY = 2;
	if (typeof(macIEDX)=="undefined")     macIEDX    = -3;
	if (typeof(macIEDY)=="undefined")     macIEDY    = 0;

	if (b_MAC&&b_IE)
	{
		DX = macIEDX;
		DY = macIEDY;
		topDX = macIEtopDX;
		topDY = macIEtopDY;
	}

	// Define items' highlighting during menu navigation
	if (typeof(saveNavigationPath)=="undefined") saveNavigationPath = (b_NS4?0:1);

	// Define items' highlighting during menu navigation
	if (typeof(orientation)=="undefined") orientation = 0;
	if (typeof(columnPerSubmenu)=="undefined" || columnPerSubmenu<1) columnPerSubmenu = 1;

	if (typeof(bottomUp)=="undefined") bottomUp = 0;
	if (typeof(showByClick)=="undefined") showByClick = 0;
}

function apy_createPopupMenu() {
	// increase items level
	for (var i=0; i<menuItems.length && typeof (menuItems[i]) != "undefined"; i++)
	menuItems[i][0] = '|' + menuItems[i][0];

	// add new root item
	var newItem = [[""]];
	menuItems = newItem.concat(menuItems);
}

var fixPrefixes = ["http://", "https://", "ftp://"];
function canPrefix(url) {
	for (var i=0; i < fixPrefixes.length; i++)
	if (url.indexOf(fixPrefixes[i]) == 0) return false;
	return true;
}

function apy_setPathPrefix(pathArr) {
	var arr = [""];
	for (var i=0; i<pathArr.length; i++)
	if (pathArr[i] && canPrefix(pathArr[i]))
	arr[i] = pathPrefix + pathArr[i];
	return arr;
}


function apy_init() {
	if (!iMenu || iMenu==1000) apy_setOnLoad();
	if (b_NS4 && iMenu>0) return;                                             // only 1 menu in NS4 on page

	var s="";
	var ss = "";
	apy_checkGlobalParams();

	// Create menu object apy_o[iMenu]
	apy_o[iMenu] = {
		m            : [],                     // menu arrays
		oi           : iMenu,                  // � of this menu
		id           : "apy" + iMenu,          // HTML id
		hideAllTimer : null,                   // timer to hide all submenus
		right         : posX,
		top          : posY,
		floating     : floatable,
		moving       : movable,
		abspos       : absolutePos,
		iterations   : (floatIterations<=0)?6:floatIterations,
		pressedMode  : pressedItem,
		curPressedSm : 0,
		curPressedI  : curPressedI_,
		cross        : crossframe,
		crossMainF   : crossMainFrame,
		crossSubF    : crossSubFrame,
		crossV       : crossView,               // 0: Top-Bottom; 1: Left-Right
		crossFset    : crossFrameset,
		popup        : popupMode,
		css          : cssStyle,
		cssClassName : cssClass,
		saveNavigation  : saveNavigationPath,
		view            : orientation,
		showUp          : bottomUp,
		showClick       : (b_NS4?0:showByClick),
		showClicked     : 0
	};
	var root = apy_o[iMenu];
	var rootm;
	var r = "", stst = statusString;

	//*********************************************************
	//start parse menuItems var and init submenus and items
	//*********************************************************
	var pl=-1,        // number of "|" in previous item
	cl;           // number of "|" in current item

	// --------- Popup Mode ----------------------------------------------------
	if (popupMode)              // configure items for popup mode
	apy_createPopupMenu();
	// --------- End of Popup Mode ---------------------------------------------

	var cssClassName_ = null;
	var subStyle, singleStyle;
	// Submenu styles ----------
	var menuBorderWidth_ = null;
	var menuBorderStyle_ = null;
	var menuBorderColor_ = null;
	var menuBackColor_   = null;
	var menuBackImage_   = null;
	// Item styles -------------
	var fntColors = null;
	var fntStyles = null;
	var fntDecors = null;
	var bgcs      = null;
	var borcs     = null;
	var borws     = null;
	var borstyles = null;
	var icons     = null;
	var arrowms   = null;
	var arrowss   = null;
	var bgimages  = null;
	var itemWidth = null;
	var cssItemClassName_ = null;
	// Define global item styles
	var garrowms   = [apy_getParam (arrowImageMain[0],""), apy_getParam (arrowImageMain[1],"")];
	var garrowss   = [apy_getParam (arrowImageSub[0], ""), apy_getParam (arrowImageSub[1], "")];
	var gbgimages  = [apy_getParam (itemBackImage[0], ""), apy_getParam (itemBackImage[1],"")];
	var gitemWidth = "0px";
	var gfntColors = [fontColor[0], apy_getParam (fontColor[1], "")];
	var gfntStyles = [fontStyle, fontStyle];
	var gfntDecors = [fontDecoration[0], apy_getParam(fontDecoration[1],"")];
	var gbgcs      = [itemBackColor[0],  apy_getParam (itemBackColor[1],"")];
	var gborws     = itemBorderWidth;
	var gborcs     = [itemBorderColor[0], apy_getParam (itemBorderColor[1],"")];
	var gborstyles = [itemBorderStyle[0], apy_getParam (itemBorderStyle[1],"")];
	var cols_      = columnPerSubmenu;
	//--------------------------------------------------------------------------
	var target_ = "";
	var act_ = "";
	var tid  = "";

	if (typeof(menuBorderStyle)=="object" && menuBorderStyle.length==1)
	menuBorderStyle = menuBorderStyle[0];

	for (var i=0; (i<menuItems.length && typeof (menuItems[i]) != "undefined"); i++) {
		cl=0;
		while (menuItems[i][0].charAt(cl)=="|") cl++;                                      // menu item nesting
		if (cl>0) menuItems[i][0] = menuItems[i][0].substring(cl,menuItems[i][0].length);  //remove ||| from item label


		// Getting individual styles for submenus ------------------------------
		subStyle = apy_getParam (menuItems[i][7],"");
		sN = (subStyle)?parseInt(subStyle):-1;

		if (!cssStyle)                    // CSS style disabled -> define style params
		{
			menuBorderWidth_ = apy_getStyleParam ("menuBorderWidth", sN, "submenu", menuBorderWidth);
			menuBorderStyle_ = apy_getStyleParam ("menuBorderStyle", sN, "submenu", menuBorderStyle);
			menuBorderColor_ = apy_getStyleParam ("menuBorderColor", sN, "submenu", menuBorderColor);
			menuBackColor_   = apy_getStyleParam ("menuBackColor",   sN, "submenu", menuBackColor);
			menuBackImage_   = apy_getStyleParam ("menuBackImage",   sN, "submenu", menuBackImage);
			if (canPrefix(menuBackImage_))
			menuBackImage_ = pathPrefix + menuBackImage_;
		}
		else // CSS style enabled
		cssClassName_ = apy_getStyleParam ("CSS", sN, "submenu", cssClass);
		//----------------------------------------------------------------------
		cols_ = apy_getStyleParam ("columnPerSubmenu", sN, "submenu", columnPerSubmenu);;

		itemSpacing_  = apy_getStyleParam ("itemSpacing", sN, "submenu", itemSpacing);
		itemPadding_  = apy_getStyleParam ("itemPadding", sN, "submenu", itemPadding);

		if (pl<cl)
		{
			//====== Add new submenu ===========================================
			// set previous item as root for this submenu
			if (i>0) r = "m" + rootm.mi + "i" + rootm.i[iSItem].ii;      // if rootm is defined already
			iSMenu = root.m.length;                                      // root item number
			iSItem = 0;                                                  // subitem number
			root.m[iSMenu] = {
				i            : [],
				oi           : iMenu,                                    // root menu item number
				mi           : iSMenu,                                   // root submenu item number
				id           : "apy" + iMenu + "m" + iSMenu,
				shownChildID : "",                                       // if "" - no shown child submenus
				showTimer    : null,                                     // timer to delay the appearance of submenus
				rootItem     : "apy" + iMenu + r,
				level        : cl,                                       // depth level (number of |||)

				offx         : (cl>1)?DX:topDX,                          // x offset
				offy         : (cl>1)?DY:topDY,                          // y offset
				macoffX      : macIEoffX,
				macoffY      : macIEoffY,

				hasIcons     : 0,                                        // if 1 the one or more items of this menu have icon
				hasSubs      : 0,                                        // if 1 the menu has child submenus. To set blank space for items w/o icons
				borw         : menuBorderWidth_,
				borstyle     : menuBorderStyle_,
				borc         : menuBorderColor_,

				horiz        : i?((cols_>1)?1:orientation):isHorizontal,
				spac         : itemSpacing_,
				padd         : itemPadding_,
				bgc          : menuBackColor_,                            // menu background color
				bgimage      : menuBackImage_,                            // menu background image
				//bgimager:["",""]                                        // menu background image repeat
				tran         : !i?100:transparency,
				eff          : !i?0:transition?transition:1,
				dur          : transition?transDuration:0,               // appearance delay
				shdc         : shadowColor,
				shdl         : shadowLen,
				mwidth       : apy_getParam (menuWidth, "0px"),          // NN% or NNpx (default 0px)
				mHTML        : "",
				cssClassName : cssClassName_,
				cols         : cols_
			};
			rootm = apy_o[iMenu].m[iSMenu];
			//===== end add new menu ===========================================
		}// if

		if (pl>cl)    // return to a previous level
		{
			// find previous level
			while (apy_o[iMenu].m[iSMenu].level>cl) iSMenu--;
			rootm = apy_o[iMenu].m[iSMenu];
		}
		pl = cl;

		//===== Add new item ===================================================

		if (!statusString || statusString=="link")   // status string is URL
		stst = apy_getParam (menuItems[i][1], "");
		else
		if (statusString=="text")
		stst = apy_getParam (menuItems[i][0], "");                   // status string is item caption

		iSItem = rootm.i.length;                                         // subitems count ~ current subitem �

		var tid="";///added by karim .... (IE BUG) ...4/12/2005
		tid = "apy" + iMenu + "m" + iSMenu + "i" + iSItem;               // set item id

		//	alert(tid);

		if (menuItems[i][0] == "-") tid += "sep";                        // item is separator
		//----------------------------------------------------------------------

		// Getting individual styles for each item -----------------------------
		singleStyle = apy_getParam (menuItems[i][6],"");
		sN = (singleStyle)?parseInt(singleStyle):-1;

		icons     = apy_setPathPrefix([apy_getParam (menuItems[i][2],""), apy_getParam (menuItems[i][3],"")])
		arrowms   = apy_setPathPrefix(apy_getStyleParam ("arrowImageMain",  sN, "item", garrowms  ));
		arrowss   = apy_setPathPrefix(apy_getStyleParam ("arrowImageSub",   sN, "item", garrowss  ));
		bgimages  = apy_setPathPrefix(apy_getStyleParam ("itemBackImage",   sN, "item", gbgimages ));
		itemWidth = apy_getStyleParam ("itemWidth",       sN, "item", gitemWidth);

		if (!cssStyle)                    // if menu doesn't use CSS styles -> define item style params
		{
			fntColors = apy_getStyleParam ("fontColor",       sN, "item", gfntColors);
			fntStyles = apy_getStyleParam ("fontStyle",       sN, "item", gfntStyles);
			fntDecors = apy_getStyleParam ("fontDecoration",  sN, "item", gfntDecors);
			bgcs      = apy_getStyleParam ("itemBackColor",   sN, "item", gbgcs     );
			borcs     = apy_getStyleParam ("itemBorderColor", sN, "item", gborcs    );
			borws     = apy_getStyleParam ("itemBorderWidth", sN, "item", gborws    );
			borstyles = apy_getStyleParam ("itemBorderStyle", sN, "item", gborstyles);
		}
		else // CSS style enabled
		cssItemClassName_ = apy_getStyleParam ("CSS", sN, "item", cssClass);

		// Define "enabled" property for item ----------------------------------
		act_ = apy_getParam (menuItems[i][5],"");
		if (act_=="_") act_ = 0;
		else           act_ = 1;

		// Define target property for item -------------------------------------
		target_ = apy_getParam (menuItems[i][5], "_self");
		if (target_=="_self" && itemTarget!="")
		target_ = itemTarget;

		// Define link property for item ---------------------------------------
		link_ = apy_getParam (menuItems[i][1], "");
		if (link_ && link_.toLowerCase().indexOf("javascript:")!=0 && pathPrefix)
		link_ = pathPrefix + link_;

		// Define item alignment -----------------------------------------------
		if (!cl) itemAlign_ = itemAlign;
		else     itemAlign_ = subMenuAlign;
		//----------------------------------------------------------------------
		rootm.i[iSItem] = {
			oi      : iMenu,
			mi      : iSMenu,
			ii      : iSItem,
			id      : tid,
			child   : "",                                           // id of child submenu
			// item settings
			text    : menuItems[i][0],
			link    : link_,
			target  : target_,                                      // target of this item link
			status  : stst,
			tip     : apy_getParam (menuItems[i][4], ""),
			align   : itemAlign_,
			valign  : "middle",
			cursor  : itemCursor?itemCursor:"hand",
			act     : act_,                                         // 1 - item is active, 0 - disabled
			space   : rootm.spac,
			padd    : rootm.padd,
			// with mouseout and mouseover states
			fontc   : fntColors,                                    // item font color
			font    : fntStyles,                                    // item font style string, eg "bold italic 8pt Verdana"
			fontdec : fntDecors,                                    // item font style

			bgc      : bgcs,                                        // item background color
			bgimage  : bgimages,                                    // item background image
			bgimager : ["",""],                                     // item background image repeat

			icon     : icons,                                       //item icons
			iconw    : cl?iconWidth:iconTopWidth,
			iconh    : cl?iconHeight:iconTopHeight,
			arrowm   : arrowms,                                     // main item arrow
			arrows   : arrowss,                                     // subitem arrow
			arroww   : arrowWidth,
			arrowh   : arrowHeight,
			borc     : borcs,                                       // item border color
			borw     : borws,
			borstyle : borstyles,                                   // item border style
			pressed  : false,                                       // item is pressed (function apy_setPressedItem() )
			width    : itemWidth,
			cssClassName : cssItemClassName_,
			highlighted  : 0
		};
		if (!rootm.i[iSItem].icon[0] && rootm.i[iSItem].icon[1]) rootm.i[iSItem].icon[0] = blankImage; // if icon is unknown
		if (rootm.i[iSItem].icon[0] != "") rootm.hasIcons = 1;
		//========== end add new item ==========================================
	};//for
	// End parse menuItems
	//==========================================================================


	// Link submenus with root items -------------------------------------------
	var rooi;     //root item
	for (var i=1; i<apy_o[iMenu].m.length; i++)                      // run all menu items
	{
		rooi = apy_getVarByID (apy_o[iMenu].m[i].rootItem);
		rooi.child = apy_o[iMenu].m[i].id;
		apy_o[rooi.oi].m[rooi.mi].hasSubs = 1;                       // this menu has child submenus
	}

	//==========================================================================
	// Start create HTML string
	//==========================================================================
	var mLen = apy_o[iMenu].m.length;
	var cFrame, cEvents, cClickEvent;
	var clmnN=-1;




	for (var im=0; im<mLen; im++)
	{
		var mn=apy_o[iMenu].m[im];


		// alert(mn.id);
		if (b_NS4)
		{
			if (pos=="absolute" && !im)
			s+="<LAYER POSITION="+pos + " left="+apy_o[iMenu].left + " top="+apy_o[iMenu].top + " ID="+mn.id + " VISIBILITY=HIDE Z-INDEX="+zind + ">";
			else
			s+="<LAYER POSITION="+pos + " ID="+mn.id + " VISIBILITY=HIDE Z-INDEX="+zind + ">";
			s+="<TABLE CELLSPACING=0 CELLPADDING=0 " + (im?"":"WIDTH="+mn.mwidth) + " ";
			s+="BORDER="+mn.borw + " BGCOLOR="+mn.bgc + " BACKGROUND='"+mn.bgimage + "'>";

			for (var ii=0; ii<mn.i.length; ii++)
			{
				var it=mn.i[ii];
				s+=mn.horiz?"":"<TR>";
				s+="<TD NOWRAP WIDTH=" + ((im || !mn.horiz )?"100%":"") + '>';

				s+="<ILAYER ID="+it.id + " Z-INDEX=10 WIDTH=100%>"
				s+="<LAYER ID=" + it.id + "I WIDTH=100%><FONT STYLE='font-size:1pt'>";
				for (var jj=0; jj<2; jj++)
				{
					s+="<LAYER ID="+it.id + "IW"+jj + " VISIBILITY=" + (jj?"HIDE":"SHOW") + " BGCOLOR="+it.bgc[0] + " height=1 ";
					s+="onMouseOver='apy_over(event,\""+it.id+"\");' onMouseOut='apy_out(event,\""+it.id+"\");'>";

					if (it.text == "-")   // separator
					{

						if (itemBorderWidth>0)  // build borders
						{
							s+="<TABLE WIDTH=100% BORDER=0 CELLSPACING=0 CELLPADDING=0 BGCOLOR=" + itemBorderColor[0] + " height=1><TR><TD NOWRAP width=1 height=1>";
							s+="<TABLE WIDTH=100% BORDER=0 CELLSPACING=" + (itemBorderWidth-2) + " CELLPADDING=" + (itemBorderWidth) + " height=1><TR><TD  height=1 NOWRAP width=1>";
						}
						s+="<TABLE WIDTH=100% BORDER=0 height=1 CELLSPACING="+it.space + " CELLPADDING="+it.padd + " BGCOLOR="+it.bgc[0] + " BACKGROUND='"+it.bgimage[0] + "'>";

						s+="<TD NOWRAP width=100% VALIGN=middle align=" + ((separatorAlignment=="")?"center":separatorAlignment) + " >";
						s+="<FONT STYLE='font-size:1pt'>";

						from = it.id.indexOf("m");
						to   = it.id.indexOf("i");
						st   = parseInt (it.id.substring(from+1, to));
						if (st>0)
						{
							if (separatorImage != "")
							s+="<img src='" + separatorImage + "' width=" + ((separatorWidth=="")?"50":separatorWidth) + " height=" + ((separatorHeight=="")?"1":separatorHeight) + ">";
							else
							s+="<img src='" + blankImage + "' width=0 height=0>";
						}
						else
						{
							if (separatorVImage != "")
							s+="<img src='" + separatorVImage + "' width=" + ((separatorVWidth=="")?"1":separatorVWidth) + " height=" + ((separatorVHeight=="")?"1":separatorVHeight) + ">";
							else
							s+="<img src='" + blankImage + "' width=0 height=0>";
						}
						s+="</FONT></TD></TABLE>"
						if (itemBorderWidth>0)     // close borders
						{
							s+="</TR></TD></TABLE>";
							s+="</TR></TD></TABLE>";
						}

					}
					else
					{
						if (itemBorderWidth>0)  // build borders
						{
							s+="<TABLE WIDTH=100% BORDER=0 CELLSPACING=0 CELLPADDING=0 BGCOLOR=" + itemBorderColor[jj] + "><TD NOWRAP width=1>";
							s+="<TABLE WIDTH=100% BORDER=0 CELLSPACING=" + (itemBorderWidth-2) + " CELLPADDING=" + (itemBorderWidth) + "><TD NOWRAP width=1>";
						}
						s+="<TABLE WIDTH=100% BORDER=0 CELLSPACING="+it.space + " CELLPADDING="+it.padd + " BGCOLOR="+it.bgc[jj] + " BACKGROUND='" + it.bgimage[jj] + "'>";

						if (jj && !it.icon[jj])
						it.icon[jj] = it.icon[0];
						s+="<TD NOWRAP ALIGN=LEFT VALIGN=MIDDLE WIDTH="+((it.icon[0] || it.icon[1])?it.iconw:1) + ">" + apy_getImageHTML (it.icon[jj],it.id + "ICO", it.iconw,it.iconh) + "</TD>";

						if (it.text)
						{
							s+="<TD NOWRAP WIDTH=100% ALIGN="+it.align + " VALIGN="+it.valign + ">";
							s+="<a id='"+it.id+"A"+jj + "' TARGET='"+it.target + "' href=\"#\" onClick='apy_click(event,\""+it.id+"\");'>";
							s+="<FONT STYLE='font:"+it.font[jj] + ";color: "+it.fontc[jj] + ";text-decoration:"+it.fontdec[jj] + ";'>";
							s+=it.text + "</FONT></a></TD>";
						}

						if ((im?it.arrows[0]:it.arrowm[0]) && it.child)
						{
							s+="<TD WIDTH="+it.arroww + " NOWRAP ALIGN=RIGHT VALIGN=MIDDLE>";
							s+=apy_getImageHTML(im?it.arrows[jj]:it.arrowm[jj],it.id+"ARR",it.arroww,it.arrowh) + "</TD>";
						}
						s+="</TABLE>"
						if (itemBorderWidth>0)    // close borders
						{
							s+="</TD></TABLE>";
							s+="</TD></TABLE>";
						}
					}
					s+="</LAYER>";
				}//for
				s+="</FONT></LAYER></ILAYER></TD>" + (mn.horiz?"":"</TR>");
			}//for
			s+="</TABLE></LAYER>";
		}

		else   // end NS4
		{

			s+=b_IE?"<TABLE CELLPADDING=" + (shadowTop?mn.shdl:"0") + " CELLSPACING=0 ":"<DIV ";
			s+=" ID="+mn.id + " STYLE='width:";
			if (b_IE5)
			s+=(im?(b_IE5?"0px":"1px"):mn.mwidth) + ";";
			else
			s+=(im?"0px":mn.mwidth) + ";";

			if (im || (!im && shadowTop))  // Create filter
			s+=apy_getFilterHTML(mn);

			s+=" position:"+pos  + ";left:"+apy_o[iMenu].left+"px; top:"+apy_o[iMenu].top+"px;";
			s+="z-index:"+zind+100 + ";visibility:"+vis + "'>";
			s+=b_IE?"<TD>":"";

			s+="<TABLE ID="+mn.id + "TB CELLPADDING=0 CELLSPACING="+mn.spac;

			if (!cssStyle)
			{
				s+=" STYLE='width:"+(im?(b_IE5?"0px":"1px"):mn.mwidth);
				s+=";border-style:"+mn.borstyle + ";border-width:"+mn.borw+"px;";
				s+="border-color:"+mn.borc     + ";background:"+mn.bgc + ";margin:0px;";
				s+="background-image:url("+mn.bgimage+");background-repeat:repeat'>";
			}
			else
			s+=" class='"+mn.cssClassName + "'>";

			if (!im && movable)  // build move capture region before 1st item
			apy_createMoveSpacer(mn.horiz, mn.id);

			clmnN=-1;
			for (var ii=0; ii<mn.i.length; ii++)      // run submenu items
			{
				var it=mn.i[ii];

				ss = "";                                // necessary define this variable because of IE has low speed during loading big menus without it

				if (im && mn.cols>1) clmnN++;
				ss+=((!mn.horiz || clmnN==0)?"<TR ID="+it.id+"TR>":"");
				ss+="<TD ID=" + it.id + " NOWRAP VALIGN=MIDDLE HEIGHT=100% " + ((it.width && it.text!="-")?"WIDTH="+it.width:"");
				//ss+=" STYLE='padding:" + it.space + "px;'>";
				ss+=" STYLE='padding:0px;'>";
				ss+="<TABLE ID=\"" + it.id + "I\" CELLSPACING=0 CELLPADDING=0 HEIGHT=100% WIDTH=100% BORDER=0 TITLE='"+it.tip+"'";

				if (!cssStyle)
				{
					ss+= " STYLE='border-style:"+it.borstyle[0] + ";border-width:"+it.borw + "px;margin:0px;";
					ss+="border-color:"+it.borc[0] + ";background-color:"+it.bgc[0] + ";";

					if (it.text!="-")
					ss+="cursor:" + ((it.cursor=="hand")?(b_IE?"hand":"pointer"):it.cursor) + ";";

					if (!b_NS || (b_NS && b_VER>=7))                              // if it isn't NS6 -> write font in TD-tag
					ss+="font:" + it.font[0] + ";text-decoration:" + it.fontdec[0]+";color:" + it.fontc[0] + ";";
					ss+="background-image:url(" + it.bgimage[0] + ");background-repeat:repeat;' ";
				}
				else
				ss+=" class='" + it.cssClassName[0] + "'";


				if (apy_o[iMenu].cross && im && crossType==1)
				{
					cFrame  = "parent.frames["+apy_o[iMenu].crossMainF+"]";
					cEvents = "onMouseOver='"+cFrame+".apy_over(event,\""+it.id+"I\");' onMouseOut='"+cFrame+".apy_out(event,\""+it.id+"I\");'";
					cClickEvent = ((it.text=="-")?">":"onClick='"+cFrame+".apy_click(event,\""+it.id+"I\");'>");
				}
				else
				{
					cEvents     = "onMouseOver='apy_over(event,\""+it.id+"I\");' onMouseOut='apy_out(event,\""+it.id+"I\");'";
					cClickEvent = ((it.text=="-")?">":"onClick='apy_click(event,\""+it.id+"I\");'>");
				}

				if (it.text == "-")                       // separator
				{
					ss+=cEvents + cClickEvent;
					ss+="<TD ID="+it.id+"ITD NOWRAP width=100%  height=100% align=" + ((!separatorAlignment)?"center":separatorAlignment);
					ss+=((!cssStyle)?" STYLE='color:"+it.fontc[0]+";padding:"+it.padd+"px;'><FONT STYLE='font-size:1px'>":">");

					if (im>0) {
						if (separatorImage)
						ss+=apy_createSeparator(separatorImage, separatorWidth, separatorHeight)
					}
					else
					if (separatorVImage)
					ss+=apy_createSeparator(separatorVImage, separatorVWidth, separatorVHeight)

					ss+="</FONT></TD>";
				}
				else
				{
					ss+=cEvents + cClickEvent;

					if (it.icon[0] || it.icon[1])
					{
						ss+="<TD ID=" + it.id + "IITD WIDTH=" + it.iconw + " NOWRAP ALIGN=CENTER VALIGN=MIDDLE HEIGHT=100% ";
						ss+="STYLE='padding:" + it.padd + "px'>";
						ss+=apy_getImageHTML(it.icon[0],it.id+"ICO",it.iconw,it.iconh) + "</TD>";
					}
					if (it.text)
					{
						ss+="<TD ID="+it.id+"ITD NOWRAP ALIGN="+it.align+" VALIGN="+it.valign + " width=100% ";
						ss+="STYLE='padding:"+it.padd+"px;'>";

						if (b_NS && (b_VER<7))                                      // write FONT-tag in NS6
						ss+="<FONT id=\""+it.id+"ITX\" STYLE='font:"+it.font[0] + ";text-decoration:"+it.fontdec[0]+";color:" + it.fontc[0] + ";'>" + it.text + "</FONT>";
						else                                                        // else write only text
						ss+=it.text;
						ss+="</TD>";
					}
					if ((im?it.arrows[0]:it.arrowm[0]) && it.child)
					{
						ss+="<TD ID="+it.id + "IATD WIDTH="+it.arroww + " NOWRAP ALIGN=CENTER VALIGN=MIDDLE HEIGHT=100% STYLE='padding:"+it.padd+"px'>";
						ss+=apy_getImageHTML(im?it.arrows[0]:it.arrowm[0],it.id+"ARR",it.arroww,it.arrowh) + "</TD>";
					}
				}
				ss+="</TABLE></TD>" + ((!mn.horiz || clmnN==mn.cols-1)?"</TR>":"");
				if (clmnN==mn.cols-1) clmnN=-1;

				s+=ss;
			}
			s+="</TABLE>" + (b_IE?"</TD></TABLE>":"</DIV>");



		}

		if (b_NS4) out_+=s;
		else
		{
			if (apy_o[iMenu].cross && crossType!=3)   // crossframe mode and frame resizing off
			{
				root.m[im].mHTML = s;               // save HTML code for submenus
				if (!im) document.write(s);         // write only top menu to main frame
			}
			else
			if (b_IE5 && !b_MAC)
			{
				if (!im)
				document.write(s);
				else
				document.body.insertAdjacentHTML('afterBegin', s);
			}
			else document.write(s);
		}//end !NS4

		s = "";
		ss = "";
		pos = "absolute";
		vis = (b_NS4)?"hide":"hidden";
		zind += 10;
	}
	if (b_NS4)
	{
		out_+=s;
		document.write (out_);
	}

	// set pressed item
	if (apy_o[iMenu].pressedMode>=0)              // toggle mode on -> select top item with number curPressedI
	if (crossType==1 || crossType==3)
	{
		pressedSelf = true;                       // menu calls func by self
		apy_setPressedItem (iMenu, apy_o[iMenu].curPressedSm, apy_o[iMenu].curPressedI, false);
	}

	//*********************************************************
	//end create HTML
	iMenu++; //next menu on page
	curPressedI_ = -1;                                                        // set current pressed item for next menu on page
} //end apy_init()


function apy_createMoveSpacer (horiz, id) {
	if (moveCursor=="hand" && !b_IE) moveCursor="pointer";
	var cMBegin  = "<TD STYLE='cursor:" + moveCursor + ";' background='" + moveImage + "' id='" + id + "mT' ";
	var cMSpacer = "<img src='" + blankImage + "' width=" + moveWidth + " height=0><img src='" + blankImage + "' width=0 height=" + moveHeight + "></TD>";
	var cMEvents = " onMouseDown='apy_startMoving(event,"+iMenu+")' onMouseUp='apy_stopMoving()'>";
	if (horiz)
	s+=cMBegin + "height=100%" + cMEvents + cMSpacer;
	else
	s+="<TR>" + cMBegin + cMEvents + cMSpacer + "</TR>";
}

function apy_createSeparator(sepImg, sepW, sepH) {
	return "<img src='"+sepImg+"' width="+((!sepW)?"100%":sepW) + " height="+((!sepH)?"1":sepH) + ">";
}

function apy_getStyleParam (pName, styleN, stype, defValue) {       //*** extract individual styles from array for items and submenus ***//
	if (styleN==-1) return defValue;
	var stylePrm = [];
	if (stype=="item")    var sp = itemStyles[styleN];                          // item styles
	if (stype=="submenu") var sp = menuStyles[styleN];                          // submenu styles

	var f = false;
	for (var j=0; !f; j++)    // search for parameter's name
	{
		if (!sp[j]) return defValue;                                              // if parameter is absent -> return null
		else
		if (sp[j].indexOf(pName) >= 0) break;
	}

	var sstr = sp[j];
	var pos  = sstr.indexOf("=");
	var pos2 = sstr.indexOf(",");
	if (pos2 == -1 || pName=="fontStyle")      // only one parameter exists
	{
		pos2 = sstr.length;
		stylePrm[0] = sstr.substring (pos+1, pos2);
	}
	else                                      // two parameters exist
	{
		stylePrm[0] = sstr.substring (pos+1,  pos2);
		stylePrm[1] = sstr.substring (pos2+1, sstr.length);
	}
	if (stylePrm.length==1 && b_NS && b_VER>=6 && b_VER<7)   // array length=1 and NS6 -> correct value (get clear value, e.g. [val0] -> val0)
	if (pName.indexOf("font")<0)
	stylePrm = stylePrm[0];

	return stylePrm;
}

//==============================================================================
//*** Code for movable menu ***
//==============================================================================
var userMoveEvent=null;      // variable for saving users' mousemove event

function apy_getEventXY(e) {
	with (e) return [(b_IE||b_OP)?clientX:pageX, (b_IE||b_OP)?clientY:pageY];
}

function apy_startMoving(evnt, menuN) {
	if (b_NS4 || moveFlag) return;
	mMenu = apy_getObjectByID ("apy"+menuN+"m0");       // set current processed menu
	mMenuVar = apy_o[menuN];

	var mouseXY = apy_getEventXY(evnt);
	var mnuXY   = apy_getObjectStyleXY(mMenu);
	var pageOff = b_IEComp?apy_getPageScroll():[0,0];
	mdX = mouseXY[0] - mnuXY[0] + pageOff[0];
	mdY = mouseXY[1] - mnuXY[1] + pageOff[1];
	moveFlag = true;                                    // capture current menu
}

function apy_stopMoving() {
	var pageOff = apy_getPageScroll();
	var mnuXY = apy_getObjectStyleXY(mMenu);
	mMenuVar.left = mnuXY[0] - pageOff[0];                                   // set new absolute coords
	mMenuVar.top  = mnuXY[1] - pageOff[1];;                                  // ---
	moveFlag = false;                                                        // uncapture current menu
}

function apy_checkMainMenuIntersection(mMenuVar) { // called for floatable menu
	var mnu = apy_getObjectByID (mMenuVar.id + 'm0');
	var smSize = apy_getObjectSize (mnu);
	apy_showHiddenObj (smSize, mnu.id);
	if (b_IE) apy_checkIntersection (smSize, "SELECT", mnu.id, mMenuVar);
	if ((b_NS && b_VER<7) || b_OP) apy_checkIntersection (smSize, "IFRAME", mnu.id, mMenuVar);
	apy_checkIntersection (smSize, "APPLET", mnu.id, mMenuVar);
	//apy_checkIntersection (smSize, "OBJECT", mnu.id, mMenuVar);
	/* ^^^ This ability was disabled 'cause there is another way to cover flash objects:
	<object>
	<PARAM NAME=wmode VALUE=opaque>
	</object> */
}

function apy_Move(event) {  // Sets new menu coords during moving process
	if (moveFlag && isLoaded) // menu in moving process
	{
		var mouseXY = apy_getEventXY(event);
		var pageOff = (b_IEComp?apy_getPageScroll():[0,0]);
		var newX = mouseXY[0] - mdX + pageOff[0];
		var newY = mouseXY[1] - mdY + pageOff[1];

		mMenu.style.left = ((newX>=0)?newX:0) + dUnits;
		mMenu.style.top  = ((newY>=0)?newY:0) + dUnits;
		apy_checkMainMenuIntersection (mMenuVar);

	}
	return true;
}

function apy_setMoveEvent() { // Assigns mousemove event to document (called from apy_tLoad())
	if (document.attachEvent)
	document.attachEvent("onmousemove", apy_Move);
	else
	{
		userMoveEvent=document.onmousemove;       // remember user event
		document.onmousemove = function(e)         // create new mousemove event
		{
			apy_Move((b_MAC&&b_IE)?window.event:e);
			if (userMoveEvent) userMoveEvent();    // call user event
			return true;
		}
	}
}

// ------------------------- Assign document events ----------------------------
if (b_IE) {
	document.onselectstart = function() {  // ban select ability if menu in moving process
		if (moveFlag) return false;
		return true;
	}
}

// -------------------- End of events ------------------------------------------
//==============================================================================
//*** End of code for moving menu ***
//==============================================================================

function apy_getStyle(is) {
	return b_NS4?is:is.style;
}

function apy_changeStyle(it, over, sm) {
	// Mouse out and item was highlighted during menu navigation -> return
	if (!over && it.highlighted) return;
	if (apy_o[it.oi].css)
	apy_getObjectByID(it.id+"I").className = it.cssClassName[over];
	else
	{
		var is = apy_getStyle (apy_getObjectByID (it.id + "I"));
		if (it.bgc[over])      is.backgroundColor = it.bgc[over];
		if (it.borc[over])     is.borderColor     = it.borc[over];
		if (it.borstyle[over]) is.borderStyle     = it.borstyle[over];
		if (it.bgimage[over])  is.backgroundImage = "url("+it.bgimage[over]+")";

		if (b_NS && b_VER<7)       // working with FONT-tag with NS6
		{
			if (it.fontc[over] || it.fontdec[over])
			{
				var fnt = apy_getObjectByID (it.id + "ITX").style;
				if (it.fontc[over])   fnt.color = it.fontc[over];
				if (it.fontdec[over]) fnt.textDecoration = it.fontdec[over];
			}
		}
		else
		{                                                                       // working with TD-tag
			if (it.fontc[over])   is.color = it.fontc[over];
			if (it.fontdec[over]) is.textDecoration = it.fontdec[over];
		}
		//if (it.font[over]) fnt.font = it.font[over];
		if (it.icon[over])
		apy_getObjectByID(it.id+"ICO").src = it.icon[over];
		if (it.child && (sm?it.arrows[over]:it.arrowm[over]))
		apy_getObjectByID(it.id+"ARR").src=sm?it.arrows[over]:it.arrowm[over];
	}
}

function apy_over(e, id) {
	var it = apy_getVarByID (id);                                         // menu item param array



	if (apy_o[it.oi].showClick && !apy_o[it.oi].showClicked && !it.mi)
	return;

	sep = ((id.indexOf("sep")>=0)?1:0);   // item is separator
	var obj = apy_getObjectByID (id);

	if (b_IE)
	if (e.fromElement && obj.contains(e.fromElement)) return;           // eliminate flickering

	var mn = apy_o[it.oi].m[it.mi];                                       // menu param array
	if (apy_o[it.oi].hideAllTimer)
	{
		clearTimeout(apy_o[it.oi].hideAllTimer);
		apy_o[it.oi].hideAllTimer = null;
	}

	if (mn.showTimer)
	{
		clearTimeout(mn.showTimer);
		mn.showTimer = null;
	}

	if (!it.act) return;
	if (b_NS4)
	{
		if (!it.pressed)
		{
			obj.document.layers[0].document.layers[1].visibility = "show";
			obj.document.layers[0].document.layers[0].visibility = "hide";
		}
	}
	else
	if (!sep && !it.pressed)
	apy_changeStyle(it, 1, it.mi);

	// If one of submenus is visible and it is not a child of current item -> hide them
	if (mn.shownChildID != "" && mn.shownChildID != it.child)
	{
		if (apy_o[it.oi].cross && crossType==1)    // crossframe mode and need get submenu from subframe
		{
			if (apy_frameAccessible (apy_o[it.oi], mn.id, apy_o[it.oi].crossSubF)) apy_hideMenu(mn.shownChildID); // if subframe is accessible -> hide submenu in them, else do nothing
		}
		else
		apy_hideMenu(mn.shownChildID);
	}
	//-------------
	if (it.child != "" && isLoaded)       // if item has submenu and document loaded
	mn.showTimer = setTimeout ("apy_showMenu('"+it.child+"')",150);
	status = it.status;
}


function apy_out(e, id) {
	sep = ((id.indexOf("sep")>=0)?1:0);   // item is separator
	var obj = apy_getObjectByID(id);

	if (b_IE && e.toElement && obj.contains (e.toElement)) return;        // eliminate flickering

	var it = apy_getVarByID (id);                                         // menu item param array
	var mn = apy_o[it.oi].m[it.mi];                                       // menu param array
	var mainmn = apy_o[it.oi].m[0];                                       // the root of all menus

	if (mainmn.shownChildID != "")
	apy_o[it.oi].hideAllTimer = setTimeout ("apy_hideMenu('"+mainmn.shownChildID+"'); status='';", 1000);

	if (mn.showTimer)
	{
		clearTimeout (mn.showTimer);
		mn.showTimer = null;
	}

	if (!it.act) return;
	if (b_NS4)
	{
		if (!it.pressed)
		{
			obj.document.layers[0].document.layers[0].visibility="show";
			obj.document.layers[0].document.layers[1].visibility="hide";
		}
	}
	else
	if (!sep && !it.pressed)
	apy_changeStyle (it, 0, it.mi);
}

function apy_click(e,id) {
	if (b_NS4) apy_out (e,id);
	var it = apy_getVarByID (id);                                // menu item param array

	if (apy_o[it.oi].showClick && !apy_o[it.oi].showClicked && !it.mi && it.child)
	{
		apy_o[it.oi].showClicked = 1;
		apy_over(e, id);
		return;
	}

	if (apy_o[it.oi].pressedMode != -2)                          // toggle mode on
	apy_setPressedItem(it.oi, it.mi, it.ii, true);


	if (!it.act || !it.link) return;
	var mainmn = apy_o[it.oi].m[0];                                       // the root of all menus
	if (mainmn.shownChildID)
	apy_hideMenu (mainmn.shownChildID);

	if (apy_o[it.oi].hideAllTimer)
	{
		clearTimeout (apy_o[it.oi].hideAllTimer);
		apy_o[it.oi].hideAllTimer = null;
	}

	if (it.link)      // open link or call js if any
	{
		if (it.link.toLowerCase().indexOf("javascript:")==0)               // Java script presents
		eval(it.link.substring(11,it.link.length));
		else
		{
			if (!it.target || it.target=="_self")
			{
				if (apy_o[it.oi].cross && (crossType==1 || crossType==3))
				parent.frames[apy_o[it.oi].crossSubF].location.href = it.link;     // if item was clicked in subframe -> open link in subframe
				else
				location.href = it.link;                                           // else open link in specified by target window
			}
			else
			open (it.link, it.target);
		}
	}
}

function apy_pointInRect (px, py, rect) {                              // return true if rect includes point
	if (px>=rect[0] && px<=(rect[0]+rect[2]) && py>=rect[1] && py<=(rect[1]+rect[3])) return true;
	return false;
}

function apy_rectInRect (rect1,rect2) {                                // return true if rect2 includes rect2
	var rx1 = rect1[0], rx2 = rect1[0] + rect1[2];
	var ry1 = rect1[1], ry2 = rect1[1] + rect1[3];
	if (apy_pointInRect (rx1,ry1,rect2) || apy_pointInRect (rx1,ry2,rect2) || apy_pointInRect (rx2,ry1,rect2) || apy_pointInRect (rx2,ry2,rect2) )
	return true;
	return false;
}

function apy_objIntersectMenu (orect, mrect) {                             // return true if object rect intersect menu rect
	var ox1 = orect[0], ox2 = orect[0] + orect[2];
	var oy1 = orect[1], oy2 = orect[1] + orect[3];
	if (ox1<mrect[0] && ox2>(mrect[0]+mrect[2]) && oy1>mrect[1] && (oy2<mrect[1]+mrect[3])) return true;
	return false;
}

function apy_showHiddenObj (mSize, objID) {  // show hidden objects
	if (b_NS4) return;
	if (hidID.length>0)    // if any object was hide
	{
		for (var ind=0; ind<hidID.length; ind+=2)   // run hidden object array
		{
			if (hidID[ind]==objID)                                              // if specified menu has hide objects
			{
				hidID[ind+1].style.visibility = "visible";                        // show hidden object
				hidID[ind]   = null;                                              // clear hidden
				hidID[ind+1] = null;                                              //   object params
			}
		}
		//---------------
		var empty = true;
		for (ind=0; ind<hidID.length; ind+=2)                              // check if array has no values...
		if (hidID[ind])
		{
			empty = false;
			break;
		}
		if (empty) hidID = [];                                             // ...set it to empty
	}
}

function apy_checkIntersection (mSize, tag, objID, mMenu) {   // hide all object by tag value if they intersects with menu objID
	if (b_NS4 || (b_OP & b_VER<6)) return;

	if (!mMenu.cross || crossType==3)                          // crossframe mode disabled or all submenus in this frame
	var frame = window;
	else
	var frame = parent.frames[mMenu.crossSubF];

	if (b_NS || b_MZ || b_OP)
	var obj = frame.document.getElementsByTagName(tag);           // get object array on page by tag
	else
	var obj = frame.document.body.all.tags(tag);

	if (obj != null)                                             // specified object presents in document
	{
		for (var j=0; j<obj.length; ++j)                                   // run objects and if objects[j] is visible and must be hide -> remember them and hide
		{
			oSize  = apy_getObjectSize (obj[j]);                              // get object size
			if ((obj[j].style.visibility != "hidden") && (apy_rectInRect (oSize,mSize) || apy_rectInRect (mSize,oSize) || apy_objIntersectMenu(oSize,mSize)))
			{
				obj[j].style.visibility = "hidden";                             // hide object
				hidID[hidID.length] = objID;                                    // save menu id that hides object
				hidID[hidID.length] = obj[j];                                   // save hidden object
			}
		}//for
	}
}

function apy_getSubmenusHTML (mMenu) {
	var txt = "";
	for (var i=1; i<mMenu.m.length; i++)                 // run all submenus
	txt += mMenu.m[i].mHTML;                             // get HTML code with events from self window
	return txt;
}

//=== Attach onResize event for Netscape 4 =====================================
//    If browser window has been resized -> refresh document
function apy_resizeNS4() {
	document.location.href = document.location.href;
	if (oldResize) oldResize ();
	return true;
}
var oldResize = null;

if (b_NS4)
{
	if (typeof(onresize)!="undefined") oldResize = onresize;
	onresize = apy_resizeNS4;
}
//==============================================================================


function apy_error(eMessage, url, line) {
	return true;
}

//*** function apy_frameAccessible (mMenu, id, frmN) ***************************
//=== Check access to subframe document. If its not accessible, it means =======
//=== that other page was loaded into subframe from another domain.      =======
//=== Not evaluate code for Netscape 4 (this browser doesn't know try-catch construction)
if (!b_NS4 && !(b_IE && b_VER<5)) {
	var es = "";
	es+="function apy_frameAccessible (mMenu, id, frmN) {";
	es+="var apyFrame = parent.frames[frmN];";
	es+="try {";                                                // try to access to subframe objects
	es+=" var obj = apyFrame.document.getElementById (id);";
	es+=" crossType = 1;";
	es+=" return true;";
	es+="}";
	es+="catch (e) {";
	es+=" crossType = 3;";
	es+=" return false;";
	es+="} }";
	eval(es);
}
//******************************************************************************

function apy_createCrossHTML(mMenu,id) {   // copy menu data to subframe if it doesnt' exist
	var apyFrame = parent.frames[mMenu.crossSubF];
	var obj = apyFrame.document.getElementById(id)
	if (!obj)                                                                  // if submenus didn't exist in subframe
	{
		if (b_IEComp)
		apyFrame.document.body.insertAdjacentHTML("beforeEnd", apy_getSubmenusHTML (mMenu));
		else
		apyFrame.document.body.innerHTML += apy_getSubmenusHTML(mMenu);
	}
}


function apy_extractFrameSize(sStr, frmN) {  // Return 3 strings from frameset sizes (e.g. "40%,50,100,*" + frmN=1 => ["40%,","50",",100,*"]) ***//
	var iOld = 0;
	var cnt  = -1;
	var dl = ((!frmN)?0:1);

	for (var i=0; i<sStr.length; i++)                         // run string with framset sizes
	{
		if (sStr.charAt(i)==',' || i==sStr.length-1)              // if delimeter ',' founded
		{
			cnt++;
			if (cnt==frmN)
			{                                          // if delimeter hes index frmN
				var b = sStr.substring (0, iOld+dl)
				if (frmN>0)
				{
					var m = sStr.substring (iOld+dl, i+dl-1);
					var e = sStr.substring (i+dl-1, sStr.length)
				}
				else
				{
					var m = sStr.substring (iOld+dl, i+dl)
					var e = sStr.substring (i+dl, sStr.length)
				}
				return [b,m,e]                                            // return strings: [sizes before, specified size, sizes after]
			}
			iOld = i;
		}
	}
}

var oldFsetSizes;

function apy_setCrossPressedItem(mMenuVar) {
	var m = mMenuVar.curPressedSm;
	var i = mMenuVar.curPressedI;
	pressedSelf     = true;
	changeStyleOnly = true;
	apy_setPressedItem(mMenuVar.oi,m,i,true);
}

function apy_showMenu(id) {
	var submpar = apy_getVarByID (id);
	var mMenu   = apy_o[submpar.oi];
	var flEn = (submpar.dur && !b_MAC && b_IE5 && b_VER>=5.5);

	if (mMenu.cross && crossType>0)   // crossframe mode and it is a top frame
	{
		if (!apy_frameAccessible(mMenu,id,mMenu.crossSubF))      // subframe page was loaded from another domain
		{
			var subm = apy_getObjectByID(id);
			if (!subm)
			{
				if (b_IE || (b_OP && b_VER>=7))
				document.body.insertAdjacentHTML("beforeEnd", apy_getSubmenusHTML(mMenu));
				else
				document.body.innerHTML += apy_getSubmenusHTML (mMenu);

				apy_setCrossPressedItem(mMenu);
				var subm = apy_getObjectByID(id);
			}
		}
		else                            // subframe page was loaded from the same domain
		{
			apy_createCrossHTML (mMenu,id);   // create submenus in subframe
			var subm = parent.frames[mMenu.crossSubF].document.getElementById(id);
			if (mMenu.pressedMode>=0 && mMenu.curPressedI!=-1)   // toggle mode on and some item was pressed
			apy_setCrossPressedItem(mMenu);
		}
	}
	else
	var subm = apy_getObjectByID(id);       // crossframe mode disabled

	if (flEn)
	{
		var fl = subm.filters[0];        // filter
		if (b_VER>=5.5) fl.enabled = 1;
		if (fl.Status!=0) fl.stop();
	}

	var xy = apy_getSubmenuXY (submpar);
	var it = apy_getVarByID (submpar.rootItem);                   // parent item param array

	// alert(xy);

	if (b_NS4)
	{
		subm.left = xy[0]+itemBorderWidth+itemPadding+itemSpacing-1;
		subm.top  = xy[1]-itemBorderWidth+(isHorizontal?itemBorderWidth+itemPadding:0);
		if (subm.visibility != "show") subm.visibility="show";
		for (var i=0; i<submpar.i.length; i++)                     // looking for pressed items
		if (submpar.i[i].pressed)     // item is pressed
		{
			var obj = apy_getObjectByID (submpar.i[i].id);
			with (obj.document.layers[0])
			{
				document.layers[1].visibility = "show";
				document.layers[0].visibility = "hide";
			}
		}
		else
		{
			var obj = apy_getObjectByID (submpar.i[i].id);
			if (obj.document.layers[0].document.layers[1].visibility == "show")
			with (obj.document.layers[0])
			{
				document.layers[1].visibility = "hide";
				document.layers[0].visibility = "show";
			}
		}
		apy_o[it.oi].m[it.mi].shownChildID = id;
	}
	else  //end NS4
	{
		if (mMenu.cross && crossType==1 && submpar.level==1) // set coords in subframe
		{
			var dc       = apy_getClientSize(mMenu, 1);
			var mfScroll = apy_getClientSize(null);          // mainframe scroll offset
			var l=0, t=0;

			if (mMenu.crossV == 1)   // vertical frame orientation
			{
				if (b_IE || b_OP)
				var dy = parent.frames[mMenu.crossSubF].window.screenTop - window.screenTop + mfScroll[1];
				else
				var dy = mfScroll[1];
				l = dc[0];
				t = xy[1] + dc[1] - dy;
			}
			else                     // horizontal frame orientation
			{
				if (b_IE || b_OP)
				var dx = parent.frames[mMenu.crossSubF].window.screenLeft - window.screenLeft + mfScroll[0];
				else
				var dx = mfScroll[0];
				l = xy[0] + dc[0] - dx;
				t = dc[1];
			}



			// Check submenu position with page bounds
			var subms = apy_getObjectSize(apy_getObjectByID(subm.id+'TB'));
			if (l+subms[2] > dc[0]+dc[2]) l = dc[0]+dc[2] - subms[2];
			if (t+subms[3] > dc[1]+dc[3]) t = dc[1]+dc[3] - subms[3];
			if (l < dc[0]) l = dc[0];
			if (t < dc[1]) t = dc[1];
			subm.style.left = l + dUnits;
			subm.style.top  = t + dUnits;
			//--------------------------------------
		}
		else
		{                                          // set coords in this page
			subm.style.left = xy[0] + dUnits;
			subm.style.top  = xy[1] + dUnits;

			////**************** the error here
			//alert(xy[0]+"  "+ xy[1]);

			if (!b_OP && !b_MZ && !b_NS && crossType==3)  // frame resizing
			{
				if (mMenu.crossV==1)     // vertical frame orientation
				var sizes = parent.document.getElementById (mMenu.crossFset).cols;  // get frame's sizes from frameset
				else
				var sizes = parent.document.getElementById (mMenu.crossFset).rows;  // get frame's sizes from frameset

				if (!oldFsetSizes)       // if old frame's sizes wasn't saved ->
				oldFsetSizes = sizes;                                               // save their

				var szs  = apy_extractFrameSize (sizes, mMenu.crossMainF);          // divide sizes string (extract top frame size)
				var wins = apy_getClientSize (mMenu);                               // get document size
				var objs = apy_getObjectSize (subm);                                // get submenu size



				if (mMenu.crossV==1)                                                // vertical frame orientation
				{
					if (objs[0]+objs[2] > wins[2])                                      // if submenu bounds exceed the document bounds of top frame
					parent.document.getElementById (mMenu.crossFset).cols = szs[0] + (objs[0]+objs[2]) + szs[2]; // resize top frame

				}
				else
				if (objs[1]+objs[3] > wins[3]) {              // if submenu bounds exceed the document bounds of top frame--//
					parent.document.getElementById (mMenu.crossFset).rows = szs[0] + (objs[1]+objs[3]) + szs[2]; // resize top frame
				}
			}//end crossType==3
		}

		apy_o[it.oi].m[it.mi].shownChildID = id;
		it.highlighted = apy_o[it.oi].saveNavigation;

		if (subm.style.visibility != "visible")                            // to remove false effect start
		{
			if (flEn) fl.apply ();
			subm.style.visibility = "visible";
			if (flEn) fl.play ();
		}
	}



	if (!b_NS4)                                                         // check for intersection with objects
	{
		oo = apy_getObjectByID(subm.id + "TB");
		smSize = apy_getObjectSize (oo);
		if (b_IE || (b_OP && b_VER<7)) apy_checkIntersection (smSize, "SELECT", oo.id, mMenu);
		if ((b_NS && b_VER<7) || (b_OP && b_VER>=7)) apy_checkIntersection (smSize, "IFRAME", oo.id, mMenu);
		apy_checkIntersection (smSize, "APPLET", oo.id, mMenu);                 // for all navigators
		//apy_checkIntersection (smSize, "OBJECT", oo.id, mMenu);                 // for all navigators
	}

}

function apy_hideMenu(id) {
	var subm = apy_getObjectByID(id);
	if (!subm) return;

	var submpar = apy_getVarByID(id);
	if (submpar.shownChildID != "")         // hide all visible submenus
	apy_hideMenu(submpar.shownChildID);

	// De-highlight root item -------------------
	if (apy_o[submpar.oi].saveNavigation)
	{
		var ritVar = apy_getVarByID(submpar.rootItem);
		ritVar.highlighted = 0;
		if (!ritVar.pressed)
		apy_changeStyle(ritVar, 0, ritVar.mi);
	}
	//-------------------------------------------

	submpar.shownChildID = "";
	if (submpar.showTimer)                                                // clear show timer
	{
		clearTimeout (submpar.showTimer);
		submpar.showTimer = null;
	}
	if (b_NS4)
	subm.visibility = "hide";
	else
	subm.style.visibility = "hidden";
	// show hidden objects
	if (!b_NS4)
	{
		oo = apy_getObjectByID (subm.id + "TB");
		smSize = apy_getObjectSize (oo);
		apy_showHiddenObj(smSize, oo.id);
	}

	// If submenu level=1 and frame resizing and old frameset sizes were saved
	if (submpar.level==1 && crossType==3 && oldFsetSizes)
	{
		if (apy_o[submpar.oi].crossV)
		parent.document.getElementById (apy_o[submpar.oi].crossFset).cols = oldFsetSizes;  // set saved frameset sizes to frameset
		else
		parent.document.getElementById (apy_o[submpar.oi].crossFset).rows = oldFsetSizes;  // set saved frameset sizes to frameset
		oldFsetSizes = null;                                                                 // clear sizes
	}

	// Show by click: if all submenus was hidden -> enable "need to click" -----
	if (apy_o[submpar.oi].showClick && apy_o[submpar.oi].hideAllTimer)
	apy_o[submpar.oi].showClicked = 0;
	//--------------------------------------------------------------------------
}

function apy_getParam (param,defparam) {
	return (typeof(param) != "undefined" && param)?param:defparam;
}

function apy_getObjectByID (id) {
	if (b_IE && b_VER<5) return document.all[id];
	if (b_NS4) {
		var e = regexp_i.exec (id);
		var l = document.layers[id];
		if (!l && e)
		l = document.layers[e[2]].document.layers[id];
		return l;
	}
	var it = apy_getVarByID (id);
	if (apy_o[it.oi].cross && crossType!=3)   // crossframe mode enabled and submenus not in this (top frame) document
	{
		if (it.mi==0)
		return document.getElementById (id);                              // if item parent is top menu
		else
		return parent.frames[apy_o[it.oi].crossSubF].document.getElementById (id); // object getting from subframe
	}
	else return document.getElementById (id);
}

function apy_getVarByID (id) {
	var ex;
	if (id.indexOf("i")>0) {
		ex=regexp_i.exec(id);
		return apy_o[parseInt(ex[1])].m[parseInt(ex[2])].i[parseInt(ex[3])];
	}
	else {
		ex = regexp_m.exec (id);
		return apy_o[parseInt(ex[1])].m[parseInt(ex[2])];
	}
}

function apy_getBrowser() {
	var a = navigator.userAgent;
	var n = navigator.appName;
	var v = navigator.appVersion;
	b_MAC = v.indexOf("Mac") >= 0;
	b_DOM = document.getElementById?1:0;

	// --- Safari detect ---//
	var b_t = (parseInt(navigator.productSub) >= 20020000) && (navigator.vendor.indexOf("Apple Computer") != -1);
	var b_SAF = b_t && (navigator.product == "Gecko");
	if (b_SAF) {
		b_NS  = 1;
		b_VER = 6;
		return;
	}
	// ---------------------//

	if (a.indexOf("Opera")>=0) {
		b_OP = 1;
		b_VER = parseFloat(a.substring(a.indexOf("Opera")+6,a.length));
	}
	else if (n.toLowerCase()=="netscape") {
		if (a.indexOf("rv:") != -1 && a.indexOf("Gecko") != -1 && a.indexOf("Netscape")==-1) {
			b_MZ  = 1;
			b_VER = parseFloat(a.substring(a.indexOf("rv:")+3,a.length));
		}
		else {
			b_NS = 1;
			if (a.indexOf("Gecko") != -1 && a.indexOf("Netscape") > a.indexOf("Gecko")) {
				if (a.indexOf("Netscape6") > -1) b_VER = parseFloat (a.substring(a.indexOf("Netscape")+10,a.length));
				else if (a.indexOf("Netscape") > -1) b_VER = parseFloat (a.substring(a.indexOf("Netscape")+9,a.length));
			}
			else
			b_VER = parseFloat (v);
		}
	}
	else if (document.all?1:0) {
		b_IE  = 1;
		b_VER = parseFloat (a.substring(a.indexOf("MSIE ")+5,a.length));
	}
	b_NS4 = b_NS && b_VER<6;
	b_IE5 = b_IE && b_VER>=5;
	b_IEComp = b_IE || (b_OP && b_VER>=7);
	//alert("b_IE = "+b_IE+"\n"+"b_OP = "+b_OP+"\n"+"b_MZ = "+b_MZ+"\n"+"b_NS = "+b_NS+"\n"+"b_DOM = "+b_DOM+"\n"+"b_MAC = "+b_MAC+"\n"+"b_VER = "+b_VER);
}

/*function apy_getClientScroll(mMenu) {
var xs=0, ys=0;

if (mMenu && mMenu.cross && crossType==1)
var doc = parent.frames[mMenu.crossSubF].window;
else
var doc = window;
if (b_IEComp)
{
xs = doc.document.body.scrollLeft;
ys = doc.document.body.scrollTop;
}
else
{
xs = doc.pageXOffset;
ys = doc.pageYOffset;
}
return [xs,ys];
} */

function apy_getFrameDocElement(mMenu) {
	var frm = parent.frames[mMenu.crossSubF];
	return (frm.document.compatMode=="CSS1Compat" && !b_MZ)?frm.document.documentElement:frm.document.body
}

function apy_getClientSize(mMenu, q) {
	var l=0,t=0,w=0,h=0;
	if (b_NS || b_MZ || b_OP)
	{
		var doc = ((mMenu && mMenu.cross && crossType==1)?parent.frames[mMenu.crossSubF].window:window);
		w = doc.innerWidth;
		h = doc.innerHeight;
		l = doc.pageXOffset;
		t = doc.pageYOffset;
	}
	else
	{
		//var doc = ((mMenu && mMenu.cross && crossType==1)?mMenu.docElementFrame:docElement);
		var doc = ((mMenu && mMenu.cross && crossType==1)?apy_getFrameDocElement(mMenu):docElement);
		l = doc.scrollLeft;
		t = doc.scrollTop;
		w = doc.clientWidth;
		h = doc.clientHeight;
	}
	return [l,t,w,h];
}

function apy_getObjectSize (o) {
	var l=0,t=0,h=0,w=0;
	if (!o) return [l,t,w,h];
	if (b_OP && b_VER<6)
	{
		h = o.style.pixelHeight;
		w = o.style.pixelWidth;
	}
	else
	{
		if (b_NS4)
		{
			h = o.clip.height;
			w = o.clip.width;
		}
		else
		{
			h = o.offsetHeight;
			w = o.offsetWidth;
		}
	}
	var obj = (b_NS4)?o:o.offsetParent;


	//  alert('V');
	while (obj)
	{
		l += parseInt (b_NS4?o.pageX:o.offsetLeft);
		t += parseInt (b_NS4?o.pageY:o.offsetTop);
		t += (b_MAC&&b_IE)?o.parentNode.offsetTop:0;




		// alert(obj.id+" "+obj.tagName);


		//////////// if it is IE ////////////////
		////////// ** ADDED BY KARIM ..4/12/2005
		if(b_IE)
		{
			o = o.offsetParent;
			obj = (b_NS4)?o:o.offsetParent;

			continue;
		}
		///////// if it is Not IE
		else
		{
			//alert("l: "+l+"   "+"t: "+t);
			o = o.offsetParent;
			// alert(o.offsetParent.tagName+"  "+o.tagName);

			if (o.offsetParent.tagName=="BODY" && o.tagName!="DIV")
			{
				//alert("BODY after DIV ");
				//break;
			}

			obj = (b_NS4)?o:o.offsetParent;

			if (obj.tagName=="BODY")
			{
				break;
			}



			//	alert(o+" "+o.scrollTop);
			////	l= o.offsetTop;
			//	t = o.offsetTop;

			//   alert("l: "+l+"   "+"t: "+t);
			//  t = t -6;
			//break
		}////////// ** ADDED BY KARIM ..4/12/2005
		///////////////////////////////////////////////////

	}

	return [l,t,w,h];
}


function apy_getSubmenuXY(mn) {                         // get XY of mn menu


	var subm     = apy_getObjectByID(mn.id);
	var rooti    = apy_getObjectByID(mn.rootItem);

	//alert(rooti.id);

	var roots    = apy_getObjectSize(rooti);
	var rootivar = apy_getVarByID(mn.rootItem);
	var cl       = apy_getClientSize(apy_o[mn.oi]);      // size of client browser window

	// alert(roots);

	if (!b_NS4)
	{
		var submTB = apy_getObjectByID(subm.id + 'TB');
		var subs   = apy_getObjectSize(submTB);
	}
	else
	var subs = apy_getObjectSize(subm);

	//alert(subs);

	var x=0, y=0;

	if (apy_o[rootivar.oi].m[rootivar.mi].horiz)   // drop down if root menu is horizontal
	{
		if (b_IE || b_NS)
		{
			if (itemAlign == "right") x = roots[0] + roots[2] - subs[2] - mn.offx;
			else
			if (itemAlign == "center")
			x = roots[0] + (roots[2] - subs[2])/2;
			else
			x = roots[0] + mn.offx;


		}
		else
		{

			var scwidth=screen.width;

			var scheight=screen.height;

			var pixels=0;

			if(parseInt(scwidth)==1024 && parseInt(scheight)==768)
			{
				pixels=125;
			}
			if(parseInt(scwidth)==1280 && parseInt(scheight)==720)
			{
				pixels=380;
			}
			if(parseInt(scwidth)==1280 && parseInt(scheight)==800)
			{
				pixels=380;
			}
			if(parseInt(scwidth)==1280 && parseInt(scheight)==960)
			{
				pixels=380;
			}
			if(parseInt(scwidth)==800 && parseInt(scheight)==600)
			{
				pixels=-100;
			}
			if(parseInt(scwidth)==960 && parseInt(scheight)==600)
			{
				pixels=60;
			}
			x = roots[0]+pixels;
		}
		if (apy_o[mn.oi].showUp)
		{
			if (b_IE || b_NS)
			{
				y = roots[1] - subs[3] - mn.offy;
			}
			else
			{
				y = roots[1] - subs[3] - mn.offy+10;
			}

		}
		else
		{
			if (b_IE || b_NS)
			{
				y = roots[1] + roots[3] + mn.offy;
			}
			else
			{
				y = roots[1] + roots[3] + mn.offy+10;
			}

		}


	}
	else /////// parent is vertical
	{
		//alert('d');
		x = mn.offx + roots[0] + roots[2];
		y = mn.offy + roots[1]; /// changed by karim [was 1 ] 3 = height   ///returned 1 again


		//alert("X"+x +"  Y"+y);

	}

	cl[2] += cl[0];
	cl[3] += cl[1];

	if (!apy_o[mn.oi].cross || (mn.level>1 && crossType!=3))
	{
		if (x + subs[2] > cl[2]) x = cl[2] - subs[2];
		if (x < cl[0]) x = cl[0];
		if (y + subs[3] > cl[3]) y = cl[3] - subs[3];
		if (y < cl[1]) y = cl[1];
	}

	if (b_MAC&&b_IE)
	{
		x += mn.macoffX;
		y += mn.macoffY;
	}
	if (subMenu_dir=="1")
	{
		x=((x-roots[2])-subs[2])+4;
	}
	return[x,y];
}
function apy_getImageHTML(src, id, w, h) {
	if (!src && b_NS4 && (id.indexOf("ICO")>0))
	{
		w = 1;
		src = blankImage;
	}
	if (!src) return "";

	var sImg = "<IMG SRC=\""+src+"\"";
	if (id) sImg+=" ID="+id;

	if (w!="100%")
	{
		if (w>0)
		sImg+=" WIDTH="+w;
		else
		if (b_NS)
		sImg+=" WIDTH=0";
	}
	if (h>0)
	sImg+=" HEIGHT="+h;
	else
	if(b_NS)
	sImg+=" HEIGHT=0";
	sImg += " BORDER=0>";
	return sImg;
}

var apy_fNames = [      // Additional DX filters
['Blinds'],
['Checkerboard'],
['GradientWipe'],
['Inset'],
['Iris'],
['Pixelate'],
['RadialWipe'],
['RandomBars'],
['RandomDissolve'],
['Slide'],
['Spiral'],
['Stretch'],
['Strips'],
['Wheel'],
['Zigzag']
];


function apy_getAdditionalFilterHTML(fNum, fDur) {
	if (b_VER<5.5) return;
	var sF="progid:DXImageTransform.Microsoft."+apy_fNames[fNum-25] + '(' + transOptions + ',duration='+fDur + ')';
	return sF;
}

function apy_getFilterHTML(mn) {
	if (b_IE5 && !b_MAC)
	{
		var sF = "filter:";
		if (mn.eff)
		if (mn.eff==24) sF+="blendTrans(Duration="+mn.dur/1000+") ";
		else
		if (mn.eff<24)
		sF+="revealTrans(Transition="+mn.eff+",Duration="+mn.dur/1000+") ";
		else
		sF+=apy_getAdditionalFilterHTML(mn.eff, mn.dur/1000);
		if (mn.tran) sF+="Alpha(opacity="+mn.tran+") ";
		if (mn.shdc) sF+="Shadow(color="+mn.shdc+",direction=135,strength="+mn.shdl+") ";
		sF += ";";
		return sF;
	}
	else
	return "";     // no filter
}

function apy_getItemID(n,m,i) {
	return 'apy'+n+'m'+m+'i'+i + ((b_NS && b_VER<7)?'ITX':'ITD');
}

function apy_changeItemText (n,m,i,text) {                         // n - menu, m - submenu, i - item. All of them >= 0.
	if (b_NS4) return null;
	var item = apy_getObjectByID(apy_getItemID(n,m,i)); // get FONT-tag for NS6
	item.innerHTML = text;
}

function apy_changeItem(n,m,i, newText, newTarget, newTip, newImgOver, newImgOut) {         // n - menu, m - submenu, i - item. All of them >= 0.
	if (b_NS4) return null;
	var item = apy_getObjectByID(apy_getItemID(n,m,i)); // get FONT-tag for NS6

	if (newText)
	item.innerHTML = newText;
	// change text
	var it = apy_getVarByID(item.id);
	if (newTarget) it.target = newTarget;                // change target
	if (newTip)
	{
		item = apy_getObjectByID('apy'+n+'m'+m+'i'+i+'I');
		item.title = newTip;                               // change hint
	}
	if (newImgOut)
	{
		it.icon[0] = newImgOut;
		item = apy_getObjectByID('apy'+n+'m'+m+'i'+i+'ICO');
		item.src = newImgOut;
	}
	if (newImgOver)
	it.icon[1] = newImgOver;
}

// n - menu, m - submenu, i - item. All of them >= 0.
// recurse = true -> change all expanded items
var pressedSelf = false;
var changeStyleOnly = false;

function apy_setPressedItem(n,m,i, recurse) {
	var mMenu = apy_o[n];
	if (!pressedSelf && mMenu.curPressedI!=-1)  // if function didn't call itself and pressed item exist
	{
		pressedSelf = true;
		with (mMenu)
		{
			apy_setPressedItem(n, curPressedSm, curPressedI, recurse);   // unpress pressed item
			if (curPressedSm==m && curPressedI==i)  // if specified indexes = current indexes -> it needs just unpress, set defaults and than do nothing
			{
				curPressedSm = 0;
				curPressedI  = -1;
				return;
			}
		}//with
	}

	if (!pressedSelf)    // if func didn't call itself -> set new pressed indexes
	{
		mMenu.curPressedSm = m;
		mMenu.curPressedI  = i;
	}
	else
	pressedSelf = false;

	var it = apy_getVarByID ('apy'+n+'m'+m+'i'+i);
	if (!changeStyleOnly)
	it.pressed = !it.pressed;
	changeStyleOnly = false;

	if (!b_NS4)
	apy_changeStyle(it, (it.pressed?1:0), it.mi);

	if (recurse && m>0)   // if recurse=true (change all expanded items) and submenu isn't a root menu
	{
		var subm = apy_o[n].m[m];
		for (var j=subm.level; j>0; j--)
		{
			rootI = apy_getVarByID(subm.rootItem)
			if (!b_NS4)
			apy_changeStyle (rootI, (it.pressed?1:0), rootI.mi);
			else                                                     // for NS4: change top item
			if (j==1)    // if it's a top item
			with (apy_getObjectByID(rootI.id).document.layers[0])
			{
				document.layers[1].visibility = (it.pressed?"show":"hide");
				document.layers[0].visibility = (it.pressed?"hide":"show");
			}

			rootI.pressed = it.pressed;            // check root item as pressed
			subm = apy_o[n].m[rootI.mi];           // get next parent submenu
		}
	}

}

//----------------------------------

function apy_getMouseCoords(event) {
	var x = 0;
	var y = 0;
	if (b_IE || b_OP)
	{
		x = event.clientX + (b_IEComp?docElement.scrollLeft:0);
		y = event.clientY + (b_IEComp?docElement.scrollTop:0);
	}
	else {
		x = event.pageX;
		y = event.pageY;
	}
	return [x,y];
}

function apy_popup (menuN, hidePause, event, x, y) {   // Function to call popup menu (var popupMode=1;)
	if (b_IE) event.returnValue = false;
	if (x && y)
	var xy = [x,y];
	else
	var xy = apy_getMouseCoords (event);
	var mMenu = apy_o[menuN];
	var sMenu = mMenu.m[1];      // get first submenu (in reality it is all original menu trasformated in apy_init()->apy_createPopupMenu())

	if (sMenu)
	{
		var obj = apy_getObjectByID(sMenu.id);
		if (obj.style.visibility == "visible")             // if popup menu visible already -> hide it
		{
			clearTimeout(mMenu.hideAllTimer);
			apy_hideMenu(mMenu.m[0].shownChildID);
			status='';
		}

		mMenu.m[0].shownChildID = sMenu.id;
		apy_showMenu(sMenu.id);

		obj.style.left = xy[0] + dUnits;
		obj.style.top  = xy[1] + dUnits;

		if (hidePause>0)
		mMenu.hideAllTimer = setTimeout ("apy_hideMenu('" + mMenu.m[0].shownChildID + "'); status='';", hidePause);
	}
	return false;
}