var activeIdx = -1; function activate(idx, bgColor) { if (null == bgColor) bgColor = "#F7F7F7"; if (-1 != activeIdx) { deactivate(activeIdx); } if (idx == activeIdx) { deactivate(idx); activeIdx = -1; return; } activeIdx = idx; var question = document.getElementById("question_" + idx); question.style.backgroundColor = bgColor; // changing selected question to bold style... var tbl = getChild( getChild(question, "TD"), "TABLE"); for (i=0; i