var DDSPEED = 5;
var DDTIMER = 10;

// function to handle menu definitions //

var links = new Array();
links[0] = "../contact/contact.html";
links[1] = "../schedule/schedule.html";
links[2] = "../teachers/teachers.html";
links[3] = "../testimonials/testimonials.html";
links[4] = "../tuition/tuition.html";
links[5] = "../adults/adults.html";
links[6] = "../kids/kids.html";
links[7] = "../teens/teens.html";
links[8] = "../seniors/seniors.html"
links[9] = "../qi gong/qi gong.html";
links[10] = "../little pandas/littlepandas.htm";
links[11] = "../adapted/adapted.html";
links[12] = "../mei hua chuan/mei hua chuan.html";
links[13] = "../shaolin/shaolin.html";
links[14] = "../tai chi/tai chi.html";
links[15] = "../wudang/wudang.html";
links[16] = "../southern/southern.html";
links[17] = "../drunkard/drunkard.html";
links[18] = "../video/video.html";
links[19] = "../publications/publications.html";
links[20] = "../shows/shows.html";
links[21] = "../press/press.html";
links[22] = "../reiki/reiki.html";
links[23] = "../mission/mission.html";
links[24] = "../howto/howto.html";
links[25] = "../benefits/benefits.html";
links[26]= "../weapons/weapons.html"
links[27]= "../tai chi qi gong class/tai chi qi gong class.html";

links[1000]= "../index.html";


var gNewLocation; // global variable that will be the new href
var number;
function gotoMyUrl(number)
{
gNewLocation=links[number];
location=gNewLocation;
}

var menuname = new Array();
menuname[0] = "CONTACT";
menuname[1] = "SCHEDULE";
menuname[2] = "TEACHERS";
menuname[3] = "TESTIMONIALS";
menuname[4] = "TUITION";
menuname[5] = "ADULT CLASSES";
menuname[6] = "KUNG FU KIDS 6-12";
menuname[7] = "KUNG FU TEENS";
menuname[8] = "SENIORS";
menuname[9] = "QI GONG";
menuname[10] = "LITTLE PANDAS 3-5";
menuname[11] = "DIFFERENT NEEDS";
menuname[12] = "MEI HUA CHUAN";
menuname[13] = "SHAOLIN";
menuname[14] = "TAI CHI";
menuname[15] = "WUDANG";
menuname[16] = "SOUTHERN SHAOLIN";
menuname[17] = "DRUNKARD KUNG FU";
menuname[18] = "VIDEO";
menuname[19] = "PUBLICATIONS";
menuname[20] = "SHOWS";
menuname[21] = "PRESS";
menuname[22] = "REIKI";
menuname[23] = "MISSION";
menuname[24] = "GET STARTED";
menuname[25] = "BENEFITS";
menuname[26] = "WEAPONS";
menuname[27] = "TAI CHI & QI GONG";
menuname[28] = "blank";
menuname[29] = "blank";
menuname[30] = "blank";
menuname[31] = "blank";

menuname[1000] = "HOME";


var gMenuName; // global variable that will be the new href
var number;
function getmyMenuName(number)
{
gMenuName=menuname[number];
location=gMenuName;
}

// main function to handle the mouse events //
function ddMenu(id,d){
  var h = document.getElementById(id + '-ddheader');
  var c = document.getElementById(id + '-ddcontent');
  clearInterval(c.timer);
  if(d == 1){
    clearTimeout(h.timer);
    if(c.maxh && c.maxh <= c.offsetHeight){return}
    else if(!c.maxh){
      c.style.display = 'block';
      c.style.height = 'auto';
      c.maxh = c.offsetHeight;
      c.style.height = '0px';
    }
    c.timer = setInterval(function(){ddSlide(c,1)},DDTIMER);
  }else{
    h.timer = setTimeout(function(){ddCollapse(c)},50);
  }
}

// collapse the menu //
function ddCollapse(c){
  c.timer = setInterval(function(){ddSlide(c,-1)},DDTIMER);
}

// cancel the collapse if a user rolls over the dropdown //
function cancelHide(id){
  var h = document.getElementById(id + '-ddheader');
  var c = document.getElementById(id + '-ddcontent');
  clearTimeout(h.timer);
  clearInterval(c.timer);
  if(c.offsetHeight < c.maxh){
    c.timer = setInterval(function(){ddSlide(c,1)},DDTIMER);
  }
}

// incrementally expand/contract the dropdown and change the opacity //
function ddSlide(c,d){
  var currh = c.offsetHeight;
  var dist;
  if(d == 1){
    dist = (Math.round((c.maxh - currh) / DDSPEED));
  }else{
    dist = (Math.round(currh / DDSPEED));
  }
  if(dist <= 1 && d == 1){
    dist = 1;
  }
  c.style.height = currh + (dist * d) + 'px';
  c.style.opacity = currh / c.maxh;
  c.style.filter = 'alpha(opacity=' + (currh * 100 / c.maxh) + ')';
  if((currh < 2 && d != 1) || (currh > (c.maxh - 2) && d == 1)){
    clearInterval(c.timer);
  }
}
