var mg_slideSpeed = 10; var mg_timer = 10; var objectIdToSlideDown = false; var mg_activeId = false; var mg_slideInProgress = false; function showHideContent(e,inputId) { if(mg_slideInProgress)return; mg_slideInProgress = true; if(!inputId)inputId = this.id; inputId = inputId + ''; var numericId = inputId.replace(/[^0-9]/g,''); var answerDiv = document.getElementById('mg_a' + numericId); objectIdToSlideDown = false; if(!answerDiv.style.display || answerDiv.style.display=='none'){ if(mg_activeId && mg_activeId!=numericId){ objectIdToSlideDown = numericId; slideContent(mg_activeId,(mg_slideSpeed*-1)); }else{ answerDiv.style.display='block'; answerDiv.style.visibility = 'visible'; slideContent(numericId,mg_slideSpeed); } }else{ slideContent(numericId,(mg_slideSpeed*-1)); mg_activeId = false; } } function slideContent(inputId,direction) { var obj =document.getElementById('mg_a' + inputId); var contentObj = document.getElementById('mg_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('slideContent(' + inputId + ',' + direction + ')',mg_timer); }else{ if(height<=1){ obj.style.display='none'; if(objectIdToSlideDown && objectIdToSlideDown!=inputId){ document.getElementById('mg_a' + objectIdToSlideDown).style.display='block'; document.getElementById('mg_a' + objectIdToSlideDown).style.visibility='visible'; slideContent(objectIdToSlideDown,mg_slideSpeed); }else{ mg_slideInProgress = false; } }else{ mg_activeId = inputId; mg_slideInProgress = false; } } } function initShowHideDivs() { var divs = document.getElementsByTagName('DIV'); var divCounter = 1; for(var no=0;no