var DDSPEED = 5;
var DDTIMER = 8;

// 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 = 0.95;
  c.style.mozopacity = 0.95;
  c.style.filter = 'alpha(opacity=' + (currh * 95 / c.maxh) + ')';
    if((currh < 2 && d != 1) || (currh > (c.maxh - 2) && d == 1)){
    clearInterval(c.timer);
  }
}

function moi1() 
{ 
document.getElementById("two-ddheader").style.opacity='0.7'; 
document.getElementById("two-ddheader").style.filter='alpha(Opacity=70)'; 
document.getElementById("tre-ddheader").style.opacity='0.7'; 
document.getElementById("tre-ddheader").style.filter='alpha(Opacity=70)'; 
document.getElementById("four-ddheader").style.opacity='0.7'; 
document.getElementById("four-ddheader").style.filter='alpha(Opacity=70)'; 
document.getElementById("fiv-ddheader").style.opacity='0.7'; 
document.getElementById("fiv-ddheader").style.filter='alpha(Opacity=70)'; 
} 
function mou1() 
{ 
document.getElementById("two-ddheader").style.opacity='1.0'; 
document.getElementById("two-ddheader").style.filter='alpha(Opacity=100)'; 
document.getElementById("tre-ddheader").style.opacity='1.0'; 
document.getElementById("tre-ddheader").style.filter='alpha(Opacity=100)'; 
document.getElementById("four-ddheader").style.opacity='1.0'; 
document.getElementById("four-ddheader").style.filter='alpha(Opacity=100)'; 
document.getElementById("fiv-ddheader").style.opacity='1.0'; 
document.getElementById("fiv-ddheader").style.filter='alpha(Opacity=100)'; 
} 
function moi2() 
{ 
document.getElementById("one-ddheader").style.opacity='0.7'; 
document.getElementById("one-ddheader").style.filter='alpha(Opacity=70)'; 
document.getElementById("tre-ddheader").style.opacity='0.7'; 
document.getElementById("tre-ddheader").style.filter='alpha(Opacity=70)'; 
document.getElementById("four-ddheader").style.opacity='0.7'; 
document.getElementById("four-ddheader").style.filter='alpha(Opacity=70)'; 
document.getElementById("fiv-ddheader").style.opacity='0.7'; 
document.getElementById("fiv-ddheader").style.filter='alpha(Opacity=70)'; 
} 
function mou2() 
{ 
document.getElementById("one-ddheader").style.opacity='1.0'; 
document.getElementById("one-ddheader").style.filter='alpha(Opacity=100)'; 
document.getElementById("tre-ddheader").style.opacity='1.0'; 
document.getElementById("tre-ddheader").style.filter='alpha(Opacity=100)'; 
document.getElementById("four-ddheader").style.opacity='1.0'; 
document.getElementById("four-ddheader").style.filter='alpha(Opacity=100)'; 
document.getElementById("fiv-ddheader").style.opacity='1.0'; 
document.getElementById("fiv-ddheader").style.filter='alpha(Opacity=100)'; 
} 
function moi3() 
{ 
document.getElementById("one-ddheader").style.opacity='0.7'; 
document.getElementById("one-ddheader").style.filter='alpha(Opacity=70)'; 
document.getElementById("two-ddheader").style.opacity='0.7'; 
document.getElementById("two-ddheader").style.filter='alpha(Opacity=70)'; 
document.getElementById("four-ddheader").style.opacity='0.7'; 
document.getElementById("four-ddheader").style.filter='alpha(Opacity=70)'; 
document.getElementById("fiv-ddheader").style.opacity='0.7'; 
document.getElementById("fiv-ddheader").style.filter='alpha(Opacity=70)'; 
} 
function mou3() 
{ 
document.getElementById("one-ddheader").style.opacity='1.0'; 
document.getElementById("one-ddheader").style.filter='alpha(Opacity=100)'; 
document.getElementById("two-ddheader").style.opacity='1.0'; 
document.getElementById("two-ddheader").style.filter='alpha(Opacity=100)'; 
document.getElementById("four-ddheader").style.opacity='1.0'; 
document.getElementById("four-ddheader").style.filter='alpha(Opacity=100)'; 
document.getElementById("fiv-ddheader").style.opacity='1.0'; 
document.getElementById("fiv-ddheader").style.filter='alpha(Opacity=100)'; 
} 
function moi4() 
{ 
document.getElementById("one-ddheader").style.opacity='0.7'; 
document.getElementById("one-ddheader").style.filter='alpha(Opacity=70)'; 
document.getElementById("two-ddheader").style.opacity='0.7'; 
document.getElementById("two-ddheader").style.filter='alpha(Opacity=70)'; 
document.getElementById("tre-ddheader").style.opacity='0.7'; 
document.getElementById("tre-ddheader").style.filter='alpha(Opacity=70)'; 
document.getElementById("fiv-ddheader").style.opacity='0.7'; 
document.getElementById("fiv-ddheader").style.filter='alpha(Opacity=70)'; 
} 
function mou4() 
{ 
document.getElementById("one-ddheader").style.opacity='1.0'; 
document.getElementById("one-ddheader").style.filter='alpha(Opacity=100)'; 
document.getElementById("two-ddheader").style.opacity='1.0'; 
document.getElementById("two-ddheader").style.filter='alpha(Opacity=100)'; 
document.getElementById("tre-ddheader").style.opacity='1.0'; 
document.getElementById("tre-ddheader").style.filter='alpha(Opacity=100)'; 
document.getElementById("fiv-ddheader").style.opacity='1.0'; 
document.getElementById("fiv-ddheader").style.filter='alpha(Opacity=100)'; 
} 
function moi5() 
{ 
document.getElementById("one-ddheader").style.opacity='0.7'; 
document.getElementById("one-ddheader").style.filter='alpha(Opacity=70)'; 
document.getElementById("two-ddheader").style.opacity='0.7'; 
document.getElementById("two-ddheader").style.filter='alpha(Opacity=70)'; 
document.getElementById("tre-ddheader").style.opacity='0.7'; 
document.getElementById("tre-ddheader").style.filter='alpha(Opacity=70)'; 
document.getElementById("four-ddheader").style.opacity='0.7'; 
document.getElementById("four-ddheader").style.filter='alpha(Opacity=70)'; 
} 
function mou5() 
{ 
document.getElementById("one-ddheader").style.opacity='1.0'; 
document.getElementById("one-ddheader").style.filter='alpha(Opacity=100)'; 
document.getElementById("two-ddheader").style.opacity='1.0'; 
document.getElementById("two-ddheader").style.filter='alpha(Opacity=100)'; 
document.getElementById("tre-ddheader").style.opacity='1.0'; 
document.getElementById("tre-ddheader").style.filter='alpha(Opacity=100)'; 
document.getElementById("four-ddheader").style.opacity='1.0'; 
document.getElementById("four-ddheader").style.filter='alpha(Opacity=100)'; 
} 
var win=null;
function newwindow(mypage,myname,w,h,scroll,pos){
if(pos=="random"){leftposition=(screen.width)?math.floor(math.random()*(screen.width-w)):100;topposition=(screen.height)?math.floor(math.random()*((screen.height-h)-75)):100;}
if(pos=="center"){leftposition=(screen.width)?(screen.width-w)/2:100;topposition=(screen.height)?(screen.height-h)/2:100;}
else if((pos!="center" && pos!="random") || pos==null){leftposition=0;topposition=20}
settings='width='+w+',height='+h+',top='+topposition+',left='+leftposition+',scrollbars='+scroll+',location=no,directories=no,status=yes,menubar=no,toolbar=no,resizable=no';
win=window.open(mypage,myname,settings);
}

