// JSMenu class developed by Julian Lishev, All rights reserved!
// Last modified: 30.07.2004
// Support a large set of browsers.
// IE 4,5,6; NS 4,6,7; Mozilla 0.9,1.1,1.2; Opera 5,6,7; Phoenix 0.4

function JSMenu()
{
 var items = new Array();
 var root  = new Object();
 
 var s = new Array();
 for (var i=1; i<=8; i++) { s[i-1] = Math.sin(i/8)+0.35; if(s[i-1] < 0.75) s[i-1] = 0.75; }
 s[8] = 1;
 for (i=1; i<=8; i++) { s[i+8] = Math.cos(i/8)+0.35; if(s[i-1] < 0.75) s[i-1] = 0.75; }
 s[16] = 1;
 
 root.parent       = -1;
 root.id           = 0;
 root.name         = "root";
 root.html         = "";
 root.count        = 0;
 root.type         = "M";
 root.next_id      = 1;
 root.layer_id     = "";
 root.has_layer    = 0;
 root.html_h       = "";
 root.html_f       = "";
 root.html_m       = "";
 root.html_l       = "";
 root.html         = "";
 root.T            = 0;
 root.last_menu_parent = 0;
 root.last_menu_width  = 0;
 root.last_item_width  = 0;
 
 items[0]          = root;
 this.items        = items;
 
 this.bgimage      		= "";			// Backgroung Image
 this.hovercolor   		= "#BBBBBB";		// Href Over Color
 this.bgcolor      		= "#DDDDDD";		// Backgroung Color
 this.cur_hover 		= this.bgcolor;		// Current link "over" color
 this.border  			= 1;			// Menu Border  (NS 6+, Mozilla, IE 4+)
 this.spacing  			= 0;			// Spacing for menu tables
 this.padding  			= 1;			// Padding for menu tables
 this.margin			= 2;			// Default margin/padding for layers.
 this.border_color 		= "#000000";		// Border Color (NS 6+, Mozilla, IE 4+)
 this.showstatus		= false;
 this.arrow_pic    		= "menu_arow.gif";	// Menu Arrow Image
 this.arrow_pic_width		= 6;			// it's Width and
 this.arrow_pic_height		= 10;			// it's Height
 this.Top          		= 6;			// Top offset from "parent" menu
 this.Left         		= 12;			// Left offset from "parent" menu
 this.Width        		= -8;			// Width correction
 this.hide_timeout 		= 500;			// Hide TimeOut (in ms)
 this.shine                     = 1;                    // Apply shine effect
 this.font_size                 = 11;                   // Font size in px 
 this.menu_header      = "";
 this.menu_footer      = "";
 
 this.self         = "";
 this.link         = 'menu_link';
 this.T            = 0;
 
 this.timer        = "";
 this.steps        = s;
 this.sleep        = 20;
 this.lastmenu     = 0;
 this.rowObj       = '';
 
 this.JSMenu_browser();
}

function ArrayShift(a)
{
 if(a.shift) { a.shift(); return(a);}
 var r = new Array();
 for(var ind=1; ind < r.length; ind++)
  {
   r[r.length] = a[ind];
  }
 return(r);
}

function ArrayPush(v,a)
{
 if(a.push) { a.push(v); return(a);}
 a[a.length] = v;
 return(a);
}

function ArrayPop(a)
{
 if(a.pop) { a.pop(); return(a);}
 delete(a[a.length-1]);
 return(a);
}

function ArrayUnshift(v,a)
{
 if(a.unshift) { a.unshift(v); return(a);}
 var r = new Array();
 r[0]  = v;
 for(var ind=1; ind < r.length; ind++)
  {
   r[r.length] = a[ind];
  }
 return(r);
}

function ArrayReverse(a)
{
 if(a.reverse) return(a.reverse());
 var r = new Array();
 for(var ind=r.length+1; ind >= 0; ind--)
  {
   r[r.length] = a[ind];
  }
 return(r);
}

JSMenu.prototype.JSMenu_browser = function()
{
 if(typeof(this.browser) == 'object') return(1);     // browser object already contain needed browser info
 var b=navigator.appName;
 var bw = new Object();
 if (b.indexOf('Netscape')!=-1) bw.b="ns";
 else if ((b=="Opera") || (navigator.userAgent.indexOf("Opera")>0)) bw.b = "opera";
 else if (b=="Microsoft Internet Explorer") bw.b="ie";
 bw.version=navigator.appVersion;
 bw.v=parseInt(bw.version);
 bw.ns=(bw.b=="ns" && bw.v>=4);
 bw.ns4=(bw.b=="ns" && bw.v==4);
 bw.ns6=(bw.b=="ns" && bw.v==5);
 bw.ie=(bw.b=="ie" && bw.v>=4);
 bw.ie4=(bw.version.indexOf('MSIE 4')>0);
 var regex = new RegExp("MSIE (\\d)\\.(\\d)");
 var resarr = regex.exec(bw.version);
 bw.ie_version = parseInt(RegExp.$1)+"."+parseInt(RegExp.$2);
 bw.opera=(bw.b=="opera" && (navigator.userAgent.indexOf('Opera 5.')>0 || navigator.userAgent.indexOf('Opera 6.')>0))?true:false;
 bw.opera7=(bw.b=="opera" && navigator.userAgent.indexOf('Opera 7.')>0)?true:false;
 //bw.dom=(document.createElement && document.appendChild && document.getElementsByTagName)?true:false;
 bw.dom=(document.getElementById)?true:false;
 bw.def=(bw.ie||bw.dom);
 var ua=navigator.userAgent.toLowerCase();
 if (ua.indexOf("win")>-1) bw.platform="win32";
 else if (ua.indexOf("mac")>-1) bw.platform="mac";
 else bw.platform="other";
 this.browser = bw;
 return(true);
};

function getObjectBy_ID(id)
{
 var t=this,d=document;
 t.obj   = 'undefined';
 t.style = 'undefined';
 t.browser = 'undefined';
 t.visible = 'undefined';
 t.hidden  = 'undefined';
 var o;
 if(id == "") return("");
 if(d.getElementById)
  {
   t.browser = "DOM";
   t.visible = "visible";
   t.hidden  = "hidden";
   o = d.getElementById(id);
   if(o)
    {
     t.obj     = o;
     t.style   = o.style;
    }
  }
 else if(d.all)
  {
   t.browser = "IE4x";
   t.visible = "visible";
   t.hidden  = "hidden";
   o = d.all[id];
   if(o)
    {
     t.obj     = o;
     t.style   = o.style;
    }
  }
 else if(d.layers)
  {
   t.browser = "NS4x";
   t.visible = "show";
   t.hidden  = "hide";
   var lo;
   var al = new Array();
   lo = d.layers;
   al = ArrayPush(lo,al);
   while(al.length)
    {
     var nl = al[0];
     al = ArrayShift(al);
     for (i=0; i< nl.length; i++)
      {
       if(nl[i].id == id)
        {
         t.obj     = nl[i];
         t.style   = nl[i];
         return("");
        }
       if(nl[i].layers)
        {
         if(nl[i].layers.length)
          {
           al[al.length] = nl[i].layers;
          }
        }
      }
    }
  }
 return(true);
}

getObjectBy_ID.prototype.getObjectBy_ID = getObjectBy_ID;

function getAnchorPosition(anchorname)
{
	var c=new Object();
	var x=0,y=0,d=document;

	var ug=false, uc=false, ul=false;
	if (d.getElementById) { ug=true; }
	else if (d.all) { uc=true; }
	else if (d.layers) { ul=true; }

 	if (ug && d.all) {
		x=AnchorPosition_getPageOffsetLeft(d.all[anchorname]);
		y=AnchorPosition_getPageOffsetTop(d.all[anchorname]);
		}
	else if (ug) {
		var o=d.getElementById(anchorname);
		x=o.offsetLeft; y=o.offsetTop;
		}
 	else if (uc) {
		x=AnchorPosition_getPageOffsetLeft(d.all[anchorname]);
		y=AnchorPosition_getPageOffsetTop(d.all[anchorname]);
		}
	else if (ul) {
		var found=0;
		for (var i=0; i<d.anchors.length; i++) {
			if (d.anchors[i].name==anchorname) { found=1; break; }
			}
		if (found==0) {
			c.x=0; c.y=0; return c;
			}
		x=d.anchors[i].x;
		y=d.anchors[i].y;
		}
	else {
		c.x=0; c.y=0; return c;
		}
	c.x=x;
	c.y=y;
	return c;
	}

function AnchorPosition_getPageOffsetLeft (el) {
	var ol=el.offsetLeft;
	while ((el=el.offsetParent) != null) { ol += el.offsetLeft; }
	return ol;
}
function AnchorPosition_getWindowOffsetLeft (el) {
	return AnchorPosition_getPageOffsetLeft(el)-document.body.scrollLeft;
}
function AnchorPosition_getPageOffsetTop (el) {
	var ot=el.offsetTop;
	while((el=el.offsetParent) != null) { ot += el.offsetTop; }
	return ot;
}
function AnchorPosition_getWindowOffsetTop (el) {
	return AnchorPosition_getPageOffsetTop(el)-document.body.scrollTop;
}

JSMenu.prototype.JSMenu_find_menu = function(id)
{
 var m = this.items;
 var root  = m[0];
 var i;
 for (i=0;i<m.length;i++)
  {
   if(m[i].type == "M" && m[i].id == id) return(id);
  }
 return('undefined');
};

JSMenu.prototype.JSMenu_find_item = function(parent,id)
{
 var it = this.items;
 var i;
 for (i=0;i<it.length;i++)
  {
   if(it[i].type == "I" && it[i].id == id && it[i].parent == parent) return(id);
  }
 return('undefined');
};

JSMenu.prototype.JSMenu_find_all = function(parent)
{
 var it = this.items;
 var a = new Array();
 var ptr = 0;
 var i;
 for (i=0;i<it.length;i++)
  {
   if(it[i].parent == parent)
    {
     a[ptr++] = i;
    }
  }
 return(a);
};

JSMenu.prototype.JSMenu_define = function(parent,self)
{
 var it = this.items;
 var a = new Array();
 var ptr = 0;
 var i;
 for (i=0;i<it.length;i++)
  {
   if(it[i].parent == parent)
    {
     a[ptr++] = i;
    }
  }
 var obj = new Object();
 obj.count = a.length();
 if(!obj.count) return(undefined);
 for(i=0;i<obj.count;i++)
  {
   if(a[i].id == self)
    {
     if(i<obj.count) obj.place = 'middle';
     if(i==obj.count) obj.place = 'last';
     if(i==0) obj.place = 'first';
     obj.type = a[i].type;
     obj.object = a[i];
    }
  }
 return(obj);
};


JSMenu.prototype.JSMenu_walk_to_deep = function(parent)
{
 var it = this.items;
 var a = new Array();
 var q  = new Array();
 var self   = '';
 var i;

 q = ArrayPush(parent,q);

 while(q.length > 0)
  {
   self = q[0];
   q = ArrayShift(q);
   for (i=0;i<it.length;i++)
   {
    if(it[i].parent == self && it[i].type == "M")
     {
      q  = ArrayPush(i,q);
      a = ArrayPush(i,a);
     }
   }
  }
 return(a);
};

JSMenu.prototype.JSMenu_walk_to_root = function(id)
{
 var it = this.items;
 var a = new Array();
 var q  = new Array();
 var self   = '';
 var i;
 q  = ArrayPush(id,q);
 while(q.length > 0)
  {
   self = q[0];
   q = ArrayShift(q);
   if(self > 0)
    if(self != 0)
      for (i=0;i<it.length;i++)
        if(it[i].id == it[self].parent && it[i].type == "M")
          if(it[i].id > 0)
           {
            q  = ArrayPush(i,q);
            a = ArrayPush(i,a);
           }
  }
 a = ArrayReverse(a);
 a = ArrayPush(id,a);
 return(a);
};

JSMenu.prototype.setTRPointer = function(rowObj, color)
{
    if(typeof(rowObj) == 'string' || typeof(rowObj) != 'object')
     {
      var obj = new getObjectBy_ID(rowObj);
      if(obj.obj != 'undefined') { rowObj = obj.obj; }
      else return(0);
     }
    clearTimeout(this.shine_timer);
    if(!this.browser.opera)
     {
      this.rowObj = '';
      if (typeof(rowObj.style) == 'undefined' || typeof(rowObj.cells) == 'undefined') return false;
      var row_cells_cnt = rowObj.cells.length;
      for (var c = 0; c < row_cells_cnt; c++)
       {
         rowObj.cells[c].bgColor = color;
       }
     }
    else
     {
      this.rowObj = '';
      if (typeof(rowObj.style) == 'undefined' || typeof(rowObj.children) == 'undefined') return false;
      var row_cells_cnt = rowObj.children.length;
      for (var c = 0; c < row_cells_cnt; c++)
       {
       	 rowObj.children[c].style.background = color;
       }
     }
    return true;
}

function setBGColorForNS4(layerObj, Whence, OverColor,OutColor)
{
 if(OutColor == "" || OverColor == "") return false;
 if(Whence == 'over')layerObj.bgColor = OverColor;
 if(Whence == 'out') layerObj.bgColor = OutColor;
 return true;
}
function chkDB(v,d) { return (typeof(v) == 'undefined' || v == "" || v == false) ? d : v;}
function chkDE(v,d) { return (typeof(v) != 'undefined' && v != "" && v != false) ? v : d;}
function chkDP(v,d) { return (typeof(v) != 'undefined' && v != "") ? v : d;}

JSMenu.prototype.JSMenu_match_url = function(self)
{
 var url  = chkDE(self.url,"");
 var hostname = document.location.hostname;
 var href = document.location.href;
 var indh = href.indexOf(hostname);
 var rel = "";
 if(indh > -1)
  {
   rel = href.substr(indh+hostname.length);
   indh = url.indexOf(hostname);
   if(indh > -1) url  = url.substr(indh+hostname.length);
   if(rel == url) return(true);
  }
 return(false);
}
JSMenu.prototype.JSMenu_create_window = function(self)
{
 var menu  = new Object();
 var k  = new Object();
 var win;
 if(typeof(window.keepw) != 'object') {window.keepw = k;}
 menu.name  = chkDB(self.name,false);
 menu.focus = chkDB(self.target_focus,false);
 menu.link  = chkDB(self.link,"about:blank");
 if(typeof(menu.name) != 'boolean' && menu.name != false)
  {
   if((eval('typeof(eval(eval("window.keepw."+menu.name)))') != 'undefined') && (!eval(eval("window.keepw."+menu.name+".closed"))))
    {
     win = eval(eval("window.keepw."+menu.name));
     if(typeof(win) != 'undefined') win.document.location.href = menu.link;
     if(menu.focus) win.focus();
    }
   else
    {
     win = window.open(menu.link,menu.name);
     eval("window.keepw."+menu.name+" = win;");
     if(menu.focus) win.focus();
     else window.focus();
    }
  }
}

JSMenu.prototype.JSMenu_add_menu = function(self)
{
 var root  = this.items[0];
 var menu  = new Object();
 menu.id     = root.next_id;
 menu.parent = chkDP(self.parent,-1);
 if(self.parent == "0") { root.last_menu_parent = 0; }
 menu.parent = chkDP(self.parent,root.last_menu_parent);
 root.last_menu_parent = menu.id;
 self.parent = menu.parent;
 var parid = this.JSMenu_find_menu(self.parent);
 menu.name   = chkDP(self.name,"");
 self.html = ((typeof(self.html) != 'undefined') && (self.html != "")) ? this.menu_header+self.html+this.menu_footer : self.html;
 menu.html   = self.html;
 menu.width  = chkDP(self.width,root.last_menu_width);
 root.last_menu_width = menu.width;
 self.width = menu.width;
 var arrs    = "";
 if(typeof(self.cur_hover) == 'undefined')
  {
   arrs = (arrs == "") ? this.JSMenu_find_all(parid) : arrs;
   if((arrs.length) && (this.items[arrs[0]].cur_hover)) self.cur_hover = this.items[arrs[0]].cur_hover;
   else if(this.items[parid].cur_hover) self.cur_hover = this.items[parid].cur_hover;
  }
 menu.cur_hover  = chkDB(self.cur_hover,false);
 menu.left   = self.left ? self.left : 0;
 menu.top    = self.top ? self.top : 0;
 menu.padding = chkDP(self.padding,this.margin);
 menu.direction = chkDP(self.direction,'right');
 menu.onclick = chkDB(self.onclick,false);
 menu.link    = chkDB(self.link,false);
 menu.target  = chkDB(self.target,false);
 menu.target_focus  = chkDB(self.target_focus,true);
 menu.filter  = chkDB(self.filter,"");
 if(typeof(self.separator) != 'undefined' && self.separator != false)
  {
   menu.separator = new Object();
   with(menu.separator) {color = this.border_color || '#000000'; size = this.border || '1';}
   if(typeof(self.separator) == 'object')
    {
     with(self.separator)
      {
       menu.separator.color = mappingColor(chkDP(color,menu.separator.color));
       if(typeof(size) != 'undefined') menu.separator.size = parseInt(size);
      }
    }
   else if(typeof(self.separator) != 'undefined' && self.separator != false) menu.separator.size = parseInt(self.separator);
  }
 menu.layer_id  = 'JSMenuLayer'+menu.id;
 menu.has_layer = 0;
 menu.type   = "M";
 menu.T      = 0;
 menu.count  = 0;
 this.items[0].next_id++;
 if(self.parent != 0 )
  {
   menu.top = this.items[self.parent].top + this.Top;
   menu.left = this.items[self.parent].left + this.Left + menu.width;
   if(menu.direction == 'left') menu.left = this.items[self.parent].left - this.Left - menu.width;
  }
 if((parid != 'undefined') && (parid != -1)) this.items[parid].count++;
 var mybgcolor = this.bgcolor;
 if(menu.cur_hover && mappingColor(this.cur_hover) != mappingColor(this.bgcolor) && this.JSMenu_match_url({url:menu.link})) mybgcolor = mappingColor(this.cur_hover);
  var onclk,href,trgt;
  if(typeof(menu.onclick) != 'boolean' && menu.onclick != false) onclk = 'onClick="'+menu.onclick+'" ';
  else if(typeof(menu.link) != 'boolean' && menu.link != false) { onclk = 'onClick="'+this.self+'.JSMenu_hide(); return true;" '; }
       else onclk = 'onClick="return false;" ';
  if(typeof(menu.link) != 'boolean' && menu.link != false) href = 'href="'+menu.link+'" ';
  else href = 'href="#" ';
  if(typeof(menu.target) != 'boolean' && menu.target != false)
   {
    if(menu.target.indexOf('_') == 0) trgt = 'target="'+menu.target+'" ';
    else
     {
      if(typeof(menu.link) == 'boolean' && menu.link == false) onclk = 'onClick="'+this.self+'.JSMenu_create_window({name:'+"'"+menu.target+"'"+',target_focus:'+menu.target_focus+',link:'+"'"+menu.link+"'"+'}); return false;" ';
      else if(onclk.indexOf("onClick=\"'")) onclk = 'onClick="'+this.self+'.JSMenu_create_window({name:'+"'"+menu.target+"'"+',target_focus:'+menu.target_focus+',link:'+"'"+menu.link+"'"+'}); return false;" ';
      trgt = 'target="'+menu.target+'" ';
     }
   }
  else trgt = 'target="_self" ';
 if(this.browser.def && this.browser.v >= 4 && menu.html != "")
  {
   var subfx = 2;
   if(this.browser.ie4) subfx = -2-(menu.padding*2);
   var br_spec = 0;
   if(this.browser.ns6) {br_spec = menu.padding*2;}
   var usesep = "", mysep = "";
   if(typeof(this.items[parid]) == 'object' && typeof(this.items[parid].separator) == 'object')
    {
     arrs = (arrs == "") ? this.JSMenu_find_all(parid) : arrs;
     if(arrs.length > 0) mysep = this.items[parid].separator;
    }
   var marginpadding = (this.browser.opera || this.browser.opera7)?'margin':'padding';
   var pd = 0;
   if(typeof(this.items[parid].padding) == 'number') pd = (this.items[parid].padding * 2);
   subfx += pd;
   var hlie6 = (this.browser.ie)?pd:0;
   //hlie6 = (this.browser.opera && !this.browser.opera7)?-pd:0;
   if(this.browser.ie && this.browser.ie_version < 5) hlie6 = -pd;
   var cursor = 'pointer';
   if(this.browser.ie) cursor = 'hand';
   
   if(typeof(mysep) == 'object') usesep = "<div style=\"position:absolute; overflow:hidden; left:0; width:"+(self.width+this.Width+2-hlie6)+"px; height:"+(mysep.size)+"px; clip:rect(0 100% "+(mysep.size)+"px 0); background:"+(mysep.color)+";\"></div>";
   menu.html_h = usesep+"<TABLE width='"+(self.width+this.Width-this.arrow_pic_width-subfx)+"' border='0' cellspacing='"+this.spacing+"' cellpadding='"+this.padding+"'><TR id=\""+menu.layer_id+'TR'+"\" BGCOLOR='"+mybgcolor+"'><TD width='"+(self.width+this.Width-this.arrow_pic_width-subfx+br_spec)+"' ALIGN='LEFT' NOWRAP><A CLASS=\"JSMenuA\" "+href+trgt+onclk+"onMouseOver='"+this.self+".JSMenu_show({id:"+menu.id+",filter:true,check:true});clearTimeout("+this.self+".timer);"+this.self+".timer=0;"+this.self+".JSMenu_shine(\""+menu.layer_id+'TR'+"\",\""+this.hovercolor+"\",0);' onMouseOut='"+this.self+".setTRPointer(\""+menu.layer_id+'TR'+"\",\""+mybgcolor+"\");'><DIV CLASS='JSMenuDIV' STYLE='position:relative; overflow:hidden; "+marginpadding+":"+parseInt(this.items[parid].padding)+"px; z-index:9200; cursor:"+cursor+"; width:"+(self.width+this.Width-this.arrow_pic_width-subfx)+"'>";
   menu.html_f = "</DIV></A></TD>";
   menu.html_m = "<TD ALIGN='RIGHT'><IMG SRC='"+this.arrow_pic+"' WIDTH='"+this.arrow_pic_width+"' HEIGHT='"+this.arrow_pic_height+"' BORDER=0 align='middle'></TD>";
   menu.html_l = "</TR></TABLE>";
   menu.html = self.html;
  }
 else if(this.browser.ns4 && menu.html != "")
  {
   var usesep = "", mysep = "";
   if(typeof(this.items[parid]) == 'object' && typeof(this.items[parid].separator) == 'object')
    {
     arrs = (arrs == "") ? this.JSMenu_find_all(parid) : arrs;
     if(arrs.length > 0) mysep = this.items[parid].separator;
    }
   if(typeof(mysep) == 'object') usesep = "<layer TOP="+(this.items[self.parent].T+parseInt(this.border))+" left=1 height="+(mysep.size)+" bgcolor="+(mysep.color)+" width="+(self.width+this.Width-1)+"></layer>";
   menu.html_h = "<LAYER BGCOLOR='"+mybgcolor+"' z-index=9201 onMouseOver='setBGColorForNS4(this,\"over\",\""+this.hovercolor+"\",\""+mybgcolor+"\")' onMouseOut='setBGColorForNS4(this,\"out\",\""+this.hovercolor+"\",\""+mybgcolor+"\")' WIDTH="+(self.width+this.Width-this.arrow_pic_width+4)+" TOP="+(this.items[self.parent].T+this.border)+" LEFT="+(this.border)+">&nbsp;<A CLASS=\"JSMenuA\" "+href+trgt+onclk+"onMouseOver='"+this.self+".JSMenu_show({id:"+menu.id+",filter:true,check:true});'>";
   menu.html_f = "</A></LAYER>"+usesep;
   menu.html_m = "<LAYER z-index=9201 WIDTH="+(this.arrow_pic_width)+" TOP="+(this.items[self.parent].T+6)+" LEFT="+(self.width+this.Width-this.arrow_pic_width-2)+"><IMG SRC='"+this.arrow_pic+"' WIDTH='"+this.arrow_pic_width+"' HEIGHT='"+this.arrow_pic_height+"' BORDER=0></LAYER>";
   menu.html_l = "";
   menu.html = self.html;
  }
 if(this.items[self.parent].id != 0) menu.top = menu.top + this.items[self.parent].T;
 this.items[self.parent].T += 9 + this.font_size;
 
 this.items[menu.id] = menu;
 return(menu.id);
};
JSMenu.prototype.JSMenu_add_item = function(self)
{
 var root  = this.items[0];
 var item  = new Object();
 item.id     = root.next_id;
 item.parent = chkDP(self.parent,root.last_menu_parent);
 self.parent = item.parent;
 root.last_menu_parent = self.parent;
 var parid = this.JSMenu_find_menu(self.parent);
 item.name   = self.name;
 self.html = ((typeof(self.html) != 'undefined') && (self.html != "")) ? this.menu_header+self.html+this.menu_footer : self.html;
 item.html   = self.html;
 var arrs    = "";
 if(typeof(self.width) == 'undefined')
  {
   arrs = (arrs == "") ? this.JSMenu_find_all(parid) : arrs;
   if((arrs.length) && (this.items[arrs[0]].width)) self.width = this.items[arrs[0]].width;
   else if(this.items[parid].width) self.width = this.items[parid].width;
  }
 item.width  = chkDP(self.width,root.last_item_width);
 root.last_item_width = item.width;
 self.width = item.width;
 if(typeof(self.cur_hover) == 'undefined')
  {
   arrs = (arrs == "") ? this.JSMenu_find_all(parid) : arrs;
   if((arrs.length) && (this.items[arrs[0]].cur_hover)) self.cur_hover = this.items[arrs[0]].cur_hover;
   else if(this.items[parid].cur_hover) self.cur_hover = this.items[parid].cur_hover;
  }
 item.cur_hover  = chkDB(self.cur_hover,false);
 item.left   = self.left ? self.left : 0;
 item.top    = self.top ? self.top : 0;
 item.onclick = chkDB(self.onclick,false);
 item.link    = chkDB(self.link,false);
 item.target  = chkDB(self.target,false);
 item.target_focus  = chkDB(self.target_focus,true);
 if((typeof(self.separator) != 'undefined' || typeof(this.items[parid].separator == 'object')) && self.separator != false)
  {
   item.separator = new Object();
   with(item.separator) {color = this.border_color || '#000000'; size = this.border || '1';}
   if(typeof(self.separator) == 'object')
    {
     with(self.separator)
      {
       item.separator.color = mappingColor(chkDP(color,item.separator.color));
       if(typeof(size) != 'undefined') item.separator.size = parseInt(size);
      }
    }
   else if(typeof(self.separator) != 'undefined' && self.separator != false) item.separator.size = parseInt(self.separator);
   if(typeof(this.items[parid].separator) == 'object')
    {
      arrs = (arrs == "") ? this.JSMenu_find_all(parid) : arrs;
      if(arrs.length > 0) item.separator = this.items[parid].separator;
    }
  }
 item.layer_id  = 'JSMenuLayer'+item.id;
 item.has_layer = 0;
 item.type   = "I";
 item.T      = 0;
 item.count  = 0;
 this.items[0].next_id++;

 if(parid != 'undefined' && parid != -1) this.items[parid].count++;
 var mybgcolor = this.bgcolor;
 if(item.cur_hover && mappingColor(this.cur_hover) != mappingColor(this.bgcolor) && this.JSMenu_match_url({url:item.link})) mybgcolor = mappingColor(this.cur_hover);
  var onclk,href,trgt;   
  if(typeof(item.onclick) != 'boolean' && item.onclick != false) onclk = 'onClick="'+item.onclick+'" ';
  else if(typeof(item.link) != 'boolean' && item.link != false) { onclk = 'onClick="'+this.self+'.JSMenu_hide(); return true;" '; }
       else onclk = 'onClick="return false;" ';
  if(typeof(item.link) != 'boolean' && item.link != false) href = 'href="'+item.link+'" ';
  else href = 'href="#" ';
  if(typeof(item.target) != 'boolean' && item.target != false)
   {
    if(item.target.indexOf('_') == 0) trgt = 'target="'+item.target+'" ';
    else
     {
      if(typeof(item.link) == 'boolean' && item.link == false) onclk = 'onClick="'+this.self+'.JSMenu_create_window({name:'+"'"+item.target+"'"+',target_focus:'+item.target_focus+',link:'+"'"+item.link+"'"+'}); return false;" ';
      else if(onclk.indexOf("onClick=\"'")) onclk = 'onClick="'+this.self+'.JSMenu_create_window({name:'+"'"+item.target+"'"+',target_focus:'+item.target_focus+',link:'+"'"+item.link+"'"+'}); return false;" '; //onclk.substr(9)
      trgt = 'target="'+item.target+'" ';
     }
   }
  else trgt = 'target="_self" ';

 if(this.browser.def && this.browser.v >= 4 && item.html != "")
  {
   var usesep = "";
   var marginpadding = (this.browser.opera || this.browser.opera7)?'margin':'padding';
   var pd = 0;
   if(typeof(this.items[parid].padding) == 'number') pd = (this.items[parid].padding * 2);
   var hlie6 = (this.browser.ie)?pd:0;
   if(this.browser.ie && this.browser.ie_version < 5) hlie6 = -pd;
   //hlie6 = (this.browser.opera && !this.browser.opera7)?-pd:0;
   var cursor = 'pointer';
   if(this.browser.ie) cursor = 'hand';
   
   if(typeof(item.separator) == 'object') usesep = "<div style=\"position:absolute; overflow:hidden; left:0; width:"+(self.width+this.Width+2-hlie6)+"px; height:"+(item.separator.size)+"px; clip:rect(0 100% "+(item.separator.size)+"px 0); background:"+(item.separator.color)+";\"></div>";
   item.html_h = usesep+"<TABLE width='100%' border='0' cellspacing='"+this.spacing+"' cellpadding='"+this.padding+"'><TR id=\""+item.layer_id+'TR'+"\" BGCOLOR='"+mybgcolor+"'><TD width='"+(self.width+this.Width-pd)+"' ALIGN='LEFT' NOWRAP><A CLASS=\"JSMenuA\" "+href+trgt+onclk+"onMouseOver='"+this.self+".JSMenu_show({id:"+item.parent+",filter:false});clearTimeout("+this.self+".timer);"+this.self+".timer=0;"+this.self+".JSMenu_shine(\""+item.layer_id+'TR'+"\",\""+this.hovercolor+"\",0);' onMouseOut='"+this.self+".setTRPointer(\""+item.layer_id+'TR'+"\",\""+mybgcolor+"\");'><DIV CLASS='JSMenuDIV' STYLE='position:relative; overflow:hidden; "+marginpadding+":"+parseInt(this.items[parid].padding)+"px; z-index:9200; cursor:"+cursor+"; width:"+(self.width+this.Width-pd)+"'>";
   item.html_f = "</DIV></A></TD></TR></TABLE>";
   item.html_m = "";
   item.html_l = "";
   item.html = self.html;
  }
 else if(this.browser.ns4 && item.html != "")
  {
   var usesep = "";
   if(typeof(item.separator) == 'object') usesep = "<layer TOP="+(this.items[self.parent].T+parseInt(this.border))+" left=1 height="+(item.separator.size)+" bgcolor="+(item.separator.color)+" width="+(self.width+this.Width-2)+"></layer>";
   item.html_h = "<TABLE width='"+(self.width+this.Width)+"' border='0' cellspacing='"+this.spacing+"' cellpadding='0'><TR BGCOLOR='"+mybgcolor+"'><TD width='"+(self.width+this.Width)+"' ALIGN='LEFT' NOWRAP><LAYER ID='"+('JSMenuInnerLayer'+item.id)+"' BGCOLOR='"+mybgcolor+"' z-index=9200 onMouseOver='setBGColorForNS4(this,\"over\",\""+this.hovercolor+"\",\""+mybgcolor+"\")' onMouseOut='setBGColorForNS4(this,\"out\",\""+this.hovercolor+"\",\""+mybgcolor+"\")' WIDTH="+(self.width+this.Width-parseInt(this.border)*2)+" POSITION=absolute TOP="+(this.items[self.parent].T+parseInt(this.border))+" LEFT='"+this.border+"'>&nbsp;<A CLASS=\"JSMenuA\" "+href+trgt+onclk+"onMouseOver='"+this.self+".JSMenu_show({id:"+item.parent+",filter:true,check:true});'>";
   item.html_f = "</A></LAYER>"+usesep+"</TD></TR></TABLE>";
   item.html_m = "";
   item.html_l = "";
   item.html = self.html;
  }
 this.items[self.parent].T += 9 + this.font_size;
 this.items[item.id] = item;
 return(item.id);
};

JSMenu.prototype.JSMenu_init = function(layer_id,vis)
{
 this.items[0].layer_id = layer_id;
 var obj = new getObjectBy_ID(layer_id);
 if(obj.obj != 'undefined')
  {
   obj.style.visibility = eval("obj."+vis);
  }
};

JSMenu.prototype.JSMenu_moveBy = function(withX,withY,linkobj)
{
 var items = this.items;
 var a;
 var arr = (typeof(this.walk_to_deep_root) != "undefined") ? this.walk_to_deep_root : this.JSMenu_walk_to_deep(0);
 
 if(typeof(withX) != "number") withX=0;
 if(typeof(withY) != "number") withY=0;
 
 for (a=0;a<arr.length;a++)
  {
   var i = arr[a];
   var obj = new getObjectBy_ID(items[i].layer_id);
   var object = obj.obj;

   obj.style.left = (parseInt(obj.style.left)+parseInt(withX));
   obj.style.top = (parseInt(obj.style.top)+parseInt(withY));
   var ypos = parseInt(obj.style.top);
   var obj = getAnchorPosition(items[i].layer_id+'_l');
   var ysize = obj.y-ypos;
   
   var obj = new getObjectBy_ID(items[i].layer_id+'_f');
   var object = obj.obj;
   obj.style.left = (parseInt(obj.style.left)+parseInt(withX));
   obj.style.top = (parseInt(obj.style.top)+parseInt(withY));
   obj.style.height = ysize+2+'px';
  }
}

JSMenu.prototype.JSMenu_menu_move = function(l)
{
 var obj = (typeof(l) == "object") ? l : getAnchorPosition(this.link);
 var thisX = parseInt(this.x);
 var thisY = parseInt(this.y);
 this.x = obj.x;
 this.y = obj.y;
 var diffX  = obj.x-thisX;
 var diffY  = obj.y-thisY;
 this.JSMenu_moveBy(diffX,diffY,obj);
}

JSMenu.prototype.JSMenu_show = function(self)
{
 var id   = (typeof(self) != 'object') ? self : self.id;
 var hide = (typeof(self) == 'object') ? self.hide : 'undefined';
 var fltr = (typeof(self) == 'object') ? self.filter : false;
 var check = (typeof(self) == 'object') ? self.check : false;
 
 if(this.timer) clearTimeout(this.timer);
 else if(typeof(hide) != 'undefined' && (!this.browser.ns4)) {return(0);}
 this.timer = '';
 var items = this.items;
 var mlayer;
 var i,a,obj,obj_frame;
 var lob = getAnchorPosition(this.link);
 this.JSMenu_menu_move(lob);
 if(this.lastmenu != id)
 {
 for (i=0;i<items.length;i++)
  {
   if(items[i].has_layer == 1 && items[i].parent != -1)
    {     
     obj = new getObjectBy_ID(items[i].layer_id);
     if(obj.obj != 'undefined')
      {
       if(check && !hide && id == items[i].id && !this.browser.ns4) if(obj.style.visibility == obj.visible) fltr=false;
       obj.style.visibility = obj.hidden;
       obj_frame = new getObjectBy_ID(items[i].layer_id+"_f");
       obj_frame.style.visibility = obj_frame.hidden;
      }
    }
  }
 }
 if((id >= 0) && (items[id].parent == 0)) window.focus();
 if(this.lastmenu != id && id != -2)
 { 
 var arr = this.JSMenu_walk_to_root(id);
 for (a=0;a<arr.length;a++)
  {
   i = arr[a];
   if(i > 0)
    {
     obj = new getObjectBy_ID(items[i].layer_id);
     if(obj.obj != 'undefined')
      {
       var y,maxy;
       var busy = false;
       var condition = false;
       if((a == arr.length-1) && fltr && this.browser.ie && this.browser.ie_version >= 4 && 
          (typeof(obj.obj.filters) == 'object') && (items[i].filter != "")) condition = true;
       if(condition)
        {
         maxy = obj.obj.filters.length;
         if(this.browser.ie_version < 5.5) maxy = 1;
         if(obj.obj.filters.length > 0)
           for(y=0;y<maxy;y++) if(obj.obj.filters.item(y).status == 2) {busy=true;break;}
         if(!busy && obj.obj.filters.length > 0)
           for(y=0;y<maxy;y++) if(obj.obj.filters.item(y).status != 2) obj.obj.filters.item(y).apply();
        }
       obj.style.visibility = obj.visible;
       obj_frame = new getObjectBy_ID(items[i].layer_id+"_f");
       obj_frame.style.visibility = obj_frame.visible;
       if(condition && !busy)
        {
         if(obj.obj.filters.length > 0)
           for(y=0;y<maxy;y++) if(obj.obj.filters.item(y).status != 2) obj.obj.filters.item(y).play();
        }
      }
    }
  }
 }
 this.lastmenu = id;
}

JSMenu.prototype.JSMenu_hide = function(id)
{
 this.timer = setTimeout(this.self+".JSMenu_show({id:-2,hide:true})", this.hide_timeout);
}

function toHex_prim(value)
{
 if(value <= 9)  return(value);
 return(String.fromCharCode(value+55));
}

function toHex(value)
{
 var res = "" + toHex_prim(Math.floor(value/16));
 res += toHex_prim(value & 15);
 return(res);
}

function mappingColor(color)
{
 if(typeof(color) == 'undefined' || color == "") return("");
 if(color.indexOf("#") == 0) return(color);
 var i,colors = new Array('black','#00000','silver','#C0C0C0','gray','#808080','white','#FFFFFF',
     'maroon','#800000','red','#FF0000','purple','#800080','fuchsia','#FF00FF','green','#008000',
     'lime','#00FF00','olive','#808000','yellow','#FFFF00','navy','#000080','blue','#0000FF',
     'teal','#008080','aqua','#00FFFF');
 for(i=0;i<colors.length;i+=2) if(color.toLowerCase() == colors[i]) return(colors[i+1]);
}

JSMenu.prototype.JSMenu_shine = function(rowObj,color,num)
{
 if((typeof(rowObj) == 'string') || (typeof(rowObj) != 'object'))
  {
   var obj = new getObjectBy_ID(rowObj);
   if(obj.obj != 'undefined') { rowObj = obj.obj; }
   else {if(rowObj != " ") return(0);}
  }
 if(!this.shine) { this.setTRPointer(rowObj,color); return (1);}
 if(!num)
  {
   num = 0;
   this.rowObj = rowObj;
  }
 else
  {
   rowObj = this.rowObj;
  }
 
 var row_cells_cnt;
 
 if(!this.browser.opera)
  {
   if (typeof(rowObj.style) == 'undefined' || typeof(rowObj.cells) == 'undefined') return false;
   row_cells_cnt = rowObj.cells.length;
  }
 else
  {
   if (typeof(rowObj.style) == 'undefined' || typeof(rowObj.children) == 'undefined') return false;
   row_cells_cnt = rowObj.children.length;
  }

 var cnt = this.steps.length;
 var str = new String(mappingColor(color));

 for(var c = 0; c < row_cells_cnt; c++)
   {
    var coeff = this.steps[num];
    var n_r = parseInt(parseInt(str.substr(1,2),16)*coeff,10);
    if(n_r > 255) n_r = 255;
    var n_g = parseInt(parseInt(str.substr(3,2),16)*coeff,10);
    if(n_g > 255) n_g = 255;
    var n_b = parseInt(parseInt(str.substr(5,2),16)*coeff,10);
    if(n_b > 255) n_b = 255;
    var n_color = "#"+toHex(n_r)+toHex(n_g)+toHex(n_b);
    if(!this.browser.opera) rowObj.cells[c].bgColor = n_color;
    else rowObj.children[c].style.background = color;
   }
  num++;
  if(num < this.steps.length) this.shine_timer = setTimeout(this.self+".JSMenu_shine(\" \",\""+color+"\","+num+")", this.sleep);
  else this.rowObj = "";
 return(true);
}

JSMenu.prototype.JSMenu_build = function(layer,menu,link)
{
 if(this.browser.v < this.version) return(false);
 var items = this.items;
 var a;
 if(typeof(link) == "undefined" || link == "") link = this.link;
 else this.link = link;
 if(typeof(menu) == "undefined" || menu == "") menu = this.self;
 else this.self = menu;
 var obj = getAnchorPosition(link);
 if(typeof(obj) == 'object')
  {
   this.x = obj.x;
   this.y = obj.y;
  }
 var arr = this.JSMenu_walk_to_deep(0);
 this.walk_to_deep_root = arr;
 var cursor = 'pointer';
 if(this.browser.ie) cursor = 'hand';
 var Z = '';
 for (a=0;a<arr.length;a++)
  {
   var i = arr[a];
   var els = this.JSMenu_find_all(i);
   var html = '';
   var innerWidth = 0;
   
   if(els.length)
   {
    for (var b=0;b<els.length;b++)
     {    
      if(this.browser.ie4 && els.length)
      {
       if(innerWidth < items[els[b]].width) innerWidth = items[els[b]].width;
      }
    
      html += items[els[b]].html_h;
      html += items[els[b]].html;
      html += items[els[b]].html_f;
      if((this.JSMenu_find_all(els[b])).length > 0)
       {
        html += items[els[b]].html_m+items[els[b]].html_l;
       }
      else
       {
        if(items[els[b]].type == "M")
         {
       	  html += "<TD ALIGN='RIGHT'>&nbsp;</TD>";
          html += "</TR></TABLE>";
         }
       }
     }
   }
   else
   {
    html = '';
   }
   if(innerWidth != 0) innerWidth = " width:"+innerWidth+";";
   else innerWidth = "";
   var background = this.bgimage;
   if(this.browser.def && this.browser.v >= 4)
    {
     if(!background) { background = this.bgcolor; }
     else { background = "url("+this.bgimage+")"; }
    }
   if(this.browser.def && this.browser.v >= 4)
    {
     if(html != "")
      {
       var divsize = items[els[0]].width + this.Width;
       if(this.browser.opera7 || this.browser.ns6) {divsize += 2;}
       this.items[i].has_layer = 1;
       if(this.browser.ie)
        {
         //https://hostname/blank.htm
         Z += '<IFRAME frameborder="0" id="'+items[i].layer_id+'_f" src="javascript:false;" scroll="none" style="FILTER:progid:DXImageTransform.Microsoft.Alpha(style=0,opacity=0); visibility:hidden; overflow:hidden; height:20; position:absolute; width:'+(divsize+2)+'px; left:'+(items[i].left+this.Left+this.x)+'px; top:'+(items[i].top+this.Top+this.y)+'px; z-index:9199"></IFRAME>';
        }
       var alink = '<A name="'+items[i].layer_id+'_l'+'" id="'+items[i].layer_id+'_l'+'" border="0" style="display:inline;visible:hidden;"> </A>';
       var iefilter = "";
       if(this.browser.ie && this.browser.ie_version >= 4 && items[i].filter != "") {iefilter = items[i].filter+" ";}
       Z += "<DIV onMouseOver='clearTimeout("+menu+".timer)' onMouseOut='"+menu+".JSMenu_hide("+i+")' ID='"+items[i].layer_id+"' STYLE='position:absolute; "+iefilter+" z-index:9200; visibility:hidden; cursor:"+cursor+"; background:"+background+"; top:"+(items[i].top+this.Top+this.y)+"; left:"+(items[i].left+this.Left+this.x)+"; width:"+divsize+"px; "+innerWidth+" border: "+this.border+"px solid "+this.border_color+"'>"+html+
            alink+"</DIV>";
      }
     else this.items[i].has_layer = 0;
    }
   else if(this.browser.ns4)
    {
     if(html != "")
      {
       this.items[i].has_layer = 1;
       var bottomeborder = "";
       if(this.border > 0) {bottomeborder = "<layer TOP="+(items[i].T+parseInt(this.border))+" left=1 height="+(this.border)+" bgcolor="+(this.border_color)+" width="+(items[els[0]].width + this.Width - 2)+"></layer>";}
       var bgclr = '';
       if(this.border > 0) {bgclr = "BGCOLOR='"+this.border_color+"' ";}
       Z += "<LAYER z-index=9200 onMouseOver='clearTimeout("+menu+".timer)' onMouseOut='"+menu+".JSMenu_hide("+i+")' ID='"+items[i].layer_id+"' POSITION=ABSOLUTE VISIBILITY=HIDDEN "+bgclr+"BACKGROUND='"+background+"' TOP="+(items[i].top+this.Top+this.y)+" LEFT="+(items[i].left+this.Left+this.x)+">"+html+bottomeborder+"</LAYER>";
      }
     else this.items[i].has_layer = 0;
    }
  }
 //alert(Z);
 //document.write('<textarea>'+Z+'</textarea>');
 document.write(Z);
 this.JSMenu_init(layer,"visible")
 if(this.browser.ns4) this.JSMenu_reload_ns(true);
}

JSMenu.prototype.JSMenu_reload_ns = function(init)
{
 if(init==true)
   {
    var ns4 = new Object();
    ns4.innerWidth = innerWidth;
    ns4.innerHeight = innerHeight;
    document.netscape4 = ns4;
    document.netscape4.events = new Object();
    if(typeof(onresize) != 'undefined') document.netscape4.events.onresize = onresize;
    onresize=eval(this.self+".JSMenu_reload_ns");
   }
  else if (innerWidth!=document.netscape4.innerWidth || innerHeight!=document.netscape4.innerHeight) {document.location.reload();}
  if(typeof(document.netscape4.events.onresize) == 'function') document.netscape4.events.onresize();
}

JSMenu.prototype.JSMenu_preload_images = function()
{
 return(1);
}

JSMenu.prototype.JSMenu_anchor = function(name,howto)
{
 var cache = "";
 if(typeof(howto) == 'undefined') howto=false;
 if(typeof(name) == "undefined" || name == "") name = 'menu_link_'+parseInt(Math.random()*1000);
 this.link = name;
 if(this.browser.ns6 || this.browser.opera || this.browser.opera7) cache = '<DIV name="'+name+'" id="'+name+'" style="position:relative; top:0; left:0; visibility:hidden;"></DIV>';
 else cache = '<A name="'+name+'" id="'+name+'"> </A>';
 if(howto) return(cache);
 else document.write(cache);
}