// menucom.js :


//
function gethtmlelement( id ) 
{
 return document.getElementById(id);
}
//
function item (

 id,
 text,
 enable,
 current,
 link,
 href

)
 {

 this.id = id;
 this.text = text;
 this.enable = enable;
 this.current = current;
 this.link = link;
 this.href = href;
 this.sub = null;

}
//
function menu (

 id,
 padding,
 align,
 arrow

) {

 this.id = id;
 this.top = 0;
 this.left = 0;
 this.width = 0;
 this.height = 0;
 this.border = "1px solid #e0e0c0";
 this.background = "#fffff0";
 this.firstpadding = padding;//"5px 0px 5px 5px";
 this.align = align;
 this.secondpadding = "4px";
 this.font = "normal 10px Verdana,sans-serif";
 this.disable = "#cccccc";
 this.current = "#008080";
 this.over = "#b00000";
 this.out = "#af9070";
 this.arrow = arrow;
 this.items = new Array();
 this.parentmenu = null;
 this.parentitem = 0;
 this.interval = 0;
 this.intervalid = null;
 this.add = add;
 this.link = link;
 this.html = html;
 this.init = init;
 this.simplyshow = simplyshow;
 this.simplyhide = simplyhide;
 this.intervalshow = intervalshow;
 this.intervalhide = intervalhide;

}


//
function add( _item ) {
 this.items.push( _item ) ;
}


//
function link( _id, i, _sub, _interval ) {

 this.items[i].id = _id;
 this.items[i].sub = _sub;
 _sub.interval = _interval;
 _sub.parentmenu = this;
 _sub.parentitem = i;

}


//
function html( ) {

 var _html = "";

 _html += "<table"
 _html += " id=\"" + this.id + "\"";
 _html += " cellspacing=\"0px\"";
 _html += " cellpadding=\"0px\"";
 _html += " style=\"";
 _html += "visibility:hidden;";
 _html += "position:absolute;";
 _html += "z-index:1;";
 _html += "top:" + this.top +"px;";
 _html += "left:" + this.left +"px;";
 _html += "width:" + this.width +"px;";
 _html += "height:" + this.height +"px;";
 _html += "border:" + this.border +";";
 _html += "background:" + this.background +";";
 _html += "\"";
 _html += ">";
 _html += "<tr>";
 _html += "<td";
 _html += " style=\"";
 _html += " padding:" + this.firstpadding + ";";
 _html += "\"";
 _html += ">";

 _html += "<table";
 _html += " cellspacing=\"0px\"";
 _html += " cellpadding=\"" + this.secondpadding +"\"";
 _html += " style=\"";
 _html += " text-align:" + this.align + ";";
 _html += " font:" + this.font + ";";
 _html += "\"";
 _html += ">";

 for ( i=0; i<this.items.length; i++ ) {

  _html += "<tr>";

  if ( this.align == "left" ) {

   if ( this.items[i].sub == null ) {

    _html += "<td";
    _html += " style=\"";
    _html += "cursor:default";
    _html += "\"";
    _html += ">";
    _html += "&nbsp;";
    _html += "</td>";

   }

   else {

    _html += "<td";
    _html += " style=\"";
    _html += "font-size:0px;";
    _html += "\"";
    _html += ">";
    _html += "<img";
    if ( this.items[i].id != "" ) {
     _html += " id=\"" + this.items[i].id + "_arrow" + "\"";
    }
    _html += " src=\"" + this.arrow + "\"";
    _html += " style=\"";
    _html += " visibility:hidden";
    _html += "\"";
    _html += ">";
    _html += "</td>";

   }

  }

  if ( this.items[i].enable == false ) {

   _html += "<td";
   if ( this.items[i].id != "" ) {
    _html += " id=\"" + this.items[i].id + "\"";
   }
   _html += " style=\"";
   _html += "white-space:nowrap;";
   _html += "color:" + this.disable +";";
   _html += "cursor:default;";
   _html += " onmouseover='";
   if ( this.parentmenu != null ) {
    _html += this.id + ".intervalshow();";
    if ( this.parentmenu.parentmenu != null ) {
     _html += this.parentmenu.id + ".intervalshow();";
    }
   }
   _html += "'";
   _html += " onmouseout='";
   if ( this.parentmenu != null ) {
    _html += this.id + ".intervalhide();";
    if ( this.parentmenu.parentmenu != null ) {
     _html += this.parentmenu.id + ".intervalhide();";
    }
   }
   _html += "'";
   _html += "\"";
   _html += ">";
   _html += this.items[i].text;
   _html += "</td>";

  }

  if (

   this.items[i].enable == true &&
   this.items[i].current == true &&
   this.items[i].sub == null

  ) {

   _html += "<td";
   if ( this.items[i].id != "" ) {
    _html += " id=\"" + this.items[i].id + "\"";
   }
   _html += " style=\"";
   _html += "white-space:nowrap;";
   _html += "color:" + this.current + ";";
   _html += "cursor:default;";
   _html += "\"";
   _html += " onmouseover='";
   for ( j=0; j<this.items.length; j++ ) {
    if ( ( j != i ) && ( this.items[j].sub != null ) ) {
     _html += this.items[j].sub.id + ".simplyhide();";
    }
   }
   if ( this.parentmenu != null ) {
    _html += this.id + ".intervalshow();";
    if ( this.parentmenu.parentmenu != null ) {
     _html += this.parentmenu.id + ".intervalshow();";
    }
   }
   _html += "'";
   _html += " onmouseout='";
   if ( this.parentmenu != null ) {
    _html += this.id + ".intervalhide();";
    if ( this.parentmenu.parentmenu != null ) {
     _html += this.parentmenu.id + ".intervalhide();";
    }
   }
   _html += "'";
   _html += ">";
   _html += this.items[i].text;
   _html += "</td>";

  }

  if (

   this.items[i].enable == true &&
   this.items[i].current == true &&
   this.items[i].sub != null

  ) {

   _html += "<td";
   if ( this.items[i].id != "" ) {
    _html += " id=\"" + this.items[i].id + "\"";
   }
   _html += " style=\"";
   _html += "white-space:nowrap;";
   _html += "color:" + this.current + ";";
   _html += "cursor:default;";
   _html += "\"";
   _html += " onmouseover='";
   for ( j=0; j<this.items.length; j++ ) {
    if ( ( j != i ) && ( this.items[j].sub != null ) ) {
     _html += this.items[j].sub.id + ".simplyhide();";
    }
   }
   if ( this.parentmenu != null ) {
    _html += this.id + ".intervalshow();";
    if ( this.parentmenu.parentmenu != null ) {
     _html += this.parentmenu.id + ".intervalshow();";
    }
   }
   _html += this.items[i].sub.id + ".intervalshow();";
   _html += "'";
   _html += " onmouseout='";
   if ( this.parentmenu != null ) {
    _html += this.id + ".intervalhide();";
    if ( this.parentmenu.parentmenu != null ) {
     _html += this.parentmenu.id + ".intervalhide();";
    }
   }
   _html += this.items[i].sub.id + ".intervalhide();";
   _html += "'";
   _html += ">";
   _html += this.items[i].text;
   _html += "</td>";
   
  }

  if (

   this.items[i].enable == true &&
   this.items[i].current == false &&
   this.items[i].link == 0 &&
   this.items[i].sub == null

  ) {

   // ?

  }

  if (

   this.items[i].enable == true &&
   this.items[i].current == false &&
   this.items[i].link == 0 &&
   this.items[i].sub != null

  ) {

   _html += "<td";
   if ( this.items[i].id != "" ) {
    _html += " id=\"" + this.items[i].id + "\"";
   }
   _html += " style=\"";
   _html += "white-space:nowrap;";
   _html += "color:" + this.out + ";";
   _html += "cursor:default;";
   _html += "\"";
   _html += " onmouseover='";
   for ( j=0; j<this.items.length; j++ ) {
    if ( ( j != i ) && ( this.items[j].sub != null ) ) {
     _html += this.items[j].sub.id + ".simplyhide();";
    }
   }
   if ( this.parentmenu != null ) {
    _html += this.id + ".intervalshow();";
    if ( this.parentmenu.parentmenu != null ) {
     _html += this.parentmenu.id + ".intervalshow();";
    }
   }
   _html += this.items[i].sub.id + ".intervalshow();";
   _html += "'";
   _html += " onmouseout='";
   if ( this.parentmenu != null ) {
    _html += this.id + ".intervalhide();";
    if ( this.parentmenu.parentmenu != null ) {
     _html += this.parentmenu.id + ".intervalhide();";
    }
   }
   _html += this.items[i].sub.id + ".intervalhide();";
   _html += "'";
   _html += ">";
   _html += this.items[i].text;
   _html += "</td>";

  }

  if (

   this.items[i].enable == true &&
   this.items[i].current == false &&
   this.items[i].link > 0 &&
   this.items[i].sub == null 

  ) {

   _html += "<td";
   _html += " style=\"";
   _html += "white-space:nowrap;";
   _html += "\"";
   _html += ">";
   _html += "<a";
   if ( this.items[i].id != "" ) {
    _html += " id=\"" + this.items[i].id + "\"";
   }
   _html += " href=\"" + this.items[i].href + "\"";
   if ( this.items[i].link == 2 ) {
    _html += " target=\"blank\"";
   }
   _html += " style=\"";
   _html += "color:" + this.out + ";";
   _html += "text-decoration:none;";
   _html += "\"";
   _html += " onmouseover='";
   _html += "this.style.color=\"" + this.over + "\";";
   for ( j=0; j<this.items.length; j++ ) {
    if ( ( j != i ) && ( this.items[j].sub != null ) ) {
     _html += this.items[j].sub.id + ".simplyhide();";
    }
   }
   if ( this.parentmenu != null ) {
    _html += this.id + ".intervalshow();";
    if ( this.parentmenu.parentmenu != null ) {
     _html += this.parentmenu.id + ".intervalshow();";
    }
   }
   _html += "'";
   _html += " onmouseout='";
   _html += "this.style.color=\"" + this.out + "\";";
   if ( this.parentmenu != null ) {
    _html += this.id + ".intervalhide();";
    if ( this.parentmenu.parentmenu != null ) {
     _html += this.parentmenu.id + ".intervalhide();";
    }
   }
   _html += "'";
   _html += " onfocus='";
   _html += "this.blur();";
   _html += "'";
   _html += ">";
   _html += this.items[i].text;
   _html += "</a>";
   _html += "</td>";

  }

  if (

   this.items[i].enable == true &&
   this.items[i].current == false &&
   this.items[i].link > 0 &&
   this.items[i].sub != null

  ) {

   // ?

  }

  if ( this.align == "right" ) {

   if ( this.items[i].sub == null ) {

    _html += "<td";
    _html += " style=\"";
    _html += "cursor:default";
    _html += "\"";
    _html += ">";
    _html += "&nbsp;";
    _html += "</td>";

   }

   else {

    _html += "<td";
    _html += " style=\"";
    _html += "font-size:0px;";
    _html += "\"";
    _html += ">";
    _html += "<img";
    if ( this.items[i].id != "" ) {
     _html += " id=\"" + this.items[i].id + "_arrow" + "\"";
    }
    _html += " src=\"" + this.arrow + "\"";
    _html += " style=\"";
    _html += " visibility:hidden";
    _html += "\"";
    _html += ">";
    _html += "</td>";

   }

  }

   _html += "</tr>";

 }

 _html += "</table>";
 _html += "</td>";
 _html += "</tr>";
 _html += "</table>";
 return _html;

}


//
function init( ) {
 document.write(this.html());
}


//
function simplyshow() {
 gethtmlelement(this.id).style.visibility = "visible";
}


//
function simplyhide() {

 gethtmlelement(this.id).style.visibility = "hidden";
 if ( this.parentmenu.items[this.parentitem].current == false ) {
  gethtmlelement(this.parentmenu.items[this.parentitem].id).style.color = this.out;
 }
 gethtmlelement(this.parentmenu.items[this.parentitem].id+"_arrow").style.visibility = "hidden";
 for( i=0; i<this.items.length; i++ ) {
  if (
    this.items[i].sub != null &&
    gethtmlelement(this.items[i].sub.id).style.visibility != "hidden"
  ) {
    this.items[i].sub.simplyhide();
  }
 }

}


//
function intervalshow() {

 if ( this.parentmenu.items[this.parentitem].current == false ) {
  gethtmlelement(this.parentmenu.items[this.parentitem].id).style.color = this.over;
 }
 gethtmlelement(this.parentmenu.items[this.parentitem].id + "_arrow").style.visibility = "visible";
 gethtmlelement(this.id).style.visibility = "visible";
 window.clearInterval(this.intervalid);

}


//
function intervalhide() {

 var hidecmd = "gethtmlelement(\""+this.id+"\")"+".style.visibility='hidden';";
 if ( this.parentmenu.items[this.parentitem].current == false ) {
  hidecmd += "gethtmlelement(\""+this.parentmenu.items[this.parentitem].id+"\")"+".style.color='"+this.out+"';"
 }
 hidecmd += "gethtmlelement(\""+this.parentmenu.items[this.parentitem].id+"_arrow"+"\")"+".style.visibility='hidden';";
 this.intervalid = window.setInterval (
   hidecmd,
   this.interval
 );

}