var Dh_slideSpeed = 8;
var Dh_timer = 10;

var objectIdToSlideDown = false;
var Dh_activeId = false;
var Dh_slideInProgress = false;
function showHideContent(e,inputId)
{
	if(Dh_slideInProgress)return;
	Dh_slideInProgress = true;
	if(!inputId)inputId = this.id;
	inputId = inputId + '';
	var numericId = inputId.replace(/[^0-9]/g,'');
	var answerDiv = document.getElementById('Dh_a' + numericId);

	objectIdToSlideDown = false;

	if(!answerDiv.style.display || answerDiv.style.display=='none'){
		if(Dh_activeId &&  Dh_activeId!=numericId){
			objectIdToSlideDown = numericId;
			openContent(Dh_activeId,(Dh_slideSpeed*-1));
		}else{

			answerDiv.style.display='block';
			answerDiv.style.visibility = 'visible';

			openContent(numericId,Dh_slideSpeed);
		}
	}else{
		openContent(numericId,(Dh_slideSpeed*-1));
		Dh_activeId = false;
	}
}

function openContent(inputId,direction)
{

	var obj =document.getElementById('Dh_a' + inputId);
	var contentObj = document.getElementById('Dh_ac' + inputId);
	height = obj.clientHeight;
	if(height==0)height = obj.offsetHeight;
	height = height + direction;
	rerunFunction = true;
	if(height>contentObj.offsetHeight){
		height = contentObj.offsetHeight;
		rerunFunction = false;
	}
	if(height<=1){
		height = 1;
		rerunFunction = false;
	}

	obj.style.height = height + 'px';
	var topPos = height - contentObj.offsetHeight;
	if(topPos>0)topPos=0;
	contentObj.style.top = topPos + 'px';
	if(rerunFunction){
		setTimeout('openContent(' + inputId + ',' + direction + ')',Dh_timer);
	}else{
		if(height<=1){
			obj.style.display='none';
			if(objectIdToSlideDown && objectIdToSlideDown!=inputId){
				document.getElementById('Dh_a' + objectIdToSlideDown).style.display='block';
				document.getElementById('Dh_a' + objectIdToSlideDown).style.visibility='visible';
				openContent(objectIdToSlideDown,Dh_slideSpeed);
			}else{
				Dh_slideInProgress = false;
			}
		}else{
			Dh_activeId = inputId;
			Dh_slideInProgress = false;
		}
	}
}



function initMenus()
{
	var divs = document.getElementsByTagName('DIV');
	var divCounter = 1;
	for(var no=0;no<divs.length;no++){
		if(divs[no].className=='Dh_h'){
			divs[no].onmouseover = showHideContent;
			divs[no].id = 'Dh_q'+divCounter;
			var answer = divs[no].nextSibling;
			while(answer && answer.tagName!='DIV'){
				answer = answer.nextSibling;
			}
			answer.id = 'Dh_a'+divCounter;
			contentDiv = answer.getElementsByTagName('DIV')[0];
			contentDiv.style.top = 0 - contentDiv.offsetHeight + 'px';
			contentDiv.className='Dh_c_content';
			contentDiv.id = 'Dh_ac' + divCounter;
			answer.style.display='none';
			answer.style.height='1px';
			divCounter++;
		}
	}
MM_preloadImages('images/menu/menu1_on.jpg','images/menu/menu2_on.jpg','images/menu/menu3_on.jpg','images/menu/menu4_on.jpg','images/menu/smenu1_on.jpg','images/menu/smenu2_on.jpg','images/menu/smenu3_on.jpg','images/menu/menu4_on.jpg','images/menu/menu5_on.jpg')	
}

function MM_preloadImages() {
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() {
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) {
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() {

  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}


window.onload = initMenus;