var DDSPEED = 10;
var DDTIMER = 15;

// main function to handle the mouse events //
function ddMenu(id,dir) {
  var head = document.getElementById(id + '-ddheader');
  var cont = document.getElementById(id + '-ddcontent');
  clearInterval(cont.timer);
  if(dir == 1) {
    clearTimeout(head.timer);
    if(cont.maxh && cont.maxh <= cont.offsetHeight) {
      return;
    } else if(!cont.maxh) {
      cont.style.display = 'block';
      cont.style.height = 'auto';
      cont.maxh = cont.offsetHeight;
      cont.style.height = '0px';
    }
    cont.timer = setInterval("ddSlide('" + id + "-ddcontent', 1)", DDTIMER);
  } else {
    head.timer = setTimeout('ddCollapse(\'' + id + '-ddcontent\')', 50);
  }
}

// collapse the menu //
function ddCollapse(id) {
  var cont = document.getElementById(id);
  cont.timer = setInterval("ddSlide('" + id + "', -1)", DDTIMER);
}

// cancel the collapse if a user rolls over the dropdown content //
function cancelHide(id) {
  var head = document.getElementById(id + '-ddheader');
  var cont = document.getElementById(id + '-ddcontent');
  clearTimeout(head.timer);
  clearInterval(cont.timer);
  if(cont.offsetHeight < cont.maxh) {
    cont.timer = setInterval("ddSlide('" + id + "-ddcontent', 1)", DDTIMER);
  }
}

// incrementally expand/contract the dropdown and change the opacity //
function ddSlide(id,dir) {
  var cont = document.getElementById(id);
  var currheight = cont.offsetHeight;
  var dist;
  if(dir == 1) {
    dist = (Math.round((cont.maxh - currheight) / DDSPEED));
  } else {
    dist = (Math.round(currheight / DDSPEED));
  }
  if(dist <= 1 && dir == 1) {
    dist = 1;
  }
  cont.style.height = currheight + (dist * dir) + 'px';
  cont.style.opacity = currheight / cont.maxh;
  cont.style.filter = 'alpha(opacity=' + (currheight * 100 / cont.maxh) + ')';
  if((currheight < 2 && dir != 1) || (currheight > (cont.maxh - 2) && dir == 1)) {
    clearInterval(cont.timer);
  }
}
function jsDisplayFullSize(strImageID) {
	var intWindowWidth = 820;
	var intWindowHeight = 600;
	var intTop = (screen.height-intWindowHeight)/2;
	var intLeft = (screen.width-intWindowWidth)/2;
	myWin = window.open('','','width='+intWindowWidth+',height='+intWindowHeight+',top='+intTop+',left='+intLeft+',scrollbars=no,toolbar=no,locationbar=no');
	myWin.document.write('<html>');
	myWin.document.write('<head>');
	myWin.document.write('<title>Gallery Photo</title>');
	myWin.document.write('<style>.button {font-family: Verdana;font-size: 10pt; color: #000000; background-color: #FFFFFF; border: 1px solid #000000; cursor:hand;}');
	myWin.document.write('</style>');
	myWin.document.write('</head>');
	myWin.document.write('<body bgcolor="#FFFFFF" onLoad="Javascript:self.focus();" onBlur="Javascript:self.close();">');
	myWin.document.write('<p align="center"><img src="gallery/lg'+strImageID+'.jpg" border="0" width="800" height="531"/></p>');
	myWin.document.write('<form>');
	myWin.document.write('<p align="center"><input type="button" class="button" name="btnClose" value="Close Window" onClick="Javascript:self.close();"></p>');
	myWin.document.write('</form>');
	myWin.document.write('</body>');
	myWin.document.write('</html>');
	myWin.document.close();
	myWin.focus();	
}