

function MultiColMenu(orientation) {
  // Functions
  this.show = _show;
  this.addItem = _addItem;
  this.addSubItem = _addSubItem;
  this.addSubItem = _addSubItem;
  this.hoverMenu = _hoverMenu;
  this.clearMenu = _clearMenu;
  this.popDown = _popDown;
  this.highlightMenu = _highlightMenu;
  this.tdMouseClick = _tdMouseClick;
  this.getOffset = _getOffset;  

  // Protected variables
  this.isIE = (document.getElementById && document.all)?true:false;
  this.isNS4 = (document.layers)?true:false;
  this.isNS6 = (document.getElementById && !document.all)?true:false;
  this.timmer = '';
  this.obj = (this.isIE)?'document.all':'document.getElementById';
  this.menuItens = new Array();
  this.menuSubItens = new Array();

  // Options that can be changed
  
  // Orientation,  can  be "horizontal" or "vertical"
  // default is "vertical"
  this.orientation = (typeof(orientation) == 'undefined')?'vertical':orientation;

  // Instance name. When you create a instance of menu, you mus change this property to
  // instance name. ex.
  // test_menu = new MultiColMenu();
  // test_menu.instance_name = 'test_menu';
  this.instance_name = '';

  // you can set a delay to submenu
  this.subMenuDelay = 2;

  // You can set a vertical offset to better menu positioning
  this.verticalOffset = 0;

  // You can set a horizontal offset to better menu positioning
  this.horizontalOffset = 0;

  // default submenu columns number
  this.menu_number_columns = 5;

  // Here you can put additional option to tag TD that is cell of menu
  // Ex. this.menu_add_option = 'nowrap';
  this.menu_add_option = '';

  // width menu, this will be used in style tag in table
  this.menu_width = '142px';

  // background color of menu
  this.menu_bgcolor = '#000000';

  // style used to create CSS tags to be used in cells of menu
  this.menu_style_static = 'font-family:Verdana; font-size:8pt; color:#FFFFFF; font-weight:normal; background-color:#217B8C; text-decoration:none;';

  // like last option , but this is used to create a hover efect
  this.menu_style_hover = 'font-family:Verdana; font-size:8pt; color:#000000; font-weight:normal; background-color:#EEEECC; text-decoration:none;';

  // cell spacing, this can be used to create a efect of a line between cells
  this.menu_cellspacing = '1';

  // default style used in links (tag <a>)
  this.menu_item_style = 'font-family:Verdana; font-size: 9px; font-weight: normal;';

  // string put before link in each cell´s menu. You can put <span> to format it
  // ex.   this.menu_beflabel = '<span color="#ffffff">    </span>';
  this.menu_beflabel = '    ';
  
  // these options is equal above menu options, difference is used to set Submenu options
  this.submenu_add_option = '';
  this.submenu_bgcolor = '#000000';
  this.submenu_style_static = 'font-family:Verdana; font-size:8pt; color:#FFFFFF; font-weight:normal; text-decoration:none; background-color:#217B8C;';
  this.submenu_style_hover = 'font-family:Verdana; font-size:8pt; color:#000000; font-weight:normal; text-decoration:none; background-color:#EEEECC;';
  this.submenu_item_style = 'font-family:Verdana; font-size: 9px; font-weight: normal;';
  this.submenu_beflabel = ' ';

  this.orientation = orientation;
  if (this.orientation != 'horizontal' && this.orientation != 'vertical') {
    this.orientation = 'vertical';
  }

  // when you create a menu link, you must use the same ID to create its submenu links
  // style is a css used in tag style
  // ncol is a number columns used to create submenu links
  // ex. 'Empresa', 'http://www.example.com/empresa.htm",'_top', 'color: #000000;', 0
  function _addItem(id, label, action, target, style, ncol) {
    id = (typeof(id) != 'number')?1:id;
    id = (id > 0)?id:1;
    label = (typeof(label) == 'undefined')?'Menu Item':label;
    target = (typeof(target) == 'undefined')?'_self':target;
    action = (typeof(action) == 'undefined')?'#':action;
    ncol = (typeof(ncol) != 'number')?this.menu_number_columns:ncol;
    style = (typeof(style) == 'undefined')?'':style;
    style = (style == ''?this.menu_item_style:style);
    this.menuItens[id] = new Array(label, action, target, style, ncol);
    this.menuSubItens[id] = new Array();
  }

  function _addSubItem(id, label, action, target, style) {
    if (typeof(id) == 'number') {
      i = this.menuSubItens[id].length;
      i = (i > 0)?i:1;
      label = (typeof(label) == 'undefined')?'':label;
      target = (typeof(target) == 'undefined')?'':target;
      action = (typeof(action) == 'undefined')?'':action;
      style = (typeof(style) == 'undefined')?'':style;
      style = (style == ''?this.submenu_item_style:style);
      this.menuSubItens[id][i] = new Array(label, action, target, style);
    }
  }

  function _show () {
    if (this.instance_name == '') {
      alert('You must define, this.instance_name with instance name of menu !!');
      return false;
    }
    if (this.verticalOffset == 0 || this.verticalOffset == '')
      this.verticalOffset = (this.orientation == 'horizontal')?20:-1;
    if (this.horizontalOffset == 0 || this.horizontalOffset == '')
      this.horizontalOffset = (orientation == 'horizontal')?-2:140;

    if (this.menuItens.length <= 0) {
      this.addItem();
    }
    // menu styles
    document.writeln ('<style>');
    document.writeln ('.MCMMenuStatic {'+this.menu_style_static+'}');
    document.writeln ('.MCMMenuHover  {'+this.menu_style_hover+'}');
    document.writeln ('.MCMSubMenuStatic {'+this.submenu_style_static+'}');
    document.writeln ('.MCMSubMenuHover  {'+this.submenu_style_hover+'}');
    document.writeln ('</style>');

    // main menu
    document.writeln ('<table border="0" cellpadding="0" cellspacing="'+this.menu_cellspacing+'" style="background-color: '+this.menu_bgcolor+'; width: '+this.menu_width+';">');
    if (this.orientation == 'horizontal') document.writeln ('<tr>');

    // main menu items
    for (i = 1; i < this.menuItens.length; i++) {
      if (this.orientation == 'vertical') document.writeln('<tr>');
      label = this.menuItens[i][0];
      action = this.menuItens[i][1];
      target = this.menuItens[i][2];
      target = (target?target:'#');
      onclick = (target=='#'?'onClick=\"javascript:return false;\"':'');
      style = this.menuItens[i][3];
      beflabel = (label?this.menu_beflabel:'');
      if (style) style = ' style="'+style+'" ';
     /*onClick="'+this.instance_name+'.tdMouseClick(\'mainLink'+i+'\');"*/
      document.writeln ('<td '+onclick);
       document.writeln ('onMouseOver="'+this.instance_name+'.hoverMenu(); '+this.instance_name+'.popDown('+i+', \'button'+i+'\');"');
       document.writeln ('onMouseOut="'+this.instance_name+'.clearMenu('+i+');"');
       document.writeln ('<div id="button'+i+'"><table border="0" cellpadding="3" cellspacing="0" width="100%">');
       document.writeln ('<tr><td class="MCMMenuStatic" id="cell'+i+'"'+this.menu_add_option+style+'>'+beflabel);
       document.writeln ('<a id="mainLink'+i+'" href="'+action+'" target="'+target+'"'+style+' class="MCMMenuStatic">'+label+'</a></td>');
       document.writeln ('</tr></table></div></td>');
       if (this.orientation == 'vertical') document.writeln ('</tr>');
    }
    if (this.orientation == 'vertical') document.writeln ('</table>');
    else document.writeln ('</tr></table>');

     // sub menu items
    for (i = 1; i < this.menuItens.length; i++) {
      if (this.menuSubItens[i].length > 0) {
        // Styles
        document.writeln ('<div id="MENU'+i+'" style="visibility:hidden; position:absolute; z-index:2">');
        document.writeln ('<table border="0" cellpadding="3" cellspacing="1" style="background-color: '+this.submenu_bgcolor+';">');

        nlines = (this.menuSubItens[i].length - 1) / this.menuItens[i][4];
        if (nlines > parseInt(nlines)) nlines = parseInt(nlines) + 1;

        ncol = 1;
        for (j = 1; j <= (nlines * this.menuItens[i][4]); j++) {
          if (typeof(this.menuSubItens[i][j]) == 'undefined') {
            label = action = target = style = beflabel = '';
          } else {
            label = this.menuSubItens[i][j][0];
            action = this.menuSubItens[i][j][1];
            target = this.menuSubItens[i][j][2];
            style = this.menuSubItens[i][j][3];
            beflabel = (label)?this.submenu_beflabel:'';
          }
          if (style) style = ' style="'+style+'" ';
          if (ncol == 1) document.writeln('<tr>');

          document.writeln ('<td id="subMenu'+i+j+'" class="MCMSubMenuStatic"');
           document.writeln ('onclick="'+this.instance_name+'.tdMouseClick(\'subLink'+i+j+'\');"'+this.submenu_add_option);
           document.writeln ('onMouseOver="'+this.instance_name+'.hoverMenu(); '+this.instance_name+'.highlightMenu(\'sub\','+i+','+j+');"');
           document.writeln ('onMouseOut="'+this.instance_name+'.clearMenu('+i+');"');
          document.writeln ('>'+beflabel+'<a id="subLink'+i+j+'" href="'+action+'" target="'+target+'" class="MCMSubMenuStatic" '+style+'>'+label+'</a></td>');
          ncol++;
          if (ncol > this.menuItens[i][4]) {
            document.writeln('</tr>');
            ncol = 1;
          }
        }
        document.writeln ('</table></div>');
      }
    }
  }
  
  function _highlightMenu(element, mainMenu, dropMenu, state) {
    state = (state == 'hover')?'MCMMenuHover':'MCMMenuStatic';
    if (element == 'sub') {
      // coloquei desta forma para que as celulas vazias dos submenus nao fiquem sempre acesas
      // ja que se eu seguir o  this.menuSubIten soh alcançarei os itens cadastrados e nao
      // todos os visiveis
      nlines = (this.menuSubItens[mainMenu].length - 1) / this.menuItens[mainMenu][4];
      if (nlines > parseInt(nlines)) nlines = parseInt(nlines) + 1;
      for (i = 1; i <= (nlines * this.menuItens[mainMenu][4]); i++) {
        eval(this.obj+'("subMenu'+mainMenu+i+'").className = "MCMSubMenuStatic"');
        eval(this.obj+'("subLink'+mainMenu+i+'").className = "MCMSubMenuStatic"');
      }
      eval(this.obj+'("subMenu'+mainMenu+dropMenu+'").className="MCMSubMenuHover"');
      eval(this.obj+'("subLink'+mainMenu+dropMenu+'").className="MCMSubMenuHover"');
    } else {
      eval(this.obj+'("cell'+mainMenu+'").className = "'+state+'"');
      eval(this.obj+'("mainLink'+mainMenu+'").className = "'+state+'"');
    }
  }

  // find positioning for sub menus
  function _getOffset (obj, dim) {
    if (dim == 'left') {
      oLeft = obj.offsetLeft;
      if (obj.offsetParent != null) {
        while (obj.offsetParent) {
          oLeft += obj.offsetLeft;
          obj = obj.offsetParent;
        }
      } else if (obj.x)
        oLeft += obj.x;
      return oLeft;
    } else if (dim == 'top') {
      oTop = obj.offsetTop;
      if (obj.offsetParent != null) {
        while(obj.offsetParent != null) {
          oParent = obj.offsetParent;
          oTop += oParent.offsetTop;
          obj = oParent;
        }
      } else if (obj.y)
        oTop += obj.y;
      return oTop;
    } else {
      alert("Error: invalid offset dimension '" + dim + "' in getOffset()");
      return false;
    }
  }

  // show sub menus
  function _popDown(param, id) {
    var menu;
    var button;

    if (id) {
      oLeft = this.getOffset(eval(this.obj+'("'+id+'")'),'left');
      oTop = this.getOffset(eval(this.obj+'("'+id+'")'),'top');
    }
    
    n = 1;
    while (n < this.menuItens.length) {
      menu = 'MENU' + n;
      if (param == n) {
        if (eval(this.obj+'("'+menu+'")')) {
          eval(this.obj+'("'+menu+'").style.visibility = "visible"');
          eval(this.obj+'("'+menu+'").style.left = '+(oLeft + this.horizontalOffset)+';');
          eval(this.obj+'("'+menu+'").style.top = '+(oTop + this.verticalOffset)+';');
        }
        this.highlightMenu('main', n, '', 'hover');
        if (this.menuSubItens[param].length > 0) {
          for (i = 1; i < this.menuSubItens[param].length; i++) {
            eval (this.obj+'("subMenu'+param+i+'").className = "MCMSubMenuStatic"');
            eval (this.obj+'("subLink'+param+i+'").className = "MCMSubMenuStatic"');
          }
        }
      } else {
        if (eval(this.obj+'("'+menu+'")')) eval(this.obj+'("'+menu+'").style.visibility = "hidden"');
        this.highlightMenu ('main', n, '', 'static');
      }
      n++;
    }
  }

  // re-set timer for sub menus
  function _hoverMenu () {
    if (this.timer) clearTimeout(this.timer);
  }

  // set timer for sub menus
  function _clearMenu (menu) {
    setDelay = this.subMenuDelay * 1000;
    delay = (this.menuSubItens[menu].length > 0)?setDelay:1;
    this.timer = setTimeout(this.instance_name+'.popDown('+(this.menuItens.length + 1)+');', delay);
  }

  // when you click the box, perform the same function as if the user had clicked the hyperlink
  function _tdMouseClick(theElement) {
    eval(this.obj+'('+theElement+').click();');
  }
}


var menu_esquerdo = new MultiColMenu();


  menu_esquerdo.instance_name = 'menu_esquerdo';
  
  // line 1
  menu_esquerdo.addItem(1, "Home", "0index.html");

  // line 2
  menu_esquerdo.addItem(2, "About Us", "0aboutus.html");

  // line 3
  menu_esquerdo.addItem(3, "Contact Us", "0contactus.php");

  // line 4
  menu_esquerdo.addItem(4, "Mission", "0mission.html");

  // line 5
  menu_esquerdo.addItem(5, "Reasons to Choose Kaye", "0reasons.html");

  // line 6
  menu_esquerdo.addItem(6, "Safety", "0safety.html");


   // line 7
  menu_esquerdo.addItem(7, "Bios", "0bios.html", "", "", 1);
  menu_esquerdo.addSubItem(7, "*   Dr. Alan David Kaye MD, PhD, DABPM", "0bios1.html");
  menu_esquerdo.addSubItem(7, "*   David Tardo", "0bios2.html");
  menu_esquerdo.addSubItem(7, "*   Ed Runci", "0bios3.html");
  menu_esquerdo.addSubItem(7, "*   Paolo Zambito", "0bios4.html");
 
  // line 8
  menu_esquerdo.addItem(8, "ULTRA RAPID DETOX AND KAYE METHOD", "0ultrarapid.html");

  // line 9
  menu_esquerdo.addItem(9, "DRUGS WE DETOX", "0drugswedetox.html");

  // line 10
  menu_esquerdo.addItem(10, "LOCATION", "0institute.html");

  // line 11
  menu_esquerdo.addItem(11, "INFORMATION & NEWS", "", "", "", 2);
  menu_esquerdo.addSubItem(11, "*   National Institute on Drug Abuse", "http://www.drugabuse.gov");
  menu_esquerdo.addSubItem(11, "*   addictionintervention.com", "http://www.addictionintervention.com");
  menu_esquerdo.addSubItem(11, "*   Costs of Drug Abuse to Society", "http://www.drugabuse.gov/Infofacts/costs.html");
  menu_esquerdo.addSubItem(11, "*   facesandvoicesofrecovery.org", "http://www.facesandvoicesofrecovery.org/");
  menu_esquerdo.addSubItem(11, "*   ncadi.samhsa.gov", "http://ncadi.samhsa.gov/");
  menu_esquerdo.addSubItem(11, "*   Prescription Drugs often Abused", "http://www.drugabuse.gov/PDF/PrescriptionDrugs.pdf");
  menu_esquerdo.addSubItem(11, "*   teens.drugabuse.gov", "http://teens.drugabuse.gov/facts/facts_brain1.asp");
  menu_esquerdo.addSubItem(11, "*   nida.nih.gov", "http://www.nida.nih.gov/scienceofaddiction/");
  menu_esquerdo.addSubItem(11, "*   Heroin Abuse & Addiction", "http://www.drugabuse.gov/ResearchReports/Heroin/Heroin.html");
  menu_esquerdo.addSubItem(11, "*   Opiate Info for Teens", "http://teens.drugabuse.gov/mom/mom_opi1.asp");
  menu_esquerdo.addSubItem(11, "*   NIDA Facts Sheet", "http://www.drugabuse.gov/infofacts/Infofaxindex.html");
  menu_esquerdo.addSubItem(11, "*   Drug Abuse Treatment Should Get Equal Treatment for Insurance Coverage", "http://www.jointogether.org/keyissues/coverage/");


  // line 12
  menu_esquerdo.addItem(12, "USEFUL LINKS", "", "", "", 2);
  menu_esquerdo.addSubItem(12, "*   thewellnessstore.com", "http://www.thewellnessstore.com/");
  menu_esquerdo.addSubItem(12, "*   selfgrowth.com", "http://www.selfgrowth.com/");
  menu_esquerdo.addSubItem(12, "*   healthtransformations.com", "http://healthtransformations.com/");
  menu_esquerdo.addSubItem(12, "*   National Survey on American Attitudes on Substance Abuse XIII: Teens & Parents", "http://www.casacolumbia.org/articlefiles/380-2008%20Teen%20Survey%20Report.pdf");
  menu_esquerdo.addSubItem(12, "*   HRHero", "http://www.hrhero.com/audio/substance_abuse/");
  menu_esquerdo.addSubItem(12, "*   Kids on Meds - Trouble Ahead", "http://www.sciam.com/article.cfm?id=kids-on-meds-trouble-ahead");
  menu_esquerdo.addSubItem(12, "*   Study Suggests Marijuana Abuse Increases Risk of Depression", "http://www.sciam.com/article.cfm?id=study-suggests-marijuana");
  menu_esquerdo.addSubItem(12, "*   Illicit Drug Abuse Down Amoung Adolescents, but Doubles Amoung Baby Boomers", "http://www.jointogether.org/news/features/2008/survey-illicit-drug-use-down.html");
  menu_esquerdo.addSubItem(12, "*   projectcork.org", "http://www.projectcork.org/powerpoint_presentations/index.html");


