/************************************************************************************************************ (C) www.dg.com, November 2005 This is a script from www.dg.com. You will find this and a lot of other scripts at our website. Terms of use: You are free to use this script as long as the copyright message is kept intact. However, you may not redistribute, sell or repost it without our permission. Thank you! www.dg.com Alf Magne Kalleland ************************************************************************************************************/ var dg_slideSpeed = 10; var dg_timer = 10; var objectIdToSlideDown = false; var dg_activeId = false; var dg_slideInProgress = false; function showHideContent(e,inputId) { if(dg_slideInProgress)return; dg_slideInProgress = true; if(!inputId)inputId = this.id; inputId = inputId + ''; var numericId = inputId.replace(/[^0-9]/g,''); var ansDiv = document.getElementById('dg_a' + numericId); objectIdToSlideDown = false; if(!ansDiv.style.display || ansDiv.style.display=='none'){ if(dg_activeId && dg_activeId!=numericId){ objectIdToSlideDown = numericId; slideContent(dg_activeId,(dg_slideSpeed*-1)); }else{ ansDiv.style.display='block'; ansDiv.style.visibility = 'visible'; slideContent(numericId,dg_slideSpeed); } }else{ slideContent(numericId,(dg_slideSpeed*-1)); dg_activeId = false; } } function slideContent(inputId,direction) { var obj =document.getElementById('dg_a' + inputId); var contentObj = document.getElementById('dg_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 + ')',dg_timer); }else{ if(height<=1){ obj.style.display='none'; if(objectIdToSlideDown && objectIdToSlideDown!=inputId){ document.getElementById('dg_a' + objectIdToSlideDown).style.display='block'; document.getElementById('dg_a' + objectIdToSlideDown).style.visibility='visible'; slideContent(objectIdToSlideDown,dg_slideSpeed); }else{ dg_slideInProgress = false; } }else{ dg_activeId = inputId; dg_slideInProgress = false; } } } function initShowHideDivs() { var divs = document.getElementsByTagName('DIV'); var divCounter = 1; for(var no=0;no