// URL: http://www.softdrawer.com/javascript/menu
// Email: support@softdrawer.com
// Version: 2.0.1
// Last Modify: 01/18/2004
// Notes: Registration is needed to use this script on your web site.
// Registration for personal and non-profit use is FREE for charge.
// Copyright (c) 1999-2003 by SoftDrawer.Com
bw=new Browser();
function SoftDrawerMenu(def,name){
  this.def=def;this.format=def.format;name=name||'menu';this.name=name;this.num=0;this.anim_ref=0;this.id='SDMenu'+name;
  this.timer=null;
    if (und(window.SDMHTimers)) window.SDMHTimers=[];
  window.SDMHTimers[this.name]=0;
  this.items=[];this.root={id:name+"_i",w:0,h:0,l:0,t:0,html:'root'};
  this.root.level_format=this.format;
  this.level_formats=def.level_formats || [];
  this.root.format=this.format;
  this.root.pos=[-1,-1];
  this.root.sub=def.sub;eval("window."+this.id+"=this");
  if(!bw) bw=new Browser();
  this.init=function(){
    this.code='';this.top_code='';
    this.container=new DHTMLObjectM(this.name+'_back');
    this._init(null,this.root,-1,0);
    this.top_code = this.container.draw(this.format.left,this.format.top,this.w,this.h,0,0,0,this.getp(this.root,"back_css",0),this.top_code,this.format.relative&&!bw.ns4,'','','');
    if (this.format.relative){
      if (bw.ns4) {
        this.nsf='<div id="DummyNN4" class="" style="position: absolute;"></div>';
        this.code=this.top_code+this.code;
        this.top_code = '<img name="'+this.name+'_anchor" src="'+this.format.transparent_gif+'" border=0 width="'+this.w+'" height="'+this.h+'" alt=""/>';
            } else {
        this.top_code = '<table cellpadding=0 cellspacing=0 border=0 width='+this.w+' height='+this.h+'><tr><td>'+this.top_code+'</td></tr></table>';
      }
    }
  };
  this.init_place=function(){
    document.write(this.top_code);
  }
  this.init_items=function(){
    document.write(this.code);
    if(this.format.init_on_start)for(var i in this.items)this.move_item(this.items[i]);
  };
  this._init=function(parent,node,lvl,num){
    if(!node) return;
        node.i=num;
    node.z=lvl+5+50;
    node.pos=[0,0];
    node.parent=parent; node.id=node.id||node.parent.id+"_"+num;node.lvl=lvl;node.ind=(this.num++)-1;
    if(node!=this.root){
      this.items[node.id]=node;
      var s=this.gen_item(node);
      if(node.parent==this.root) this.top_code+=s; else this.code+=s;
    }
    if(node.sub) for(var i=0;i<node.sub.length;i++) this._init(node,node.sub[i],lvl+1,i);
    if(node==this.root){
      this.w=0;this.h=0;
      for(var i=0;i<node.sub.length;i++){
        var n = node.sub[i];
        if(n.l+n.w>this.w)this.w=n.l+n.w;
        if(n.t+n.h>this.h)this.h=n.t+n.h;
      }
    }
    if (node.url&&node.url.match(this.nnn)) this.aff=1;
  };
    this.getp=function(n,name,def,nf,lvl){
    lvl = (!nf?n.lvl:lvl);
    if(n.parent==this.root&&this.level_formats['level_'+lvl]&&this.level_formats['level_'+lvl][name]) return this.level_formats['level_'+lvl][name];
    return !nf&&!und(n[name])?n[name]:!nf&&n.format&&!und(n.format[name])?n.format[name]:n.parent==null?def:n.parent.level_format&&!und(n.parent.level_format[name])?n.parent.level_format[name]:this.getp(n.parent,name,def,1,lvl)
  };
  this.gen_html=function(n,over){
    var css=(over?this.getp(n,"over_class",0):this.getp(n,"normal_class",0));
    css=css?' class="'+css+'"':'';
    var table_css=(over?this.getp(n,"over_item_css",0):this.getp(n,"normal_item_css",0));
    table_css=table_css?' class="'+table_css+'"':'';
    var w =n.w-n.br[1]-n.br[3];
    var html='<table width="'+w+'" cellspacing=0 cellpadding="0" border=0 height="'+(n.h-n.br[0]-n.br[2])+'"'+table_css+'><tr>';
    var code=(over?n.over_html||n.html:n.html);
    var tr='';var aw = 0;var iw = 0;
    var arrow = this.getp(n,"arrow",0);
    arrow=this.getp(n,"arrow_off",0)?0:arrow;
    if (n.sub&&arrow) {
      as=this.getp(n,"arrow_size",[16,16]);
      w-=as[0];
    }
        if(n.image){
      n.image_mode=this.getp(n,"image_mode",'none');
      var is=n.image_mode=='full'?[n.w,n.h]:this.getp(n,"image_size",[16,16]);
            var _img = '<img src="'+(over?n.over_image||n.image:n.image)+'" border="0" width="'+is[0]+'" height="'+is[1]+'">';
      var img='<td width="'+is[0]+'">'+_img+'</td>';
      switch (n.image_mode) {
        case 'left': tr+=img+'<td width="'+(w-is[0])+'"'+css+'>'+code+'</td>'; break;
        case 'right': tr+='<td width="'+(w-is[0])+'"'+css+'>'+code+'</td>'+img; break;
        case 'full': tr+=img; break;
      }
    } else
      tr+='<td width="'+w+'"'+css+'>'+code+'</td>';
    if (n.sub&&arrow) {
      var over_arrow = this.getp(n,"over_arrow",0);
      var aimg = '<img src="'+(over?over_arrow||arrow:arrow)+'" border="0" width="'+as[0]+'" height="'+as[1]+'">';
      tr+='<td width="'+as[0]+'">'+aimg+'</td>';
    }
    html+=tr+'</tr></table>';
    return html;
  }
  this.make_a=function(n,code){var t=this.getp(n,"target",0);t=t?' target="'+t+'"':'';return '<a name="'+n.id+'l" href="'+(n.url||'#')+'" border="0"'+t+'>'+code+'</a>';}
  this.move_sub=function(n){
    this.container.pageXY();
    if(this.container.pageX==n.pos[0]&&this.container.pageY==n.pos[1])return;
    n.pos=[this.container.pageX,this.container.pageY];
        for (var i=0;i<n.sub.length;i++) {
      if(n!=this.root){
        this.get_item_pos(n.sub[i]);
        this.move_item(n.sub[i],this.container.pageX+n.sub[i].l,this.container.pageY+n.sub[i].t);
      }
    }
  }
  this.move_all=function(){
    this.container.pageXY();
    this.root.pos=[this.container.pageX,this.container.pageY];
        for (var i in this.items) {
      var n = this.items[i];
      if(n.parent!=this.root){
        this.get_item_pos(n);
        this.move_item(n,this.container.pageX+n.l,this.container.pageY+n.t);
      }
    }
  }
  this.show_sub=function(n,s){
    if (s&&n!=this.root&&this.format.relative)this.move_sub(n);
        for (var i=0;i<n.sub.length;i++) {
      this.show_item(n.sub[i],s);
      if(!s)n.sub[i].selected=0;
      if(!s&&n.sub[i].sub&&n.sub[i].sub_vis) this.show_sub(n.sub[i],0);
    }
    n.sub_vis=s;
  }
  this.show=function(){
    this.container.init();this.container.show();
    if (this.format.relative&&bw.ns4) {
      var im = document.images[this.name+'_anchor'];
      this.container.move(im.x,im.y);
    }
    //if (this.format.relative)
    this.move_all();
    this.show_sub(this.root,1);
  }
  this.get_item_pos=function(n){
    var root=n.parent==this.root;
    var fd = n.parent.parent == this.root;
      var first=n.i==0;
    var o=this.getp(n,"orientation",'horizontal');
    var ob=this.getp(n,"overlap_borders",0);
    var prev=!first?n.parent.sub[n.i-1]:n.parent;
    var io=this.getp(n,"offset",[0,0]);
    var lo=this.getp(n,"level_offset",[0,0]);
    if(o=='horizontal') {
      n.l=prev.l+(first?(n.lvl==1?0:prev.w):(root?prev.w:0));
      if(ob)n.l-=(root&&!first||!root&&first&&n.lvl!=1?n.br[0]:0);
      n.t=prev.t+((root||first&&n.lvl!=1)?0:prev.h)
      if(ob)n.t-=(!root&&!first||first&&n.lvl==1?n.br[1]:0);
      if(first){n.l+=lo[0];n.t+=lo[1]};
    } else if(o=='vertical') {
      n.l=prev.l+(first?prev.w:0);
      if(ob)n.l-=(first?n.br[0]:0);
      n.t=prev.t+(first?0:prev.h);
      if(ob)n.t-=(!first?n.br[1]:0);
      if(first){n.l+=lo[0];n.t+=lo[1]};
    } else {
      n.l=prev.l+(first?lo[0]:io[0]);
      n.t=prev.t+(first?lo[1]:io[1]);
    }
      n.w=this.getp(n,"width",0);
    n.h=this.getp(n,"height",0);
    var off=this.getp(n,"offset",[0,0]);
    n.l+=off[0];
    n.t+=off[1];
  }
  this.gen_item=function(n,typ){
    function ea(a){return a[0]==0&&a[1]==0&&a[2]==0&&a[3]==0}
    var bm = this.getp(n,"border_mode",'custom');
    var bc = this.getp(n,"border_color",'black');
    var br=[0,0,0,0];
    if (bm=='custom')br=this.getp(n,"border",[0,0,0,0]);
    var al=n.parent==this.root&&this.format.orientation=='horizontal'?[[1,0,1,1],[1,1,1,0],[1,0,1,0]]:[[1,1,0,1],[0,1,1,1],[0,1,0,1]];
    var ai=n.parent==this.root&&this.format.orientation=='horizontal'?[[1,0,1,1],[1,1,1,1],[1,0,1,1]]:[[1,1,1,1],[0,1,1,1],[0,1,1,1]];
    if (bm=='around_level')br=n.i==0?al[0]:n.i==n.parent.sub.length-1?al[1]:al[2];
    if (bm=='around_item') br=n.i==0?br=ai[0]:n.i==n.parent.sub.length-1?ai[1]:ai[2];
    n.is_b=!ea(br);
    var sh=this.getp(n,"shadow",[0,0,0,0]);
    n.is_s=!ea(sh);
    n.br=br;n.sh=sh;
    this.get_item_pos(n);
    n.obj_o=new DHTMLObjectM(n.id+'o');
    n.obj_n=new DHTMLObjectM(n.id+'n');
    n.obj_a=new DHTMLObjectM(n.id+'a');
    if(n.is_b)n.obj_b=new DHTMLObjectM(n.id+'b');
    if(n.is_s)n.obj_s=new DHTMLObjectM(n.id+'s');
    var s='';
    if(this.format.relative&&n.parent!=this.root){n.l=n.t=bw.ns4?0:-1000;};

    if(n.is_s)s+=n.obj_s.draw(n.l+sh[3],n.t+sh[0],n.w+sh[1],n.h+sh[2],this.getp(n,"shadow_color",'gray'),0,n.z,0,'','','','','filter:alpha(opacity=70); -moz-opacity:0.7;');
    if(n.is_b)s+=n.obj_b.draw(n.l,n.t,n.w,n.h,bc,0,n.z,this.getp(n,"border_css",0),'','','','','');

    s+=n.obj_n.draw(n.l+br[3],n.t+br[0],n.w-br[1]-br[3],n.h-br[0]-br[2],this.getp(n,"bgcolor",'gray'),0,n.z,this.getp(n,"normal_div",0),this.gen_html(n,0),0,'','');
        s+=n.obj_o.draw(n.l+br[3],n.t+br[0],n.w-br[1]-br[3],n.h-br[0]-br[2],this.getp(n,"bgcolor_over",'silver'),0,n.z,this.getp(n,"over_div",0),this.gen_html(n,1),0,'','');
    var bi='<img src="'+this.format.transparent_gif+'" border=0 width="'+n.w+'" height="'+n.h+'"/>';
    s+=n.obj_a.draw(n.l+br[3],n.t+br[0],n.w-br[1]-br[3],n.h-br[0]-br[2],0,0,n.z,0,n.not_a_link?bi:this.make_a(n,bi),0,this.id+'.mover(\''+n.id+'\')', this.id+'.mout(\''+n.id+'\')','');

    n.bw=n.w-br[3]-br[1];
    n.bh=n.h-br[2]-br[0];

    return s;
  };
  this.init_item=function(n){
    var p=this.root==n.parent?this.container:0;
    if(n.is_s)n.obj_s.init(p);
    if(n.is_b)n.obj_b.init(p);
    n.obj_o.init(p);
    n.obj_n.init(p);
    n.obj_a.init(p);
  }
  this.move_item=function(n,x,y){
    if(!n.obj_o.el) this.init_item(n);
    if(n.obj_o.x==x+n.br[3]&&n.obj_o.y==y+n.br[0])return;
    if(n.is_s)n.obj_s.move(x+n.sh[3],y+n.sh[0]);
    if(n.is_b)n.obj_b.move(x,y);
    n.obj_o.move(x+n.br[3],y+n.br[0]);
    n.obj_n.move(x+n.br[3],y+n.br[0]);
    n.obj_a.move(x+n.br[3],y+n.br[0]);
  }
  this.show_item=function(n,s){
    if(!n.obj_o.el) this.init_item(n);
    if(n.is_s)n.obj_s.vis(s);
    if(n.is_b)n.obj_b.vis(s);
    n.obj_n.vis(s);
    if(n.selected)n.obj_o.vis(s);
    n.obj_a.vis(s);
    n.v=s;
  }
  this.set_item_state=function(n,over,silent){
    if(!n.v) return;
    n.obj_o.vis(over);
    n.selected=over;
    n.parent.active=over||silent?n:0;
  };
  this.mover2=function(id){
    if(this.mover_timer)clearTimeout(this.mover_timer);
    var n=this.items[id];
    var st = this.format.show_delay||0;
    if(n.sub&&!n.sub[0].v&&st!=0)
      this.mover_timer=setTimeout(this.id+'.mover2("'+id+'")',st)
    else
      this.mover2(id);
  };
  this.show_sub_id=function(id){
    this.show_sub(this.items[id],1);

  };
  this.mover=function(id){
    this.clearTimer(0);
    if(this.mover_timer)window.clearTimeout(this.mover_timer);
    var n=this.items[id];
    var act=n.parent.active;
    if(act&&act!=n)this.set_item_state(act,0);
    if(act&&act!=n&&act.sub)this.show_sub(act,0);
    if (n.parent!=this.root&&!this.format.parent_stay_active) {
      this.set_item_state(n.parent.parent.active,0,1);
    }
    if (n.active&&!this.format.parent_stay_active) {
      this.set_item_state(n.active,0);
    }
        this.set_item_state(n,1);
        if(n.sub&&!n.sub[0].v){
      var st = this.getp(n,'show_delay',0);
      if(st)this.mover_timer=window.setTimeout(this.id+'.show_sub_id("'+id+'")',st); else this.show_sub(n,1);
    }
  };
  this.hide=function(){
    for (var i=0;i<this.root.sub.length;i++) {
      var n=this.root.sub[i];
      this.set_item_state(n,0);
      if(n.sub)this.show_sub(n,0);
    }
  }
  this.clearTimer=function(){if (this.timer!=null){window.clearTimeout(this.timer);this.timer=null;}};
    this.mout=function(id){
    this.clearTimer();
    this.timer=window.setTimeout(this.id+'.hide()',this.format.hide_delay||600);
  };
  this.nnn=unescape('%73%6F%66%74%64%72%61%77%65%72');
  this.init();
  return this;
}
function Browser(){this.ver=navigator.appVersion;this.agent=navigator.userAgent;this.dom=document.getElementById?1:0;this.opera5=this.agent.indexOf("Opera 5")>-1;this.opera6=this.agent.indexOf("Opera 5")>-1;this.opera7=(this.agent.indexOf("Opera/7")>-1)||(this.agent.indexOf("Opera 7")>-1);this.ie5=(this.ver.indexOf("MSIE 5")>-1 && this.dom && !this.opera5)?1:0;this.ie6=(this.ver.indexOf("MSIE 6")>-1 && this.dom && !this.opera5)?1:0;this.ie4=(document.all && !this.dom && !this.opera5)?1:0;this.ie=this.ie4||this.ie5||this.ie6;this.mac=this.agent.indexOf("Mac")>-1;this.ns6=(this.dom && parseInt(this.ver)>=5)?1:0;this.ns4=(document.layers && !this.dom)?1:0;this.operaOld=window.opera&&!this.opera7;this.bw=(this.ie6||this.ie5||this.ie4||this.ns4||this.ns6||this.opera5||this.opera6||this.opera7);return this};
function DHTMLObjectM(id){
  this.id=id;if(!bw.bw)return;
  this.name='DHTMLObjectM_'+this.id;
  this.init=function(ns4p){this.el=bw.dom?document.getElementById(this.id):bw.ie4?document.all[this.id]:bw.ns4?ns4p?ns4p.doc.layers[this.id]:document.layers[this.id]:0;if(!this.el) return;this.css=bw.dom||bw.ie4?this.el.style:this.el;this.doc=bw.dom||bw.ie4?document:this.css.document;this.x=parseInt(this.css.left)||this.css.pixelLeft||this.el.offsetLeft||0;this.y=parseInt(this.css.top)||this.css.pixelTop||this.el.offsetTop||0;this.w=this.el.offsetWidth||this.css.clip.width||this.doc.width||this.css.pixelWidth||0;this.h=this.el.offsetHeight||this.css.clip.height||this.doc.height||this.css.pixelHeight||0;if(this.initClip)this.initClip()};
  this.draw=function(x,y,w,h,bg,v,z,css,code,rel,mover,mout,add_style){this.v=v;return (bw.ns4?'<'+(rel?'i':'')+'layer id="'+this.id+'" z-index='+z+' left='+x+' top='+y+' '+(w&&w!='auto'?'width='+w:'')+' height='+h+(!v?' visibility=hidden':'')+(bg!=""?' bgcolor="'+bg+'"':'')+(add_style?' style="'+add_style+'"':'')+(css!=''?' class="'+css+'"':'')+(mover?' onmouseover="'+mover+'"':'')+(mout?' onmouseout="'+mout+'"':'')+'>'+code+'</'+(rel?'i':'')+'layer>':'<div id="'+this.id+'" style="position:'+(rel?'relative':'absolute')+';z-index:'+z+';left:'+x+'px;top:'+y+'px;'+(w?'width:'+w+(w=='auto'?'':'px;'):'')+(h?'height:'+h+'px;':'')+(!v?'visibility:hidden;':'')+(bg!=""?''+(bw.ns4?'layer-':'')+'background-color:'+bg+';':'')+(add_style?add_style:'')+'"'+(css!=''?' class="'+css+'"':'')+(mover?' onmouseover="'+mover+'"':'')+(mout?' onmouseout="'+mout+'"':'')+'>'+code+'</div>')};
  this.move=function(x,y){this.css.left=this.x=x;this.css.top=this.y=y};
  this.show=function(){this.css.visibility="visible";this.v=1};
  this.hide=function(){this.css.visibility="hidden";this.v=0};
  this.pageXY=function(){function domPageXY(el,wh){var x=el['offset'+wh];var parent=el.offsetParent;while(parent&&parent!=document.body){x+=parent['offset'+wh];parent=parent.offsetParent}return x};this.pageX=bw.ns4?this.el.pageX:domPageXY(this.el,'Left');this.pageY=bw.ns4?this.el.pageY:domPageXY(this.el,'Top')};
  this.vis=function(v){if(this.v!=v){if(this.v=v)this.show(); else this.hide()}};
  eval(this.name+'=this');
  return this
};
function pldImg(arg){for(var i in arg)if(arg[i]&&arg[i]!=''){var im=new Image();im.src=arg[i]}}
function und(val){return typeof(val)=='undefined'}

var MENU_ITEMS={
    format:{
    //position and orientation
    left:176,top:103,relative:0,
    //orientation:'vertical',
    orientation:'horizontal',

    //borders
    border_mode:'custom',//[around_item,custom], border:[1,1,1,1],//only if custom
    border:[0,0,0,0],
    border_color:'white',
    shadow:[2,0,0,2],
    shadow_color:'gray',

    //default item size
    width:106+28,height:22,

    //colors
    bgcolor:'#7A79AE',bgcolor_over:'#7A79AE',

    //CSS classes
    //back_css:'clsMenu',
    normal_class:'clsMenuItem',
    over_class:'clsMenuItemOn',
    //over_class:'clsMenuItemON',
    //normal_div:'clsTransparent1',
    //over_div:'clsMenuFullItemON',
    //normal_item_css:'clsMenuFullItem',
    //over_item_css:'clsMenuFullItemON2',

    //images
    image_mode:'left',image_size:[28,22],

    //misc
    hide_delay:600,
    show_delay:0,
    init_on_start: false,
    parent_stay_active:1,
    transparent_gif:'images/spacer.gif'
    },
  level_formats:{
    level_0:{border:[0,0,0,0], border_mode:'custom',arrow_off:1, shadow:[0,0,0,0], normal_class:'clsMenuItemTop', over_class:'clsMenuItemTopOn'},
    level_1:{width:180, bgcolor_over:'#A39CBF', border_mode:"around_level", height:23, image_size:[23,22]},
    level_2:{width:160, bgcolor_over:'#A39CBF', border_mode:"around_level",level_offset:[-11,11]}
  },
  sub:[
    {html:'FOREX', image:"images/menu_separator.gif",
      sub:[
        {html:'Кто это', image:"images/menu_separator_h.gif",url:"/FX-about.php"},
        {html:'Чем измеряется', image:"images/spacer.gif",
          sub:[
            {html:'&nbsp;&nbsp;- технически',url:"/tech.php"},
            {html:'&nbsp;&nbsp;- фундаментально',url:"/fynd.php"}
          ]
        },
        {html:'В чем секрет<br>успешного трейдинга', image:"images/spacer.gif", height:44, url:"/psiho.php"}
      ]
    },
    {html:'ОТКУДА МЫ', image:"images/menu_separator.gif",
      sub:[
        {html:'У истоков', image:"images/menu_separator_h.gif",url:"/istoki.php"},
        {html:'В чем отличие', image:"images/spacer.gif",url:"/difference.php"},
        {html:'Где эта улица', image:"images/spacer.gif",url:"/whereis.php"}
      ]
    },
    {html:'ЗА ОБЛОЖКОЙ', image:"images/menu_separator.gif",
      sub:[
        {html:'Из чего выбрать', image:"images/menu_separator_h.gif",
          sub:[
            {html:'&nbsp;&nbsp;демо',url:"/choice.php"},
            {html:'&nbsp;&nbsp;стрельба боевыми',url:"/choice_r.php"}
          ]
        },
        {html:'Правила соревнований', image:"images/spacer.gif",url:"/tournament.php"},
        {html:'Любителям экзотики', image:"images/spacer.gif",url:"/exotic.php"}
      ]
    },
    {html:'ПРОЕКТ INT', image:"images/menu_separator.gif", level_format:{width:210},
      sub:[
        {html:'Во что это выльется', image:"images/menu_separator_h.gif",url:"/INT-about.php"},
        {html:'Регистрация добровольцев', image:"images/spacer.gif",url:"/INT-about_2.php"}
      ]
    },
    {html:'ФОРУМ', image:"images/menu_separator.gif",url:"/sel_brd_frm.php"},
    {html:'', image:"images/menu_separator.gif",width:1}
  ]

}