var lastrequest = ""
var timerid = 0;
var myx=0;
function addslashes(str) {
str=str.replace(/\'/g,'\\\'');
str=str.replace(/\"/g,'\\"');
str=str.replace(/\\/g,'\\\\');
str=str.replace(/\0/g,'\\0');
return str;
}
function stripslashes(str) {
str=str.replace(/\\'/g,'\'');
str=str.replace(/\\"/g,'"');
str=str.replace(/\\\\/g,'\\');
str=str.replace(/\\0/g,'\0');
return str;
}
function showbuttons() {
if (document.getElementById('questiontitle').innerHTML.length>600) {
document.getElementById('questiontitle').className = "questiontext4";
} else if (document.getElementById('questiontitle').innerHTML.length>500) {
document.getElementById('questiontitle').className = "questiontext3";
} else if (document.getElementById('questiontitle').innerHTML.length>300) {
document.getElementById('questiontitle').className = "questiontext2";
} else {
document.getElementById('questiontitle').className = "questiontext";
}
var oDiv = document.getElementById('questionoptions');
var maxchars = 0;
if(oDiv.firstChild) {
var oChild = oDiv.firstChild;
while(oChild) {
if(oChild.nodeType==1 && oChild.nodeName == "DIV") {
if (oChild.innerHTML.length>maxchars) {maxchars = oChild.innerHTML.length;}
}
oChild = oChild.nextSibling;
}
if (maxchars>80) {
oChild = oDiv.firstChild;
while(oChild) {
oChild.className="questionbutton5";
oChild.style.height="120px";
oChild = oChild.nextSibling;
}
} else if (maxchars>60) {
oChild = oDiv.firstChild;
while(oChild) {
oChild.className="questionbutton4";
oChild = oChild.nextSibling;
}
} else if (maxchars>40) {
oChild = oDiv.firstChild;
while(oChild) {
oChild.className="questionbutton3";
oChild = oChild.nextSibling;
}
} else if (maxchars>20) {
oChild = oDiv.firstChild;
while(oChild) {
oChild.className="questionbutton2";
oChild = oChild.nextSibling;
}
}
}
}
function collectanswers(totalanswers) {
myansers = "";
for (x=1;x<=totalanswers;x++) {
if (document.getElementById("answer"+x).style.backgroundColor == 'teal') {
myansers = myansers + 1+"{}[]{}";
} else {
myansers = myansers + 0+"{}[]{}";
}
}
return myansers;
}
function uncolorotheroptions() {
for (x=0;x<45;x++) {
if (document.getElementById("answer"+x)) {
if (document.getElementById("answer"+x).style.backgroundColor == 'teal') {
document.getElementById("answer"+x).style.backgroundColor = 'white';
}
}
}
}
function uncolorexclusiveoptions() {
for (x=0;x<45;x++) {
if (document.getElementById("answer"+x)) {
if (document.getElementById("answer"+x).exclusive == 'yes') {
document.getElementById("answer"+x).style.backgroundColor = 'white';
}
}
}
}
function findPosX(obj) {
var curleft = 0;
if(obj.offsetParent) {
while(1) {
curleft += obj.offsetLeft;
if(!obj.offsetParent) {break;}
obj = obj.offsetParent;
}
} else if(obj.x) {
curleft += obj.x;
}
return curleft;
}
function findPosY(obj) {
var curtop = 0;
if(obj.offsetParent) {
while(1) {
curtop += obj.offsetTop;
if(!obj.offsetParent) {break;}
obj = obj.offsetParent;
}
} else if(obj.y) {
curtop += obj.y;
}
return curtop;
}
function toCamelCase( sInput ) {
var oStringList = sInput.split('-');
if(oStringList.length == 1)
return oStringList[0];
var ret = sInput.indexOf("-") == 0 ?
oStringList[0].charAt(0).toUpperCase() + oStringList[0].substring(1) : oStringList[0];
for(var i = 1, len = oStringList.length; i < len; i++){
var s = oStringList[i];
ret += s.charAt(0).toUpperCase() + s.substring(1)
}
return ret;
}
function getStyle(el, style) {
if(!document.getElementById) return;
var value = el.style[toCamelCase(style)];
if(!value) {
if(document.defaultView) {
value = document.defaultView.getComputedStyle(el, "").getPropertyValue(style);
} else if (el.currentStyle) {
value = el.currentStyle[toCamelCase(style)];
}
}
return value;
}
function showwaiting() {
// document.getElementById("questiontitle").innerHTML = " ";
// document.getElementById("questionoptions").innerHTML = document.getElementById("waitingwindowdiv").innerHTML;
}
function hidewaiting() {
// document.getElementById("waitingwindowdiv").style.visibility = "hidden";
}
function trim(s) {
return rtrim(ltrim(s));
}
function ltrim(s) {
var l=0;
while(l < s.length && s[l] == ' ') {
l++;
}
return s.substring(l, s.length);
}
function rtrim(s) {
var r=s.length -1;
while(r > 0 && s[r] == ' ') {
r-=1;
}
return s.substring(0, r+1);
}
function Ajax() {
this.toString = function() { return "Ajax"; }
this.http = new HTTP();
this.makeRequest = function(_method, _url, _callbackMethod) {
clearTimeout(timerid);
myx=0;
lastrequest = _url + "&tt=" + Date();
document.getElementById("questioninfo").innerHTML = "Please wait while we progress to the next question";
document.getElementById("questiontitle").innerHTML = " ";
document.getElementById("questionoptions").innerHTML = '
';
// // document.getElementById("questionoptions").innerHTML = '';
// document.getElementById("body2").innerHTML = "If you've been waiting for the question to appear longer than than 10 seconds and it appears frozen, (the progress bar above is not moving) please click this link";
// document.getElementById("body2a").innerHTML = "If you've been waiting for the question to appear longer than than 10 seconds and it appears frozen, (the progress bar above is not moving) please click this link";
// document.getElementById("body").innerHTML = "current page trying - " + _url;
this.request = (window.XMLHttpRequest)? new XMLHttpRequest(): new ActiveXObject("MSXML2.XMLHTTP");
this.request.onreadystatechange = _callbackMethod;
this.request.open(_method, _url + "&tt=" + Date(), true);
this.request.send(_url + "&tt=" + Date());
timerid = setTimeout("achecktimer()", 1000);
// showwaiting();
}
this.checkReadyState = function(_id, _1, _2, _3) {
switch(this.request.readyState) {
case 1:
// document.getElementById(_id).innerHTML = _1;
break;
case 2:
// document.getElementById(_id).innerHTML = _2;
break;
case 3:
// document.getElementById(_id).innerHTML = _3;
break;
case 4:
mystatus = this.http.status(this.request.status);
if (mystatus == "OK") {
myx=0;
// document.getElementById(_id).innerHTML = "";
return mystatus;
}
}
if (myx>20) {
clearTimeout(timerid);
timerid = setTimeout('tryagain("' + lastrequest + '");', 1000);
} else {
clearTimeout(timerid);
timerid = setTimeout("achecktimer()", 1000);
}
}
}
function achecktimer() {
myx++;
ajax.checkReadyState('body', 'loading1', 'loading2', 'loading3');
}
function tryagain(theurl) {
// document.getElementById("body3").innerHTML = "Asdfasdf";
ajax.makeRequest("GET", theurl, onResponse);
}
function onResponse() {
if(ajax.checkReadyState('body', 'loading1', 'loading2', 'loading3') == "OK") {
clearTimeout(timerid);
var data = trim(ajax.request.responseText);
// document.getElementById("subtext").innerHTML = data.replace("<", "<").replace(">", ">");
var thing = data.split("{||}");
// hidewaiting();
if (thing[0] == 0) {
document.getElementById("questionprogress").innerHTML = thing[2];
ajax.makeRequest('GET', thing[1], onResponse);
} else if (thing[0] == 1 || thing[0] == 8) {
if (Get_Cookie("debug") == "yes") {
document.getElementById("questioninfo").innerHTML = thing[1];
} else {
document.getElementById("questioninfo").innerHTML = "";
}
document.getElementById("questiontitle").innerHTML = thing[2];
document.getElementById("questionprogress").innerHTML = thing[4];
if (thing[3].toLowerCase().indexOf("