function checkquest() { var arrPs = document.getElementsByTagName("p"); for(i = 0; i < arrPs.length; i++){ var lenChild = arrPs[i].childNodes.length; if(lenChild>2){ nn = arrPs[i].childNodes[0]; if(nn.nodeType == 3){ if(nn.nodeValue.substring(0,4)=="[Q01"){ var qid = "q" + i; newlink = document.createElement('a'); newlink.setAttribute('href', "javascript:showdiv('"+qid+"');"); str_question = nn.nodeValue.substring(5, nn.nodeValue.length-2); tn = document.createTextNode(str_question); newlink.appendChild(tn); nn.parentNode.replaceChild(newlink, nn); n2 = arrPs[i].childNodes[2]; newspan = document.createElement('span'); newspan.style.display="none"; newspan.id = qid; str_question = n2.nodeValue.substring(5, n2.nodeValue.length-2); tn = document.createTextNode(str_question); newspan.appendChild(tn); n2.parentNode.replaceChild(newspan, n2); } } } } } function showdiv(id) { //safe function to show an element with a specified id if (document.getElementById) { // DOM3 = IE5, NS6 document.getElementById(id).style.display = 'block'; } else { if (document.layers) { // Netscape 4 document.id.display = 'block'; } else { // IE 4 document.all.id.style.display = 'block'; } } }