var LastWord; function assocGetWord(w) { assocSendRequest(widgetUrl() + "?w=" + w); } function assocSbm(frmObj) { assocSendRequest(widgetUrl() + "?nw=" + frmObj.w.value + "&d=" + frmObj.d.value); return false; } function assocCcl() { assocSendRequest(widgetUrl() + "?w=" + LastWord); } function widgetUrl() { return "http://www.pitchstorm.tv/wp-content/plugins/widgets/assoc_dict.php"; } function assocSendRequest(url) { assocReq = false; // branch for native XMLHttpRequest object if (window.XMLHttpRequest) { try { assocReq = new XMLHttpRequest(); assocReq.onreadystatechange = assocProcessReqChange; assocReq.open('GET', url, true); assocReq.send(null); } catch(e) { assocReq = false; } } else if (window.ActiveXObject) { // branch for IE/Windows ActiveX version try { assocReq = new ActiveXObject('Msxml2.XMLHTTP'); } catch(e) { try { assocReq = new ActiveXObject('Microsoft.XMLHTTP'); } catch(e) { assocReq = false; } } if (assocReq) { assocReq.onreadystatechange = assocProcessReqChange; assocReq.open('GET', url, true); assocReq.send(); } } } function assocProcessReqChange() { if (4 != assocReq.readyState) { return; } if (200 != assocReq.status) { return; } var parts, newwords, i, r, stripped, idx; parts = assocReq.responseText.split("#"); switch (parts[0]) { case "200": newwords = parts[2].split(" "); LastWord = parts[1]; r = "

" + parts[1] + ": "; for (i = 0; i < newwords.length; i++) { stripped = newwords[i]; idx = stripped.indexOf("'"); while (idx > -1) { stripped = stripped.replace("'", ""); idx = stripped.indexOf("'"); } r += "" + newwords[i] + " "; } document.getElementById("assoc_dict_word").innerHTML = r + "

"; break; case "404": r = '

' + parts[1] + ': Words fail me -- you can add a description if you want.


'; document.getElementById("assoc_dict_word").innerHTML = r; break; default: break; } }