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;
var regexp_m   = /apy([0-9]+)m([0-9]+)/;
var regexp_i   = /apy([0-9]+)m([0-9]+)i([0-9]+)/;

var iMenu  = 0;
var iSMenu = 0;
var iSItem = 0;
var apy_o  = [];
var hidID  = [];

var moveFlag = false;
var mdX, mdY;
var mMenu;
var mMenuVar;

var curPressedI_  = -1;
var loadFunc = null;

var s     = "";
var out_  = "";
var zind  = 1000;

var docElement;

apy_getBrowser();
if (!(b_OP && b_VER<6))
  var dUnits = "px";
else
  var dUnits = "";

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() {
 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);
      var pageOff = apy_getPageScroll();
      var l = pageOff[0] + apy_o[j].left;
      var t = pageOff[1] + apy_o[j].top;

      if (mnuXY[0]!=l || mnuXY[1]!=t)
      {
        var dx = (l - mnuXY[0])/apy_o[j].iterations;
        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;
          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]);
      }
   }
}

var crossType = 1;

function apy_onload() {
  docElement = (document.compatMode=="CSS1Compat" && !b_MZ)?document.documentElement:document.body;

  if (b_NS4) document.layers[0].visibility = "show";
  
  if (!(b_OP && b_VER<6))
    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);
        break;
      }

  s    = "";
  out_ = "";
  isLoaded = 1;
  apy_setMoveEvent();
  if (loadFunc)
    loadFunc();
  onerror = apy_error;
}

var crossframe     = 0;
var crossFrameset  = "";
var crossMainFrame = 0;
var crossSubFrame  = 1;
var crossView      = 0;

function apy_initFrame(fsetID, mainFrameInd, subFrameInd, view) {
  if (b_NS4 || (b_OP && b_VER<7) || (b_IE && b_VER<5))
  {
    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;
    onload = apy_onload;
  }
}

var pos, vis;
function apy_checkGlobalParams() {
  if (typeof(popupMode)=="undefined" || b_NS4) popupMode = 0;

  pos = (absolutePos || popupMode)?"absolute":"static";
  vis = (b_NS4)?"show":((popupMode)?"hidden":"visible");

  if (typeof(pressedItem)=="undefined")
    pressedItem = -2;
  else
    if (pressedItem >= 0)
      curPressedI_ = pressedItem;

  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)
  {
    cssStyle = 0;
    cssClass = "";
  }

  if (typeof(pathPrefix)=="undefined") pathPrefix = "";

  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;
  }
  
  if (typeof(saveNavigationPath)=="undefined") saveNavigationPath = (b_NS4?0:1);
  
  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() {
 for (var i=0; i<menuItems.length && typeof (menuItems[i]) != "undefined"; i++)
   menuItems[i][0] = '|' + menuItems[i][0];

 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;

    var ss = "";
    apy_checkGlobalParams();

    apy_o[iMenu] = {
       	m            : [],
       	oi           : iMenu,
       	id           : "apy" + iMenu,
       	hideAllTimer : null,
       	left         : 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,
       	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;
    
    var pl=-1,
        cl;

    if (popupMode)
      apy_createPopupMenu();

    var cssClassName_ = null;
    var subStyle, singleStyle;
    var menuBorderWidth_ = null;
    var menuBorderStyle_ = null;
    var menuBorderColor_ = null;
    var menuBackColor_   = null;
    var menuBackImage_   = null;
    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;
    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++;
        if (cl>0) menuItems[i][0] = menuItems[i][0].substring(cl,menuItems[i][0].length);

        subStyle = apy_getParam (menuItems[i][7],"");
        sN = (subStyle)?parseInt(subStyle):-1;

        if (!cssStyle)
        {
          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
          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)
        {
            if (i>0) r = "m" + rootm.mi + "i" + rootm.i[iSItem].ii;
            iSMenu = root.m.length;
            iSItem = 0;
            root.m[iSMenu] = {
                i            : [],
                oi           : iMenu,
                mi           : iSMenu,
                id           : "apy" + iMenu + "m" + iSMenu,
                shownChildID : "",
                showTimer    : null,
                rootItem     : "apy" + iMenu + r,
                level        : cl,

                offx         : (cl>1)?DX:topDX,
                offy         : (cl>1)?DY:topDY,
                macoffX      : macIEoffX,
                macoffY      : macIEoffY,

                hasIcons     : 0,
            	hasSubs      : 0,
            	borw         : menuBorderWidth_,
            	borstyle     : menuBorderStyle_,
            	borc         : menuBorderColor_,
 
              	horiz        : i?((cols_>1)?1:orientation):isHorizontal,
            	spac         : itemSpacing_,
            	padd         : itemPadding_,
            	bgc          : menuBackColor_,
            	bgimage      : menuBackImage_,
            	tran         : !i?100:transparency,
                eff          : !i?0:transition?transition:1,
                dur          : transition?transDuration:0,
            	shdc         : shadowColor,
            	shdl         : shadowLen,
                mwidth       : apy_getParam (menuWidth, "0px"),
                mHTML        : "",
                cssClassName : cssClassName_,
                cols         : cols_
            };
            rootm = apy_o[iMenu].m[iSMenu];                
        }
        
    	if (pl>cl)
        {
          while (apy_o[iMenu].m[iSMenu].level>cl) iSMenu--;
          rootm = apy_o[iMenu].m[iSMenu];
        }
    	pl = cl;

    	if (!statusString || statusString=="link")
          stst = apy_getParam (menuItems[i][1], "");
    	else
          if (statusString=="text")
            stst = apy_getParam (menuItems[i][0], "");

    	iSItem = rootm.i.length;
    	tid = "apy" + iMenu + "m" + iSMenu + "i" + iSItem;
    	if (menuItems[i][0] == "-") tid += "sep";

    	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)
        {
          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
          cssItemClassName_ = apy_getStyleParam ("CSS", sN, "item", cssClass);

    	act_ = apy_getParam (menuItems[i][5],"");
    	if (act_=="_") act_ = 0;
    	else           act_ = 1;
    	  
    	target_ = apy_getParam (menuItems[i][5], "_self");
    	if (target_=="_self" && itemTarget!="")
          target_ = itemTarget;
    	
    	link_ = apy_getParam (menuItems[i][1], "");
    	if (link_ && link_.toLowerCase().indexOf("javascript:")!=0 && pathPrefix)
          link_ = pathPrefix + link_;
    	
    	if (!cl) itemAlign_ = itemAlign;
    	else     itemAlign_ = subMenuAlign;
    	rootm.i[iSItem] = {
            oi      : iMenu,
            mi      : iSMenu,
            ii      : iSItem,
            id      : tid,
            child   : "",
            text    : menuItems[i][0],
            link    : link_,
            target  : target_,
            status  : stst,
            tip     : apy_getParam (menuItems[i][4], ""),
            align   : itemAlign_,
            valign  : "middle",
            cursor  : itemCursor?itemCursor:"hand",
            act     : act_,
            space   : rootm.spac,
            padd    : rootm.padd,
            fontc   : fntColors,
            font    : fntStyles,
            fontdec : fntDecors,

            bgc      : bgcs,
            bgimage  : bgimages,
            bgimager : ["",""],

            icon     : icons,
            iconw    : cl?iconWidth:iconTopWidth,
            iconh    : cl?iconHeight:iconTopHeight,
            arrowm   : arrowms,
            arrows   : arrowss,
            arroww   : arrowWidth,
            arrowh   : arrowHeight,
            borc     : borcs,
            borw     : borws,
            borstyle : borstyles,
            pressed  : false,
            width    : itemWidth,
            cssClassName : cssItemClassName_,
            highlighted  : 0
        };
        if (!rootm.i[iSItem].icon[0] && rootm.i[iSItem].icon[1]) rootm.i[iSItem].icon[0] = blankImage;
    	if (rootm.i[iSItem].icon[0] != "") rootm.hasIcons = 1;
    };

    var rooi;
    for (var i=1; i<apy_o[iMenu].m.length; i++)
    {
    	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;
    }

    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];
      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 == "-")
              {

                if (itemBorderWidth>0)
                {
                   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)
                {
                  s+="</TR></TD></TABLE>";
                  s+="</TR></TD></TABLE>";
                }

              }
              else
              {
                if (itemBorderWidth>0)
                {
                   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)
                {
                  s+="</TD></TABLE>";
                  s+="</TD></TABLE>";
                }
              }
              s+="</LAYER>";
          }
          s+="</FONT></LAYER></ILAYER></TD>" + (mn.horiz?"":"</TR>");
        }
      s+="</TABLE></LAYER>";
      }
      
      else
      {

          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))
            s+=apy_getFilterHTML(mn);

          s+=" position:"+pos  + ";left:"+apy_o[iMenu].left+"px; top:"+apy_o[iMenu].top+"px;";
          s+="z-index:"+zind + ";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)
            apy_createMoveSpacer(mn.horiz, mn.id);

          clmnN=-1;
          for (var ii=0; ii<mn.i.length; ii++)
          {
            var it=mn.i[ii];
            ss = "";

            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: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))
                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 == "-")
            {
              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))
		 {
	           if ( it.id != null )
		   {
		      var styleout = false;
	              ss += "<FONT id=\"" + it.id + "ITX\"";
	              if ( it.font != null && it.font[0] != null )
		      {
		         ss += " STYLE='font:" + it.font[0] + ";";
			 styleout = true;
		      }
		      if ( it.fontdec != null && it.fontdec[0] != null )
		      {
                         if ( !styleout )
			 {
			    ss += " STYLE='";
			    styleout = true;
			 }
			 ss += "text-decoration:" + it.fontdec[0] + ";";
		      }
		      if ( it.fontc != null && it.fontc[0] != null )
		      {
		      }
		      if ( styleout )
		      {
		         ss += "'";
                         if ( !styleout )
			 {
			    ss += " STYLE='";
			    styleout = true;
			 }
			 ss += "color:" + it.fontc[0] + ";";
		      }
		      ss += ">" + it.text + "</FONT>";
		   }
		   else
		   {
                      ss+=it.text;
		   }
		 }
                 else
                   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)
          {
            root.m[im].mHTML = s;
            if (!im) document.write(s);
          }
          else
            if (b_IE5 && !b_MAC)
            {
              if (!im)
                document.write(s);
              else
                document.body.insertAdjacentHTML('afterBegin', s);
            }
            else document.write(s);
        }

        s = "";
        ss = "";
        pos = "absolute";
        vis = (b_NS4)?"hide":"hidden";
        zind += 10;
    }
    if (b_NS4)
    {
      out_+=s;
      document.write (out_);
    }

    if (apy_o[iMenu].pressedMode>=0)
      if (crossType==1 || crossType==3)
      {
        pressedSelf = true;
        apy_setPressedItem (iMenu, apy_o[iMenu].curPressedSm, apy_o[iMenu].curPressedI, false);
      }

    iMenu++;
    curPressedI_ = -1;
}


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) {
  if (styleN==-1) return defValue;
  var stylePrm = [];
  if (stype=="item")    var sp = itemStyles[styleN];
  if (stype=="submenu") var sp = menuStyles[styleN];

  var f = false;
  for (var j=0; !f; j++)
  {
    if (!sp[j]) return defValue;
    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")
  {
    pos2 = sstr.length;
    stylePrm[0] = sstr.substring (pos+1, pos2);
  }
  else
  {
    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)
    if (pName.indexOf("font")<0)
      stylePrm = stylePrm[0];

  return stylePrm;
}

var userMoveEvent=null;

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");
  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;
}

function apy_stopMoving() {
  var pageOff = apy_getPageScroll();
  var mnuXY = apy_getObjectStyleXY(mMenu);
  mMenuVar.left = mnuXY[0] - pageOff[0];
  mMenuVar.top  = mnuXY[1] - pageOff[1];
  moveFlag = false;
}

function apy_checkMainMenuIntersection(mMenuVar) {
  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);
}

function apy_Move(event) {
  if (moveFlag && isLoaded)
  {
    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() {
    if (document.attachEvent)
      document.attachEvent("onmousemove", apy_Move);
    else
    {
      userMoveEvent=document.onmousemove;
      document.onmousemove = function(e)
      {
        apy_Move((b_MAC&&b_IE)?window.event:e);
        if (userMoveEvent) userMoveEvent();
        return true;
      }
    }
}

if (b_IE) {
  document.onselectstart = function() {
    if (moveFlag) return false;
    return true;
  }
}

function apy_getStyle(is) {
  return b_NS4?is:is.style;
}

function apy_changeStyle(it, over, sm) {
  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)
   {
     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
   {
     if (it.fontc[over])   is.color = it.fontc[over];
     if (it.fontdec[over]) is.textDecoration = it.fontdec[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);
    
    if (apy_o[it.oi].showClick && !apy_o[it.oi].showClicked && !it.mi)
      return;

    sep = ((id.indexOf("sep")>=0)?1:0);
    var obj = apy_getObjectByID (id);

    if (b_IE)
      if (e.fromElement && obj.contains(e.fromElement)) return;

    var mn = apy_o[it.oi].m[it.mi];
    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 (mn.shownChildID != "" && mn.shownChildID != it.child)
    {
      if (apy_o[it.oi].cross && crossType==1)
      {
        if (apy_frameAccessible (apy_o[it.oi], mn.id, apy_o[it.oi].crossSubF)) apy_hideMenu(mn.shownChildID);
      }
      else
        apy_hideMenu(mn.shownChildID);
    }
    if (it.child != "" && isLoaded)
      mn.showTimer = setTimeout ("apy_showMenu('"+it.child+"')",150);
    status = it.status;
}


function apy_out(e, id) {
    sep = ((id.indexOf("sep")>=0)?1:0);
    var obj = apy_getObjectByID(id);

    if (b_IE && e.toElement && obj.contains (e.toElement)) return;
    
    var it = apy_getVarByID (id);
    var mn = apy_o[it.oi].m[it.mi];
    var mainmn = apy_o[it.oi].m[0];

    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);

    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)
      apy_setPressedItem(it.oi, it.mi, it.ii, true);


    if (!it.act || !it.link) return;
    var mainmn = apy_o[it.oi].m[0];
    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)
    {
      	if (it.link.toLowerCase().indexOf("javascript:")==0)
          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;
              else
                location.href = it.link;
            }
            else
              open (it.link, it.target);
        }
    }
}

function apy_pointInRect (px, py, rect) {
  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) {
  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) {
  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) {
  if (b_NS4) return;
  if (hidID.length>0)
  {
    for (var ind=0; ind<hidID.length; ind+=2)
    {
       if (hidID[ind]==objID)
       {
         hidID[ind+1].style.visibility = "visible";
         hidID[ind]   = null;
         hidID[ind+1] = null;
       }
    }
    var empty = true;
    for (ind=0; ind<hidID.length; ind+=2)
       if (hidID[ind])
       {
         empty = false;
         break;
       }
    if (empty) hidID = [];
  }
}

function apy_checkIntersection (mSize, tag, objID, mMenu) {
  if (b_NS4 || (b_OP & b_VER<6)) return;

  if (!mMenu.cross || crossType==3)
    var frame = window;
  else
    var frame = parent.frames[mMenu.crossSubF];

  if (b_NS || b_MZ || b_OP)
    var obj = frame.document.getElementsByTagName(tag);
  else
    var obj = frame.document.body.all.tags(tag);

  if (obj != null)
  {
    for (var j=0; j<obj.length; ++j)
    {
       oSize  = apy_getObjectSize (obj[j]);
       if ((obj[j].style.visibility != "hidden") && (apy_rectInRect (oSize,mSize) || apy_rectInRect (mSize,oSize) || apy_objIntersectMenu(oSize,mSize)))
       {
         obj[j].style.visibility = "hidden";
         hidID[hidID.length] = objID;
         hidID[hidID.length] = obj[j];
       }
    }
  }
}

function apy_getSubmenusHTML (mMenu) {
  var txt = "";
  for (var i=1; i<mMenu.m.length; i++)
    txt += mMenu.m[i].mHTML;
  return txt;
}

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;
}

  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 {";
    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) {
  var apyFrame = parent.frames[mMenu.crossSubF];
  var obj = apyFrame.document.getElementById(id)
  if (!obj)
  {
    if (b_IEComp)
      apyFrame.document.body.insertAdjacentHTML("beforeEnd", apy_getSubmenusHTML (mMenu));
    else
      apyFrame.document.body.innerHTML += apy_getSubmenusHTML(mMenu);
  }
}


function apy_extractFrameSize(sStr, frmN) {
  var iOld = 0;
  var cnt  = -1;
  var dl = ((!frmN)?0:1);

  for (var i=0; i<sStr.length; i++)
  {
    if (sStr.charAt(i)==',' || i==sStr.length-1)
    {
      cnt++;
      if (cnt==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];
      }
      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)
    {
      if (!apy_frameAccessible(mMenu,id,mMenu.crossSubF))
      {
        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
      {
        apy_createCrossHTML (mMenu,id);
        var subm = parent.frames[mMenu.crossSubF].document.getElementById(id);
        if (mMenu.pressedMode>=0 && mMenu.curPressedI!=-1)
          apy_setCrossPressedItem(mMenu);
      }
    }
    else
      var subm = apy_getObjectByID(id);

    if (flEn)
    {
      var fl = subm.filters[0];
      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);
    
    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++)
          if (submpar.i[i].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
    {
      if (mMenu.cross && crossType==1 && submpar.level==1)
      {
        var dc       = apy_getClientSize(mMenu, 1);
        var mfScroll = apy_getClientSize(null);
        var l=0, t=0;
        
        if (mMenu.crossV == 1)
        {
          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
        {
          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];
        }
        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
      {
        subm.style.left = xy[0] + dUnits;
        subm.style.top  = xy[1] + dUnits;

        if (!b_OP && !b_MZ && !b_NS && crossType==3)
        {
          if (mMenu.crossV==1)
            var sizes = parent.document.getElementById (mMenu.crossFset).cols;
          else
            var sizes = parent.document.getElementById (mMenu.crossFset).rows;
            
          if (!oldFsetSizes)
            oldFsetSizes = sizes;
            
          var szs  = apy_extractFrameSize (sizes, mMenu.crossMainF);
          var wins = apy_getClientSize (mMenu);
          var objs = apy_getObjectSize (subm);
          if (mMenu.crossV==1)
          {
            if (objs[0]+objs[2] > wins[2])
              parent.document.getElementById (mMenu.crossFset).cols = szs[0] + (objs[0]+objs[2]) + szs[2];

          }
          else
            if (objs[1]+objs[3] > wins[3]) {
              parent.document.getElementById (mMenu.crossFset).rows = szs[0] + (objs[1]+objs[3]) + szs[2];
            }
        }
      }

      apy_o[it.oi].m[it.mi].shownChildID = id;
      it.highlighted = apy_o[it.oi].saveNavigation;

      if (subm.style.visibility != "visible")
      {
          if (flEn) fl.apply ();
          subm.style.visibility = "visible";
          if (flEn) fl.play ();
      }
    }

    if (!b_NS4)
    {
      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);
    }

}

function apy_hideMenu(id) {
    var subm = apy_getObjectByID(id);
    if (!subm) return;

    var submpar = apy_getVarByID(id);
    if (submpar.shownChildID != "")
      apy_hideMenu(submpar.shownChildID);

    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)
    {
      clearTimeout (submpar.showTimer);
      submpar.showTimer = null;
    }
    if (b_NS4)
      subm.visibility = "hide";
    else
      subm.style.visibility = "hidden";
    if (!b_NS4)
    {
      oo = apy_getObjectByID (subm.id + "TB");
      smSize = apy_getObjectSize (oo);
      apy_showHiddenObj(smSize, oo.id);
    }

    if (submpar.level==1 && crossType==3 && oldFsetSizes)
    {
      if (apy_o[submpar.oi].crossV)
        parent.document.getElementById (apy_o[submpar.oi].crossFset).cols = oldFsetSizes;
      else
        parent.document.getElementById (apy_o[submpar.oi].crossFset).rows = oldFsetSizes;
      oldFsetSizes = null;
    }

    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)
  {
    if (it.mi==0)
      return document.getElementById (id);
    else
      return parent.frames[apy_o[it.oi].crossSubF].document.getElementById (id);
  }
  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;

    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);
}

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)?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;
  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;
    o = o.offsetParent;
    obj = (b_NS4)?o:o.offsetParent;
  }
  return [l,t,w,h];
}


function apy_getSubmenuXY(mn) {
    var subm     = apy_getObjectByID(mn.id);
    var rooti    = apy_getObjectByID(mn.rootItem);
    var roots    = apy_getObjectSize(rooti);
    var rootivar = apy_getVarByID(mn.rootItem);
    var cl       = apy_getClientSize(apy_o[mn.oi]);
    if (!b_NS4)
    {
      var submTB = apy_getObjectByID(subm.id + 'TB');
      var subs   = apy_getObjectSize(submTB);
    }
    else
      var subs = apy_getObjectSize(subm);

    var x=0, y=0;

    if (apy_o[rootivar.oi].m[rootivar.mi].horiz)
    {
      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 
        x = roots[0] + mn.offx;
      if (apy_o[mn.oi].showUp)
        y = roots[1] - subs[3] - mn.offy;
      else  
        y = roots[1] + roots[3] + mn.offy;
    }
    else
    {
      x = mn.offx + roots[0] + roots[2];
      y = mn.offy + roots[1];
    }

    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;
    }
    
    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 = [
  ['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 "";
}

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) {
  if (b_NS4) return null;
  var item = apy_getObjectByID(apy_getItemID(n,m,i));
  item.innerHTML = text;
}

function apy_changeItem(n,m,i, newText, newTarget, newTip, newImgOver, newImgOut) {
  if (b_NS4) return null;
  var item = apy_getObjectByID(apy_getItemID(n,m,i));

  if (newText)
    item.innerHTML = newText;
  var it = apy_getVarByID(item.id);
  if (newTarget) it.target = newTarget;
  if (newTip)
  {
    item = apy_getObjectByID('apy'+n+'m'+m+'i'+i+'I');
    item.title = newTip;
  }
  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;
}

var pressedSelf = false;
var changeStyleOnly = false;

function apy_setPressedItem(n,m,i, recurse) {
  var mMenu = apy_o[n];
  if (!pressedSelf && mMenu.curPressedI!=-1)
  {
    pressedSelf = true;
    with (mMenu)
    {
      apy_setPressedItem(n, curPressedSm, curPressedI, recurse);
      if (curPressedSm==m && curPressedI==i)
      {
        curPressedSm = 0;
        curPressedI  = -1;
        return;
      }
    }
  }
  
  if (!pressedSelf)
  {
    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)
  {
    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
        if (j==1)
          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;
      subm = apy_o[n].m[rootI.mi];
    }
  }

}

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) {
  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];

  if (sMenu)
  {
    var obj = apy_getObjectByID(sMenu.id);
    if (obj.style.visibility == "visible")
    {
      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;
}


