








var bIE4 = 1;//(navigator.appName == "Microsoft Internet Explorer" && navigator.appVersion.substring(0,1) >= "4");
var menustyle=0;  // 1 is old, 0 is new
var prefix = '';
var MN_ITEMHEIGHT = 19;
var MN_on_col = '#DDDDDD';
var rd_m_on_col = '';  // #ef2b2d
var rd_m_of_col = '#cd6005';
var bl_m_on_col = '#b7ccdb';
var bl_m_of_col = '#003893';
var gr_m_on_col = '#8cd600';
var gr_m_of_col = '#008751';
var yl_m_on_col = '#f77f00';
var yl_m_of_col = '#e0aa0f';
var rdcounter=0;
var curitem = -1;
var DA = [];
var bi_c = 1;

var showntip = 0;
var hint_box_width = 300;
var tips_cache = new Array();
var tip_tmpl = "/forms/cabinet/tipbox::std";

//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
function ShowTip(params) {
  var obj;
  var e = params.evnt;
  if (!e) return;
  var top =   e.clientY - 20 + document.body.scrollTop; 
  var left = (e.clientX >  document.body.clientWidth - hint_box_width - 20)?
              e.clientX - 20 - hint_box_width
              :
              e.clientX + 20;
  HideTip();
  showntip = params.tip;
  if (tips_cache[params.tip]) {
    obj = tips_cache[params.tip];
    obj.style.visibility = 'visible';
    obj.style.top   = top;
    obj.style.left  = left;
                                             
  } else {


    JsHttpRequest.query(
      "/php/js_server.php",
       {'__fn':'gettip',
        'tip':params.tip,
        'tmpl':tip_tmpl  
       },
       function(result, errors) {
         if (errors) {
           alert(errors);
         } else {
           var obj = document.createElement("DIV");
           obj.style.position = 'absolute';
           obj.style.visibility = 'visible';
           obj.style.width = hint_box_width;
           obj.style.top   = top;
           obj.style.left  = left;
           obj.innerHTML = result.html;
           document.body.appendChild(obj);
           tips_cache[params.tip] = obj;
         };
       }, true );
  }

}
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
function HideTip() {
  if (!showntip) return;
  var obj = tips_cache[showntip];
  if (obj) obj.style.visibility = 'hidden';
}
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=




if (menustyle) {
  MN_of_col = 'white';
  MN_LEFT_CONST = 0;
  MN_TOP_CONST = 21;
} else {
  MN_of_col = '#fff5ee';
  MN_LEFT_CONST = 0;
  MN_TOP_CONST = 0;
}

//MN_TOP = 0;
//MN_LEFT = 0;

//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
function Dbg(text) {
var d = document.getElementById('debug');
d.innerHTML += "<br>"+text;
}
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
function gettop(id) {
  if (id < 3 ) {
    var d = document.getElementById('td'+id);
//    d = document.all[];
    if (d) {
      t = d.offsetHeight;
      while (d.tagName != 'HTML' && d.tagName != 'BODY') {
//alert(d + " " + d.tagName);
        t += parseInt(d.offsetTop);
        d = d.offsetParent;
      }
      t += MN_TOP_CONST;
      return t  ;
    } else {
      return 0;
    }
  }
  else {
    if (menustyle) {
      t = MA[id].num*MN_ITEMHEIGHT + gettop(MA[id].parent) + 5;
    } else {
//      t = MA[id].num*MN_ITEMHEIGHT + gettop(MA[id].parent) + 5;
      d = document.getElementById('td'+id);
      if (d) {
        t = d.offsetTop + gettop(MA[id].parent);
      } else {
        t = 0;
      }
    }
//    Dbg('V-Parent('+id+'):'+t);
    return  parseInt(t);
  }
}

//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
function getleft(id) {
 var t,d;
  if (id<3) {
    d = document.getElementById('td'+id);
    if (d) {
      t = 0;
      while (d.tagName != 'HTML' && d.tagName != 'BODY') {
        t += parseInt(d.offsetLeft);
        d = d.offsetParent;
      }
      t += MN_LEFT_CONST;
      return t;
    } else { return 0; }
  }
  else {
    d = document.getElementById('d'+MA[id].div);
    if (d) {
      if (menustyle) {
        t = getleft(MA[id].parent) - d.offsetWidth + 5;
      } else {
        t = getleft(MA[id].parent) + d.offsetWidth - 1;
      }
      return  parseInt(t);
    } else { return 0; }
  }
}
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
function h_Resize() {
var td,d,obj,i;
var mleft = 0;
var mtop = 0;


  for (i=0;i<MA.length; i++) {
    if (MA[i].submenu) {
      d = document.getElementById('d'+MA[MA[i].submenu].div);
      if (i<3) {
        td = document.getElementById('td'+i);
        if (td) {
          d.style.width = td.offsetWidth+'px';
        }
      }
      d.style.top = gettop(i)+'px';//+((i<3)?(-MN_TOPBLOCKH):(MN_TOPBLOCKH));
      d.style.left = getleft(i)+'px';
    }
  }
}
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

function TMenuItem (parent,div,submenu,num,title,path,oncol,offcol,ref_id) {
  this.parent = parent;
  this.title = title;
  this.path = path;
  this.div = div;
  this.num = num;
  this.oncol = oncol;
  this.offcol = offcol;
  this.submenu = submenu;
  this.ref_id = ref_id;
  return this;
}

//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
function GenerateMenu() {
  if (!bIE4) {return;}
  for (i=3;i<MA.length;i++) {
    div = MA[i].div;
    if (!DA[div]) {
      if (menustyle) {
        DA[div] = '<div id=d'+div+' bgcolor=red class=dropmenudiv style="position:absolute;visibility:hidden;left:0px;top:0px;width:120px;">'
                 +'<table id=tmi'+div+' width=100% border=0 cellspacing=0 cellpadding=0 bgcolor='+MN_of_col+' style="border-width:1;border-style:solid;border-color:#999999;">';
      } else {
        if ((MA[i].parent>=0)&&(MA[i].parent<3))  {
          DA[div] = '<div id=d'+div+' bgcolor=red align=left' 
                   +' style="position:absolute;visibility:hidden;left:0px;top:0px;width:120px;z-index:100;">'
                   +'<table id=tmi'+div+' width=100% border=0 cellspacing=0 cellpadding=0' 
                   +' bgcolor='+MN_of_col+' style="border-width:1px;border-style:solid;border-color:#999999;">';
//          alert(DA[div]);
        } else {
          DA[div] = '<div id=d'+div+' bgcolor=red class=dropmenudiv style="position:absolute;visibility:hidden;left:0px;top:0px;width:120px;z-index:100;">'
                   +'<table id=tmi'+div+' width=100% border=0 cellspacing=0 cellpadding=0 bgcolor='+MN_of_col+' style="border-width:1px;border-style:solid;border-color:#999999;">';
        }
      }
    }
//    DA[div] = DA[div] + '<tr id=td'+(i)+' ><td onclick="h_Clk('+(i)+')" onmouseover="h_Over('+(i)+')"  onmouseout="h_Out('+(i)+')" class=dropmenutd>'+(MA[(i)].submenu?"<img src=/imn/gray_arrow_left.gif width=9 height=5 style='margin-left:5'>":"")+'<nobr>'+MA[(i)].title+'</nobr></td></tr>';
    if (menustyle) {
      DA[div] = DA[div] + '<tr id=td'+(i)+' ><td onclick="h_Clk('+(i)+')" onmouseover="h_Over('+(i)+')"  onmouseout="h_Out('+(i)+')" class=dropmenutd>'+(MA[(i)].submenu?"<img src=/imn/gray_arrow_left.gif width=9 height=5 style='margin-left:5px'>":"")+''+MA[(i)].title+'</td></tr>';
    } else {
      DA[div] = DA[div] + '<tr id=td'+(i)+' ><td onclick="h_Clk('+(i)+')" onmouseover="h_Over('+(i)+')"  onmouseout="h_Out('+(i)+')" class=dropmenutd>'+''+MA[(i)].title+(MA[(i)].submenu?"<img src=/imn/gray_arrow.gif width=9 height=5 style='margin-left:5px'>":"")+'</td></tr>';
    }
  }

  for (i=1;i<DA.length;i++) {
    if (DA[i]) {
     DA[i] += "</table></div>";
     document.write(DA[i]);
     DA[i] = 0;
    }
  }
}
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
function h_Clk(id){
  document.location = MA[id].path + prefix;
}
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
function h_Over(id) {
 curitem=id;
 if (MA[id].submenu) {
   DA[MA[MA[id].submenu].div] = 1;
 }
 while ((MA[id].parent>=0)&&(id > 2)) {
   DA[MA[id].div] = 1;
   if (MA[id].parent > 2)
      DA[MA[MA[id].parent].div] = 1;
   id = MA[id].parent;
 }
 rdcounter++;
 setTimeout("RedrawMenu("+(rdcounter)+");",1);

}
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
function h_Out(id) {
  for (i=1;i < DA.length; i++) {
    DA[i] = 0;
  }
  curitem=-1;
  rdcounter++;
  setTimeout("RedrawMenu("+(rdcounter)+");",500);
}
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
function RedrawMenu(rdct) {
 if (rdcounter != rdct) return;
 for (i=0;i<MA.length; i++) {
//     if (MA[i].offcol) {
       var d = document.getElementById('td'+i);
       if (d) {
         d.style.backgroundColor = MA[i].offcol;
  //     } else {
  //       alert('TD'+i+' not found');
//       }
     }
 }
 if  (curitem >= 0) {
   i = curitem;
   do  {
     if (MA[i].oncol) {
       var d = document.getElementById('td'+i);
       if (d) {
         d.style.backgroundColor = MA[i].oncol;
       }
     }
     i = MA[i].parent;
   } while (i >= 0);
 }
 for (i=1;i<DA.length;i++) {
    var d = document.getElementById('d'+i);
    if (DA[i]) {
       d.style.visibility = 'visible';
    } else {
       d.style.visibility = 'hidden';
    }
 }
}
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
function LastSetup() {
  h_Resize();
}

//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
function OpenWin2(url,width,height) {
  wnd = window.open(url, 'wwf_popup'+width+height ,"width="+width+",height="+height+",location=no,menubar=no,toolbar=no,resizable=yes,top=0,left=30,scrollbars=no");
}
function GetDim() {
  var ret = {};
  if (window.document.body && window.document.body.clientWidth) {
    ret.scl  = window.document.body.scrollLeft;
    ret.sct  = window.document.body.scrollTop;
    ret.scwf = window.document.body.scrollWidth;
    ret.schf = window.document.body.scrollHeight;
    ret.scw  = window.document.body.clientWidth;
    ret.sch  = window.document.body.clientHeight;
  } else {
    if (windows.scroll) {
      ret.scl  = window.scrollX;
      ret.sct  = window.scrollY;
      ret.scw  = window.innerWidth;
      ret.sch  = window.innerHeight;
      ret.scwf = window.innerWidth +window.scrollMaxX;
      ret.schf = window.innerHeight +window.scrollMaxY;
    } else if (document.documentElement) {
      ret.scl  = document.documentElement.scrollLeft;
      ret.sct  = document.documentElement.scrollTop;
      ret.scwf = document.documentElement.scrollWidth;
      ret.schf = document.documentElement.scrollHeight;
      ret.scw  = document.documentElement.clientWidth;
      ret.sch  = document.documentElement.clientHeight;
    }
  }
  return ret;
}
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
function getClientWidth() {  return document.compatMode=='CSS1Compat' && !window.opera?document.documentElement.clientWidth:document.body.clientWidth;}
//function getClientHeight(){  return document.compatMode=='CSS1Compat' && !window.opera?document.documentElement.clientHeight:document.body.clientHeight;}
function getClientHeight_(){  /*return document.compatMode=='CSS1Compat' && !window.opera?document.documentElement.clientHeight:document.documentElement.clientHeight*/
           return  document.documentElement.clientHeight;}
function getClientHeight() {
var t = getClientHeight_();
if (t==0) t=getDocumentHeight();
//alert(t);
return t;
}
function getBodyScrollTop() {	return self.pageYOffset || (document.documentElement && document.documentElement.scrollTop) || (document.body && document.body.scrollTop);}
function getBodyScrollLeft(){	return self.pageXOffset || (document.documentElement && document.documentElement.scrollLeft) || (document.body && document.body.scrollLeft);}
function getDocumentHeight() {   return Math.max(document.compatMode != 'CSS1Compat' ? document.body.scrollHeight : document.documentElement.scrollHeight, getClientHeight_());}
function getDocumentWidth() {   return Math.max(document.compatMode != 'CSS1Compat' ? document.body.scrollWidth : document.documentElement.scrollWidth, getClientWidth());}
//function getDocumentHeight(){	return (document.body.scrollHeight > document.body.offsetHeight)?document.body.scrollHeight:document.body.offsetHeight;}
//function getDocumentWidth(){	return (document.body.scrollWidth > document.body.offsetWidth)?document.body.scrollWidth:document.body.offsetWidth;}
function getClientCenterX(){	return parseInt(getClientWidth()/2)+getBodyScrollLeft();}
function getClientCenterY(){	return parseInt(getClientHeight()/2)+getBodyScrollTop();}

//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
function OBBG(id) {

  var obj = document.createElement("DIV");
  obj.style.borderWidth = '0px';
  obj.style.position = 'absolute';
  obj.style.top  = '0px';
  obj.style.left = '0px';
  obj.style.width  = getDocumentWidth() + 'px';
  obj.style.height = getDocumentHeight() + 'px';
  obj.style.backgroundImage="url('/imn/chess1pix.gif')";
  obj.style.zIndex=1000;
  obj.id = 'bg'+id;
  document.body.appendChild(obj);


}
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
function OBU(id,inner,width,height,left,top) {
//  var scw = 0, sch=0, scwf=0, schf=0, sct=0; scl=0;

  OBBG(id);
  var obj = document.createElement("DIV");
  obj.style.borderWidth = '0px';
//alert(   scl  + " | " +  sct  + " | " +  scw    + " | " +  sch    + " | " +   scwf   + " | " +   schf ); 
  obj.style.backgroundColor = 'red';
  obj.style.position = 'absolute';
//  obj.style.top  = '100px';
  if (left) {
    obj.style.left = left + 'px';
  } else {
    obj.style.left = Math.floor(getClientCenterX() -  ((width)?(width/2):0)) + 'px';
  }
//alert(getClientCenterX() +"-" +  (width) + "["+ left + "+" +(getClientCenterX() -  ((width)?(width/2):0) )+ "=="+ obj.style.left);
  if (top) {
    obj.style.top  = top + 'px';
  } else {
    obj.style.top  = Math.floor(getClientCenterY() -  ((height)?(height/2):0)) + 'px';
  }
  if (width)  { obj.style.width  = width  + 'px';  }
  if (height) { obj.style.height = height + 'px';  }
  obj.style.padding = '15px';
  obj.style.backgroundColor='white';
  obj.style.backgroundImage='url(\'/imn/nd/xbut1.gif\')';
  obj.style.backgroundRepeat='no-repeat';
  obj.style.backgroundPosition='top right';
  obj.style.borderWidth='1px';
  obj.style.borderColor='gray';
  obj.style.borderStyle='solid';
  obj.style.textAlign='left';
  obj.style.fontSize='90%';
  obj.style.color='black';
  obj.style.zIndex=1010;
  obj.onclick=function(){BI_cls(this.id);}
  obj.style.cursor='pointer';
  obj.id = id;
  obj.innerHTML = inner;
  document.body.appendChild(obj);
/*
alert(
document.body.scrollHeight +" > " + document.body.offsetHeight + " -- " 
+ window.document.body.scrollHeight + " -- "  + (window.innerHeight + " -- " + window.scrollMaxY) + " ---- " +(window.innerHeight + window.scrollMaxY)   + 
 "\ngetClientWidth() = " + getClientWidth()  
+"\ngetClientHeight() = " + getClientHeight() 
+"\ngetBodyScrollTop() = " + getBodyScrollTop() 
+"\ngetBodyScrollLeft() = " +getBodyScrollLeft()
+"\ngetDocumentHeight() = " +getDocumentHeight()
+"\ngetDocumentWidth() = " +getDocumentWidth()
+"\ngetClientCenterX() = " +getClientCenterX()
+"\ngetClientCenterY() = " +getClientCenterY()
);
*/

}


//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
function OBI(url,width,height,descr) {
  var id = '_bi' + (bi_c++);
  var inner  = "<img src="+url+(width?(" width="+width+" "):"")+(height?(" height="+height+" "):"")+" title=\"Click to close\" "+((width||height)?"":(" onLoad=\"BI_cnt('"+id+"')\" "))+">"
   + (descr?("<br>"+descr):"");
//alert(width+","+height+","+inner);
  OBU(id, inner, width, height);
}
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
function OBV(url,width,height,descr) {
  var id = '_bv' + (bi_c++);
  var inner  = 
"<object width='"+width+"' height='"+height+"'><param name='movie' value='"+url+"'"
+"></param><param name='allowFullScreen' value='true'></param><param name='allowscriptaccess' value='always'></param><embed "
+"src='"+url+"' type='application/x-shockwave-flash' allowscriptaccess='always' allowfullscreen='true' width='"+width+"' height='"+height+"'></embed></object>"
   + (descr?("<br>"+descr):"");
  OBU(id, inner, width, height);
}
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
function BI_cnt(id) {
  var obj = document.getElementById(id);
  if (!obj) {alert (id + ' not found');return;}
/*
  var dim = GetDim();
  var l = (dim.scw  - obj.offsetWidth)/2;
  var t = (dim.sch  - obj.offsetHeight)/2;
  if (l<0) l=0;
  if (t<0) t=0;
  t += dim.sct;
  l += dim.scl;
  obj.style.top  = t;
  obj.style.left = l;
*/
  obj.style.left = Math.floor(getClientCenterX() -  (obj.offsetWidth/2)) + 'px';
  obj.style.top  = Math.floor(getClientCenterY() -  (obj.offsetWidth/2)) + 'px';


}
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
function BI_cls(id) {
  var obj = document.getElementById(id);
  if (obj.removeNode) {
    obj.removeNode(true);
  } else {
    document.body.removeChild(obj);
  }
  obj = document.getElementById('bg'+id);
  if (obj.removeNode) {
    obj.removeNode(true);
  } else {
    document.body.removeChild(obj);
  }
}
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
// '_'_'_'_'_'_'_'_'_'_'_'_'_'_'_'_'_'_'_'_'_'_'_'_'_'_'_'_'_'_'_'_'_'_'_'_'_'_'_'_'_'_'_
// ":":":":":":":":":":":":":":":":":":":":":":":":":":":":":":":":":":":":":":":":":":":
//                                                                                          
function Dump(d,l) {
    if (l == null) l = 1;
    var s = '';
    if (typeof(d) == "object") {
        s += typeof(d) + " {\n";
        for (var k in d) {
            for (var i=0; i<l; i++) s += "  ";
            s += k+": " + Dump(d[k],l+1);
        }
        for (var i=0; i<l-1; i++) s += "  ";
        s += "}\n"
    } else {
        s += "" + d + "\n";
    }
    return s;
 return '';
}
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
function SetCookie(n,v,e) {var x=new Date();x.setTime(x.getTime()+(e>0?e:63072000000));document.cookie=n+"="+escape(v)+"; expires="+x.toGMTString()+"; path=/";}
function GetCookie(n) {var p=n+"=";var s1=document.cookie.indexOf(p);if(s1==-1) return "";var s2=document.cookie.indexOf(";",s1+p.length);if(s2==-1) s2=document.cookie.length;return unescape(document.cookie.substring(s1+p.length,s2));}
